startx 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/.prettierignore +0 -13
  2. package/.prettierrc.js +52 -52
  3. package/.vscode/launch.json +32 -0
  4. package/.vscode/settings.json +9 -3
  5. package/apps/core-server/.env.example +18 -24
  6. package/apps/core-server/Dockerfile +35 -61
  7. package/apps/core-server/eslint.config.ts +7 -0
  8. package/apps/core-server/package.json +41 -52
  9. package/apps/core-server/src/config/custom-type.ts +2 -40
  10. package/apps/core-server/src/events/index.ts +37 -37
  11. package/apps/core-server/src/index.ts +4 -13
  12. package/apps/core-server/src/middlewares/auth-middleware.ts +24 -7
  13. package/apps/core-server/src/middlewares/cors-middleware.ts +7 -6
  14. package/apps/core-server/src/middlewares/error-middleware.ts +7 -4
  15. package/apps/core-server/src/middlewares/logger-middleware.ts +81 -21
  16. package/apps/core-server/src/middlewares/notfound-middleware.ts +6 -14
  17. package/apps/core-server/src/middlewares/serve-static.ts +30 -24
  18. package/apps/core-server/src/routes/files/router.ts +9 -7
  19. package/apps/core-server/src/routes/server.ts +30 -36
  20. package/apps/core-server/tsdown.config.ts +4 -3
  21. package/biome.json +58 -60
  22. package/configs/eslint-config/package.json +16 -19
  23. package/configs/eslint-config/src/configs/base.ts +185 -225
  24. package/configs/eslint-config/src/configs/extend.ts +3 -0
  25. package/configs/eslint-config/src/configs/frontend.ts +81 -56
  26. package/configs/eslint-config/src/configs/node.ts +6 -6
  27. package/configs/eslint-config/src/plugin.ts +1 -0
  28. package/configs/eslint-config/src/rules/index.ts +8 -12
  29. package/configs/eslint-config/src/rules/no-json-parse-json-stringify.test.ts +30 -17
  30. package/configs/eslint-config/src/rules/no-json-parse-json-stringify.ts +52 -49
  31. package/configs/eslint-config/src/rules/no-uncaught-json-parse.ts +43 -45
  32. package/configs/tsdown-config/package.json +10 -3
  33. package/configs/typescript-config/package.json +10 -1
  34. package/configs/typescript-config/tsconfig.common.json +3 -3
  35. package/configs/vitest-config/dist/base.mjs +1 -0
  36. package/configs/vitest-config/dist/frontend.mjs +1 -0
  37. package/configs/vitest-config/dist/node.mjs +1 -0
  38. package/configs/vitest-config/package.json +12 -0
  39. package/configs/vitest-config/src/base.ts +17 -29
  40. package/configs/vitest-config/src/index.ts +1 -0
  41. package/package.json +21 -13
  42. package/packages/@repo/constants/eslint.config.ts +4 -0
  43. package/packages/@repo/constants/package.json +16 -0
  44. package/packages/@repo/constants/src/index.ts +8 -8
  45. package/packages/@repo/db/eslint.config.ts +4 -0
  46. package/packages/@repo/db/package.json +16 -8
  47. package/packages/@repo/db/src/index.ts +26 -20
  48. package/packages/@repo/db/src/schema/common.ts +45 -49
  49. package/packages/@repo/env/eslint.config.ts +4 -0
  50. package/packages/@repo/env/package.json +39 -0
  51. package/packages/@repo/env/src/default-env.ts +12 -0
  52. package/packages/@repo/env/src/define-env.ts +70 -0
  53. package/packages/@repo/env/src/index.ts +2 -0
  54. package/packages/@repo/env/src/utils.ts +52 -0
  55. package/packages/@repo/env/tsconfig.json +7 -0
  56. package/packages/@repo/lib/eslint.config.ts +4 -0
  57. package/packages/@repo/lib/package.json +34 -34
  58. package/packages/@repo/lib/src/bucket-module/file-storage.ts +50 -49
  59. package/packages/@repo/lib/src/bucket-module/index.ts +3 -0
  60. package/packages/@repo/lib/src/bucket-module/s3-storage.ts +120 -114
  61. package/packages/@repo/lib/src/bucket-module/utils.ts +10 -11
  62. package/packages/@repo/lib/src/{cookie-module.ts → cookie-module/cookie-module.ts} +48 -42
  63. package/packages/@repo/lib/src/cookie-module/index.ts +1 -0
  64. package/packages/@repo/lib/src/extra/index.ts +1 -0
  65. package/packages/@repo/lib/src/extra/pagination-module.ts +35 -0
  66. package/packages/@repo/lib/src/{token-module.ts → extra/token-module.ts} +12 -5
  67. package/packages/@repo/lib/src/file-system-module/index.ts +170 -0
  68. package/packages/@repo/lib/src/{hashing-module.ts → hashing-module/index.ts} +9 -9
  69. package/packages/@repo/lib/src/index.ts +0 -26
  70. package/packages/@repo/lib/src/mail-module/index.ts +2 -0
  71. package/packages/@repo/lib/src/mail-module/mock.ts +8 -8
  72. package/packages/@repo/lib/src/mail-module/nodemailer.ts +17 -7
  73. package/packages/@repo/lib/src/notification-module/index.ts +1 -172
  74. package/packages/@repo/lib/src/notification-module/push-notification.ts +97 -90
  75. package/packages/@repo/lib/src/{oauth2-client.ts → oauth2-module/index.ts} +107 -109
  76. package/packages/@repo/lib/src/otp-module/index.ts +91 -0
  77. package/packages/@repo/lib/src/session-module/index.ts +113 -0
  78. package/packages/@repo/lib/src/utils.ts +43 -42
  79. package/packages/@repo/lib/src/validation-module/index.ts +242 -0
  80. package/packages/@repo/logger/eslint.config.ts +4 -0
  81. package/packages/@repo/logger/package.json +40 -0
  82. package/packages/@repo/logger/src/index.ts +2 -0
  83. package/packages/@repo/logger/src/logger.ts +72 -0
  84. package/packages/@repo/{lib/src/logger-module → logger/src}/memory-profiler.ts +64 -65
  85. package/packages/@repo/logger/tsconfig.json +7 -0
  86. package/packages/@repo/mail/eslint.config.ts +4 -0
  87. package/packages/@repo/mail/package.json +10 -3
  88. package/packages/@repo/mail/src/emails/admin/OtpEmail.tsx +169 -168
  89. package/packages/@repo/mail/src/index.ts +1 -2
  90. package/packages/@repo/mail/tsconfig.json +3 -3
  91. package/packages/@repo/redis/dist/index.d.mts +3 -0
  92. package/packages/@repo/redis/dist/index.mjs +5 -0
  93. package/packages/@repo/redis/dist/lib/redis-client.d.mts +7 -0
  94. package/packages/@repo/redis/dist/lib/redis-client.mjs +25 -0
  95. package/packages/@repo/redis/dist/lib/redis-client.mjs.map +1 -0
  96. package/packages/@repo/redis/dist/lib/redis-module.d.mts +5 -0
  97. package/packages/@repo/redis/dist/lib/redis-module.mjs +6 -0
  98. package/packages/@repo/redis/dist/lib/redis-module.mjs.map +1 -0
  99. package/packages/@repo/redis/eslint.config.ts +4 -0
  100. package/packages/@repo/redis/package.json +13 -10
  101. package/packages/@repo/redis/src/index.ts +2 -2
  102. package/packages/@repo/redis/src/lib/redis-client.ts +36 -23
  103. package/packages/@repo/redis/src/lib/redis-module.ts +69 -3
  104. package/packages/cli/dist/index.mjs +203 -0
  105. package/packages/cli/eslint.config.ts +4 -0
  106. package/packages/cli/package.json +44 -0
  107. package/packages/cli/tsconfig.json +12 -0
  108. package/packages/cli/tsdown.config.ts +17 -0
  109. package/packages/ui/components.json +0 -1
  110. package/packages/ui/eslint.config.ts +4 -0
  111. package/packages/ui/package.json +16 -3
  112. package/packages/ui/postcss.config.mjs +9 -9
  113. package/packages/ui/src/components/lib/utils.ts +53 -53
  114. package/packages/ui/src/components/ui/alert-dialog.tsx +118 -116
  115. package/packages/ui/src/components/ui/avatar.tsx +52 -53
  116. package/packages/ui/src/components/ui/badge.tsx +45 -46
  117. package/packages/ui/src/components/ui/breadcrumb.tsx +108 -109
  118. package/packages/ui/src/components/ui/card.tsx +91 -92
  119. package/packages/ui/src/components/ui/carousel.tsx +243 -243
  120. package/packages/ui/src/components/ui/checkbox.tsx +32 -32
  121. package/packages/ui/src/components/ui/command.tsx +144 -155
  122. package/packages/ui/src/components/ui/dialog.tsx +124 -127
  123. package/packages/ui/src/components/ui/form.tsx +166 -165
  124. package/packages/ui/src/components/ui/input-otp.tsx +74 -76
  125. package/packages/ui/src/components/ui/input.tsx +19 -21
  126. package/packages/ui/src/components/ui/multiple-select.tsx +4 -4
  127. package/packages/ui/src/{components/lucide.tsx → lucide.ts} +3 -3
  128. package/packages/ui/tailwind.config.ts +94 -94
  129. package/packages/ui/tsconfig.json +7 -1
  130. package/pnpm-workspace.yaml +41 -1
  131. package/turbo.json +20 -27
  132. package/apps/core-server/eslint.config.mjs +0 -47
  133. package/configs/eslint-config/src/rules/no-dynamic-import-template.ts +0 -32
  134. package/configs/eslint-config/src/rules/no-plain-errors.ts +0 -50
  135. package/configs/eslint-config/tsdown.config.ts +0 -11
  136. package/packages/@repo/constants/eslint.config.mjs +0 -21
  137. package/packages/@repo/db/eslint.config.mjs +0 -21
  138. package/packages/@repo/lib/eslint.config.mjs +0 -49
  139. package/packages/@repo/lib/src/command-module.ts +0 -77
  140. package/packages/@repo/lib/src/constants.ts +0 -3
  141. package/packages/@repo/lib/src/custom-type.ts +0 -54
  142. package/packages/@repo/lib/src/env.ts +0 -13
  143. package/packages/@repo/lib/src/file-system/index.ts +0 -90
  144. package/packages/@repo/lib/src/logger-module/log-config.ts +0 -16
  145. package/packages/@repo/lib/src/logger-module/logger.ts +0 -78
  146. package/packages/@repo/lib/src/mail-module/api.ts +0 -0
  147. package/packages/@repo/lib/src/otp-module.ts +0 -98
  148. package/packages/@repo/lib/src/pagination-module.ts +0 -49
  149. package/packages/@repo/lib/src/user-session.ts +0 -117
  150. package/packages/@repo/lib/src/validation-module.ts +0 -187
  151. package/packages/@repo/mail/tsconfig.build.json +0 -14
  152. package/packages/@repo/mail/tsdown.config.ts +0 -9
  153. package/packages/@repo/redis/eslint.config.mjs +0 -8
  154. package/packages/ui/eslint.config.mjs +0 -18
