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

View File

@@ -1,6 +1,6 @@
import { FastifyRequest, FastifyReply } from "fastify";
import { CreateOrgInput } from "./organization.schema";
import { createOrg } from "./organization.service";
import { createOrg, getOrg } from "./organization.service";
export async function createOrgHandler(
req: FastifyRequest<{ Body: CreateOrgInput }>,
@@ -15,3 +15,20 @@ export async function createOrgHandler(
return err;
}
}
export async function getOrgHandler(
req: FastifyRequest<{ Params: { orgId: string } }>,
res: FastifyReply
) {
const { orgId } = req.params;
try {
const org = await getOrg(orgId);
if (org === null)
return res.code(404).send({ error: "resource not found" });
return res.code(200).send(org);
} catch (err) {
return err;
}
}