31 lines
748 B
TypeScript
31 lines
748 B
TypeScript
import fastify from "fastify";
|
|
|
|
import routes from "./routes";
|
|
import { userSchemas } from "./user/user.schema";
|
|
import { orgSchemas } from "./organization/organization.schema";
|
|
import { tokenSchemas } from "./tokens/token.schema";
|
|
import { errorHandler } from "./utils/errors";
|
|
import { authorize } from "./auth";
|
|
import { permitSchemas } from "./permit/permit.schema";
|
|
|
|
const app = fastify({ logger: true });
|
|
|
|
app.get("/health", (req, res) => {
|
|
return { status: "OK" };
|
|
});
|
|
|
|
app.decorate("authorize", authorize);
|
|
app.setErrorHandler(errorHandler);
|
|
app.register(routes, { prefix: "/api/v1" });
|
|
|
|
for (const schema of [
|
|
...userSchemas,
|
|
...orgSchemas,
|
|
...tokenSchemas,
|
|
...permitSchemas,
|
|
]) {
|
|
app.addSchema(schema);
|
|
}
|
|
|
|
export default app;
|