55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import fastify from "fastify";
|
|
import cors from "@fastify/cors";
|
|
import multipart from "@fastify/multipart";
|
|
|
|
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";
|
|
import { fileSchemas } from "./file/file.schema";
|
|
import { oauth } from "./oauth";
|
|
import { authRoutes } from "./auth/auth.route";
|
|
import { rtsSchemas } from "./rts/rts.schema";
|
|
import { taskSchemas } from "./task/task.schema";
|
|
import { notificationSchemas } from "./notification/notification.schema";
|
|
import { noteSchemas } from "./note/note.schema";
|
|
import { webAuthnRoutes } from "./webauthn/webauthn.route";
|
|
|
|
const app = fastify({ logger: true, trustProxy: true });
|
|
|
|
app.get("/health", (req, res) => {
|
|
return { status: "OK" };
|
|
});
|
|
|
|
oauth(app);
|
|
|
|
app.decorate("authorize", authorize);
|
|
app.setErrorHandler(errorHandler);
|
|
app.register(cors, {
|
|
origin: [process.env.UI_DOMAIN || ""],
|
|
credentials: true,
|
|
});
|
|
app.register(multipart, { limits: { fileSize: 50000000 } });
|
|
app.register(authRoutes, { prefix: "/auth" });
|
|
app.register(webAuthnRoutes, { prefix: "/webauthn" });
|
|
app.register(routes, { prefix: "/api/v1" });
|
|
|
|
for (const schema of [
|
|
...userSchemas,
|
|
...orgSchemas,
|
|
...tokenSchemas,
|
|
...permitSchemas,
|
|
...fileSchemas,
|
|
...rtsSchemas,
|
|
...taskSchemas,
|
|
...notificationSchemas,
|
|
...noteSchemas,
|
|
]) {
|
|
app.addSchema(schema);
|
|
}
|
|
|
|
export default app;
|