diff --git a/main.ts b/main.ts index 6d26411..534346b 100644 --- a/main.ts +++ b/main.ts @@ -17,6 +17,18 @@ const PORT = Number(Deno.env.get('PORT')) || 8000; const app = new Hono(); /** MIDDLEWARES */ + +app.use('/v1/*', cors()); + +app.get( + '/v1/*', + cache({ + cacheName: 'nsapi', + cacheControl: 'max-age=900', + wait: true, + }) +); + if (Deno.env.get('NODE_ENV') === 'production') { console.log('Rate limiting enabled'); @@ -27,7 +39,7 @@ if (Deno.env.get('NODE_ENV') === 'production') { const limiter = rateLimiter({ windowMs: 15 * 60 * 1000, // 15 minutes - limit: 5, // Limit each IP to 50 requests per `window` (here, per 15 minutes). + limit: 100, // Limit each IP to 50 requests per `window` (here, per 15 minutes). standardHeaders: 'draft-6', // draft-6: `RateLimit-*` headers; draft-7: combined `RateLimit` header keyGenerator: (c) => c.req.header('cf-connecting-ip') ?? '', // Method to generate custom identifiers for clients. store: new RedisStore({ client: redis }), @@ -36,17 +48,6 @@ if (Deno.env.get('NODE_ENV') === 'production') { app.use(limiter); } -app.use('/v1/*', cors()); - -app.get( - '/v1/*', - cache({ - cacheName: 'nsapi', - cacheControl: 'max-age=900', - wait: true, - }) -); - /** ROUTES */ // Root route app.get('/', (c) => {