Skip to content

Commit

Permalink
Add apicache dependency and implement caching middleware for improved…
Browse files Browse the repository at this point in the history
… performance
  • Loading branch information
ubeydeozdmr committed Nov 13, 2024
1 parent 7544e1f commit 4e6649b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
17 changes: 16 additions & 1 deletion package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"author": "Ubeyde Emir Özdemir",
"license": "MIT",
"dependencies": {
"apicache": "^1.6.3",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.21.1",
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ const express = require('express');
const swaggerUI = require('swagger-ui-express');
const swaggerSpec = require('./swagger');
const morgan = require('morgan');
const apicache = require('apicache');
const { rateLimit } = require('express-rate-limit');
require('dotenv').config();

const app = express();
const cache = apicache.middleware;

const { PORT, NODE_ENV } = process.env;

Expand All @@ -28,6 +30,7 @@ app.options('*', cors());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(morgan('combined'));
app.use(cache('24 hour'));
app.use(limiter);

app.use('/swagger', swaggerUI.serve, swaggerUI.setup(swaggerSpec));
Expand Down

0 comments on commit 4e6649b

Please sign in to comment.