Add dockerfile, small fixes
This commit is contained in:
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@@ -0,0 +1,9 @@
|
||||
FROM node:22-alpine
|
||||
WORKDIR /home/app
|
||||
|
||||
COPY package.json .
|
||||
RUN npm install --force
|
||||
|
||||
COPY ./dist ./dist
|
||||
EXPOSE 8000
|
||||
CMD ["node", "./dist/index.js"]
|
||||
@@ -6,7 +6,7 @@ import app from "./server";
|
||||
const DB_URI = process.env.DB_URI ?? "";
|
||||
|
||||
await mongoose.connect(DB_URI);
|
||||
await app.listen({ port: PORT });
|
||||
await app.listen({ port: PORT, host: "0.0.0.0" });
|
||||
})().catch((err) => {
|
||||
console.log(err);
|
||||
process.exit(1);
|
||||
|
||||
@@ -29,7 +29,6 @@ export const orgModel = mongoose.model(
|
||||
);
|
||||
|
||||
const orgCore = {
|
||||
_id: z.string().optional(),
|
||||
name: z.string().max(30),
|
||||
domain: z.string().max(30).optional(),
|
||||
avatar: z.string().url().optional(),
|
||||
@@ -44,6 +43,7 @@ const createOrgInput = z.object({
|
||||
});
|
||||
|
||||
const createOrgResponse = z.object({
|
||||
_id: z.string().optional(),
|
||||
pid: z.string(),
|
||||
...orgCore,
|
||||
});
|
||||
|
||||
@@ -3,8 +3,10 @@ import userRoutes from "./user/user.route";
|
||||
import organizationRoutes from "./organization/organization.route";
|
||||
import { tokenRoutes } from "./tokens/token.route";
|
||||
import { permitRoutes } from "./permit/permit.route";
|
||||
import { authHandler } from "./auth";
|
||||
|
||||
export default async function routes(fastify: FastifyInstance) {
|
||||
fastify.addHook("preHandler", authHandler);
|
||||
fastify.register(userRoutes, { prefix: "/users" });
|
||||
fastify.register(organizationRoutes, { prefix: "/orgs" });
|
||||
fastify.register(tokenRoutes, { prefix: "/tokens" });
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import mongoose from "mongoose";
|
||||
import fastify from "fastify";
|
||||
|
||||
import routes from "./routes";
|
||||
@@ -6,7 +5,7 @@ import { userSchemas } from "./user/user.schema";
|
||||
import { orgSchemas } from "./organization/organization.schema";
|
||||
import { tokenSchemas } from "./tokens/token.schema";
|
||||
import { errorHandler } from "./utils/errors";
|
||||
import { authHandler, authorize } from "./auth";
|
||||
import { authorize } from "./auth";
|
||||
import { permitSchemas } from "./permit/permit.schema";
|
||||
|
||||
const app = fastify({ logger: true });
|
||||
@@ -17,7 +16,6 @@ app.get("/health", (req, res) => {
|
||||
|
||||
app.decorate("authorize", authorize);
|
||||
app.setErrorHandler(errorHandler);
|
||||
app.addHook("onRequest", authHandler);
|
||||
app.register(routes, { prefix: "/api/v1" });
|
||||
|
||||
for (const schema of [
|
||||
|
||||
Reference in New Issue
Block a user