Added token authentication, organization module. Moved server bootstrapping code to server.ts file
This commit is contained in:
20
src/index.ts
20
src/index.ts
@@ -1,28 +1,10 @@
|
||||
import mongoose from "mongoose";
|
||||
import fastify from "fastify";
|
||||
|
||||
import routes from "./routes";
|
||||
import { userSchemas } from "./user/user.schema";
|
||||
import { orgSchemas } from "./organization/organization.schema";
|
||||
import { errorHandler } from "./utils/errors";
|
||||
|
||||
const app = fastify({ logger: true });
|
||||
|
||||
app.get("/health", (req, res) => {
|
||||
return { status: "OK" };
|
||||
});
|
||||
|
||||
app.register(routes, { prefix: "/api/v1" });
|
||||
app.setErrorHandler(errorHandler);
|
||||
import app from "./server";
|
||||
|
||||
(async () => {
|
||||
const PORT = parseInt(process.env.PORT ?? "8000");
|
||||
const DB_URI = process.env.DB_URI ?? "";
|
||||
|
||||
for (const schema of [...userSchemas, ...orgSchemas]) {
|
||||
app.addSchema(schema);
|
||||
}
|
||||
|
||||
await mongoose.connect(DB_URI);
|
||||
await app.listen({ port: PORT });
|
||||
})().catch((err) => {
|
||||
|
||||
Reference in New Issue
Block a user