added refreshtoken logic to backend

This commit is contained in:
Kai Ritthaler 2025-06-20 11:18:02 +02:00 committed by Luisa Bellitto
parent a9bda19891
commit ae318b61bf
2 changed files with 29 additions and 0 deletions

View file

@ -31,6 +31,7 @@ export const minioClient = new Client({
//swagger configuration
import swaggerJSDoc from "swagger-jsdoc";
import swaggerUi from "swagger-ui-express";
import { deleteExpiredTokens } from "./tasks/deleteTokens";
const options = {
definition: {
@ -65,6 +66,15 @@ const options = {
};
const specs = swaggerJSDoc(options);
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(specs));
// remove old tokens every ten minutes
setInterval(
() => {
console.log("Deleting old tokens");
deleteExpiredTokens();
},
10 * 60 * 1000
);
app.use(bodyParser.json());
app.use("/api/user", userRouter);
app.use("/api/posts", authenticateToken(), postRouter);