feat: bunch of work done here, got comments and edit and delete

This commit is contained in:
2026-02-04 13:00:16 -08:00
parent b6d66d34cb
commit 318f3bc500
19 changed files with 1868 additions and 117 deletions
+20
View File
@@ -11,6 +11,18 @@ declare module "fastify" {
}
}
declare module "@fastify/jwt" {
interface FastifyJWT {
user: {
id: string;
username: string;
email?: string;
avatar?: string;
isAdmin: boolean;
};
}
}
const authPlugin: FastifyPluginAsync = async (app) => {
// Register JWT plugin
app.register(fastifyJwt, {
@@ -19,6 +31,14 @@ const authPlugin: FastifyPluginAsync = async (app) => {
cookieName: "auth-token",
signed: false,
},
formatUser: (payload: { sub: string; email?: string; username: string; isAdmin: boolean }) => {
return {
id: payload.sub,
email: payload.email,
username: payload.username,
isAdmin: payload.isAdmin,
};
},
});
// Register cookie plugin