浏览代码

Исправлена опечатка в слове schema

Vadim 6 月之前
父节点
当前提交
80d572addd

+ 1 - 1
package.json

@@ -8,7 +8,7 @@
     "#*": "./src/*",
     "#api": "./src/api/api.ts",
     "#db": "./src/db/db.ts",
-    "#db-shema": "./src/db/db-shema.ts",
+    "#db-schema": "./src/db/db-schema.ts",
     "#exceptions": "./src/exceptions/",
     "#logger": "./src/plugins/logger.ts",
     "#dayjs": "./src/plugins/dayjs.ts",

+ 2 - 2
src/db/db-shema.ts → src/db/db-schema.ts

@@ -1,6 +1,6 @@
 import { z } from "zod";
 
-const DbShema = {
+const DbSchema = {
   ev: {
     eventDates: {
       eventId: z.string().uuid(),
@@ -125,4 +125,4 @@ const DbShema = {
   },
 };
 
-export { DbShema };
+export { DbSchema };

+ 8 - 8
src/db/db-service.ts

@@ -2,7 +2,7 @@ import { selPool } from "#db";
 
 import { sql } from "slonik";
 import { z } from "zod";
-import { DbShema } from "./db-shema.js";
+import { DbSchema } from "./db-schema.js";
 import { logger } from "#logger";
 
 function camelToSnake(str: string) {
@@ -11,7 +11,7 @@ function camelToSnake(str: string) {
 
 // база данных
 class DbService {
-  async checkDbShema() {
+  async checkDbSchema() {
     logger.info("Проверка схемы БД...");
 
     const dbColumns = await selPool.any(sql.type(
@@ -41,17 +41,17 @@ class DbService {
             c.column_name;
         `);
 
-    logger.silly("Текущая бд: ", dbColumns, "Необходимая БД: ", DbShema);
+    logger.silly("Текущая бд: ", dbColumns, "Необходимая БД: ", DbSchema);
 
     // перебор схем
-    for (const shema in DbShema) {
+    for (const schema in DbSchema) {
       // перебор таблиц
-      for (const table in DbShema[shema]) {
+      for (const table in DbSchema[schema]) {
         // перебор столбцов
-        for (const column in DbShema[shema][table]) {
+        for (const column in DbSchema[schema][table]) {
           const foundColumn = dbColumns.find(
             (c) =>
-              c.table_schema === camelToSnake(shema) &&
+              c.table_schema === camelToSnake(schema) &&
               c.table_name === camelToSnake(table) &&
               c.column_name === camelToSnake(column),
           );
@@ -59,7 +59,7 @@ class DbService {
           // если нет столбца
           if (!foundColumn)
             throw Error(
-              `Несоответствие схемы БД: схема ${shema}, таблица ${table}, столбец ${column}`,
+              `Несоответствие схемы БД: схема ${schema}, таблица ${table}, столбец ${column}`,
             );
         }
       }

+ 1 - 1
src/main.ts

@@ -74,7 +74,7 @@ logger.info("✅ Роутеры загружены!");
 const start = async () => {
   try {
     // проверка схемы БД
-    await DbService.checkDbShema();
+    await DbService.checkDbSchema();
 
     logger.info("Запуск сервера...");
     app.listen(PORT, () => logger.info(`🚀 Сервер запущен на порту ${PORT}`));

+ 4 - 4
src/modules/companies-management/companies-router.ts

@@ -5,7 +5,7 @@ export default router;
 
 // db
 import { selPool, updPool } from "#db";
-import { DbShema } from "#db-shema";
+import { DbSchema } from "#db-schema";
 import { sql } from "slonik";
 
 // api
@@ -67,9 +67,9 @@ router.get("/user-companies", async (req, res, next) => {
     const companies = await selPool.any(
       sql.type(
         z.object({
-          companyId: DbShema.usr.companies.companyId,
-          name: DbShema.usr.companies.name,
-          timezone: DbShema.usr.companies.timezone,
+          companyId: DbSchema.usr.companies.companyId,
+          name: DbSchema.usr.companies.name,
+          timezone: DbSchema.usr.companies.timezone,
         }),
       )`
         select

+ 12 - 12
src/modules/companies-management/companies-service.ts

@@ -3,7 +3,7 @@
 import { selPool } from "#db";
 import { sql } from "slonik";
 import { z } from "zod";
-import { DbShema } from "#db/db-shema.js";
+import { DbSchema } from "#db/db-schema.js";
 import { ApiError } from "#exceptions/api-error.js";
 
 class companiesService {
@@ -11,8 +11,8 @@ class companiesService {
     const companyData = await selPool.maybeOne(
       sql.type(
         z.object({
-          name: DbShema.usr.companies.name,
-          timezone: DbShema.usr.companies.timezone,
+          name: DbSchema.usr.companies.name,
+          timezone: DbSchema.usr.companies.timezone,
         }),
       )`
     select 
@@ -43,11 +43,11 @@ class companiesService {
     const events = await selPool.any(
       sql.type(
         z.object({
-          eventId: DbShema.ev.events.eventId,
-          localName: DbShema.ev.events.localName,
-          timezone: DbShema.ev.events.timezone,
-          companyId: DbShema.ev.events.companyId,
-          dates: z.array(DbShema.ev.eventDates.date),
+          eventId: DbSchema.ev.events.eventId,
+          localName: DbSchema.ev.events.localName,
+          timezone: DbSchema.ev.events.timezone,
+          companyId: DbSchema.ev.events.companyId,
+          dates: z.array(DbSchema.ev.eventDates.date),
         }),
       )`
         SELECT
@@ -79,10 +79,10 @@ class companiesService {
     const company = await selPool.maybeOne(
       sql.type(
         z.object({
-          companyId: DbShema.usr.companies.companyId,
-          name: DbShema.usr.companies.name,
-          ownerId: DbShema.usr.companies.ownerId,
-          timezone: DbShema.usr.companies.timezone,
+          companyId: DbSchema.usr.companies.companyId,
+          name: DbSchema.usr.companies.name,
+          ownerId: DbSchema.usr.companies.ownerId,
+          timezone: DbSchema.usr.companies.timezone,
         }),
       )`
         select

+ 16 - 16
src/modules/events-management/events-router.ts

@@ -5,7 +5,7 @@ export default router;
 
 // db
 import { selPool, updPool } from "#db";
-import { DbShema } from "#db-shema";
+import { DbSchema } from "#db-schema";
 import { sql } from "slonik";
 
 // api
@@ -105,10 +105,10 @@ router.get("/event/:eventId", async (req, res, next) => {
     const event = await selPool.maybeOne(
       sql.type(
         z.object({
-          eventId: DbShema.ev.events.eventId,
-          localName: DbShema.ev.events.localName,
-          timezone: DbShema.ev.events.timezone,
-          dates: z.array(DbShema.ev.eventDates.date),
+          eventId: DbSchema.ev.events.eventId,
+          localName: DbSchema.ev.events.localName,
+          timezone: DbSchema.ev.events.timezone,
+          dates: z.array(DbSchema.ev.eventDates.date),
         }),
       )`
           select
@@ -131,7 +131,7 @@ router.get("/event/:eventId", async (req, res, next) => {
     if (!event) throw ApiError.BadRequest("EventNotFound", "Ивент не найден");
 
     // points
-    const DbPointsType = DbShema.ev.programPoints;
+    const DbPointsType = DbSchema.ev.programPoints;
     const programPoints = await selPool.any(
       sql.type(
         z.object({
@@ -161,9 +161,9 @@ router.get("/event/:eventId", async (req, res, next) => {
     const rooms = await selPool.any(
       sql.type(
         z.object({
-          roomId: DbShema.ev.rooms.roomId,
-          name: DbShema.ev.rooms.name,
-          locationId: DbShema.ev.rooms.locationId,
+          roomId: DbSchema.ev.rooms.roomId,
+          name: DbSchema.ev.rooms.name,
+          locationId: DbSchema.ev.rooms.locationId,
         }),
       )`
           select
@@ -184,8 +184,8 @@ router.get("/event/:eventId", async (req, res, next) => {
     const taskBlocks = await selPool.any(
       sql.type(
         z.object({
-          taskBlockId: DbShema.ev.taskBlocks.taskBlockId,
-          name: DbShema.ev.taskBlocks.name,
+          taskBlockId: DbSchema.ev.taskBlocks.taskBlockId,
+          name: DbSchema.ev.taskBlocks.name,
         }),
       )`
         select
@@ -201,9 +201,9 @@ router.get("/event/:eventId", async (req, res, next) => {
     const managers = await selPool.any(
       sql.type(
         z.object({
-          userId: DbShema.ev.eventManagers.userId,
-          name: DbShema.usr.users.name,
-          email: DbShema.usr.users.email,
+          userId: DbSchema.ev.eventManagers.userId,
+          name: DbSchema.usr.users.name,
+          email: DbSchema.usr.users.email,
         }),
       )`
         select
@@ -223,8 +223,8 @@ router.get("/event/:eventId", async (req, res, next) => {
     const roles = await selPool.any(
       sql.type(
         z.object({
-          roleId: DbShema.ev.roles.roleId,
-          name: DbShema.ev.roles.name,
+          roleId: DbSchema.ev.roles.roleId,
+          name: DbSchema.ev.roles.name,
         }),
       )`
         select

+ 3 - 3
src/modules/events-management/events-service.ts

@@ -3,7 +3,7 @@
 import { selPool } from "#db";
 import { sql } from "slonik";
 import { ApiError } from "#exceptions/api-error.js";
-import { DbShema } from "#db/db-shema.js";
+import { DbSchema } from "#db/db-schema.js";
 import { z } from "zod";
 
 class eventsService {
@@ -36,7 +36,7 @@ class eventsService {
   }): Promise<string> {
     if (taskBlockId) {
       const eventId = await selPool.maybeOneFirst(
-        sql.type(z.object({ eventId: DbShema.ev.taskBlocks.eventId }))`
+        sql.type(z.object({ eventId: DbSchema.ev.taskBlocks.eventId }))`
         select
           event_id as "eventId"
         from
@@ -55,7 +55,7 @@ class eventsService {
 
     if (taskId) {
       const taskBlockId = await selPool.maybeOneFirst(
-        sql.type(z.object({ taskBlockId: DbShema.ev.taskBlocks.taskBlockId }))`
+        sql.type(z.object({ taskBlockId: DbSchema.ev.taskBlocks.taskBlockId }))`
         select
           task_block_id as "taskBlockId"
         from

+ 6 - 6
src/modules/locations-management/locations-router.ts

@@ -5,7 +5,7 @@ export default router;
 
 // db
 import { selPool, updPool } from "#db";
-import { DbShema } from "#db-shema";
+import { DbSchema } from "#db-schema";
 import { sql } from "slonik";
 
 // error
@@ -91,13 +91,13 @@ router.get("/event-locations/:eventId", async (req, res, next) => {
     const locations = await selPool.any(
       sql.type(
         z.object({
-          locationId: DbShema.ev.locations.locationId,
-          name: DbShema.ev.locations.name,
+          locationId: DbSchema.ev.locations.locationId,
+          name: DbSchema.ev.locations.name,
           rooms: z.array(
             z.object({
-              roomId: DbShema.ev.rooms.roomId,
-              name: DbShema.ev.rooms.name,
-              parentId: DbShema.ev.rooms.parentId,
+              roomId: DbSchema.ev.rooms.roomId,
+              name: DbSchema.ev.rooms.name,
+              parentId: DbSchema.ev.rooms.parentId,
             }),
           ),
         }),

+ 5 - 5
src/modules/tasks-management/task-blocks-router.ts

@@ -26,7 +26,7 @@ import { RouterUtils } from "#utils/router-utils.js";
 import { TasksManagementApi } from "#api";
 import { EventsService } from "#modules/events-management/events-service.js";
 import { z } from "zod";
-import { DbShema } from "#db/db-shema.js";
+import { DbSchema } from "#db/db-schema.js";
 import { ApiError } from "#exceptions/api-error.js";
 
 dayjs.extend(utc);
@@ -112,8 +112,8 @@ router.get("/task-block/:taskBlockId", async (req, res, next) => {
     const taskBlock = await selPool.maybeOne(
       sql.type(
         z.object({
-          taskBlockId: DbShema.ev.taskBlocks.taskBlockId,
-          name: DbShema.ev.taskBlocks.name,
+          taskBlockId: DbSchema.ev.taskBlocks.taskBlockId,
+          name: DbSchema.ev.taskBlocks.name,
         }),
       )`
     select
@@ -128,7 +128,7 @@ router.get("/task-block/:taskBlockId", async (req, res, next) => {
       throw ApiError.BadRequest("Task block not found", "Task block not found");
     }
 
-    const ZDbTasks = DbShema.ev.tasks;
+    const ZDbTasks = DbSchema.ev.tasks;
     const tasks = await selPool.any(
       sql.type(
         z.object({
@@ -141,7 +141,7 @@ router.get("/task-block/:taskBlockId", async (req, res, next) => {
           taskBlockId: ZDbTasks.taskBlockId,
           programPointId: ZDbTasks.programPointId,
           roomId: ZDbTasks.roomId,
-          executors: z.array(DbShema.ev.taskExecutors.roleId),
+          executors: z.array(DbSchema.ev.taskExecutors.roleId),
         }),
       )`
           select

+ 5 - 5
src/modules/users-management/auth/routers/auth-router.ts

@@ -5,7 +5,7 @@ export default router;
 
 // db
 import { selPool, updPool } from "#db";
-import { DbShema } from "#db-shema";
+import { DbSchema } from "#db-schema";
 import { sql } from "slonik";
 
 // api
@@ -179,9 +179,9 @@ router.post("/login", async (req, res, next) => {
     const user = await selPool.maybeOne(
       sql.type(
         z.object({
-          userId: DbShema.usr.users.userId,
-          password: DbShema.usr.users.password,
-          wrongPassTries: DbShema.usr.users.wrongPassTries,
+          userId: DbSchema.usr.users.userId,
+          password: DbSchema.usr.users.password,
+          wrongPassTries: DbSchema.usr.users.wrongPassTries,
         }),
       )`
       select 
@@ -323,7 +323,7 @@ router.get("/refresh", async (req, res, next) => {
     const newUserData = await selPool.maybeOne(
       sql.type(
         z.object({
-          email: DbShema.usr.users.email,
+          email: DbSchema.usr.users.email,
         }),
       )`select email from usr.users where user_id = ${userData.userId}`,
     );

+ 5 - 5
src/modules/users-management/confirm-pins/confirm-pins-service.ts

@@ -3,7 +3,7 @@ import { logger } from "#logger";
 import { selPool, updPool } from "#db";
 import { sql } from "slonik";
 
-import { DbShema } from "#db-shema";
+import { DbSchema } from "#db-schema";
 import { z } from "zod";
 
 // dayjs
@@ -87,10 +87,10 @@ class confirmPinsService {
     const pinInfo = await selPool.maybeOne(
       sql.type(
         z.object({
-          confirmPin: DbShema.usr.confirmPins.confirmPin,
-          email: DbShema.usr.confirmPins.email,
-          createTime: DbShema.usr.confirmPins.createTime,
-          wrongPinTries: DbShema.usr.confirmPins.wrongPinTries,
+          confirmPin: DbSchema.usr.confirmPins.confirmPin,
+          email: DbSchema.usr.confirmPins.email,
+          createTime: DbSchema.usr.confirmPins.createTime,
+          wrongPinTries: DbSchema.usr.confirmPins.wrongPinTries,
         }),
       )`
       select