package/.prettierignore CHANGED
@@ -1,15 +1,7 @@
1
1
  coverage
2
2
  dist
3
3
  pnpm-lock.yaml
4
- packages/frontend/editor-ui/index.html
5
- packages/nodes-base/nodes/**/test
6
- packages/cli/templates/form-trigger.handlebars
7
- packages/cli/templates/form-trigger-completion.handlebars
8
- packages/cli/templates/form-trigger-409.handlebars
9
- packages/cli/templates/form-trigger-404.handlebars
10
- cypress/fixtures
11
4
  CHANGELOG.md
12
- .github/pull_request_template.md
13
5
  # Ignored for now
14
6
  **/*.md
15
7
  # Handled by biome
@@ -17,8 +9,3 @@ CHANGELOG.md
17
9
  **/*.js
18
10
  **/*.tsx
19
11
  **/*.jsx
20
-
21
- # Auto-generated
22
- **/components.d.ts
23
-
24
- justfile
package/.prettierrc.js CHANGED
@@ -1,52 +1,52 @@
1
- module.exports = {
2
- /**
3
- * https://prettier.io/docs/en/options.html#semicolons
4
- */
5
- semi: true,
6
-
7
- /**
8
- * https://prettier.io/docs/en/options.html#trailing-commas
9
- */
10
- trailingComma: "all",
11
-
12
- /**
13
- * https://prettier.io/docs/en/options.html#bracket-spacing
14
- */
15
- bracketSpacing: true,
16
-
17
- /**
18
- * https://prettier.io/docs/en/options.html#tabs
19
- */
20
- useTabs: true,
21
-
22
- /**
23
- * https://prettier.io/docs/en/options.html#tab-width
24
- */
25
- tabWidth: 2,
26
-
27
- /**
28
- * https://prettier.io/docs/en/options.html#arrow-function-parentheses
29
- */
30
- arrowParens: "always",
31
-
32
- /**
33
- * https://prettier.io/docs/en/options.html#quotes
34
- */
35
-
36
- doubleQuote: true,
37
-
38
- /**
39
- * https://prettier.io/docs/en/options.html#quote-props
40
- */
41
- quoteProps: "as-needed",
42
-
43
- /**
44
- * https://prettier.io/docs/en/options.html#end-of-line
45
- */
46
- endOfLine: "lf",
47
-
48
- /**
49
- * https://prettier.io/docs/en/options.html#print-width
50
- */
51
- printWidth: 100,
52
- };
1
+ module.exports = {
2
+ /**
3
+ * https://prettier.io/docs/en/options.html#semicolons
4
+ */
5
+ semi: true,
6
+
7
+ /**
8
+ * https://prettier.io/docs/en/options.html#trailing-commas
9
+ */
10
+ trailingComma: "all",
11
+
12
+ /**
13
+ * https://prettier.io/docs/en/options.html#bracket-spacing
14
+ */
15
+ bracketSpacing: true,
16
+
17
+ /**
18
+ * https://prettier.io/docs/en/options.html#tabs
19
+ */
20
+ useTabs: true,
21
+
22
+ /**
23
+ * https://prettier.io/docs/en/options.html#tab-width
24
+ */
25
+ tabWidth: 2,
26
+
27
+ /**
28
+ * https://prettier.io/docs/en/options.html#arrow-function-parentheses
29
+ */
30
+ arrowParens: "always",
31
+
32
+ /**
33
+ * https://prettier.io/docs/en/options.html#quotes
34
+ */
35
+
36
+ doubleQuote: true,
37
+
38
+ /**
39
+ * https://prettier.io/docs/en/options.html#quote-props
40
+ */
41
+ quoteProps: "as-needed",
42
+
43
+ /**
44
+ * https://prettier.io/docs/en/options.html#end-of-line
45
+ */
46
+ endOfLine: "lf",
47
+
48
+ /**
49
+ * https://prettier.io/docs/en/options.html#print-width
50
+ */
51
+ printWidth: 100,
52
+ };
@@ -0,0 +1,32 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "Debug Core Server",
6
+ "type": "node",
7
+ "request": "launch",
8
+ "runtimeExecutable": "pnpm",
9
+ "runtimeArgs": ["run", "dev:debug"],
10
+ "cwd": "${workspaceFolder}/apps/core-server",
11
+ "attachSimplePort": 9229,
12
+ "console": "integratedTerminal"
13
+ },
14
+ {
15
+ "name": "Debug Another Server",
16
+ "type": "node",
17
+ "request": "launch",
18
+ "runtimeExecutable": "pnpm",
19
+ "runtimeArgs": ["run", "dev:debug"],
20
+ "cwd": "${workspaceFolder}/apps/another-server",
21
+ "attachSimplePort": 9230,
22
+ "console": "integratedTerminal"
23
+ }
24
+ ],
25
+ "compounds": [
26
+ {
27
+ "name": "Debug ALL Servers",
28
+ "configurations": ["Debug Core Server", "Debug Another Server"],
29
+ "stopAll": true
30
+ }
31
+ ]
32
+ }
@@ -1,3 +1,9 @@
1
- {
2
- "typescript.tsdk": "node_modules\\typescript\\lib"
3
- }
1
+ {
2
+ "eslint.workingDirectories": [
3
+ {
4
+ "mode": "auto"
5
+ }
6
+ ],
7
+ "editor.defaultFormatter": "biomejs.biome",
8
+ "editor.formatOnSave": true
9
+ }
@@ -1,24 +1,18 @@
1
- # .{yourdomain}
2
- COOKIE_DOMAIN = localhost
3
- ACCESS_TOKEN_SECRET = BNcxV/f7xZpN1AE8dZKgwbFQIN3pRIJWFQ73Z9yTUInYHrjBp/1dEGOlNrG3HsWPuOovRu/1dJirQvOl14SzVA==
4
- REFRESH_TOKEN_SECRET = cO6qkpajh9YclPsyX06t9dKHIccWyWbsCRVdecPTGXXibRu8Dl9745KbFbcJck6dPcQ41VhHfSY+Si0M+7/PMw==
5
-
6
- NODE_ENV = development
7
- PORT = 3000
8
-
9
- SERVER_URL = http://api.app.localhost
10
-
11
- # DATABASE_URL = libsql://express-template-aditya-kumarr.turso.io
12
- # DATABASE_AUTH_TOKEN = eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJhIjoicnciLCJpYXQiOjE3MzA2OTk5NDksImlkIjoiOGU5ODUzMmEtOTY4Ni00M2M0LWI3ZTktMmRiMzBkOTFhOThmIn0.WvEvfKbGPEZAkUg56-P6E_qPftn2ESFQ6a6fITcqTAQYdzUIOdeG3kNNeWJQtEhrOFoSsr0t5d5ZgBGn3H5-Ag
13
-
14
- # DATABASE_URL = postgres://postgres:postgres@himob0.easypanel.host:5555/test
15
- DATABASE_URL =
16
- # mail
17
- SENDER_MAIL =
18
- # smtp
19
- SMTP_HOST =
20
- SMTP_USER =
21
- SMTP_PASSWORD =
22
- SMTP_PORT =
23
- # for admin panel
24
- CLIENT_URL= http://app.app.localhost
1
+ # .{yourdomain}
2
+ COOKIE_DOMAIN = localhost
3
+ ACCESS_TOKEN_SECRET = your_access_token_secret
4
+ REFRESH_TOKEN_SECRET = your_refresh_token_secret
5
+
6
+ NODE_ENV = development
7
+ PORT = 3000
8
+ SERVER_URL = http://api.app.localhost
9
+ DATABASE_URL =
10
+ # mail
11
+ SENDER_MAIL =
12
+ # smtp
13
+ SMTP_HOST =
14
+ SMTP_USER =
15
+ SMTP_PASSWORD =
16
+ SMTP_PORT =
17
+ # for admin panel
18
+ CLIENT_URL= http://app.app.localhost
@@ -1,61 +1,35 @@
1
- # Stage 1: Build the application
2
- FROM node:22.7-alpine AS builder
3
-
4
- # Install pnpm globally
5
- RUN npm install -g pnpm
6
-
7
- # Set the working directory in the container
8
- WORKDIR /app
9
-
10
- # Copy the monorepo root package.json and pnpm-lock.yaml to install dependencies
11
- COPY package.json ./
12
-
13
- # Copy the pnpm workspace configuration
14
- COPY pnpm-workspace.yaml ./
15
-
16
- # Copy the entire monorepo to the container
17
- COPY . .
18
-
19
- # Install dependencies for the monorepo, including shared packages
20
- RUN pnpm install
21
-
22
- # Generate the Schema
23
- RUN pnpm -r db:push
24
-
25
- # Build TypeScript code for all packages
26
- RUN pnpm build --filter=core-server --filter=admin-panel
27
-
28
-
29
- # Stage 2: Create the production image
30
- FROM node:22.7-alpine
31
-
32
- # Install pnpm globally
33
- RUN npm install -g pnpm
34
-
35
- # Set the working directory in the container
36
- WORKDIR /app
37
-
38
- # Copy necessary files from builder stage
39
- COPY --from=builder /app/package.json /app/pnpm-lock.yaml /app/pnpm-workspace.yaml ./
40
- COPY --from=builder /app/apps/core-server/dist /app/apps/core-server/dist
41
- COPY --from=builder /app/apps/admin-panel/dist /app/apps/core-server/dist/frontend
42
- COPY --from=builder /app/apps/core-server/package.json ./apps/core-server/package.json
43
- COPY --from=builder /app/packages/typescript-config ./packages/typescript-config
44
- COPY --from=builder /app/packages/eslint-config ./packages/eslint-config
45
- COPY --from=builder /app/packages/db ./packages/db
46
- COPY --from=builder /app/packages/redis ./packages/redis
47
- COPY --from=builder /app/packages/mail ./packages/mail
48
- COPY --from=builder /app/packages/lib ./packages/lib
49
- COPY --from=builder /app/packages/common ./packages/common
50
-
51
-
52
- # Install production dependencies
53
- RUN pnpm install --prod --frozen-lockfile
54
-
55
-
56
- # Expose the port that the app will run on
57
- EXPOSE 3000
58
-
59
-
60
- # Start the application
61
- CMD ["node","--conditions=production", "/app/apps/core-server/dist/index.js"]
1
+ FROM node:24-alpine AS base
2
+ RUN apk add --no-cache git \
3
+ && corepack enable \
4
+ && corepack prepare pnpm@latest --activate
5
+ WORKDIR /app
6
+
7
+ FROM base AS builder
8
+
9
+ COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
10
+
11
+ COPY --parents apps/*/package.json ./
12
+ COPY --parents packages/*/package.json ./
13
+ COPY --parents configs/*/package.json ./
14
+
15
+ RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
16
+ pnpm install --frozen-lockfile
17
+
18
+ COPY apps/core-server/ ./apps/core-server/
19
+ COPY packages ./packages
20
+ COPY configs ./configs
21
+ COPY turbo.json ./
22
+
23
+ # Build the required packages
24
+ RUN pnpm build:web
25
+
26
+ # --- Final production image ---
27
+ FROM node:24-alpine
28
+
29
+ WORKDIR /app
30
+
31
+ # Copy built server dist
32
+ COPY --from=builder /app/apps/core-server/dist ./
33
+ EXPOSE 3000
34
+
35
+ CMD ["node", "./index.mjs"]
@@ -0,0 +1,7 @@
1
+ import { baseConfig } from "eslint-config/base";
2
+ import { extend } from "eslint-config/extend";
3
+ export default extend(baseConfig, {
4
+ rules: {
5
+ "@typescript-eslint/no-explicit-any": "warn",
6
+ },
7
+ });
@@ -1,73 +1,62 @@
1
1
  {
2
2
  "name": "core-server",
3
+ "description": "",
3
4
  "version": "1.0.0",
4
5
  "type": "module",
6
+
5
7
  "scripts": {
6
- "start": "node --conditions=production dist/index.js",
8
+ "dev": "tsx watch src/index.ts",
9
+ "dev:debug": "tsx watch --inspect src/index.ts",
10
+ "bun:dev": "bun --watch src/index.ts",
11
+ "start": "node dist/index.mjs",
7
12
  "lint": "eslint .",
8
13
  "build": "tsdown --config-loader unrun",
9
14
  "clean": "rimraf dist",
10
- "dev": " tsx watch src/index.ts",
11
- "bun:dev": "bun --watch src/index.ts",
12
- "command": "tsx src/commands/index.ts",
13
- "schedule": "tsx src/commands/schedular.ts",
14
- "test": "mocha -r tsx src/test/setup.ts -r tsx src/**/*.test*.ts",
15
+ "deep:clean": "rimraf node_modules dist .turbo",
16
+ "typecheck": "tsc --noEmit",
15
17
  "lint:fix": "eslint . src/**/*.ts --fix",
