Bug fixes
This commit is contained in:
16
src/app.ts
16
src/app.ts
@@ -5,20 +5,26 @@ import * as path from 'path';
|
||||
import * as sassMiddleware from 'node-sass-middleware';
|
||||
import * as compression from 'compression';
|
||||
import indexRouter from './routes';
|
||||
import {AuthProxy, AutoReloader, DefaultConfig, HttpLogger, Polyfill, Permissions} from 'pkg-express-utils';
|
||||
import {AuthProxy, AutoReloader, DefaultConfig, HttpLogger, Polyfill, PermManager} from 'pkg-express-utils';
|
||||
|
||||
export const app = express();
|
||||
|
||||
// Permissions
|
||||
PermManager
|
||||
.grant("user")
|
||||
.execute("read").on("userinfo")
|
||||
.grant("coe_bs")
|
||||
.extend("user")
|
||||
.execute("write").on("userinfo");
|
||||
|
||||
// view engine setup
|
||||
app.set('views', path.join(__dirname, '../views'));
|
||||
app.set('view engine', 'pug');
|
||||
app.use((req, res, next) => {
|
||||
res.locals.Config = DefaultConfig;
|
||||
res.locals.DefaultConfig = DefaultConfig;
|
||||
next();
|
||||
});
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
// http logger
|
||||
app.use(HttpLogger);
|
||||
app.use(express.json());
|
||||
@@ -27,6 +33,8 @@ app.use(express.urlencoded({extended: false}));
|
||||
// compression
|
||||
app.use(compression());
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
// auth proxy middleware
|
||||
router.use(AuthProxy.router);
|
||||
// auto reloader (when running in debug mode)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/* eslint-disable no-process-exit,no-console */
|
||||
import * as http from "http";
|
||||
import urlJoin from 'proper-url-join';
|
||||
import {DefaultConfig} from 'pkg-express-utils';
|
||||
import {DefaultConfig, urlJoin} from 'pkg-express-utils';
|
||||
|
||||
const options = {
|
||||
host: DefaultConfig.HOSTNAME,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import * as express from 'express';
|
||||
import {PermManager} from 'pkg-express-utils';
|
||||
|
||||
const userRouter = express.Router();
|
||||
|
||||
/* GET users listing. */
|
||||
userRouter.get('/', async (req, res) => {
|
||||
userRouter.get('/', PermManager.getRouter("userinfo", {action: "read"}), async (req, res) => {
|
||||
res.json(await req.getUserInfo() || {});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user