Skip to content

Commit 0c3eb18

Browse files
committed
Merge pull request #38 from Kasper24/restructure
refactor: move and rename files for better organization
2 parents 9691ac5 + cbba0bb commit 0c3eb18

14 files changed

Lines changed: 16 additions & 17 deletions

File tree

apps/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"^@repo/backend/(.*)$": "<rootDir>/src/$1"
2020
},
2121
"setupFilesAfterEnv": [
22-
"<rootDir>/src/jest.setup.ts"
22+
"<rootDir>/jest.setup.ts"
2323
]
2424
},
2525
"dependencies": {
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const timeSpanType = z
55
.regex(/^\d+[smhd]$/, "Invalid format. Use formats like '15m', '1h', '7d'.")
66
.transform((val) => val as `${number}${"s" | "m" | "h" | "d"}`);
77

8-
const environmentVariableSchema = z.object({
8+
const envSchema = z.object({
99
// Node Environment
1010
NODE_ENV: z.enum(["development", "test", "production"]),
1111

@@ -76,20 +76,18 @@ const environmentVariableSchema = z.object({
7676

7777
const envValidate = () => {
7878
try {
79-
environmentVariableSchema.parse(process.env);
79+
envSchema.parse(process.env);
8080
} catch (error) {
8181
if (error instanceof ZodError) console.error(error.errors);
8282
process.exit(1);
8383
}
8484
};
8585

86-
type EnvSchemaType = z.infer<typeof environmentVariableSchema>;
87-
8886
declare global {
8987
// eslint-disable-next-line @typescript-eslint/no-namespace
9088
namespace NodeJS {
9189
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
92-
interface ProcessEnv extends EnvSchemaType {}
90+
interface ProcessEnv extends z.infer<typeof environmentVariableSchema> {}
9391
}
9492
}
9593

apps/backend/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createServer } from "@repo/backend/server";
2-
import envValidate from "@repo/backend/config";
2+
import envValidate from "@repo/backend/env";
33
import { dbPush, dbReset, dbSeed, dbWaitForConnection } from "@repo/database";
44

55
envValidate();

apps/backend/src/middlewares/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Request, Response, NextFunction } from "express";
2-
import { AuthError } from "@repo/backend/utils/errors";
2+
import { AuthError } from "@repo/backend/errors";
33
import { jwtVerifyAccessToken } from "@repo/backend/utils/jwt";
44

55
export interface AuthenticatedRequest extends Request {

apps/backend/src/middlewares/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Request, Response, ErrorRequestHandler, NextFunction } from "express";
22
import { ReasonPhrases, StatusCodes } from "http-status-codes";
3-
import { GenericError } from "@repo/backend/utils/errors";
3+
import { GenericError } from "@repo/backend/errors";
44

55
const errorHandler: ErrorRequestHandler = (
66
error: unknown,

apps/backend/src/middlewares/rate-limit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Request, Response, NextFunction } from "express";
22
import redis from "@repo/backend/redis";
33
import { parseTimeSpan, type TimeSpan } from "@repo/backend/utils/time";
4-
import { RateLimitError } from "@repo/backend/utils/errors";
4+
import { RateLimitError } from "@repo/backend/errors";
55

66
const rateLimitHandler = ({
77
endpoint = "global",

apps/backend/src/middlewares/validation.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Request, Response, NextFunction } from "express";
22
import { z, ZodError } from "zod";
3-
import { BadRequestError } from "@repo/backend/utils/errors";
3+
import { BadRequestError } from "@repo/backend/errors";
44

55
const validateHandler = (schema: z.ZodSchema) => {
66
return (req: Request, res: Response, next: NextFunction) => {
@@ -11,7 +11,8 @@ const validateHandler = (schema: z.ZodSchema) => {
1111
if (error instanceof ZodError) {
1212
const errorMessages = error.errors
1313
.map(
14-
(issue: z.ZodIssue) => `${issue.path.join(".")} is ${issue.message}`
14+
(issue: z.ZodIssue) =>
15+
`${issue.path.join(".")} is ${issue.message}`,
1516
)
1617
.join(", ");
1718
throw new BadRequestError(errorMessages);

apps/backend/src/modules/auth/auth.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import twilio from "twilio";
44
import { eq } from "drizzle-orm";
55
import { db } from "@repo/database";
66
import { otps, refreshTokens, users } from "@repo/database/schema";
7-
import { AuthError } from "@repo/backend/utils/errors";
7+
import { AuthError } from "@repo/backend/errors";
88
import {
99
jwtSignAccessToken,
1010
jwtSignRefreshToken,

0 commit comments

Comments
 (0)