arkos 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 (114) hide show
  1. package/README.md +161 -0
  2. package/dist/src/app.d.ts +10 -0
  3. package/dist/src/app.d.ts.map +1 -0
  4. package/dist/src/app.js +114 -0
  5. package/dist/src/app.js.map +1 -0
  6. package/dist/src/index.d.ts +21 -0
  7. package/dist/src/index.d.ts.map +1 -0
  8. package/dist/src/index.js +51 -0
  9. package/dist/src/index.js.map +1 -0
  10. package/dist/src/modules/auth/auth.controller.d.ts +23 -0
  11. package/dist/src/modules/auth/auth.controller.d.ts.map +1 -0
  12. package/dist/src/modules/auth/auth.controller.js +317 -0
  13. package/dist/src/modules/auth/auth.controller.js.map +1 -0
  14. package/dist/src/modules/auth/auth.router.d.ts +4 -0
  15. package/dist/src/modules/auth/auth.router.d.ts.map +1 -0
  16. package/dist/src/modules/auth/auth.router.js +64 -0
  17. package/dist/src/modules/auth/auth.router.js.map +1 -0
  18. package/dist/src/modules/auth/auth.service.d.ts +16 -0
  19. package/dist/src/modules/auth/auth.service.d.ts.map +1 -0
  20. package/dist/src/modules/auth/auth.service.js +122 -0
  21. package/dist/src/modules/auth/auth.service.js.map +1 -0
  22. package/dist/src/modules/base/base.controller.d.ts +17 -0
  23. package/dist/src/modules/base/base.controller.d.ts.map +1 -0
  24. package/dist/src/modules/base/base.controller.js +296 -0
  25. package/dist/src/modules/base/base.controller.js.map +1 -0
  26. package/dist/src/modules/base/base.middlewares.d.ts +20 -0
  27. package/dist/src/modules/base/base.middlewares.d.ts.map +1 -0
  28. package/dist/src/modules/base/base.middlewares.js +86 -0
  29. package/dist/src/modules/base/base.middlewares.js.map +1 -0
  30. package/dist/src/modules/base/base.router.d.ts +4 -0
  31. package/dist/src/modules/base/base.router.d.ts.map +1 -0
  32. package/dist/src/modules/base/base.router.js +74 -0
  33. package/dist/src/modules/base/base.router.js.map +1 -0
  34. package/dist/src/modules/base/base.service.d.ts +32 -0
  35. package/dist/src/modules/base/base.service.d.ts.map +1 -0
  36. package/dist/src/modules/base/base.service.js +149 -0
  37. package/dist/src/modules/base/base.service.js.map +1 -0
  38. package/dist/src/modules/base/utils/base.helpers.d.ts +29 -0
  39. package/dist/src/modules/base/utils/base.helpers.d.ts.map +1 -0
  40. package/dist/src/modules/base/utils/base.helpers.js +106 -0
  41. package/dist/src/modules/base/utils/base.helpers.js.map +1 -0
  42. package/dist/src/modules/email/email.service.d.ts +22 -0
  43. package/dist/src/modules/email/email.service.d.ts.map +1 -0
  44. package/dist/src/modules/email/email.service.js +45 -0
  45. package/dist/src/modules/email/email.service.js.map +1 -0
  46. package/dist/src/modules/email/utils/email.helpers.d.ts +9 -0
  47. package/dist/src/modules/email/utils/email.helpers.d.ts.map +1 -0
  48. package/dist/src/modules/email/utils/email.helpers.js +25 -0
  49. package/dist/src/modules/email/utils/email.helpers.js.map +1 -0
  50. package/dist/src/modules/error-handler/error-handler.controller.d.ts +4 -0
  51. package/dist/src/modules/error-handler/error-handler.controller.d.ts.map +1 -0
  52. package/dist/src/modules/error-handler/error-handler.controller.js +182 -0
  53. package/dist/src/modules/error-handler/error-handler.controller.js.map +1 -0
  54. package/dist/src/modules/error-handler/utils/app-error.d.ts +11 -0
  55. package/dist/src/modules/error-handler/utils/app-error.d.ts.map +1 -0
  56. package/dist/src/modules/error-handler/utils/app-error.js +23 -0
  57. package/dist/src/modules/error-handler/utils/app-error.js.map +1 -0
  58. package/dist/src/modules/error-handler/utils/catch-async.d.ts +4 -0
  59. package/dist/src/modules/error-handler/utils/catch-async.d.ts.map +1 -0
  60. package/dist/src/modules/error-handler/utils/catch-async.js +9 -0
  61. package/dist/src/modules/error-handler/utils/catch-async.js.map +1 -0
  62. package/dist/src/modules/error-handler/utils/error-handler.helpers.d.ts +43 -0
  63. package/dist/src/modules/error-handler/utils/error-handler.helpers.d.ts.map +1 -0
  64. package/dist/src/modules/error-handler/utils/error-handler.helpers.js +209 -0
  65. package/dist/src/modules/error-handler/utils/error-handler.helpers.js.map +1 -0
  66. package/dist/src/modules/file-uploader/file-uploader.service.d.ts +20 -0
  67. package/dist/src/modules/file-uploader/file-uploader.service.d.ts.map +1 -0
  68. package/dist/src/modules/file-uploader/file-uploader.service.js +114 -0
  69. package/dist/src/modules/file-uploader/file-uploader.service.js.map +1 -0
  70. package/dist/src/paths.d.ts +2 -0
  71. package/dist/src/paths.d.ts.map +1 -0
  72. package/dist/src/paths.js +9 -0
  73. package/dist/src/paths.js.map +1 -0
  74. package/dist/src/utils/features/api.features.d.ts +20 -0
  75. package/dist/src/utils/features/api.features.d.ts.map +1 -0
  76. package/dist/src/utils/features/api.features.js +177 -0
  77. package/dist/src/utils/features/api.features.js.map +1 -0
  78. package/dist/src/utils/features/prisma.helpers.d.ts +3 -0
  79. package/dist/src/utils/features/prisma.helpers.d.ts.map +1 -0
  80. package/dist/src/utils/features/prisma.helpers.js +20 -0
  81. package/dist/src/utils/features/prisma.helpers.js.map +1 -0
  82. package/dist/src/utils/helpers/api.features.helpers.d.ts +41 -0
  83. package/dist/src/utils/helpers/api.features.helpers.d.ts.map +1 -0
  84. package/dist/src/utils/helpers/api.features.helpers.js +161 -0
  85. package/dist/src/utils/helpers/api.features.helpers.js.map +1 -0
  86. package/dist/src/utils/helpers/models.helpers.d.ts +21 -0
  87. package/dist/src/utils/helpers/models.helpers.d.ts.map +1 -0
  88. package/dist/src/utils/helpers/models.helpers.js +195 -0
  89. package/dist/src/utils/helpers/models.helpers.js.map +1 -0
  90. package/dist/src/utils/helpers/text.helpers.d.ts +2 -0
  91. package/dist/src/utils/helpers/text.helpers.d.ts.map +1 -0
  92. package/dist/src/utils/helpers/text.helpers.js +12 -0
  93. package/dist/src/utils/helpers/text.helpers.js.map +1 -0
  94. package/dist/src/utils/permissions/index.d.ts +3 -0
  95. package/dist/src/utils/permissions/index.d.ts.map +1 -0
  96. package/dist/src/utils/permissions/index.js +17 -0
  97. package/dist/src/utils/permissions/index.js.map +1 -0
  98. package/dist/src/utils/scripts/export-prisma-types.d.ts +2 -0
  99. package/dist/src/utils/scripts/export-prisma-types.d.ts.map +1 -0
  100. package/dist/src/utils/scripts/export-prisma-types.js +152 -0
  101. package/dist/src/utils/scripts/export-prisma-types.js.map +1 -0
  102. package/dist/src/utils/scripts/generate-zod-schemas.d.ts +2 -0
  103. package/dist/src/utils/scripts/generate-zod-schemas.d.ts.map +1 -0
  104. package/dist/src/utils/scripts/generate-zod-schemas.js +121 -0
  105. package/dist/src/utils/scripts/generate-zod-schemas.js.map +1 -0
  106. package/dist/src/utils/scripts/prisma-db-push.d.ts +2 -0
  107. package/dist/src/utils/scripts/prisma-db-push.d.ts.map +1 -0
  108. package/dist/src/utils/scripts/prisma-db-push.js +24 -0
  109. package/dist/src/utils/scripts/prisma-db-push.js.map +1 -0
  110. package/dist/src/utils/validate-dto.d.ts +3 -0
  111. package/dist/src/utils/validate-dto.d.ts.map +1 -0
  112. package/dist/src/utils/validate-dto.js +17 -0
  113. package/dist/src/utils/validate-dto.js.map +1 -0
  114. package/package.json +91 -0
