From 53cf4076db6604ac5c426acad4dab2f8bdb9a1ee Mon Sep 17 00:00:00 2001 From: trivernis Date: Wed, 15 Jan 2020 11:51:46 +0100 Subject: [PATCH] Optimize import and Change Rate Limit - Change default Rate Limit to 60 --- config/default.toml | 2 +- src/app.ts | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/default.toml b/config/default.toml index 9c52a26..6ed31ce 100644 --- a/config/default.toml +++ b/config/default.toml @@ -73,4 +73,4 @@ maxQueryComplexity = 5000 # The time in milliseconds before the rate limit is reset expire = 60000 # The total number of calls allowed before rate limiting - total = 30 + total = 60 diff --git a/src/app.ts b/src/app.ts index 6d9aa2f..fc5e217 100644 --- a/src/app.ts +++ b/src/app.ts @@ -2,21 +2,20 @@ import * as compression from "compression"; import * as config from "config"; import * as cookieParser from "cookie-parser"; import * as cors from "cors"; -import {Request, Response} from "express"; import * as express from "express"; +import {Request, Response} from "express"; import * as graphqlHTTP from "express-graphql"; import * as session from "express-session"; -import sharedsession = require("express-socket.io-session"); import * as fsx from "fs-extra"; import {buildSchema} from "graphql"; import {importSchema} from "graphql-import"; import queryComplexity, {directiveEstimator, simpleEstimator} from "graphql-query-complexity"; -import {IncomingMessage, ServerResponse} from "http"; import * as http from "http"; +import {IncomingMessage} from "http"; import * as httpStatus from "http-status"; import * as path from "path"; -import {RedisClient} from "redis"; import * as redis from "redis"; +import {RedisClient} from "redis"; import {Sequelize} from "sequelize-typescript"; import * as socketIo from "socket.io"; import * as socketIoRedis from "socket.io-redis"; @@ -25,6 +24,7 @@ import dataaccess from "./lib/dataAccess"; import globals from "./lib/globals"; import HomeRoute from "./routes/HomeRoute"; import {UploadRoute} from "./routes/UploadRoute"; +import sharedsession = require("express-socket.io-session"); const SequelizeStore = require("connect-session-sequelize")(session.Store); const createLimiter: (...args: any) => any = require("express-limiter"); @@ -107,7 +107,7 @@ class App { store: new SequelizeStore({db: this.sequelize}), }); - await this.sequelize.sync({ logging: (msg) => logger.silly(msg)}); + await this.sequelize.sync({logging: (msg) => logger.silly(msg)}); this.sequelize.options.logging = (msg) => logger.silly(msg); logger.info("Setting up socket.io"); try { @@ -192,7 +192,7 @@ class App { }); // @ts-ignore - this.app.use("/graphql", graphqlHTTP(async (request, response, {variables}) => { + this.app.use("/graphql", graphqlHTTP(async (request, response, {variables}) => { response.setHeader("X-Max-Query-Complexity", config.get("api.maxQueryComplexity")); return { // @ts-ignore all @@ -224,7 +224,7 @@ class App { }); // redirect all request to the angular file this.app.use((req: any, res: Response) => { - if (config.get("frontend.angularIndex")) { + if (config.has("frontend.angularIndex")) { const angularIndex = path.join(this.publicPath, config.get("frontend.angularIndex")); if (fsx.existsSync(path.join(angularIndex))) { res.sendFile(angularIndex);