Skip to content

Commit

Permalink
feat: commons middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
cesgarpas committed Apr 30, 2021
1 parent c5772e2 commit bc654b5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const server = require('./server');

const env = process.env.NODE_ENV ? process.env.NODE_ENV : 'production';

governify.init().then(() => {
server.deploy(env).catch(err => { console.log(err); });
governify.init().then((commonsMiddleware) => {
server.deploy(env, commonsMiddleware).catch(err => { console.log(err); });
});

// quit on ctrl-c when running docker in terminal
Expand Down
25 changes: 16 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"compression": "^1.7.2",
"cors": "^2.8.4",
"express": "^4.16.3",
"governify-commons": "^1.4.4",
"governify-commons": "^1.8.6",
"helmet": "^3.23.3",
"js-yaml": "^3.14.0",
"mustache": "^4.0.1",
Expand Down
3 changes: 2 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function check (name, pass, config) {
return valid;
}

const deploy = (env) => {
const deploy = (env, commonsMiddleware) => {
return new Promise((resolve, reject) => {
try {
const bodyParser = require('body-parser');
Expand All @@ -47,6 +47,7 @@ const deploy = (env) => {
const logger = require('./src/backend/logger');

const app = express();
app.use("/commons", commonsMiddleware);

if (config.server.enableHTTPBasicAuth) {
logger.info("Adding 'WWW-Authenticate:' header to every path. Check config/env for getting user and pass");
Expand Down

0 comments on commit bc654b5

Please sign in to comment.