16
- "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\""
18
+ "format": "biome format --write .",
19
+ "format:check": "biome ci .",
20
+ "test": "vitest run"
17
21
  },
18
- "keywords": [],
19
- "author": "",
20
- "license": "ISC",
21
- "description": "",
22
22
  "dependencies": {
23
- "@aws-sdk/client-s3": "^3.693.0",
24
23
  "@repo/constants": "workspace:^",
25
24
  "@repo/db": "workspace:^",
26
- "@repo/email": "workspace:^",
25
+ "@repo/mail": "workspace:^",
27
26
  "@repo/lib": "workspace:^",
28
- "@vinejs/vine": "^4.3.0",
29
- "axios": "^1.7.7",
30
- "bcrypt": "^5.1.1",
31
- "blurhash": "^2.0.5",
32
- "cookie-parser": "^1.4.7",
33
- "cors": "^2.8.5",
34
- "country-state-city": "^3.2.1",
35
- "date-fns": "^4.1.0",
36
- "dotenv": "^16.4.5",
37
- "drizzle-orm": "^0.36.0",
38
- "express": "^4.21.1",
39
- "express-fileupload": "^1.5.1",
40
- "express-list-endpoints": "^7.1.0",
41
- "google-auth-library": "^9.15.1",
42
- "jsonwebtoken": "^9.0.2",
43
- "morgan": "^1.10.0",
44
- "nanoid": "^5.0.9",
45
- "node-cron": "^3.0.3",
46
- "nodemailer": "^6.9.16",
47
- "sharp": "^0.33.5",
48
- "stripe": "^17.6.0",
49
- "winston": "^3.16.0"
27
+ "@repo/redis": "workspace:^",
28
+ "@repo/env": "workspace:^",
29
+ "@repo/logger": "workspace:^",
30
+ "cookie-parser": "catalog:",
31
+ "cors": "catalog:",
32
+ "country-state-city": "catalog:",
33
+ "express": "catalog:",
34
+ "express-fileupload": "catalog:",
35
+ "express-list-endpoints": "catalog:",
36
+ "morgan": "catalog:"
50
37
  },
