summaryrefslogtreecommitdiff
path: root/payever/src/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'payever/src/app.js')
-rw-r--r--payever/src/app.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/payever/src/app.js b/payever/src/app.js
new file mode 100644
index 0000000..39754a6
--- /dev/null
+++ b/payever/src/app.js
@@ -0,0 +1,38 @@
+const express = require('express');
+const cors = require('cors');
+const bodyParser = require('body-parser');
+const helmet = require('helmet');
+const expressWinston = require('express-winston');
+
+const errorHandlers = require('./utils/errorHandlers');
+const { winstonConfig } = require('./utils/config');
+const appRoutes = require('./routes/app');
+
+const app = express();
+
+app.use(cors());
+
+app.use(bodyParser.json());
+app.use(bodyParser.urlencoded({ extended: true }));
+
+app.use(helmet());
+
+/* istanbul ignore if */
+if (process.env.NODE_ENV !== 'test') {
+ app.use(expressWinston.logger(winstonConfig));
+}
+
+app.use('/', appRoutes);
+
+/* istanbul ignore if */
+if (process.env.NODE_ENV !== 'test') {
+ app.use(expressWinston.errorLogger(winstonConfig));
+}
+
+app.use(errorHandlers.notFound);
+
+app.use(errorHandlers.flashValidationErrors);
+
+app.use(errorHandlers.productionErrors);
+
+module.exports = app;