mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-21 11:28:43 +00:00
feat(infisical-pg): updated names and simplified dal layer using ormify
This commit is contained in:
@@ -11,16 +11,16 @@ import { authDalFactory } from "@app/services/auth/auth-dal";
|
||||
import { authLoginServiceFactory } from "@app/services/auth/auth-login-service";
|
||||
import { authPaswordServiceFactory } from "@app/services/auth/auth-password-service";
|
||||
import { authSignupServiceFactory } from "@app/services/auth/auth-signup-service";
|
||||
import { tokenDalFactory } from "@app/services/auth-token/auth-token-dal";
|
||||
import { tokenServiceFactory } from "@app/services/auth-token/auth-token-service";
|
||||
import { incidentContactDalFactory } from "@app/services/org/incident-contacts-dal";
|
||||
import { orgDalFactory } from "@app/services/org/org-dal";
|
||||
import { orgRoleDalFactory } from "@app/services/org/org-role-dal";
|
||||
import { orgRoleServiceFactory } from "@app/services/org/org-role-service";
|
||||
import { orgServiceFactory } from "@app/services/org/org-service";
|
||||
import { serverCfgDalFactory } from "@app/services/server-cfg/server-cfg-dal";
|
||||
import { serverCfgServiceFactory } from "@app/services/server-cfg/server-cfg-service";
|
||||
import { TSmtpService } from "@app/services/smtp/smtp-service";
|
||||
import { tokenDalFactory } from "@app/services/token/token-dal";
|
||||
import { tokenServiceFactory } from "@app/services/token/token-service";
|
||||
import { superAdminDalFactory } from "@app/services/super-admin/super-admin-dal";
|
||||
import { superAdminServiceFactory } from "@app/services/super-admin/super-admin-service";
|
||||
import { userDalFactory } from "@app/services/user/user-dal";
|
||||
import { userServiceFactory } from "@app/services/user/user-service";
|
||||
|
||||
@@ -40,7 +40,7 @@ export const registerRoutes = async (
|
||||
const orgDal = orgDalFactory(db);
|
||||
const incidentContactDal = incidentContactDalFactory(db);
|
||||
const orgRoleDal = orgRoleDalFactory(db);
|
||||
const serverCfgDal = serverCfgDalFactory(db);
|
||||
const superAdminDal = superAdminDalFactory(db);
|
||||
const apiKeyDal = apiKeyDalFactory(db);
|
||||
|
||||
// ee db layer ops
|
||||
@@ -77,16 +77,16 @@ export const registerRoutes = async (
|
||||
orgService
|
||||
});
|
||||
const orgRoleService = orgRoleServiceFactory({ permissionService, orgRoleDal });
|
||||
const serverCfgService = serverCfgServiceFactory({
|
||||
const superAdminService = superAdminServiceFactory({
|
||||
userDal,
|
||||
authService: loginService,
|
||||
serverCfgDal
|
||||
serverCfgDal: superAdminDal
|
||||
});
|
||||
const apiKeyService = apiKeyServiceFactory({ apiKeyDal });
|
||||
|
||||
await serverCfgService.initServerCfg();
|
||||
await superAdminService.initServerCfg();
|
||||
// inject all services
|
||||
server.decorate("services", {
|
||||
server.decorate<FastifyZodProvider["services"]>("services", {
|
||||
login: loginService,
|
||||
password: passwordService,
|
||||
signup: signupService,
|
||||
@@ -94,14 +94,14 @@ export const registerRoutes = async (
|
||||
permission: permissionService,
|
||||
org: orgService,
|
||||
orgRole: orgRoleService,
|
||||
serverCfg: serverCfgService,
|
||||
apiKey: apiKeyService,
|
||||
authToken: tokenService
|
||||
} as FastifyZodProvider["services"]);
|
||||
authToken: tokenService,
|
||||
superAdmin: superAdminService
|
||||
});
|
||||
|
||||
server.decorate("store", {
|
||||
server.decorate<FastifyZodProvider["store"]>("store", {
|
||||
user: userDal
|
||||
} as FastifyZodProvider["store"]);
|
||||
});
|
||||
|
||||
await server.register(injectIdentity);
|
||||
|
||||
|
||||
+7
-7
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { ServerConfigSchema, UsersSchema } from "@app/db/schemas";
|
||||
import { SuperAdminSchema, UsersSchema } from "@app/db/schemas";
|
||||
import { getConfig } from "@app/lib/config/env";
|
||||
import { UnauthorizedError } from "@app/lib/errors";
|
||||
import { verifySuperAdmin } from "@app/server/plugins/auth/superAdmin";
|
||||
@@ -14,12 +14,12 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
|
||||
schema: {
|
||||
response: {
|
||||
200: z.object({
|
||||
config: ServerConfigSchema
|
||||
config: SuperAdminSchema
|
||||
})
|
||||
}
|
||||
},
|
||||
handler: () => {
|
||||
const config = server.services.serverCfg.getServerCfg();
|
||||
const config = server.services.superAdmin.getServerCfg();
|
||||
return { config };
|
||||
}
|
||||
});
|
||||
@@ -33,7 +33,7 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
config: ServerConfigSchema
|
||||
config: SuperAdminSchema
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -42,7 +42,7 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
|
||||
verifySuperAdmin(req);
|
||||
},
|
||||
handler: async (req) => {
|
||||
const config = await server.services.serverCfg.updateServerCfg(req.body);
|
||||
const config = await server.services.superAdmin.updateServerCfg(req.body);
|
||||
return { config };
|
||||
}
|
||||
});
|
||||
@@ -75,10 +75,10 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
|
||||
},
|
||||
handler: async (req, res) => {
|
||||
const appCfg = getConfig();
|
||||
const serverCfg = server.services.serverCfg.getServerCfg();
|
||||
const serverCfg = server.services.superAdmin.getServerCfg();
|
||||
if (serverCfg.initialized)
|
||||
throw new UnauthorizedError({ name: "Admin sign up", message: "Admin has been created" });
|
||||
const { user, token } = await server.services.serverCfg.adminSignUp({
|
||||
const { user, token } = await server.services.superAdmin.adminSignUp({
|
||||
...req.body,
|
||||
ip: req.realIp,
|
||||
userAgent: req.headers["user-agent"] || ""
|
||||
@@ -1,6 +1,6 @@
|
||||
import { registerAdminRouter } from "./admin";
|
||||
import { registerAuthRoutes } from "./auth";
|
||||
import { registerInviteOrgRouter } from "./invite-org";
|
||||
import { registerAdminRouter } from "./admin-router";
|
||||
import { registerAuthRoutes } from "./auth-router";
|
||||
import { registerInviteOrgRouter } from "./invite-org-router";
|
||||
import { registerOrgRouter } from "./organization-router";
|
||||
import { registerPasswordRouter } from "./password-router";
|
||||
import { registerUserActionRouter } from "./user-action-router";
|
||||
|
||||
Reference in New Issue
Block a user