exp-node-server 1.1.3 → 1.1.7

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 (59) hide show
  1. package/README.md +2 -2
  2. package/package.json +1 -1
  3. package/src/createProject.js +3 -0
  4. package/src/generateModule.js +54 -22
  5. package/src/utils/getProjectType.js +13 -0
  6. package/src/utils/{schemaGenerator.js → mongoose/schemaGenerator.js} +2 -2
  7. package/src/utils/prisma/prismaSchemaGenerator.js +10 -0
  8. package/src/utils/prisma/prismaServiceGenerator.js +47 -0
  9. package/templates/mongoose/.projectrc.json +3 -0
  10. package/templates/mongoose/package.json +0 -2
  11. package/templates/mongoose/src/app/middlewares/request_validator.ts +2 -2
  12. package/templates/prisma/.dockerignore +8 -0
  13. package/templates/prisma/.env.example +20 -0
  14. package/templates/prisma/.projectrc.json +3 -0
  15. package/templates/prisma/Dockerfile +27 -0
  16. package/templates/prisma/docker-compose.yml +27 -0
  17. package/templates/prisma/package.json +47 -0
  18. package/templates/prisma/prisma/schema/account.schema.prisma +19 -0
  19. package/templates/prisma/prisma/schema/profile.schema.prisma +8 -0
  20. package/templates/prisma/prisma/schema/schema.prisma +8 -0
  21. package/templates/prisma/prisma.config.ts +14 -0
  22. package/templates/prisma/readme.md +126 -0
  23. package/templates/prisma/src/app/configs/index.ts +26 -0
  24. package/templates/prisma/src/app/errors/zodError.ts +20 -0
  25. package/templates/prisma/src/app/lib/prisma.ts +10 -0
  26. package/templates/prisma/src/app/middlewares/auth.ts +30 -0
  27. package/templates/prisma/src/app/middlewares/global_error_handler.ts +51 -0
  28. package/templates/prisma/src/app/middlewares/not_found_api.ts +10 -0
  29. package/templates/prisma/src/app/middlewares/request_validator.ts +14 -0
  30. package/templates/prisma/src/app/middlewares/uploader.ts +16 -0
  31. package/templates/prisma/src/app/modules/account/account.controller.ts +116 -0
  32. package/templates/prisma/src/app/modules/account/account.route.ts +55 -0
  33. package/templates/prisma/src/app/modules/account/account.service.ts +402 -0
  34. package/templates/prisma/src/app/modules/account/account.swagger.ts +187 -0
  35. package/templates/prisma/src/app/modules/account/account.validation.ts +41 -0
  36. package/templates/prisma/src/app/modules/profile/profile.controller.ts +17 -0
  37. package/templates/prisma/src/app/modules/profile/profile.route.ts +22 -0
  38. package/templates/prisma/src/app/modules/profile/profile.service.ts +26 -0
  39. package/templates/prisma/src/app/modules/profile/profile.swagger.ts +34 -0
  40. package/templates/prisma/src/app/modules/profile/profile.validation.ts +8 -0
  41. package/templates/prisma/src/app/types/error.d.ts +10 -0
  42. package/templates/prisma/src/app/types/index.d.ts +12 -0
  43. package/templates/prisma/src/app/utils/JWT.ts +27 -0
  44. package/templates/prisma/src/app/utils/app_error.ts +12 -0
  45. package/templates/prisma/src/app/utils/catch_async.ts +13 -0
  46. package/templates/prisma/src/app/utils/cloudinary.ts +66 -0
  47. package/templates/prisma/src/app/utils/mail_sender.ts +102 -0
  48. package/templates/prisma/src/app/utils/manage_response.ts +24 -0
  49. package/templates/prisma/src/app/utils/otpGenerator.ts +29 -0
  50. package/templates/prisma/src/app.ts +42 -0
  51. package/templates/prisma/src/routes.ts +11 -0
  52. package/templates/prisma/src/server.ts +19 -0
  53. package/templates/prisma/src/swaggerOptions.ts +48 -0
  54. package/templates/prisma/tsconfig.json +23 -0
  55. /package/src/utils/{controllerGenerator.js → mongoose/controllerGenerator.js} +0 -0
  56. /package/src/utils/{routeGenerator.js → mongoose/routeGenerator.js} +0 -0
  57. /package/src/utils/{serviceGenerator.js → mongoose/serviceGenerator.js} +0 -0
  58. /package/src/utils/{swaggerGenerator.js → mongoose/swaggerGenerator.js} +0 -0
  59. /package/src/utils/{validationGenerator.js → mongoose/validationGenerator.js} +0 -0
