Skip to content

Commit

Permalink
fix ci issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wheelsandcogs committed Sep 2, 2024
1 parent 7ce9233 commit e9186d4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# connection details for this service
FRONTEND_URL=http://localhost:3000
BACKEND_URL=http://localhost:3001

SESSION_SECRET=
JWT_SECRET=

# rate limiting
RATE_LIMIT_WINDOW_MS=15*60*1000
RATE_LIMIT_MAX_REQ=100
10 changes: 5 additions & 5 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ app.set('view engine', 'ejs');
app.use('/public', express.static(`${__dirname}/public`));
app.use('/css', express.static(`${__dirname}/css`));
app.use('/assets', express.static(`${__dirname}/assets`));
app.use('/auth', auth);
app.use('/healthcheck', healthcheck);
app.use('/auth', rateLimiter, auth);
app.use('/healthcheck', rateLimiter, healthcheck);

app.use('/:lang/publish', publish, rateLimiter, ensureAuthenticated);
app.use('/:lang/dataset', view, rateLimiter, ensureAuthenticated);
app.use('/:lang/healthcheck', healthcheck);
app.use('/:lang/publish', rateLimiter, ensureAuthenticated, publish);
app.use('/:lang/dataset', rateLimiter, ensureAuthenticated, view);
app.use('/:lang/healthcheck', rateLimiter, healthcheck);

app.get('/', (req: Request, res: Response) => {
const lang = req.headers['accept-language'] || req.headers['Accept-Language'] || req.i18n.language || 'en-GB';
Expand Down
4 changes: 2 additions & 2 deletions src/middleware/rate-limiter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import rateLimit from 'express-rate-limit';

export const rateLimiter = rateLimit({
windowMs: 15 * 60 * 1000,
max: 100,
windowMs: parseInt(process.env.RATE_LIMIT_WINDOW_MS || '60000', 10),
max: parseInt(process.env.RATE_LIMIT_MAX_REQ || '100', 10),
standardHeaders: true,
legacyHeaders: false,
handler: (req, res) => {
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/session.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import session from 'express-session';

export default session({
secret: process.env.SESSION_SECRET || 'default',
secret: process.env.SESSION_SECRET || '',
resave: false,
saveUninitialized: false,
cookie: {
Expand Down

0 comments on commit e9186d4

Please sign in to comment.