|
|
@@ -1,19 +1,23 @@
|
|
|
import express from 'express';
|
|
|
import bodyParser from 'body-parser';
|
|
|
-import rateLimit from 'express-rate-limit';
|
|
|
+import expressRateLimit from 'express-rate-limit';
|
|
|
|
|
|
import routes from './api/routes/bDateRoutes.js'; // importing routes
|
|
|
|
|
|
/**
|
|
|
-* @returns {ExpressApp}
|
|
|
-*/
|
|
|
-function createServer () {
|
|
|
- const app = express();
|
|
|
-
|
|
|
- app.use(rateLimit({
|
|
|
+ * @param {ExpressApp} app
|
|
|
+ * @returns {ExpressApp}
|
|
|
+ */
|
|
|
+function createServer ({
|
|
|
+ app = express(),
|
|
|
+ rateLimit = {
|
|
|
windowMs: 1 * 60 * 1000, // 1 minute
|
|
|
max: 20
|
|
|
- }));
|
|
|
+ }
|
|
|
+} = {}) {
|
|
|
+ if (rateLimit) {
|
|
|
+ app.use(expressRateLimit(rateLimit));
|
|
|
+ }
|
|
|
|
|
|
app.use(bodyParser.urlencoded({extended: true}));
|
|
|
app.use(bodyParser.json());
|