startx 0.0.1

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 (181) hide show
  1. package/.editorconfig +20 -0
  2. package/.prettierignore +24 -0
  3. package/.prettierrc.js +52 -0
  4. package/.vscode/settings.json +3 -0
  5. package/LICENSE +21 -0
  6. package/apps/core-server/.env.example +24 -0
  7. package/apps/core-server/Dockerfile +61 -0
  8. package/apps/core-server/eslint.config.mjs +47 -0
  9. package/apps/core-server/package.json +73 -0
  10. package/apps/core-server/src/config/custom-type.ts +54 -0
  11. package/apps/core-server/src/events/index.ts +37 -0
  12. package/apps/core-server/src/index.ts +19 -0
  13. package/apps/core-server/src/middlewares/auth-middleware.ts +50 -0
  14. package/apps/core-server/src/middlewares/cors-middleware.ts +6 -0
  15. package/apps/core-server/src/middlewares/error-middleware.ts +23 -0
  16. package/apps/core-server/src/middlewares/logger-middleware.ts +21 -0
  17. package/apps/core-server/src/middlewares/notfound-middleware.ts +14 -0
  18. package/apps/core-server/src/middlewares/serve-static.ts +24 -0
  19. package/apps/core-server/src/routes/files/router.ts +7 -0
  20. package/apps/core-server/src/routes/server.ts +36 -0
  21. package/apps/core-server/tsconfig.json +10 -0
  22. package/apps/core-server/tsdown.config.ts +14 -0
  23. package/biome.json +62 -0
  24. package/configs/eslint-config/package.json +60 -0
  25. package/configs/eslint-config/plugins.d.ts +1 -0
  26. package/configs/eslint-config/src/configs/base.ts +237 -0
  27. package/configs/eslint-config/src/configs/frontend.ts +62 -0
  28. package/configs/eslint-config/src/configs/node.ts +10 -0
  29. package/configs/eslint-config/src/plugin.ts +25 -0
  30. package/configs/eslint-config/src/rules/index.ts +30 -0
  31. package/configs/eslint-config/src/rules/no-argument-spread.test.ts +47 -0
  32. package/configs/eslint-config/src/rules/no-argument-spread.ts +96 -0
  33. package/configs/eslint-config/src/rules/no-dynamic-import-template.ts +32 -0
  34. package/configs/eslint-config/src/rules/no-internal-package-import.ts +40 -0
  35. package/configs/eslint-config/src/rules/no-interpolation-in-regular-string.ts +32 -0
  36. package/configs/eslint-config/src/rules/no-json-parse-json-stringify.test.ts +34 -0
  37. package/configs/eslint-config/src/rules/no-json-parse-json-stringify.ts +49 -0
  38. package/configs/eslint-config/src/rules/no-plain-errors.ts +50 -0
  39. package/configs/eslint-config/src/rules/no-skipped-tests.ts +61 -0
  40. package/configs/eslint-config/src/rules/no-top-level-relative-imports-in-backend-module.ts +27 -0
  41. package/configs/eslint-config/src/rules/no-type-unsafe-event-emitter.ts +33 -0
  42. package/configs/eslint-config/src/rules/no-uncaught-json-parse.test.ts +21 -0
  43. package/configs/eslint-config/src/rules/no-uncaught-json-parse.ts +45 -0
  44. package/configs/eslint-config/src/rules/no-untyped-config-class-field.ts +26 -0
  45. package/configs/eslint-config/src/rules/no-unused-param-catch-clause.ts +33 -0
  46. package/configs/eslint-config/src/rules/no-useless-catch-throw.test.ts +34 -0
  47. package/configs/eslint-config/src/rules/no-useless-catch-throw.ts +47 -0
  48. package/configs/eslint-config/src/utils/json.ts +21 -0
  49. package/configs/eslint-config/tsconfig.json +8 -0
  50. package/configs/eslint-config/tsdown.config.ts +11 -0
  51. package/configs/eslint-config/vitest.config.ts +3 -0
  52. package/configs/tsdown-config/package.json +14 -0
  53. package/configs/tsdown-config/src/config/tsdown.base.ts +13 -0
  54. package/configs/typescript-config/package.json +10 -0
  55. package/configs/typescript-config/tsconfig.common.json +32 -0
  56. package/configs/typescript-config/tsconfig.frontend.json +14 -0
  57. package/configs/typescript-config/tsconfig.node.json +9 -0
  58. package/configs/vitest-config/package.json +25 -0
  59. package/configs/vitest-config/src/base.ts +34 -0
  60. package/configs/vitest-config/src/frontend.ts +15 -0
  61. package/configs/vitest-config/src/node.ts +5 -0
  62. package/configs/vitest-config/tsconfig.json +7 -0
  63. package/package.json +47 -0
  64. package/packages/@repo/constants/eslint.config.mjs +21 -0
  65. package/packages/@repo/constants/package.json +19 -0
  66. package/packages/@repo/constants/src/api.ts +1 -0
  67. package/packages/@repo/constants/src/index.ts +8 -0
  68. package/packages/@repo/constants/src/time.ts +23 -0
  69. package/packages/@repo/constants/tsconfig.json +7 -0
  70. package/packages/@repo/db/eslint.config.mjs +21 -0
  71. package/packages/@repo/db/package.json +30 -0
  72. package/packages/@repo/db/src/functions.ts +122 -0
  73. package/packages/@repo/db/src/index.ts +20 -0
  74. package/packages/@repo/db/src/schema/common.ts +49 -0
  75. package/packages/@repo/db/src/schema/index.ts +1 -0
  76. package/packages/@repo/db/tsconfig.json +13 -0
  77. package/packages/@repo/lib/eslint.config.mjs +49 -0
  78. package/packages/@repo/lib/package.json +57 -0
  79. package/packages/@repo/lib/src/bucket-module/file-storage.ts +49 -0
  80. package/packages/@repo/lib/src/bucket-module/s3-storage.ts +114 -0
  81. package/packages/@repo/lib/src/bucket-module/utils.ts +11 -0
  82. package/packages/@repo/lib/src/command-module.ts +77 -0
  83. package/packages/@repo/lib/src/constants.ts +3 -0
  84. package/packages/@repo/lib/src/cookie-module.ts +42 -0
  85. package/packages/@repo/lib/src/custom-type.ts +54 -0
  86. package/packages/@repo/lib/src/env.ts +13 -0
  87. package/packages/@repo/lib/src/error-handlers-module/index.ts +11 -0
  88. package/packages/@repo/lib/src/file-system/index.ts +90 -0
  89. package/packages/@repo/lib/src/hashing-module.ts +9 -0
  90. package/packages/@repo/lib/src/index.ts +27 -0
  91. package/packages/@repo/lib/src/logger-module/log-config.ts +16 -0
  92. package/packages/@repo/lib/src/logger-module/logger.ts +78 -0
  93. package/packages/@repo/lib/src/logger-module/memory-profiler.ts +65 -0
  94. package/packages/@repo/lib/src/mail-module/api.ts +0 -0
  95. package/packages/@repo/lib/src/mail-module/mock.ts +8 -0
  96. package/packages/@repo/lib/src/mail-module/nodemailer.ts +45 -0
  97. package/packages/@repo/lib/src/notification-module/index.ts +172 -0
  98. package/packages/@repo/lib/src/notification-module/push-notification.ts +90 -0
  99. package/packages/@repo/lib/src/oauth2-client.ts +109 -0
  100. package/packages/@repo/lib/src/otp-module.ts +98 -0
  101. package/packages/@repo/lib/src/pagination-module.ts +49 -0
  102. package/packages/@repo/lib/src/token-module.ts +35 -0
  103. package/packages/@repo/lib/src/user-session.ts +117 -0
  104. package/packages/@repo/lib/src/utils.ts +42 -0
  105. package/packages/@repo/lib/src/validation-module.ts +187 -0
  106. package/packages/@repo/lib/tsconfig.json +7 -0
  107. package/packages/@repo/mail/package.json +29 -0
  108. package/packages/@repo/mail/src/emails/admin/OtpEmail.tsx +168 -0
  109. package/packages/@repo/mail/src/index.ts +13 -0
  110. package/packages/@repo/mail/tsconfig.build.json +14 -0
  111. package/packages/@repo/mail/tsconfig.json +13 -0
  112. package/packages/@repo/mail/tsdown.config.ts +9 -0
  113. package/packages/@repo/redis/eslint.config.mjs +8 -0
  114. package/packages/@repo/redis/package.json +31 -0
  115. package/packages/@repo/redis/src/index.ts +2 -0
  116. package/packages/@repo/redis/src/lib/redis-client.ts +23 -0
  117. package/packages/@repo/redis/src/lib/redis-module.ts +3 -0
  118. package/packages/@repo/redis/tsconfig.json +12 -0
  119. package/packages/ui/components.json +17 -0
  120. package/packages/ui/eslint.config.mjs +18 -0
  121. package/packages/ui/package.json +67 -0
  122. package/packages/ui/postcss.config.mjs +9 -0
  123. package/packages/ui/src/components/custom/form-wrapper.tsx +551 -0
  124. package/packages/ui/src/components/custom/grid-component.tsx +23 -0
  125. package/packages/ui/src/components/custom/hover-tool.tsx +38 -0
  126. package/packages/ui/src/components/custom/image-picker.tsx +109 -0
  127. package/packages/ui/src/components/custom/no-content.tsx +37 -0
  128. package/packages/ui/src/components/custom/page-container.tsx +24 -0
  129. package/packages/ui/src/components/custom/page-section.tsx +59 -0
  130. package/packages/ui/src/components/custom/simple-popover.tsx +29 -0
  131. package/packages/ui/src/components/custom/switch-component.tsx +20 -0
  132. package/packages/ui/src/components/custom/theme-provider.tsx +74 -0
  133. package/packages/ui/src/components/custom/typography.tsx +111 -0
  134. package/packages/ui/src/components/extensions/carousel.tsx +392 -0
  135. package/packages/ui/src/components/hooks/event/use-click.tsx +39 -0
  136. package/packages/ui/src/components/hooks/time/useDebounce.tsx +21 -0
  137. package/packages/ui/src/components/hooks/time/useInterval.tsx +35 -0
  138. package/packages/ui/src/components/hooks/time/useTimeout.tsx +19 -0
  139. package/packages/ui/src/components/hooks/time/useTimer.tsx +51 -0
  140. package/packages/ui/src/components/hooks/use-media-query.tsx +19 -0
  141. package/packages/ui/src/components/hooks/use-persistent-storage.tsx +52 -0
  142. package/packages/ui/src/components/hooks/use-update-effect.tsx +13 -0
  143. package/packages/ui/src/components/hooks/use-window-dimension.tsx +30 -0
  144. package/packages/ui/src/components/lib/utils.ts +242 -0
  145. package/packages/ui/src/components/lucide.tsx +3 -0
  146. package/packages/ui/src/components/sonner.tsx +1 -0
  147. package/packages/ui/src/components/ui/alert-dialog.tsx +116 -0
  148. package/packages/ui/src/components/ui/avatar.tsx +53 -0
  149. package/packages/ui/src/components/ui/badge.tsx +46 -0
  150. package/packages/ui/src/components/ui/breadcrumb.tsx +109 -0
  151. package/packages/ui/src/components/ui/button.tsx +96 -0
  152. package/packages/ui/src/components/ui/card.tsx +92 -0
  153. package/packages/ui/src/components/ui/carousel.tsx +243 -0
  154. package/packages/ui/src/components/ui/checkbox.tsx +32 -0
  155. package/packages/ui/src/components/ui/command.tsx +155 -0
  156. package/packages/ui/src/components/ui/dialog.tsx +127 -0
  157. package/packages/ui/src/components/ui/dropdown-menu.tsx +226 -0
  158. package/packages/ui/src/components/ui/form.tsx +165 -0
  159. package/packages/ui/src/components/ui/input-otp.tsx +76 -0
  160. package/packages/ui/src/components/ui/input.tsx +21 -0
  161. package/packages/ui/src/components/ui/label.tsx +24 -0
  162. package/packages/ui/src/components/ui/multiple-select.tsx +510 -0
  163. package/packages/ui/src/components/ui/popover.tsx +42 -0
  164. package/packages/ui/src/components/ui/select.tsx +170 -0
  165. package/packages/ui/src/components/ui/separator.tsx +28 -0
  166. package/packages/ui/src/components/ui/sheet.tsx +130 -0
  167. package/packages/ui/src/components/ui/skeleton.tsx +13 -0
  168. package/packages/ui/src/components/ui/spinner.tsx +16 -0
  169. package/packages/ui/src/components/ui/switch.tsx +28 -0
  170. package/packages/ui/src/components/ui/table.tsx +116 -0
  171. package/packages/ui/src/components/ui/tabs.tsx +54 -0
  172. package/packages/ui/src/components/ui/textarea.tsx +18 -0
  173. package/packages/ui/src/components/ui/timeline.tsx +118 -0
  174. package/packages/ui/src/components/ui/tooltip.tsx +30 -0
  175. package/packages/ui/src/components/util/n-formattor.ts +22 -0
  176. package/packages/ui/src/components/util/storage.ts +37 -0
  177. package/packages/ui/src/globals.css +87 -0
  178. package/packages/ui/tailwind.config.ts +94 -0
  179. package/packages/ui/tsconfig.json +12 -0
  180. package/pnpm-workspace.yaml +43 -0
  181. package/turbo.json +77 -0
