@anmol0493/fullstack-app 1.0.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 (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +24 -0
  3. package/backend-express/.env.example +2 -0
  4. package/backend-express/index.js +2 -0
  5. package/backend-express/package-lock.json +1939 -0
  6. package/backend-express/package.json +25 -0
  7. package/backend-express/src/config/db.js +20 -0
  8. package/backend-express/src/controller/auth.js +71 -0
  9. package/backend-express/src/middleware/auth.js +36 -0
  10. package/backend-express/src/middleware/validator.js +16 -0
  11. package/backend-express/src/models/user.js +26 -0
  12. package/backend-express/src/routes/auth.js +25 -0
  13. package/backend-express/src/server.js +28 -0
  14. package/backend-express/src/utils/constants.js +14 -0
  15. package/backend-express/src/utils/helper.js +30 -0
  16. package/backend-express/src/utils/schema/auth.js +34 -0
  17. package/backend-nestjs/.env.example +3 -0
  18. package/backend-nestjs/.prettierrc +4 -0
  19. package/backend-nestjs/README.md +99 -0
  20. package/backend-nestjs/eslint.config.mjs +35 -0
  21. package/backend-nestjs/nest-cli.json +8 -0
  22. package/backend-nestjs/package.json +99 -0
  23. package/backend-nestjs/pnpm-lock.yaml +7848 -0
  24. package/backend-nestjs/src/app.controller.ts +12 -0
  25. package/backend-nestjs/src/app.module.ts +13 -0
  26. package/backend-nestjs/src/app.service.ts +8 -0
  27. package/backend-nestjs/src/common/decorators/user.decorator.ts +8 -0
  28. package/backend-nestjs/src/common/dtos/common.dto.ts +87 -0
  29. package/backend-nestjs/src/common/enum/index.ts +0 -0
  30. package/backend-nestjs/src/common/exceptions/custom.exception.ts +28 -0
  31. package/backend-nestjs/src/common/filters/http-exception.filter.ts +46 -0
  32. package/backend-nestjs/src/common/guard/permission.guard.ts +18 -0
  33. package/backend-nestjs/src/common/middleware/auth.middleware.ts +20 -0
  34. package/backend-nestjs/src/common/pipes/validation.pipe.ts +61 -0
  35. package/backend-nestjs/src/common/utils/constants.ts +36 -0
  36. package/backend-nestjs/src/common/utils/helper.ts +43 -0
  37. package/backend-nestjs/src/core/core.module.ts +8 -0
  38. package/backend-nestjs/src/core/jwt/jwt.module.ts +10 -0
  39. package/backend-nestjs/src/core/jwt/jwt.service.ts +45 -0
  40. package/backend-nestjs/src/core/prisma/prisma.module.ts +9 -0
  41. package/backend-nestjs/src/core/prisma/prisma.service.ts +17 -0
  42. package/backend-nestjs/src/core/prisma/schema.prisma +27 -0
  43. package/backend-nestjs/src/main.ts +26 -0
  44. package/backend-nestjs/src/module/auth/auth.controller.ts +30 -0
  45. package/backend-nestjs/src/module/auth/auth.module.ts +10 -0
  46. package/backend-nestjs/src/module/auth/auth.service.ts +83 -0
  47. package/backend-nestjs/src/module/auth/dto/index.ts +28 -0
  48. package/backend-nestjs/src/module/index.module.ts +17 -0
  49. package/backend-nestjs/src/scripts/migrate.js +40 -0
  50. package/backend-nestjs/tsconfig.build.json +4 -0
  51. package/backend-nestjs/tsconfig.json +22 -0
  52. package/frontend/.env.example +1 -0
  53. package/frontend/README.md +54 -0
  54. package/frontend/eslint.config.js +28 -0
  55. package/frontend/index.html +13 -0
  56. package/frontend/package-lock.json +3813 -0
  57. package/frontend/package.json +43 -0
  58. package/frontend/public/vite.svg +1 -0
  59. package/frontend/src/App.tsx +24 -0
  60. package/frontend/src/assets/react.svg +1 -0
  61. package/frontend/src/components/Layout.tsx +59 -0
  62. package/frontend/src/components/ui/AlertDialog.tsx +47 -0
  63. package/frontend/src/components/ui/Button.tsx +61 -0
  64. package/frontend/src/components/ui/CommonAlertDialog.tsx +57 -0
  65. package/frontend/src/components/ui/FormInput.tsx +73 -0
  66. package/frontend/src/components/ui/Loader.tsx +7 -0
  67. package/frontend/src/hook/useFetchUser.ts +38 -0
  68. package/frontend/src/index.css +1 -0
  69. package/frontend/src/lib/constants.ts +24 -0
  70. package/frontend/src/lib/schema.ts +12 -0
  71. package/frontend/src/lib/utils.ts +71 -0
  72. package/frontend/src/main.tsx +11 -0
  73. package/frontend/src/pages/Home.tsx +5 -0
  74. package/frontend/src/pages/Login.tsx +67 -0
  75. package/frontend/src/pages/Signup.tsx +67 -0
  76. package/frontend/src/redux/api/auth.ts +19 -0
  77. package/frontend/src/redux/slice/auth.ts +39 -0
  78. package/frontend/src/redux/store.ts +30 -0
  79. package/frontend/src/routes/index.tsx +20 -0
  80. package/frontend/src/routes/middleware.ts +18 -0
  81. package/frontend/src/types/index.ts +12 -0
  82. package/frontend/src/vite-env.d.ts +1 -0
  83. package/frontend/tsconfig.app.json +26 -0
  84. package/frontend/tsconfig.json +7 -0
  85. package/frontend/tsconfig.node.json +24 -0
  86. package/frontend/vite.config.ts +19 -0
  87. package/package.json +34 -0
  88. package/scripts/setup.js +73 -0
@@ -0,0 +1,28 @@
1
+ import { IsEmail, IsString, MinLength } from 'class-validator';
2
+ import { ResponseBaseDto } from 'src/common/dtos/common.dto';
3
+
4
+ export class LoginDto {
5
+ @IsString({ message: 'Email must be a string' })
6
+ @IsEmail({}, { message: 'Email must be a valid email' })
7
+ email: string;
8
+
9
+ @IsString({ message: 'Password must be a string' })
10
+ @MinLength(6, { message: 'Password must be at least 6 characters' })
11
+ password: string;
12
+ }
13
+
14
+ export class RegisterDto extends LoginDto {
15
+ @IsString({ message: 'Name must be a string' })
16
+ name: string;
17
+ }
18
+
19
+ export class UpdateUserDto {
20
+ @IsString({ message: 'Name must be a string' })
21
+ name: string;
22
+
23
+ @IsString({ message: 'Email must be a string' })
24
+ @IsEmail({}, { message: 'Email must be a valid email' })
25
+ email: string;
26
+ }
27
+
28
+ export class LoginResDto extends ResponseBaseDto<{ token: string }> {}
@@ -0,0 +1,17 @@
1
+ import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
2
+ import { AuthModule } from './auth/auth.module';
3
+ import { AuthMiddleware } from 'src/common/middleware/auth.middleware';
4
+
5
+ @Module({
6
+ imports: [
7
+ AuthModule,
8
+ ]
9
+ })
10
+ export class IndexModule implements NestModule {
11
+ configure(consumer: MiddlewareConsumer) {
12
+ consumer
13
+ .apply(AuthMiddleware)
14
+ .exclude('auth/login', 'auth/register')
15
+ .forRoutes('*');
16
+ }
17
+ }
@@ -0,0 +1,40 @@
1
+ // execution command: pnpm prisma:migrate <migration-name>
2
+ // Description: This script is used to run the prisma migrate dev command with a custom migration name.
3
+ // If no migration name is provided, it will generate a timestamp-based name.
4
+ // This script is used to avoid the need to run the prisma migrate dev command directly.
5
+
6
+ const { execSync } = require('child_process');
7
+
8
+ function generateTimestamp() {
9
+ const now = new Date();
10
+ const year = now.getFullYear();
11
+ const month = String(now.getMonth() + 1).padStart(2, '0');
12
+ const day = String(now.getDate()).padStart(2, '0');
13
+ const hours = String(now.getHours()).padStart(2, '0');
14
+ const minutes = String(now.getMinutes()).padStart(2, '0');
15
+ const seconds = String(now.getSeconds()).padStart(2, '0');
16
+ return `${year}${month}${day}_${hours}${minutes}${seconds}`;
17
+ }
18
+
19
+ function getMigrationName() {
20
+ const args = process.argv.slice(2);
21
+ if (args.length > 0) return args[0]
22
+
23
+ console.log('No migration name provided. Using a timestamp-based name.');
24
+ return generateTimestamp();
25
+ }
26
+
27
+ // Main function
28
+ function runMigration() {
29
+ try {
30
+ const migrationName = getMigrationName();
31
+ const command = `cd src/core/prisma && prisma migrate dev --name ${migrationName}`;
32
+ console.log(`Running migration with name: ${migrationName}`);
33
+ execSync(command, { stdio: 'inherit' });
34
+ } catch (error) {
35
+ console.error('Migration failed:', error);
36
+ process.exit(1);
37
+ }
38
+ }
39
+
40
+ runMigration();
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
4
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "declaration": true,
5
+ "removeComments": true,
6
+ "emitDecoratorMetadata": true,
7
+ "experimentalDecorators": true,
8
+ "allowSyntheticDefaultImports": true,
9
+ "target": "ES2021",
10
+ "sourceMap": true,
11
+ "outDir": "./dist",
12
+ "baseUrl": "./",
13
+ "incremental": true,
14
+ "skipLibCheck": true,
15
+ "strictNullChecks": true,
16
+ "forceConsistentCasingInFileNames": true,
17
+ "noImplicitAny": false,
18
+ "strictBindCallApply": false,
19
+ "noFallthroughCasesInSwitch": false,
20
+ "esModuleInterop": true
21
+ }
22
+ }
@@ -0,0 +1 @@
1
+ VITE_API_URL=http://localhost:5000
@@ -0,0 +1,54 @@
1
+ # React + TypeScript + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+
10
+ ## Expanding the ESLint configuration
11
+
12
+ If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
13
+
14
+ ```js
15
+ export default tseslint.config({
16
+ extends: [
17
+ // Remove ...tseslint.configs.recommended and replace with this
18
+ ...tseslint.configs.recommendedTypeChecked,
19
+ // Alternatively, use this for stricter rules
20
+ ...tseslint.configs.strictTypeChecked,
21
+ // Optionally, add this for stylistic rules
22
+ ...tseslint.configs.stylisticTypeChecked,
23
+ ],
24
+ languageOptions: {
25
+ // other options...
26
+ parserOptions: {
27
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
28
+ tsconfigRootDir: import.meta.dirname,
29
+ },
30
+ },
31
+ })
32
+ ```
33
+
34
+ You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
35
+
36
+ ```js
37
+ // eslint.config.js
38
+ import reactX from 'eslint-plugin-react-x'
39
+ import reactDom from 'eslint-plugin-react-dom'
40
+
41
+ export default tseslint.config({
42
+ plugins: {
43
+ // Add the react-x and react-dom plugins
44
+ 'react-x': reactX,
45
+ 'react-dom': reactDom,
46
+ },
47
+ rules: {
48
+ // other rules...
49
+ // Enable its recommended typescript rules
50
+ ...reactX.configs['recommended-typescript'].rules,
51
+ ...reactDom.configs.recommended.rules,
52
+ },
53
+ })
54
+ ```
@@ -0,0 +1,28 @@
1
+ import js from '@eslint/js'
2
+ import globals from 'globals'
3
+ import reactHooks from 'eslint-plugin-react-hooks'
4
+ import reactRefresh from 'eslint-plugin-react-refresh'
5
+ import tseslint from 'typescript-eslint'
6
+
7
+ export default tseslint.config(
8
+ { ignores: ['dist'] },
9
+ {
10
+ extends: [js.configs.recommended, ...tseslint.configs.recommended],
11
+ files: ['**/*.{ts,tsx}'],
12
+ languageOptions: {
13
+ ecmaVersion: 2020,
14
+ globals: globals.browser,
15
+ },
16
+ plugins: {
17
+ 'react-hooks': reactHooks,
18
+ 'react-refresh': reactRefresh,
19
+ },
20
+ rules: {
21
+ ...reactHooks.configs.recommended.rules,
22
+ 'react-refresh/only-export-components': [
23
+ 'warn',
24
+ { allowConstantExport: true },
25
+ ],
26
+ },
27
+ },
28
+ )
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Vite + React + TS</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>