51
38
  "devDependencies": {
52
- "@types/bcrypt": "^5.0.2",
53
- "@types/cookie-parser": "^1.4.7",
54
- "@types/cors": "^2.8.17",
55
- "@types/express": "^5.0.0",
56
- "@types/express-fileupload": "^1.5.1",
57
- "@types/express-list-endpoints": "^6.0.3",
58
- "@types/jsonwebtoken": "^9.0.7",
59
- "@types/mocha": "^10.0.9",
60
- "@types/morgan": "^1.9.9",
61
- "@types/node-cron": "^3.0.11",
62
- "@types/nodemailer": "^6.4.16",
63
- "@types/supertest": "^6.0.2",
39
+ "@types/cookie-parser": "catalog:",
40
+ "@types/cors": "catalog:",
41
+ "@types/express": "catalog:",
42
+ "@types/express-fileupload": "catalog:",
43
+ "@types/morgan": "catalog:",
64
44
  "eslint-config": "workspace:*",
65
- "globals": "^15.11.0",
66
- "mocha": "^10.8.2",
67
- "supertest": "^7.0.0",
68
- "tsc-alias": "^1.8.10",
69
- "tsx": "^4.19.2",
70
45
  "tsdown-config": "workspace:*",
71
46
  "typescript-config": "workspace:*"
47
+ },
48
+ "startx": {
49
+ "tags": [
50
+ "node",
51
+ "backend"
52
+ ],
53
+ "requiredDeps": [
54
+ "@repo/env",
55
+ "@repo/logger"
56
+ ],
57
+ "requiredDevDeps": [
58
+ "typescript-config",
59
+ "tsdown-config"
60
+ ]
72
61
  }