package/.editorconfig ADDED
@@ -0,0 +1,20 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = tab
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [package.json]
12
+ indent_style = space
13
+ indent_size = 2
14
+
15
+ [*.yml]
16
+ indent_style = space
17
+ indent_size = 2
18
+
19
+ [*.ts]
20
+ quote_type = double
@@ -0,0 +1,24 @@
1
+ coverage
2
+ dist
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
+ CHANGELOG.md
12
+ .github/pull_request_template.md
13
+ # Ignored for now
14
+ **/*.md
15
+ # Handled by biome
16
+ **/*.ts
17
+ **/*.js
18
+ **/*.tsx
19
+ **/*.jsx
20
+
21
+ # Auto-generated
22
+ **/components.d.ts
23
+
24
+ justfile
package/.prettierrc.js ADDED
@@ -0,0 +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
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "typescript.tsdk": "node_modules\\typescript\\lib"
3
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Avinash Kumar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
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
@@ -0,0 +1,61 @@
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"]
@@ -0,0 +1,47 @@
1
+ import { defineConfig } from "eslint/config";
2
+ import { baseConfig } from "eslint-config/base";
3
+
4
+ export default defineConfig(
5
+ baseConfig,
6
+ {
7
+ rules: {
8
+ "unicorn/filename-case": ["error", { case: "kebabCase" }],
9
+ complexity: ["error", 23],
10
+
11
+ "no-empty": "warn",
12
+ "id-denylist": "warn",
13
+ "no-fallthrough": "warn",
14
+ "no-useless-escape": "warn",
15
+ "import-x/order": "warn",
16
+ "no-extra-boolean-cast": "warn",
17
+ "no-case-declarations": "warn",
18
+ "no-prototype-builtins": "warn",
19
+ "@typescript-eslint/naming-convention": "warn",
20
+ "@typescript-eslint/no-base-to-string": "warn",
21
+ "@typescript-eslint/no-redundant-type-constituents": "warn",
22
+ "@typescript-eslint/prefer-nullish-coalescing": "warn",
23
+ "@typescript-eslint/prefer-optional-chain": "warn",
24
+ "@typescript-eslint/return-await": ["error", "always"],
25
+ "@typescript-eslint/no-empty-object-type": "warn",
26
+ "@typescript-eslint/no-unsafe-function-type": "warn",
27
+ "@typescript-eslint/no-duplicate-type-constituents": "warn",
28
+ "@typescript-eslint/no-unsafe-return": "warn",
29
+ "@typescript-eslint/no-unsafe-call": "warn",
30
+ "@typescript-eslint/no-unsafe-member-access": "warn",
31
+ "@typescript-eslint/no-unsafe-assignment": "warn",
32
+ "@typescript-eslint/no-explicit-any": "warn",
33
+ },
34
+ },
35
+ {
36
+ files: ["**/*.test.ts"],
37
+ rules: {
38
+ "prefer-const": "warn",
39
+ "@typescript-eslint/no-unused-expressions": "warn",
40
+ "@typescript-eslint/no-explicit-any": "warn",
41
+ "@typescript-eslint/no-unsafe-member-access": "warn",
42
+ "@typescript-eslint/no-unsafe-assignment": "warn",
43
+ "@typescript-eslint/no-unsafe-return": "warn",
44
+ "@typescript-eslint/ban-ts-comment": ["warn", { "ts-ignore": true }],
45
+ },
46
+ },
47
+ );
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "core-server",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "start": "node --conditions=production dist/index.js",
7
+ "lint": "eslint .",
8
+ "build": "tsdown --config-loader unrun",
9
+ "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
+ "lint:fix": "eslint . src/**/*.ts --fix",
16
+ "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\""
17
+ },
18
+ "keywords": [],
19
+ "author": "",
20
+ "license": "ISC",
21
+ "description": "",
22
+ "dependencies": {
23
+ "@aws-sdk/client-s3": "^3.693.0",
24
+ "@repo/constants": "workspace:^",
25
+ "@repo/db": "workspace:^",
26
+ "@repo/email": "workspace:^",
27
+ "@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"
50
+ },
51
+ "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",
64
+ "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
+ "tsdown-config": "workspace:*",
71
+ "typescript-config": "workspace:*"
72
+ }
73
+ }
@@ -0,0 +1,54 @@
1
+ /* eslint-disable @typescript-eslint/no-namespace */
2
+ import type { SessionUser } from "@repo/lib";
3
+
4
+ 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
+
42
+ namespace Express {
43
+ export interface Request {
44
+ user: SessionUser;
45
+ }
46
+ }
47
+ }
48
+
49
+ declare module "http" {
50
+ interface IncomingMessage {
51
+ user: SessionUser;
52
+ body: any;
53
+ }
54
+ }
@@ -0,0 +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
+ }
@@ -0,0 +1,19 @@
1
+ import {ping} from "@repo/constants"
2
+ import {AdminEmailTemplate} from "@repo/email"
3
+ import { logger } from "@repo/lib";
4
+ import * as sharp from "sharp"
5
+
6
+ import { ServerEvents } from "./events/index.js";
7
+ import { app } from "./routes/server.js";
8
+ // PushNotificationManager.initialize({
9
+ // type: "env",
10
+ // });
11
+ console.log(sharp)
12
+
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}`);
18
+ ServerEvents.emitServerReady();
19
+ });
@@ -0,0 +1,50 @@
1
+ import { UserSession } from "@repo/lib";
2
+ import type { NextFunction, Request, Response } from "express";
3
+ export class AuthMiddlewares {
4
+ static async validateActiveSession(req: Request, res: Response, next: NextFunction) {
5
+ try {
6
+ const accessToken = req.headers["authorization"]?.split(" ")[1];
7
+ if (!accessToken) {
8
+ res.status(401).json({ message: "access token missing" });
9
+ return;
10
+ }
11
+
12
+ const payload = await UserSession.getSessionUser(accessToken);
13
+
14
+ if (!payload) {
15
+ res.status(401).json({ message: "invalid access token" });
16
+ return;
17
+ }
18
+ req.user = payload;
19
+ return next();
20
+ } catch (error) {
21
+ next(error);
22
+ }
23
+ }
24
+ }
25
+
26
+ export function validateSession() {
27
+ return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
28
+ const originalMethod = descriptor.value;
29
+ descriptor.value = async function (req: Request, res: Response, next: NextFunction) {
30
+ try {
31
+ const accessToken = req.headers["authorization"]?.split(" ")[1];
32
+ if (!accessToken) {
33
+ res.status(401).json({ message: "access token missing" });
34
+ return;
35
+ }
36
+
37
+ const payload = await UserSession.getSessionUser(accessToken);
38
+
39
+ if (!payload) {
40
+ res.status(401).json({ message: "invalid access token" });
41
+ return;
42
+ }
43
+ req.user = payload;
44
+ return originalMethod.apply(this, [req, res, next]);
45
+ } catch (error) {
46
+ next(error);
47
+ }
48
+ };
49
+ };
50
+ }
@@ -0,0 +1,6 @@
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
+ });
@@ -0,0 +1,23 @@
1
+ import { ErrorResponse, logger } from "@repo/lib";
2
+ import type { Request, Response } from "express";
3
+
4
+ interface Error {
5
+ message?: string;
6
+ statusCode?: number;
7
+ }
8
+
9
+ export const errorMiddleware = (error: Error, req: Request, res: Response) => {
10
+ error.message = error?.message ? error.message : "Internal Server Error";
11
+ error.statusCode = error instanceof ErrorResponse ? error.statusCode : 500;
12
+
13
+ if (process.env.NODE_ENV === "development" || error.statusCode === 500) {
14
+ if (error.statusCode === 404) {
15
+ } else logger.error(error);
16
+ }
17
+
18
+ res.status(error.statusCode).json({
19
+ success: false,
20
+ message: error.message,
21
+ });
22
+ return;
23
+ };
@@ -0,0 +1,21 @@
1
+ import { logger } from "@repo/lib";
2
+ import morgan from "morgan";
3
+ morgan.token("user", (req) => {
4
+ if (req.user) {
5
+ return `(USER: ${req.user.email} ID: ${req.user.id})`; // Convert to string if it's an object
6
+ }
7
+ return "(guest)"; // Return 'null' if `req.user` is not defined
8
+ });
9
+
10
+ const morganFormat = ":method~:url~:status~:response-time~:user";
11
+ const loggerMiddleware = morgan(morganFormat, {
12
+ stream: {
13
+ write: (message) => {
14
+ const [method, url, status, responseTime, user] = message.split("~");
15
+ const log = `${method} ${url} ${status} ${responseTime}ms ${user}`;
16
+ logger.info(log, { logType: "routeInfo" });
17
+ },
18
+ },
19
+ });
20
+
21
+ export { loggerMiddleware };
@@ -0,0 +1,14 @@
1
+ import { ErrorResponse } from "@repo/lib";
2
+ import type { Request, Response, NextFunction } from "express";
3
+ export function notFoundMiddleware(
4
+ req: Request,
5
+ res: Response,
6
+ next: NextFunction,
7
+ ) {
8
+ res.status(404);
9
+ const error = new ErrorResponse(
10
+ `Route doesn't exist for ${req.method}: ${req.originalUrl}`,
11
+ 404,
12
+ );
13
+ return next(error);
14
+ }
@@ -0,0 +1,24 @@
1
+ import express, { Router, type Request, type Response, type NextFunction } from "express";
2
+ import path from "path";
3
+
4
+ const distPath =
5
+ process.env.NODE_ENV === "production" ? "../frontend" : "../../../web-client/dist/client";
6
+
7
+ // __dirname is available at runtime because we compile to CommonJS
8
+ const reactDistPath = path.resolve(__dirname, distPath);
9
+
10
+ export const serveStatic = (): Router => {
11
+ const router = Router();
12
+
13
+ router.use(express.static(reactDistPath));
14
+
15
+ router.get("*", (req: Request, res: Response, next: NextFunction) => {
16
+ const accept = req.headers.accept ?? "";
17
+ if (accept.includes("text/html")) {
18
+ return res.sendFile(path.join(reactDistPath, "index.html"));
19
+ }
20
+ return next();
21
+ });
22
+
23
+ return router;
24
+ };
@@ -0,0 +1,7 @@
1
+ import { Router, static as expressStatic } from "express";
2
+
3
+ export function createFilesRouter(): Router {
4
+ const router = Router();
5
+ router.get("/*", expressStatic("storage"));
6
+ return router;
7
+ }
@@ -0,0 +1,36 @@
1
+ import { ping } from "@repo/constants";
2
+ import cookieParser from "cookie-parser";
3
+ import type { Request, Response } from "express";
4
+ import express from "express";
5
+ import fileUpload from "express-fileupload";
6
+
7
+
8
+ import { corsMiddleware } from "@/middlewares/cors-middleware.ts";
9
+ import { errorMiddleware } from "@/middlewares/error-middleware.ts";
10
+ import { loggerMiddleware } from "@/middlewares/logger-middleware.ts";
11
+ import { notFoundMiddleware } from "@/middlewares/notfound-middleware.ts";
12
+ import { serveStatic } from "@/middlewares/serve-static.ts";
13
+
14
+ import { createFilesRouter } from "./files/router.js";
15
+
16
+ const app = express() as express.Express;
17
+ app.use(loggerMiddleware);
18
+ app.use(cookieParser());
19
+ app.use(express.urlencoded({ extended: true }));
20
+ app.use(express.json());
21
+ app.use(fileUpload());
22
+ app.use(corsMiddleware);
23
+
24
+ app.use("/files", createFilesRouter());
25
+
26
+ app.get("/test", (req: Request, res: Response) => {
27
+ res.statusCode = 200;
28
+ res.json("OK");
29
+ return;
30
+ });
31
+ console.warn(ping);
32
+ app.use(serveStatic());
33
+ app.use(notFoundMiddleware);
34
+ app.use(errorMiddleware);
35
+
36
+ export { app };
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "typescript-config/tsconfig.node.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "paths": {
6
+ "@/*": ["./src/*"]
7
+ }
8
+ },
9
+ "include": ["src/**/*.ts"]
10
+ }
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from "tsdown";
2
+ import { baseConfig } from "tsdown-config";
3
+
4
+ export default defineConfig({
5
+ ...baseConfig,
6
+ platform: "node",
7
+ external: ["sharp"],
8
+ noExternal: [/(.*)/],
9
+ outputOptions: {
10
+ codeSplitting: false,
11
+ preserveModules: false,
12
+ legalComments: "none"
13
+ },
14
+ });