diff --git a/web/package.json b/web/package.json index fefe60d..27191f2 100644 --- a/web/package.json +++ b/web/package.json @@ -12,6 +12,7 @@ "@sentry/node": "^8.0.0", "@types/ejs": "^3.1.5", "body-parser": "^1.20.2", + "compression": "^1.7.4", "cookie-parser": "~1.4.6", "debug": "~2.6.9", "dotenv": "^16.4.5", diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index 1e79507..3bdd801 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -17,6 +17,9 @@ dependencies: body-parser: specifier: ^1.20.2 version: 1.20.2 + compression: + specifier: ^1.7.4 + version: 1.7.4 cookie-parser: specifier: ~1.4.6 version: 1.4.6 @@ -1635,6 +1638,28 @@ packages: readable-stream: 3.6.2 dev: true + /compressible@2.0.18: + resolution: {integrity: sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg==} + engines: {node: '>= 0.6'} + dependencies: + mime-db: 1.52.0 + dev: false + + /compression@1.7.4: + resolution: {integrity: sha512-jaSIDzP9pZVS4ZfQ+TzvtiWhdpFhE2RDHz8QJkpX9SIpLq88VueF5jJw6t+6CUQcAoA6t+x89MLrWAqpfDE8iQ==} + engines: {node: '>= 0.8.0'} + dependencies: + accepts: 1.3.8 + bytes: 3.0.0 + compressible: 2.0.18 + debug: 2.6.9 + on-headers: 1.0.2 + safe-buffer: 5.1.2 + vary: 1.1.2 + transitivePeerDependencies: + - supports-color + dev: false + /concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} diff --git a/web/src/app.ts b/web/src/app.ts index e584c31..34ed5f0 100644 --- a/web/src/app.ts +++ b/web/src/app.ts @@ -6,6 +6,7 @@ import webRouter from "./webRouter"; import apiRouter from "./apiRouter"; import { rateLimit } from 'express-rate-limit' import ejs from "ejs"; +// import compression from "compression"; dotenv.config(); const app = express(); @@ -37,8 +38,6 @@ app.use("", cookieParser()); app.use(json()); app.use(urlencoded({ extended: true })); -app.use(express.static('public')); - // Main routes app.use(process.env.API_PREFIX, apiRouter); app.use("", webRouter); diff --git a/web/src/webRouter.ts b/web/src/webRouter.ts index 81c0a98..e4fbc32 100644 --- a/web/src/webRouter.ts +++ b/web/src/webRouter.ts @@ -206,6 +206,10 @@ webRouter.get("/", async (request: Request, response: Response) => { return response.redirect("/borrow"); }); +webRouter.get("/main.css", async (request: Request, response: Response) => { + response.sendFile(path.join(__dirname, "../public/main.css")); +}); + webRouter.use(async (request: Request, response: Response) => { return response.redirect("/"); });