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.
- package/.editorconfig +20 -0
- package/.prettierignore +24 -0
- package/.prettierrc.js +52 -0
- package/.vscode/settings.json +3 -0
- package/LICENSE +21 -0
- package/apps/core-server/.env.example +24 -0
- package/apps/core-server/Dockerfile +61 -0
- package/apps/core-server/eslint.config.mjs +47 -0
- package/apps/core-server/package.json +73 -0
- package/apps/core-server/src/config/custom-type.ts +54 -0
- package/apps/core-server/src/events/index.ts +37 -0
- package/apps/core-server/src/index.ts +19 -0
- package/apps/core-server/src/middlewares/auth-middleware.ts +50 -0
- package/apps/core-server/src/middlewares/cors-middleware.ts +6 -0
- package/apps/core-server/src/middlewares/error-middleware.ts +23 -0
- package/apps/core-server/src/middlewares/logger-middleware.ts +21 -0
- package/apps/core-server/src/middlewares/notfound-middleware.ts +14 -0
- package/apps/core-server/src/middlewares/serve-static.ts +24 -0
- package/apps/core-server/src/routes/files/router.ts +7 -0
- package/apps/core-server/src/routes/server.ts +36 -0
- package/apps/core-server/tsconfig.json +10 -0
- package/apps/core-server/tsdown.config.ts +14 -0
- package/biome.json +62 -0
- package/configs/eslint-config/package.json +60 -0
- package/configs/eslint-config/plugins.d.ts +1 -0
- package/configs/eslint-config/src/configs/base.ts +237 -0
- package/configs/eslint-config/src/configs/frontend.ts +62 -0
- package/configs/eslint-config/src/configs/node.ts +10 -0
- package/configs/eslint-config/src/plugin.ts +25 -0
- package/configs/eslint-config/src/rules/index.ts +30 -0
- package/configs/eslint-config/src/rules/no-argument-spread.test.ts +47 -0
- package/configs/eslint-config/src/rules/no-argument-spread.ts +96 -0
- package/configs/eslint-config/src/rules/no-dynamic-import-template.ts +32 -0
- package/configs/eslint-config/src/rules/no-internal-package-import.ts +40 -0
- package/configs/eslint-config/src/rules/no-interpolation-in-regular-string.ts +32 -0
- package/configs/eslint-config/src/rules/no-json-parse-json-stringify.test.ts +34 -0
- package/configs/eslint-config/src/rules/no-json-parse-json-stringify.ts +49 -0
- package/configs/eslint-config/src/rules/no-plain-errors.ts +50 -0
- package/configs/eslint-config/src/rules/no-skipped-tests.ts +61 -0
- package/configs/eslint-config/src/rules/no-top-level-relative-imports-in-backend-module.ts +27 -0
- package/configs/eslint-config/src/rules/no-type-unsafe-event-emitter.ts +33 -0
- package/configs/eslint-config/src/rules/no-uncaught-json-parse.test.ts +21 -0
- package/configs/eslint-config/src/rules/no-uncaught-json-parse.ts +45 -0
- package/configs/eslint-config/src/rules/no-untyped-config-class-field.ts +26 -0
- package/configs/eslint-config/src/rules/no-unused-param-catch-clause.ts +33 -0
- package/configs/eslint-config/src/rules/no-useless-catch-throw.test.ts +34 -0
- package/configs/eslint-config/src/rules/no-useless-catch-throw.ts +47 -0
- package/configs/eslint-config/src/utils/json.ts +21 -0
- package/configs/eslint-config/tsconfig.json +8 -0
- package/configs/eslint-config/tsdown.config.ts +11 -0
- package/configs/eslint-config/vitest.config.ts +3 -0
- package/configs/tsdown-config/package.json +14 -0
- package/configs/tsdown-config/src/config/tsdown.base.ts +13 -0
- package/configs/typescript-config/package.json +10 -0
- package/configs/typescript-config/tsconfig.common.json +32 -0
- package/configs/typescript-config/tsconfig.frontend.json +14 -0
- package/configs/typescript-config/tsconfig.node.json +9 -0
- package/configs/vitest-config/package.json +25 -0
- package/configs/vitest-config/src/base.ts +34 -0
- package/configs/vitest-config/src/frontend.ts +15 -0
- package/configs/vitest-config/src/node.ts +5 -0
- package/configs/vitest-config/tsconfig.json +7 -0
- package/package.json +47 -0
- package/packages/@repo/constants/eslint.config.mjs +21 -0
- package/packages/@repo/constants/package.json +19 -0
- package/packages/@repo/constants/src/api.ts +1 -0
- package/packages/@repo/constants/src/index.ts +8 -0
- package/packages/@repo/constants/src/time.ts +23 -0
- package/packages/@repo/constants/tsconfig.json +7 -0
- package/packages/@repo/db/eslint.config.mjs +21 -0
- package/packages/@repo/db/package.json +30 -0
- package/packages/@repo/db/src/functions.ts +122 -0
- package/packages/@repo/db/src/index.ts +20 -0
- package/packages/@repo/db/src/schema/common.ts +49 -0
- package/packages/@repo/db/src/schema/index.ts +1 -0
- package/packages/@repo/db/tsconfig.json +13 -0
- package/packages/@repo/lib/eslint.config.mjs +49 -0
- package/packages/@repo/lib/package.json +57 -0
- package/packages/@repo/lib/src/bucket-module/file-storage.ts +49 -0
- package/packages/@repo/lib/src/bucket-module/s3-storage.ts +114 -0
- package/packages/@repo/lib/src/bucket-module/utils.ts +11 -0
- package/packages/@repo/lib/src/command-module.ts +77 -0
- package/packages/@repo/lib/src/constants.ts +3 -0
- package/packages/@repo/lib/src/cookie-module.ts +42 -0
- package/packages/@repo/lib/src/custom-type.ts +54 -0
- package/packages/@repo/lib/src/env.ts +13 -0
- package/packages/@repo/lib/src/error-handlers-module/index.ts +11 -0
- package/packages/@repo/lib/src/file-system/index.ts +90 -0
- package/packages/@repo/lib/src/hashing-module.ts +9 -0
- package/packages/@repo/lib/src/index.ts +27 -0
- package/packages/@repo/lib/src/logger-module/log-config.ts +16 -0
- package/packages/@repo/lib/src/logger-module/logger.ts +78 -0
- package/packages/@repo/lib/src/logger-module/memory-profiler.ts +65 -0
- package/packages/@repo/lib/src/mail-module/api.ts +0 -0
- package/packages/@repo/lib/src/mail-module/mock.ts +8 -0
- package/packages/@repo/lib/src/mail-module/nodemailer.ts +45 -0
- package/packages/@repo/lib/src/notification-module/index.ts +172 -0
- package/packages/@repo/lib/src/notification-module/push-notification.ts +90 -0
- package/packages/@repo/lib/src/oauth2-client.ts +109 -0
- package/packages/@repo/lib/src/otp-module.ts +98 -0
- package/packages/@repo/lib/src/pagination-module.ts +49 -0
- package/packages/@repo/lib/src/token-module.ts +35 -0
- package/packages/@repo/lib/src/user-session.ts +117 -0
- package/packages/@repo/lib/src/utils.ts +42 -0
- package/packages/@repo/lib/src/validation-module.ts +187 -0
- package/packages/@repo/lib/tsconfig.json +7 -0
- package/packages/@repo/mail/package.json +29 -0
- package/packages/@repo/mail/src/emails/admin/OtpEmail.tsx +168 -0
- package/packages/@repo/mail/src/index.ts +13 -0
- package/packages/@repo/mail/tsconfig.build.json +14 -0
- package/packages/@repo/mail/tsconfig.json +13 -0
- package/packages/@repo/mail/tsdown.config.ts +9 -0
- package/packages/@repo/redis/eslint.config.mjs +8 -0
- package/packages/@repo/redis/package.json +31 -0
- package/packages/@repo/redis/src/index.ts +2 -0
- package/packages/@repo/redis/src/lib/redis-client.ts +23 -0
- package/packages/@repo/redis/src/lib/redis-module.ts +3 -0
- package/packages/@repo/redis/tsconfig.json +12 -0
- package/packages/ui/components.json +17 -0
- package/packages/ui/eslint.config.mjs +18 -0
- package/packages/ui/package.json +67 -0
- package/packages/ui/postcss.config.mjs +9 -0
- package/packages/ui/src/components/custom/form-wrapper.tsx +551 -0
- package/packages/ui/src/components/custom/grid-component.tsx +23 -0
- package/packages/ui/src/components/custom/hover-tool.tsx +38 -0
- package/packages/ui/src/components/custom/image-picker.tsx +109 -0
- package/packages/ui/src/components/custom/no-content.tsx +37 -0
- package/packages/ui/src/components/custom/page-container.tsx +24 -0
- package/packages/ui/src/components/custom/page-section.tsx +59 -0
- package/packages/ui/src/components/custom/simple-popover.tsx +29 -0
- package/packages/ui/src/components/custom/switch-component.tsx +20 -0
- package/packages/ui/src/components/custom/theme-provider.tsx +74 -0
- package/packages/ui/src/components/custom/typography.tsx +111 -0
- package/packages/ui/src/components/extensions/carousel.tsx +392 -0
- package/packages/ui/src/components/hooks/event/use-click.tsx +39 -0
- package/packages/ui/src/components/hooks/time/useDebounce.tsx +21 -0
- package/packages/ui/src/components/hooks/time/useInterval.tsx +35 -0
- package/packages/ui/src/components/hooks/time/useTimeout.tsx +19 -0
- package/packages/ui/src/components/hooks/time/useTimer.tsx +51 -0
- package/packages/ui/src/components/hooks/use-media-query.tsx +19 -0
- package/packages/ui/src/components/hooks/use-persistent-storage.tsx +52 -0
- package/packages/ui/src/components/hooks/use-update-effect.tsx +13 -0
- package/packages/ui/src/components/hooks/use-window-dimension.tsx +30 -0
- package/packages/ui/src/components/lib/utils.ts +242 -0
- package/packages/ui/src/components/lucide.tsx +3 -0
- package/packages/ui/src/components/sonner.tsx +1 -0
- package/packages/ui/src/components/ui/alert-dialog.tsx +116 -0
- package/packages/ui/src/components/ui/avatar.tsx +53 -0
- package/packages/ui/src/components/ui/badge.tsx +46 -0
- package/packages/ui/src/components/ui/breadcrumb.tsx +109 -0
- package/packages/ui/src/components/ui/button.tsx +96 -0
- package/packages/ui/src/components/ui/card.tsx +92 -0
- package/packages/ui/src/components/ui/carousel.tsx +243 -0
- package/packages/ui/src/components/ui/checkbox.tsx +32 -0
- package/packages/ui/src/components/ui/command.tsx +155 -0
- package/packages/ui/src/components/ui/dialog.tsx +127 -0
- package/packages/ui/src/components/ui/dropdown-menu.tsx +226 -0
- package/packages/ui/src/components/ui/form.tsx +165 -0
- package/packages/ui/src/components/ui/input-otp.tsx +76 -0
- package/packages/ui/src/components/ui/input.tsx +21 -0
- package/packages/ui/src/components/ui/label.tsx +24 -0
- package/packages/ui/src/components/ui/multiple-select.tsx +510 -0
- package/packages/ui/src/components/ui/popover.tsx +42 -0
- package/packages/ui/src/components/ui/select.tsx +170 -0
- package/packages/ui/src/components/ui/separator.tsx +28 -0
- package/packages/ui/src/components/ui/sheet.tsx +130 -0
- package/packages/ui/src/components/ui/skeleton.tsx +13 -0
- package/packages/ui/src/components/ui/spinner.tsx +16 -0
- package/packages/ui/src/components/ui/switch.tsx +28 -0
- package/packages/ui/src/components/ui/table.tsx +116 -0
- package/packages/ui/src/components/ui/tabs.tsx +54 -0
- package/packages/ui/src/components/ui/textarea.tsx +18 -0
- package/packages/ui/src/components/ui/timeline.tsx +118 -0
- package/packages/ui/src/components/ui/tooltip.tsx +30 -0
- package/packages/ui/src/components/util/n-formattor.ts +22 -0
- package/packages/ui/src/components/util/storage.ts +37 -0
- package/packages/ui/src/globals.css +87 -0
- package/packages/ui/tailwind.config.ts +94 -0
- package/packages/ui/tsconfig.json +12 -0
- package/pnpm-workspace.yaml +43 -0
- 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
|
package/.prettierignore
ADDED
|
@@ -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
|
+
};
|
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,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,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,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
|
+
});
|