73
62
  }
@@ -1,44 +1,7 @@
1
- /* eslint-disable @typescript-eslint/no-namespace */
2
- import type { SessionUser } from "@repo/lib";
1
+ import type { SessionUser } from "@repo/lib/session-module";
3
2
 
4
3
  declare global {
5
- namespace NodeJS {
6
- export interface ProcessEnv {
7
- // from .env
8
- COOKIE_DOMAIN: string;
9
- NODE_ENV: "development" | "staging" | "production" | "test";
10
- DATABASE_URL: string;
11
- DATABASE_AUTH_TOKEN: string;
12
- ACCESS_TOKEN_SECRET: string;
13
- REFRESH_TOKEN_SECRET: string;
14
- OAUTH_STATE_TOKEN_SECRET: string;
15
- SUPPORT_MAIL: string;
16
- AWS_ACCESS_KEY_ID: string;
17
- AWS_SECRET_ACCESS_KEY: string;
18
- AWS_REGION: string;
19
- AWS_BUCKET: string;
20
- GOOGLE_CLIENT_ID: string;
21
- GOOGLE_CLIENT_SECRET: string;
22
- GOOGLE_REDIRECT_URI: string;
23
-
24
- CLIENT_URL: string;
25
- SERVER_URL: string;
26
- REDIS_URI: string;
27
- REDIS_PORT: string;
28
- REDIS_USERNAME: string;
29
- REDIS_PASSWORD: string;
30
- FIREBASE_PROJECT_ID: string;
31
- STRIPE_WEBHOOK_SECRET: string;
32
- STRIPE_SECRET_KEY: string;
33
-
34
- SMTP_HOST: string;
35
- SMTP_PORT: string;
36
- SMTP_USER: string;
37
- SMTP_PASSWORD: string;
38
- SENDER_MAIL: string;
39
- }
40
- }
41
-
4
+ // eslint-disable-next-line @typescript-eslint/no-namespace
42
5
  namespace Express {
43
6
  export interface Request {
44
7
  user: SessionUser;
@@ -49,6 +12,5 @@ declare global {
49
12
  declare module "http" {
50
13
  interface IncomingMessage {
51
14
  user: SessionUser;
52
- body: any;
53
15
  }
54
16
  }
@@ -1,37 +1,37 @@
1
- type ServerEvent = {
2
- server: Array<() => void>;
3
- db: Array<() => void>;
4
- redis: Array<() => void>;
5
- };
6
-
7
- export class ServerEvents {
8
- static events: ServerEvent = {
9
- server: [],
10
- db: [],
11
- redis: [],
12
- };
13
-
14
- static onServerReady(fn: () => void) {
15
- ServerEvents.events.server.push(fn);
16
- }
17
-
18
- static emitServerReady() {
19
- ServerEvents.events.server.forEach(fn => fn());
20
- }
21
-
22
- static onDBReady(fn: () => void) {
23
- ServerEvents.events.db.push(fn);
24
- }
25
-
26
- static emitDBReady() {
27
- ServerEvents.events.db.forEach(fn => fn());
28
- }
29
-
30
- static onRedisReady(fn: () => void) {
31
- ServerEvents.events.redis.push(fn);
32
- }
33
-
34
- static emitRedisReady() {
35
- ServerEvents.events.redis.forEach(fn => fn());
36
- }
37
- }
1
+ type ServerEvent = {
2
+ server: Array<() => void>;
3
+ db: Array<() => void>;
4
+ redis: Array<() => void>;
5
+ };
6
+
7
+ export class ServerEvents {
8
+ static events: ServerEvent = {
9
+ server: [],
10
+ db: [],
11
+ redis: [],
12
+ };
13
+
14
+ static onServerReady(fn: () => void) {
15
+ ServerEvents.events.server.push(fn);
16
+ }
17
+
18
+ static emitServerReady() {
19
+ ServerEvents.events.server.forEach(fn => fn());
20
+ }
21
+
22
+ static onDBReady(fn: () => void) {
23
+ ServerEvents.events.db.push(fn);
24
+ }
25
+
26
+ static emitDBReady() {
27
+ ServerEvents.events.db.forEach(fn => fn());
28
+ }
29
+
30
+ static onRedisReady(fn: () => void) {
31
+ ServerEvents.events.redis.push(fn);
32
+ }
33
+
34
+ static emitRedisReady() {
35
+ ServerEvents.events.redis.forEach(fn => fn());
36
+ }
37
+ }
@@ -1,19 +1,10 @@
1
- import {ping} from "@repo/constants"
2
- import {AdminEmailTemplate} from "@repo/email"
3
- import { logger } from "@repo/lib";
4
- import * as sharp from "sharp"
1
+ import { ENV } from "@repo/env";
2
+ import { logger } from "@repo/logger";
5
3
 
6
4
  import { ServerEvents } from "./events/index.js";
7
5
  import { app } from "./routes/server.js";
8
- // PushNotificationManager.initialize({
9
- // type: "env",
10
- // });
11
- console.log(sharp)
12
6
 
13
-
14
- console.log(ping)
15
- console.log(await AdminEmailTemplate.getOtpEmail({otp:"1234"}))
16
- app.listen(process.env.PORT ?? 3000, () => {
17
- logger.info(`Server started on port ${process.env.PORT ?? 3000}`);
7
+ app.listen(ENV.PORT, () => {
18
8
  ServerEvents.emitServerReady();
9
+ logger.info(`Server started on port ${ENV.PORT}`);
19
10
  });
@@ -1,5 +1,8 @@
1
- import { UserSession } from "@repo/lib";
1
+ import { UserSession } from "@repo/lib/session-module";
2
2
  import type { NextFunction, Request, Response } from "express";
3
+
4
+ type ExpressHandler = (req: Request, res: Response, next: NextFunction) => unknown;
5
+
3
6
  export class AuthMiddlewares {
4
7
  static async validateActiveSession(req: Request, res: Response, next: NextFunction) {
5
8
  try {
@@ -22,13 +25,25 @@ export class AuthMiddlewares {
22
25
  }
23
26
  }
24
27
  }
25
-
26
28
  export function validateSession() {
27
- return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
29
+ return function <T extends ExpressHandler>(
30
+ _target: unknown,
31
+ _propertyKey: string,
32
+ descriptor: TypedPropertyDescriptor<T>
33
+ ): void {
28
34
  const originalMethod = descriptor.value;
29
- descriptor.value = async function (req: Request, res: Response, next: NextFunction) {
35
+
36
+ if (!originalMethod) return;
37
+
38
+ descriptor.value = async function (
39
+ this: unknown,
40
+ req: Request,
41
+ res: Response,
42
+ next: NextFunction
43
+ ) {
30
44
  try {
31
- const accessToken = req.headers["authorization"]?.split(" ")[1];
45
+ const accessToken = req.headers.authorization?.split(" ")[1];
46
+
32
47
  if (!accessToken) {
33
48
  res.status(401).json({ message: "access token missing" });
34
49
  return;
@@ -40,11 +55,13 @@ export function validateSession() {
40
55
  res.status(401).json({ message: "invalid access token" });
41
56
  return;
42
57
  }
58
+
43
59
  req.user = payload;
44
- return originalMethod.apply(this, [req, res, next]);
60
+
61
+ return originalMethod.call(this, req, res, next);
45
62
  } catch (error) {
46
63
  next(error);
47
64
  }
48
- };
65
+ } as T;
49
66
  };
50
67
  }
@@ -1,6 +1,7 @@
1
- import cors from "cors";
2
- // you can ditch this write your own middlewares from scratch
3
- export const corsMiddleware = cors({
4
- origin: [process.env.CLIENT_URL, process.env.CORS_URL!],
5
- credentials: true,
6
- });
1
+ import { ENV } from "@repo/env";
2
+ import cors from "cors";
3
+
4
+ export const corsMiddleware = cors({
5
+ origin: [ENV.CLIENT_URL, ENV.CORS_URL],
6
+ credentials: true,
7
+ });