@@ -0,0 +1,11 @@
1
+ import { Router } from "express";
2
+ import accountRouter from "./app/modules/account/account.route";
3
+ import profileRoute from "./app/modules/profile/profile.route";
4
+
5
+ const appRouter = Router();
6
+
7
+ const moduleRoutes = [
8
+ { path: "/profile", route: profileRoute },{ path: "/auth", route: accountRouter }];
9
+
10
+ moduleRoutes.forEach((route) => appRouter.use(route.path, route.route));
11
+ export default appRouter;
@@ -0,0 +1,19 @@
1
+ import app from "./app";
2
+ import { configs } from "./app/configs/index";
3
+ import { prisma } from "./app/lib/prisma";
4
+
5
+ async function main() {
6
+ try {
7
+ app.listen(configs.port, async () => {
8
+ await prisma.$connect();
9
+ console.log(`Server is running on port ${configs.port}`);
10
+ });
11
+ } catch (error) {
12
+ console.error("Error starting server:", error);
13
+ }
14
+ }
15
+
16
+ main().catch((error) => {
17
+ console.error("Error in main function:", error);
18
+ process.exit(1);
19
+ });
@@ -0,0 +1,48 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import path from "path";
3
+ import { configs } from "./app/configs";
4
+ import { accountSwaggerDocs } from "./app/modules/account/account.swagger";
5
+ import { profileSwaggerDocs } from "./app/modules/profile/profile.swagger";
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+
10
+ export const swaggerOptions = {
11
+ definition: {
12
+ openapi: "3.0.0",
13
+ info: {
14
+ title: "API Doc - Build with exp-node-server",
15
+ version: "1.0.0",
16
+ description: "Express + Prisma API with auto-generated Swagger docs",
17
+ },
18
+ paths: {
19
+ ...accountSwaggerDocs,
20
+ ...profileSwaggerDocs,
21
+ },
22
+ servers:
23
+ configs.env === "production"
24
+ ? [{ url: "https://live-url.com" }, { url: "http://localhost:5000" }]
25
+ : [{ url: "http://localhost:5000" }, { url: "https://live-url.com" }],
26
+ components: {
27
+ securitySchemes: {
28
+ AuthorizationToken: {
29
+ type: "apiKey",
30
+ in: "header",
31
+ name: "Authorization",
32
+ description: "Put your accessToken here ",
33
+ },
34
+ },
35
+ },
36
+ security: [
37
+ {
38
+ AuthorizationToken: [],
39
+ },
40
+ ],
41
+ },
42
+ apis: [
43
+ path.join(
44
+ __dirname,
45
+ configs.env === "production" ? "./**/*.js" : "./**/*.ts",
46
+ ),
47
+ ],
48
+ };
@@ -0,0 +1,23 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2023",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "rootDir": "./",
7
+ "outDir": "./dist",
8
+ "esModuleInterop": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "strict": true,
11
+ "skipLibCheck": true
12
+ },
13
+ "include": [
14
+ "src/**/*",
15
+ "prisma/**/*"
16
+ ],
17
+ "exclude": [
18
+ "node_modules",
19
+ "dist",
20
+ "build",
21
+ "generated/prisma"
22
+ ]
23
+ }