package/README.md ADDED
@@ -0,0 +1,161 @@
1
+ To use your package, `arkos`, with the provided example, let's break it down into understandable steps.
2
+
3
+ ### 1. **Install the Package**
4
+
5
+ Before running the code, make sure your package (`arkos`) is installed in your project. You can do this by running:
6
+
7
+ ```bash
8
+ npm install arkos
9
+ ```
10
+
11
+ or if you are using `pnpm`:
12
+
13
+ ```bash
14
+ pnpm install arkos
15
+ ```
16
+
17
+ ### 2. **Setup Prisma Client**
18
+
19
+ In the code snippet, you're passing the `prisma` instance to the `initApp` function. Here's how Prisma should be set up:
20
+
21
+ 1. **Install Prisma and initialize it:**
22
+ Make sure you have Prisma installed in your project. You can install it using:
23
+
24
+ ```bash
25
+ npm install @prisma/client
26
+ npm install prisma --save-dev
27
+ ```
28
+
29
+ 2. **Set up your Prisma schema:**
30
+ You should have your `prisma/schema.prisma` file properly configured and migrate the database with Prisma commands:
31
+
32
+ ```bash
33
+ npx prisma migrate dev
34
+ ```
35
+
36
+ 3. **Initialize Prisma client:**
37
+ You'll need to have the `prisma` client initialized in your `src/utils/prisma.ts` file. For example:
38
+
39
+ ```typescript
40
+ // src/utils/prisma.ts
41
+ import { PrismaClient } from "@prisma/client";
42
+
43
+ export const prisma = new PrismaClient();
44
+ ```
45
+
46
+ ### 3. **Using `initApp` from `arkos`**
47
+
48
+ The `initApp` function from your `arkos` package is used to initialize the app with required configurations. Here's how you can structure it:
49
+
50
+ ```typescript
51
+ // src/app.ts
52
+ import { initApp } from "arkos"; // Import initApp from arkos package
53
+ import express from "express"; // Import express
54
+ import { prisma } from "./utils/prisma"; // Import the prisma client
55
+
56
+ // Initialize the Express app
57
+ const app = express();
58
+
59
+ // Call initApp and pass the Express app and prisma instance for configuration, app will listen in 8000 by default or set PORT in .env.developement or .env.production
60
+ initApp(app, { prisma });
61
+ ```
62
+
63
+ ### 4. **How `initApp` Works:**
64
+
65
+ - **Initialization**: The `initApp` function is called with two arguments:
66
+ - `app`: The Express application instance.
67
+ - `options`: An object containing configurations for `prisma`, which can be used for Prisma database interactions.
68
+ - **What happens under the hood**:
69
+ - **Authentication Setup**: The package will set (read further to learn how to prepare the environment) up authentication routes, middleware, and necessary handlers for managing user sessions and JWT tokens.
70
+ - **Error Handling**: Automatic error handling middleware could be added.
71
+ - **File Upload**: Omin will configure necessary middleware to handle file uploads, image upload optimization, and route generation.
72
+ - **Prisma Integration**: The Prisma client will be passed and made available for your app to interact with your database.
73
+
74
+ ### 5. **Additional Configuration (Optional)**
75
+
76
+ You can customize additional settings such as routes for file uploads, email handling, and more, based on what your `arkos` package offers. The `initApp` function may have additional configuration options, depending on how flexible and customizable the package is.
77
+
78
+ ---
79
+
80
+ ### Example Directory Structure
81
+
82
+ Here is how the directory structure might look for this project:
83
+
84
+ ```
85
+ project-root/
86
+
87
+ ├── node_modules/
88
+
89
+ ├── src/
90
+ │ ├── utils/
91
+ │ │ └── prisma.ts # Prisma client initialization
92
+ │ ├── app.ts # Express app setup with initApp
93
+
94
+ ├── package.json # Your project dependencies
95
+ └── prisma/
96
+ └── schema.prisma # Your Prisma schema file
97
+ ```
98
+
99
+ ---
100
+
101
+ ### Example of `prisma/schema.prisma`:
102
+
103
+ Ensure you have a basic Prisma schema like this:
104
+
105
+ ```prisma
106
+ // prisma/schema.prisma
107
+ datasource db {
108
+ provider = "postgresql" // Replace with your database provider (e.g., 'mongodb', 'mysql', 'sqlite')
109
+ url = env("DATABASE_URL")
110
+ }
111
+
112
+ generator client {
113
+ provider = "prisma-client-js"
114
+ previewFeatures = ["prismaSchemaFolder"]
115
+ }
116
+
117
+ model Post {
118
+ id Int @id @default(autoincrement())
119
+ title String @unique
120
+ content String
121
+ createdAt Datetime @default(now())
122
+ }
123
+ ```
124
+
125
+ Run the following to generate the Prisma client:
126
+
127
+ ```bash
128
+ npx prisma generate
129
+ ```
130
+
131
+ After all there will be routes for
132
+
133
+ - Find many, GET: /api/posts
134
+ - Find one, GET: /api/posts/:id
135
+ - Create one POST: /api/posts
136
+ - Update one, PATCH: /api/posts/:id
137
+ - Delete one, DELETE: /api/posts/:id
138
+
139
+ ---
140
+
141
+ ### Recap
142
+
143
+ - You need `prisma` properly set up and the `prisma` client instance passed into `initApp`.
144
+ - Once `initApp` is invoked with your `express` app and Prisma client, the package will handle routing, authentication, file uploads, etc., automatically.
145
+ - Ensure you have all dependencies installed (`arkos`, `prisma`, `express`, etc.) before running the app.
146
+
147
+ ---
148
+
149
+ ## 📝 License
150
+
151
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
152
+
153
+ ---
154
+
155
+ ## NB: Most clear documentation coming soon
156
+
157
+ ---
158
+
159
+ ## 📫 Contact
160
+
161
+ For any issues or questions, please open an issue or contact [Uanela Como](mailto:uanelaluiswayne@gmail.com).
@@ -0,0 +1,10 @@
1
+ import express from "express";
2
+ export type InitConfigs = {
3
+ prisma: any;
4
+ port?: number;
5
+ authentication?: boolean;
6
+ };
7
+ declare let initConfigs: InitConfigs;
8
+ export declare function bootstrap(app: express.Express, configs: InitConfigs): express.Express;
9
+ export { initConfigs };
10
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AA4B9B,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,GAAG,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,QAAA,IAAI,WAAW,EAAE,WAAW,CAAC;AAE7B,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,mBA+DnE;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.initConfigs = void 0;
40
+ exports.bootstrap = bootstrap;
41
+ const express_1 = __importDefault(require("express"));
42
+ const body_parser_1 = __importDefault(require("body-parser"));
43
+ const cors_1 = __importDefault(require("cors"));
44
+ const cookie_parser_1 = __importDefault(require("cookie-parser"));
45
+ const express_query_parser_1 = require("express-query-parser");
46
+ const auth_router_1 = __importDefault(require("./modules/auth/auth.router"));
47
+ const base_router_1 = __importDefault(require("./modules/base/base.router"));
48
+ const error_handler_controller_1 = __importDefault(require("./modules/error-handler/error-handler.controller"));
49
+ const express_rate_limit_1 = require("express-rate-limit");
50
+ const path_1 = __importDefault(require("path"));
51
+ const dotenv = __importStar(require("dotenv"));
52
+ const compression_1 = __importDefault(require("compression"));
53
+ const base_middlewares_1 = require("./modules/base/base.middlewares");
54
+ const prisma_helpers_1 = require("./utils/features/prisma.helpers");
55
+ const ENV = process.env.NODE_ENV || "development";
56
+ let envPath = ".env";
57
+ if (ENV === "production") {
58
+ envPath = path_1.default.resolve(process.cwd(), ".env.production");
59
+ }
60
+ else if (ENV === "staging") {
61
+ envPath = path_1.default.resolve(process.cwd(), ".env.staging");
62
+ }
63
+ else {
64
+ envPath = path_1.default.resolve(process.cwd(), ".env.development");
65
+ }
66
+ dotenv.config({ path: envPath });
67
+ let initConfigs;
68
+ function bootstrap(app, configs) {
69
+ exports.initConfigs = initConfigs = configs;
70
+ app.use((0, compression_1.default)());
71
+ const limiter = (0, express_rate_limit_1.rateLimit)({
72
+ windowMs: 60 * 1000,
73
+ limit: 1000,
74
+ standardHeaders: "draft-7",
75
+ legacyHeaders: false,
76
+ });
77
+ app.use(limiter);
78
+ app.set("trust proxy", 1);
79
+ app.use("/api/uploads", express_1.default.static(path_1.default.join("uploads"), {
80
+ maxAge: "1y",
81
+ etag: true,
82
+ lastModified: true,
83
+ dotfiles: "ignore",
84
+ fallthrough: true,
85
+ index: false,
86
+ cacheControl: true,
87
+ }));
88
+ app.use((0, cors_1.default)({
89
+ origin: (origin, callback) => {
90
+ callback(null, true);
91
+ },
92
+ methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTION"],
93
+ allowedHeaders: ["Content-Type", "Authorization", "Connection"],
94
+ credentials: true,
95
+ }));
96
+ app.use(express_1.default.json());
97
+ app.use(body_parser_1.default.json());
98
+ app.use((0, cookie_parser_1.default)());
99
+ app.use((0, express_query_parser_1.queryParser)({
100
+ parseNull: true,
101
+ parseUndefined: true,
102
+ parseBoolean: true,
103
+ parseNumber: true,
104
+ }));
105
+ app.use((0, prisma_helpers_1.checkDatabaseConnection)(initConfigs.prisma));
106
+ // const specs = swaggerJsdoc(options)
107
+ app.use(base_middlewares_1.handleRequestLogs);
108
+ if (configs.authentication)
109
+ app.use("/api", auth_router_1.default);
110
+ app.use("/api", base_router_1.default);
111
+ app.use(error_handler_controller_1.default);
112
+ return app;
113
+ }
114
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,8BA+DC;AAnGD,sDAA8B;AAC9B,8DAAqC;AACrC,gDAAwB;AACxB,kEAAyC;AACzC,+DAAmD;AACnD,6EAAoD;AACpD,6EAAoD;AACpD,gHAA4E;AAC5E,2DAA+C;AAC/C,gDAAwB;AACxB,+CAAiC;AACjC,8DAAsC;AACtC,sEAAoE;AACpE,oEAA0E;AAE1E,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CA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import { Express } from "express";
3
+ import { InitConfigs } from "./app";
4
+ declare let server: Server<typeof IncomingMessage, typeof ServerResponse>;
5
+ declare let app: Express;
6
+ /**
7
+ * Initializes the application server.
8
+ *
9
+ * This function starts the server by listening on a specified port.
10
+ * The port is determined by the following order of precedence:
11
+ * 1. The `PORT` environment variable.
12
+ * 2. The `port` argument passed to the function.
13
+ * 3. Defaults to `3000` if neither is provided.
14
+ *
15
+ * @param {Express} app - express app.
16
+ * @param {InitConfigs} initConfigs - initial configs for the api (prisma, authentication, port).
17
+ * @returns {void} This function does not return a value.
18
+ */
19
+ export declare function initApp(app: Express, initConfigs: InitConfigs): void;
20
+ export { server, app };
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAa,WAAW,EAAE,MAAM,OAAO,CAAC;AAS/C,QAAA,IAAI,MAAM,EAAE,MAAM,CAAC,OAAO,eAAe,EAAE,OAAO,cAAc,CAAC,CAAC;AAClE,QAAA,IAAI,GAAG,EAAE,OAAO,CAAC;AAEjB;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAapE;AAiBD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.app = exports.server = void 0;
4
+ exports.initApp = initApp;
5
+ const app_1 = require("./app");
6
+ process.on("uncaughtException", (err) => {
7
+ console.error("UNCAUGHT EXCEPTION! SHUTTING DOWN...");
8
+ console.error(err.name, err.message);
9
+ console.error(err);
10
+ process.exit(1);
11
+ });
12
+ let server;
13
+ let app;
14
+ /**
15
+ * Initializes the application server.
16
+ *
17
+ * This function starts the server by listening on a specified port.
18
+ * The port is determined by the following order of precedence:
19
+ * 1. The `PORT` environment variable.
20
+ * 2. The `port` argument passed to the function.
21
+ * 3. Defaults to `3000` if neither is provided.
22
+ *
23
+ * @param {Express} app - express app.
24
+ * @param {InitConfigs} initConfigs - initial configs for the api (prisma, authentication, port).
25
+ * @returns {void} This function does not return a value.
26
+ */
27
+ function initApp(app, initConfigs) {
28
+ const port = initConfigs.port || Number(process.env.PORT) || 8000;
29
+ const application = (0, app_1.bootstrap)(app, {
30
+ authentication: false,
31
+ prisma: {},
32
+ });
33
+ exports.server = server = application.listen(port, () => {
34
+ const time = new Date().toTimeString().split(" ")[0];
35
+ console.info(`[\x1b[32mREADY\x1b[0m] \x1b[90m${time}\x1b[0m App running on port \x1b[33m${port}\x1b[0m, server waiting on http://localhost:${port}`);
36
+ });
37
+ }
38
+ process.on("unhandledRejection", (err) => {
39
+ console.error("UNHANDLED REJECTION! SHUTTING DOWN...");
40
+ console.error(err.name, err.message);
41
+ server.close(() => {
42
+ process.exit(1);
43
+ });
44
+ });
45
+ process.on("SIGTERM", () => {
46
+ console.error("👋🏽 SIGTERM RECEIVED. Shutting down gracefully!");
47
+ server.close(() => {
48
+ console.error("🔥 Process terminated");
49
+ });
50
+ });
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AA4BA,0BAaC;AAtCD,+BAA+C;AAE/C,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;IACtC,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;IACtD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAA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B,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { NextFunction, Request, Response } from 'express';
2
+ export declare const excludedUserFields: {
3
+ password: boolean;
4
+ passwordChangedAt: boolean;
5
+ passwordResetOtp: boolean;
6
+ passwordResetOtpExpiresAt: boolean;
7
+ verificationOtp: boolean;
8
+ verificationOptExpiresAt: boolean;
9
+ isVerified: boolean;
10
+ deletedSelfAccount: boolean;
11
+ active: boolean;
12
+ };
13
+ export declare const authControllerFactory: (middlewares?: any) => {
14
+ getMe: (req: Request, res: Response, next: NextFunction) => void;
15
+ logout: (req: Request, res: Response, next: NextFunction) => void;
16
+ login: (req: Request, res: Response, next: NextFunction) => void;
17
+ signup: (req: Request, res: Response, next: NextFunction) => void;
18
+ verifyEmail: (req: Request, res: Response, next: NextFunction) => void;
19
+ forgotPassword: (req: Request, res: Response, next: NextFunction) => void;
20
+ resetPassword: (req: Request, res: Response, next: NextFunction) => void;
21
+ updatePassword: (req: Request, res: Response, next: NextFunction) => void;
22
+ };
23
+ //# sourceMappingURL=auth.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.controller.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/auth.controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAMxE,eAAO,MAAM,kBAAkB;;;;;;;;;;CAU9B,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,cAAa,GAAQ;;;;;;;;;CAuc1D,CAAA"}