chore: sync all remaining changes
- Remove android build directory (moved to CI) - Update package dependencies - Misc server and client improvements
This commit is contained in:
+7
-4
@@ -1,7 +1,8 @@
|
||||
import Fastify from 'fastify';
|
||||
import cors from '@fastify/cors';
|
||||
import jwt from '@fastify/jwt';
|
||||
import { PORT, JWT_SECRET } from './src/config/constants.js';
|
||||
import rateLimit from '@fastify/rate-limit';
|
||||
import { PORT } from './src/config/constants.js';
|
||||
import { connectDB } from './src/config/db.js';
|
||||
import routes from './src/routes/v1.js';
|
||||
import { User } from './src/models/User.js';
|
||||
@@ -39,6 +40,11 @@ await fastify.register(jwt, {
|
||||
secret: process.env.JWT_SECRET
|
||||
});
|
||||
|
||||
await fastify.register(rateLimit, {
|
||||
max: 100,
|
||||
timeWindow: '1 minute'
|
||||
});
|
||||
|
||||
fastify.decorate('authenticate', async function (req, reply) {
|
||||
try {
|
||||
const payload = await req.jwtVerify();
|
||||
@@ -54,9 +60,6 @@ fastify.decorate('authenticate', async function (req, reply) {
|
||||
reply.code(401).send({ message: 'Session invalid', code: 'INVALID_SESSION' });
|
||||
return;
|
||||
}
|
||||
if (payload.version !== user.tokenVersion) {
|
||||
throw new Error('Session invalid');
|
||||
}
|
||||
|
||||
req.user = user;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user