Added token authentication, organization module. Moved server bootstrapping code to server.ts file

This commit is contained in:
2024-12-19 21:49:54 +05:30
parent 970a972b11
commit 4b49c43a0c
16 changed files with 652 additions and 22 deletions

24
src/tokens/token.route.ts Normal file
View File

@@ -0,0 +1,24 @@
import { FastifyInstance } from "fastify";
import { createTokenHandler, getTokenHandler } from "./token.controller";
import { $token } from "./token.schema";
export async function tokenRoutes(fastify: FastifyInstance) {
fastify.post(
"/",
{
schema: {
body: $token("createTokenInput"),
response: {
201: $token("createTokenResponse"),
},
},
},
createTokenHandler
);
fastify.get(
"/:tokenId",
{ schema: { response: { 200: $token("getTokenResponse") } } },
getTokenHandler
);
}