arkos 0.0.22 → 0.1.0-beta.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 (119) hide show
  1. package/README.md +199 -199
  2. package/dist/app.d.ts +5 -0
  3. package/dist/app.d.ts.map +1 -1
  4. package/dist/app.js +46 -73
  5. package/dist/app.js.map +1 -1
  6. package/dist/exports/error-handler/index.d.ts +14 -0
  7. package/dist/exports/error-handler/index.d.ts.map +1 -0
  8. package/dist/exports/error-handler/index.js +15 -0
  9. package/dist/exports/error-handler/index.js.map +1 -0
  10. package/dist/exports/index.d.ts +21 -0
  11. package/dist/exports/index.d.ts.map +1 -0
  12. package/dist/exports/index.js +21 -0
  13. package/dist/exports/index.js.map +1 -0
  14. package/dist/exports/services/index.d.ts +22 -0
  15. package/dist/exports/services/index.d.ts.map +1 -0
  16. package/dist/exports/services/index.js +21 -0
  17. package/dist/exports/services/index.js.map +1 -0
  18. package/dist/exports/utils/index.d.ts +16 -0
  19. package/dist/exports/utils/index.d.ts.map +1 -0
  20. package/dist/exports/utils/index.js +16 -0
  21. package/dist/exports/utils/index.js.map +1 -0
  22. package/dist/exports/validation/index.d.ts +13 -0
  23. package/dist/exports/validation/index.d.ts.map +1 -0
  24. package/dist/exports/validation/index.js +13 -0
  25. package/dist/exports/validation/index.js.map +1 -0
  26. package/dist/modules/auth/auth.controller.d.ts.map +1 -1
  27. package/dist/modules/auth/auth.controller.js +68 -77
  28. package/dist/modules/auth/auth.controller.js.map +1 -1
  29. package/dist/modules/auth/auth.router.js +30 -35
  30. package/dist/modules/auth/auth.router.js.map +1 -1
  31. package/dist/modules/auth/auth.service.d.ts +73 -3
  32. package/dist/modules/auth/auth.service.d.ts.map +1 -1
  33. package/dist/modules/auth/auth.service.js +101 -33
  34. package/dist/modules/auth/auth.service.js.map +1 -1
  35. package/dist/modules/base/base.controller.d.ts +1 -1
  36. package/dist/modules/base/base.controller.d.ts.map +1 -1
  37. package/dist/modules/base/base.controller.js +62 -68
  38. package/dist/modules/base/base.controller.js.map +1 -1
  39. package/dist/modules/base/base.middlewares.js +5 -12
  40. package/dist/modules/base/base.middlewares.js.map +1 -1
  41. package/dist/modules/base/base.router.d.ts.map +1 -1
  42. package/dist/modules/base/base.router.js +44 -50
  43. package/dist/modules/base/base.router.js.map +1 -1
  44. package/dist/modules/base/base.service.d.ts +78 -5
  45. package/dist/modules/base/base.service.d.ts.map +1 -1
  46. package/dist/modules/base/base.service.js +148 -55
  47. package/dist/modules/base/base.service.js.map +1 -1
  48. package/dist/modules/base/utils/base.helpers.js +5 -8
  49. package/dist/modules/base/utils/base.helpers.js.map +1 -1
  50. package/dist/modules/email/email.service.d.ts +26 -5
  51. package/dist/modules/email/email.service.d.ts.map +1 -1
  52. package/dist/modules/email/email.service.js +33 -19
  53. package/dist/modules/email/email.service.js.map +1 -1
  54. package/dist/modules/error-handler/error-handler.controller.d.ts +15 -0
  55. package/dist/modules/error-handler/error-handler.controller.d.ts.map +1 -1
  56. package/dist/modules/error-handler/error-handler.controller.js +103 -129
  57. package/dist/modules/error-handler/error-handler.controller.js.map +1 -1
  58. package/dist/modules/error-handler/utils/app-error.d.ts +40 -0
  59. package/dist/modules/error-handler/utils/app-error.d.ts.map +1 -1
  60. package/dist/modules/error-handler/utils/app-error.js +42 -4
  61. package/dist/modules/error-handler/utils/app-error.js.map +1 -1
  62. package/dist/modules/error-handler/utils/catch-async.d.ts +15 -1
  63. package/dist/modules/error-handler/utils/catch-async.d.ts.map +1 -1
  64. package/dist/modules/error-handler/utils/catch-async.js +15 -3
  65. package/dist/modules/error-handler/utils/catch-async.js.map +1 -1
  66. package/dist/modules/error-handler/utils/error-handler.helpers.js +71 -111
  67. package/dist/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  68. package/dist/modules/file-uploader/file-uploader.service.d.ts +51 -2
  69. package/dist/modules/file-uploader/file-uploader.service.d.ts.map +1 -1
  70. package/dist/modules/file-uploader/file-uploader.service.js +74 -36
  71. package/dist/modules/file-uploader/file-uploader.service.js.map +1 -1
  72. package/dist/paths.js +2 -8
  73. package/dist/paths.js.map +1 -1
  74. package/dist/server.d.ts.map +1 -1
  75. package/dist/server.js +7 -11
  76. package/dist/server.js.map +1 -1
  77. package/dist/utils/arkos-env.d.ts +7 -0
  78. package/dist/utils/arkos-env.d.ts.map +1 -0
  79. package/dist/utils/arkos-env.js +7 -0
  80. package/dist/utils/arkos-env.js.map +1 -0
  81. package/dist/utils/features/api.features.js +16 -22
  82. package/dist/utils/features/api.features.js.map +1 -1
  83. package/dist/utils/helpers/api.features.helpers.js +1 -4
  84. package/dist/utils/helpers/api.features.helpers.js.map +1 -1
  85. package/dist/utils/helpers/fs.helpers.d.ts +2 -0
  86. package/dist/utils/helpers/fs.helpers.d.ts.map +1 -0
  87. package/dist/utils/helpers/fs.helpers.js +37 -0
  88. package/dist/utils/helpers/fs.helpers.js.map +1 -0
  89. package/dist/utils/helpers/models.helpers.d.ts +37 -1
  90. package/dist/utils/helpers/models.helpers.d.ts.map +1 -1
  91. package/dist/utils/helpers/models.helpers.js +109 -97
  92. package/dist/utils/helpers/models.helpers.js.map +1 -1
  93. package/dist/utils/helpers/prisma.helpers.js +7 -48
  94. package/dist/utils/helpers/prisma.helpers.js.map +1 -1
  95. package/dist/utils/helpers/text.helpers.d.ts +8 -0
  96. package/dist/utils/helpers/text.helpers.d.ts.map +1 -1
  97. package/dist/utils/helpers/text.helpers.js +12 -7
  98. package/dist/utils/helpers/text.helpers.js.map +1 -1
  99. package/dist/utils/permissions/index.js +1 -4
  100. package/dist/utils/permissions/index.js.map +1 -1
  101. package/dist/utils/scripts/export-prisma-types.js +2 -37
  102. package/dist/utils/scripts/export-prisma-types.js.map +1 -1
  103. package/dist/utils/scripts/generate-zod-schemas.js +4 -9
  104. package/dist/utils/scripts/generate-zod-schemas.js.map +1 -1
  105. package/dist/utils/scripts/prisma-db-push.js +8 -13
  106. package/dist/utils/scripts/prisma-db-push.js.map +1 -1
  107. package/dist/utils/validate-dto.d.ts +37 -2
  108. package/dist/utils/validate-dto.d.ts.map +1 -1
  109. package/dist/utils/validate-dto.js +44 -13
  110. package/dist/utils/validate-dto.js.map +1 -1
  111. package/package.json +106 -106
  112. package/dist/index.d.ts +0 -44
  113. package/dist/index.d.ts.map +0 -1
  114. package/dist/index.js +0 -75
  115. package/dist/index.js.map +0 -1
  116. package/dist/modules/email/utils/helpers/email.helpers.d.ts +0 -9
  117. package/dist/modules/email/utils/helpers/email.helpers.d.ts.map +0 -1
  118. package/dist/modules/email/utils/helpers/email.helpers.js +0 -25
  119. package/dist/modules/email/utils/helpers/email.helpers.js.map +0 -1
package/README.md CHANGED
@@ -1,199 +1,199 @@
1
- ![Header Image](https://lh3.googleusercontent.com/fife/ALs6j_FI9nS50W4dcqqGJhLerYqqQEQwEGzDFpgm9jvfg4zFzOxdMmBt4jXnQ02DXtqbSmeBQOx_cgDwUUluVCmnX4Yd5oxeNsZSBZ-xNZTm1VocSsJKc6OXGZXGKZ9wvxvaW1XdSKuxCtbsvI5Tuuu1l5sfXGmkxpo3l3FnS6BBOMqBjhQefSLR72NU6_QNpNpY9zPMepHBjRZ6R3VyES8oJw_P6lbJzKJu5ENZ-Z6I__0tuFpSed78fWWGI7mjoMhr9vM08jn66pYl9mGucQvV2_46CCCXtaRp7PskIx8fljmEjsYVhwr2Mmaa_wr_5YBaS8L72ah5C_5pLwvhXuez9hZI8JR8oEA2GKNwxCEnA66B8j6gBm0WsIkR3mJCZTTK8L4iR23SC8Z2JKoK3DehJ2lOxzwQs59jMTOk3uMb0Z_nBYqi2qUxYtN1wb5HRtO9POmfBJr42ZDnLhgHCy6ULus9KJYztDb3yBERi7zS6JIcxcGfW0B2VHQLiTDM--gOmuRNfdjeZREnvj3CrQh1DtfcF6rJ4uPx_ITrsb-yN88A4NHVjIct2ge1avxnfFFszi_vqFKYn5UCql2PM-1lOmWK3tLOjnzpQpBvO8Zny9phV5glHlrZLKPzklN7XE64qD-qFY9akLdukJjxMF56KTVfT3c06RLNhVDmaHaAZPJ3ESmojPAjvVrN4mdqmp1rjOG3HIa1z2Y-UUthzPCjY0XdMJFzPjoXSFV73rt9gpUPehXPMNNgL161cG7Kf_YW6XU5yBkKcbh4QojNe32bJQVPSnvD_GlkpVhefHqq3N54W8-pajIHfoHbboaGs129yju22UQ9zZI1HY1oQP7sVlzJsYCXTLN9kJSnLpzmIcIbai2jFHtD5icsKLLx0RHJJZPe5Uw0cBLnFEN9udEXSur9vuIg0saMT-b_Uc5A-B2ZMZngXCWC3ObC4NRArnSRiauoEKWuMOwpPsXunrCtPn5LOKtE2PoU7fbmXkTbuWCsmoKrBZIuakRzrLig7NrtRIM8DfbvItFGIxEG2kJTpkyzQI4HzVGLRKJX6AiwTBqh-L67iciYrVGhUSzM4p1E4iN-16z_KqnhSU-6GgXA_l-FPLd9wDfRt0BKl9mmFz5iif44aKflCWS449bZh12SEJeAhCwu442E2Ldc4kiwn29r7AdH09fVx7st9WWMbhhcGfhbNEY9rvjrLKx_gamfZdnXI0nof3rqb-U5hLjYY2wUW5XTE2vHquX5JYHsUD_iYEPUOhdPzowKsKDqRTn2v9fLJe9lDutfm7Ywvax_W8oosxNT9jTbSAXnMuia3Lqr8UZwVNyJRm50VPDbtYriYv7p6YbbuV_HwTk29oskRoRVAcPB0U2nuNiJ1hWChzeGCa9XNcfThEr3BEo2b1jNcl-WOcLnRN2p3XzMe4ltGNECME31k8MmFTe64UeeidJtGAu9TCi1GOo7NQeD_62Jhn0OgByExoJ0WTf9J5HXhwSJo5wVk7Ua8tl6yO7X-LUeqI4EMNbYtdCVAUTyE4ij8OxYcvx8ciV4UNZJmu35tlRDnKsYCbSUSQMkDeGBND00sAAovkrMzmgKhvFdfTDJOwtj1so1sDVS_ZC1AXzAog=w2688-h1984)
2
-
3
- ### **What is Arkos**
4
-
5
- **Arkos** is a **lightweight backend framework** for **Express.js and Prisma** that simplifies API development by providing automatic route generation, built-in authentication, error handling, and file upload optimization. Designed to be a foundational layer for backend applications, Arkos allows developers to quickly set up a secure and scalable server with minimal configuration.
6
-
7
- ---
8
-
9
- ### **Key Features**
10
-
11
- - 🚀 **Automatic API Generation** – Instantly create RESTful API routes for Prisma models.
12
-
13
- - 🔐 **Built-in Authentication** – Supports JWT-based authentication with effortless setup.
14
-
15
- - ⚡ **Express Middlewares** – Pre-configured security, request parsing, and error handling.
16
-
17
- - 🛡️ **Built-in Data Validation** – using class-validator and class-transformer, just drop a create-post.dto.ts.
18
-
19
- - ⬆️ **File Upload & Optimization** – Efficient image, video, docs, raw-file handling.
20
-
21
- - 💠 **Prisma Integration** – Seamless connection with Prisma ORM for database management with relation feilds handling.
22
-
23
- - 👨‍💻 **Interceptors Middlewares** – Tailor as you want, intercept, customize, for example using beforeCreateOne, afterSignUp.
24
-
25
- - ✉️ **Nodemailer Integration** – Seamless nodemailer integration for sending emails.
26
-
27
- With Arkos, developers can **bootstrap their backend in seconds**, focusing on building features rather than repetitive setup tasks.
28
-
29
- ### 1. **Install the Package**
30
-
31
- Before running the code, make sure your package (`arkos`) is installed in your project. You can do this by running:
32
-
33
- ```bash
34
- npm install arkos
35
- ```
36
-
37
- or if you are using `pnpm`:
38
-
39
- ```bash
40
- pnpm install arkos
41
- ```
42
-
43
- ### 2. **Setup Prisma Client**
44
-
45
- Here's how Prisma should be set up to use seamlessly with arkos:
46
-
47
- 1. **Install Prisma and initialize it:**
48
- Make sure you have Prisma installed in your project. You can install it using:
49
-
50
- ```bash
51
- npm install @prisma/client
52
- npm install prisma --save-dev
53
- ```
54
-
55
- 2. **Set up your Prisma schema:**
56
- You should have your `prisma/schema.prisma` file properly configured and migrate the database with Prisma commands:
57
-
58
- ```bash
59
- npx prisma generate
60
- npx prisma migrate dev
61
- ```
62
-
63
- 3. **Initialize Prisma client:**
64
- You'll need to have the `prisma` client initialized in your `src/utils/prisma.ts` file. For example:
65
-
66
- ```typescript
67
- // src/utils/prisma.ts
68
- import { PrismaClient } from "@prisma/client";
69
-
70
- export const prisma = new PrismaClient();
71
- ```
72
-
73
- ### 3. **Using `init` from `arkos`**
74
-
75
- The `init` function from your `arkos` package is used to initialize the app with required configurations. Here's how you can structure it:
76
-
77
- ```typescript
78
- // src/app.ts
79
- import arkos from "arkos"; // Import arkos.init() from arkos package
80
- import express from "express"; // Import express
81
-
82
- // Initialize the Express app
83
- const app = express();
84
-
85
- // Call init and pass the Express app for configuration, app will listen in 8000 by default or set PORT in .env.developement or .env.production
86
- arkos.init(app);
87
- ```
88
-
89
- ### 4. **How `arkos.init()` Works:**
90
-
91
- - **Initialization**: The `arkos.init()` function is called with two arguments, the second being optional:
92
- - `app`: The Express application instance.
93
- - `options`: An object containing configurations for toggle `authentication` and pass the desired `port`.
94
- - **What happens under the hood**:
95
- - **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.
96
- - **Error Handling**: Automatic error handling middleware could be added.
97
- - **File Upload**: Arkos will configure necessary middleware to handle file uploads, image upload optimization, and route generation.
98
- - **Prisma Integration**: The prisma instance must be export as default or as prisma under scr/utils/prisma.ts.
99
-
100
- ### 5. **Additional Configuration (Optional)**
101
-
102
- You can customize additional settings such as routes for file uploads, email handling, and more, based on what your `arkos` package offers. The `arkos.init()` function may have additional configuration options, depending on how flexible and customizable the package is.
103
-
104
- ---
105
-
106
- ### Example Directory Structure
107
-
108
- Here is how the directory structure might look for this project:
109
-
110
- ```
111
- project-root/
112
-
113
- ├── node_modules/
114
-
115
- ├── src/
116
- │ ├── utils/
117
- │ │ └── prisma.ts # Prisma client initialization
118
- │ ├── app.ts # Express app setup with arkos.init()
119
-
120
- ├── package.json # Your project dependencies
121
- └── prisma/
122
- └── schema/
123
- └── schema.prisma # Your Prisma schema file
124
- └── post.prisma # Your Post model file
125
- ```
126
-
127
- ---
128
-
129
- ### Example of `prisma/schema.prisma`:
130
-
131
- Ensure you have a basic Prisma schema like this:
132
-
133
- ```typescript
134
- // prisma/schema.prisma
135
- datasource db {
136
- provider = "sqlite" // Replace with your database provider (e.g., 'mongodb', 'mysql', 'sqlite', 'postgresql')
137
- url = env("DATABASE_URL")
138
- }
139
-
140
- generator client {
141
- provider = "prisma-client-js"
142
- previewFeatures = ["prismaSchemaFolder"]
143
- }
144
-
145
- model Post {
146
- id Int @id @default(autoincrement())
147
- title String @unique
148
- content String
149
- createdAt DateTime @default(now())
150
- }
151
- ```
152
-
153
- Run the following to generate the Prisma client:
154
-
155
- ```bash
156
- npx prisma generate
157
- ```
158
-
159
- After all there will be routes for
160
-
161
- - Find many, GET: /api/posts
162
- - Find one, GET: /api/posts/:id
163
- - Create one POST: /api/posts
164
- - Update one, PATCH: /api/posts/:id
165
- - Delete one, DELETE: /api/posts/:id
166
-
167
- ---
168
-
169
- ### Recap
170
-
171
- - You need `prisma` properly set up.
172
- - Once `arkos.init()` is invoked with your `express` app the package will handle routing, authentication, file uploads, etc., automatically.
173
- - Ensure you have all dependencies installed (`arkos`, `prisma`, `express`, etc.) before running the app.
174
-
175
- ---
176
-
177
- ## 📝 License
178
-
179
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
180
-
181
- ---
182
-
183
- ## 📫 Contact
184
-
185
- For any issues or questions, please open an issue or contact [Uanela Como](mailto:uanelaluiswayne@gmail.com).
186
-
187
- Feel free to reach out for questions, suggestions, or contributions ❤️.
188
-
189
- ---
190
-
191
- ### **Origin of the Name "Arkos"**
192
-
193
- The name **"Arkos"** is derived from the Greek word **ἀρχή (Arkhē)**, which means **"beginning"** or **"foundation"**. This interpretation perfectly aligns with the core purpose of the package — to serve as a **foundational layer** for quickly setting up backend systems. Just as **ἀρχή** represents the starting point or origin, Arkos is designed to **initiate** and **structure** backend projects, providing developers with a robust base to build upon.
194
-
195
- This makes Arkos an essential tool for **bootstrapping** and organizing backend applications, helping developers focus on features rather than repetitive setup tasks.
196
-
197
- ---
198
-
199
- ### NB: More documentation coming soon
1
+ ![Header Image](https://lh3.googleusercontent.com/fife/ALs6j_FI9nS50W4dcqqGJhLerYqqQEQ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6GgXA_l-FPLd9wDfRt0BKl9mmFz5iif44aKflCWS449bZh12SEJeAhCwu442E2Ldc4kiwn29r7AdH09fVx7st9WWMbhhcGfhbNEY9rvjrLKx_gamfZdnXI0nof3rqb-U5hLjYY2wUW5XTE2vHquX5JYHsUD_iYEPUOhdPzowKsKDqRTn2v9fLJe9lDutfm7Ywvax_W8oosxNT9jTbSAXnMuia3Lqr8UZwVNyJRm50VPDbtYriYv7p6YbbuV_HwTk29oskRoRVAcPB0U2nuNiJ1hWChzeGCa9XNcfThEr3BEo2b1jNcl-WOcLnRN2p3XzMe4ltGNECME31k8MmFTe64UeeidJtGAu9TCi1GOo7NQeD_62Jhn0OgByExoJ0WTf9J5HXhwSJo5wVk7Ua8tl6yO7X-LUeqI4EMNbYtdCVAUTyE4ij8OxYcvx8ciV4UNZJmu35tlRDnKsYCbSUSQMkDeGBND00sAAovkrMzmgKhvFdfTDJOwtj1so1sDVS_ZC1AXzAog=w2688-h1984)
2
+
3
+ ### **What is Arkos**
4
+
5
+ **Arkos** is a **lightweight backend framework** for **Express.js and Prisma** that simplifies API development by providing automatic route generation, built-in authentication, error handling, and file upload optimization. Designed to be a foundational layer for backend applications, Arkos allows developers to quickly set up a secure and scalable server with minimal configuration.
6
+
7
+ ---
8
+
9
+ ### **Key Features**
10
+
11
+ - 🚀 **Automatic API Generation** – Instantly create RESTful API routes for Prisma models.
12
+
13
+ - 🔐 **Built-in Authentication** – Supports JWT-based authentication with effortless setup.
14
+
15
+ - ⚡ **Express Middlewares** – Pre-configured security, request parsing, and error handling.
16
+
17
+ - 🛡️ **Built-in Data Validation** – using class-validator and class-transformer, just drop a create-post.dto.ts.
18
+
19
+ - ⬆️ **File Upload & Optimization** – Efficient image, video, docs, raw-file handling.
20
+
21
+ - 💠 **Prisma Integration** – Seamless connection with Prisma ORM for database management with relation feilds handling.
22
+
23
+ - 👨‍💻 **Interceptors Middlewares** – Tailor as you want, intercept, customize, for example using beforeCreateOne, afterSignUp.
24
+
25
+ - ✉️ **Nodemailer Integration** – Seamless nodemailer integration for sending emails.
26
+
27
+ With Arkos, developers can **bootstrap their backend in seconds**, focusing on building features rather than repetitive setup tasks.
28
+
29
+ ### 1. **Install the Package**
30
+
31
+ Before running the code, make sure your package (`arkos`) is installed in your project. You can do this by running:
32
+
33
+ ```bash
34
+ npm install arkos
35
+ ```
36
+
37
+ or if you are using `pnpm`:
38
+
39
+ ```bash
40
+ pnpm install arkos
41
+ ```
42
+
43
+ ### 2. **Setup Prisma Client**
44
+
45
+ Here's how Prisma should be set up to use seamlessly with arkos:
46
+
47
+ 1. **Install Prisma and initialize it:**
48
+ Make sure you have Prisma installed in your project. You can install it using:
49
+
50
+ ```bash
51
+ npm install @prisma/client
52
+ npm install prisma --save-dev
53
+ ```
54
+
55
+ 2. **Set up your Prisma schema:**
56
+ You should have your `prisma/schema.prisma` file properly configured and migrate the database with Prisma commands:
57
+
58
+ ```bash
59
+ npx prisma generate
60
+ npx prisma migrate dev
61
+ ```
62
+
63
+ 3. **Initialize Prisma client:**
64
+ You'll need to have the `prisma` client initialized in your `src/utils/prisma.ts` file. For example:
65
+
66
+ ```typescript
67
+ // src/utils/prisma.ts
68
+ import { PrismaClient } from "@prisma/client";
69
+
70
+ export const prisma = new PrismaClient();
71
+ ```
72
+
73
+ ### 3. **Using `init` from `arkos`**
74
+
75
+ The `init` function from your `arkos` package is used to initialize the app with required configurations. Here's how you can structure it:
76
+
77
+ ```typescript
78
+ // src/app.ts
79
+ import arkos from "arkos"; // Import arkos.init() from arkos package
80
+ import express from "express"; // Import express
81
+
82
+ // Initialize the Express app
83
+ const app = express();
84
+
85
+ // Call init and pass the Express app for configuration, app will listen in 8000 by default or set PORT in .env.developement or .env.production
86
+ arkos.init(app);
87
+ ```
88
+
89
+ ### 4. **How `arkos.init()` Works:**
90
+
91
+ - **Initialization**: The `arkos.init()` function is called with two arguments, the second being optional:
92
+ - `app`: The Express application instance.
93
+ - `options`: An object containing configurations for toggle `authentication` and pass the desired `port`.
94
+ - **What happens under the hood**:
95
+ - **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.
96
+ - **Error Handling**: Automatic error handling middleware could be added.
97
+ - **File Upload**: Arkos will configure necessary middleware to handle file uploads, image upload optimization, and route generation.
98
+ - **Prisma Integration**: The prisma instance must be export as default or as prisma under scr/utils/prisma.ts.
99
+
100
+ ### 5. **Additional Configuration (Optional)**
101
+
102
+ You can customize additional settings such as routes for file uploads, email handling, and more, based on what your `arkos` package offers. The `arkos.init()` function may have additional configuration options, depending on how flexible and customizable the package is.
103
+
104
+ ---
105
+
106
+ ### Example Directory Structure
107
+
108
+ Here is how the directory structure might look for this project:
109
+
110
+ ```
111
+ project-root/
112
+
113
+ ├── node_modules/
114
+
115
+ ├── src/
116
+ │ ├── utils/
117
+ │ │ └── prisma.ts # Prisma client initialization
118
+ │ ├── app.ts # Express app setup with arkos.init()
119
+
120
+ ├── package.json # Your project dependencies
121
+ └── prisma/
122
+ └── schema/
123
+ └── schema.prisma # Your Prisma schema file
124
+ └── post.prisma # Your Post model file
125
+ ```
126
+
127
+ ---
128
+
129
+ ### Example of `prisma/schema.prisma`:
130
+
131
+ Ensure you have a basic Prisma schema like this:
132
+
133
+ ```typescript
134
+ // prisma/schema.prisma
135
+ datasource db {
136
+ provider = "sqlite" // Replace with your database provider (e.g., 'mongodb', 'mysql', 'sqlite', 'postgresql')
137
+ url = env("DATABASE_URL")
138
+ }
139
+
140
+ generator client {
141
+ provider = "prisma-client-js"
142
+ previewFeatures = ["prismaSchemaFolder"]
143
+ }
144
+
145
+ model Post {
146
+ id Int @id @default(autoincrement())
147
+ title String @unique
148
+ content String
149
+ createdAt DateTime @default(now())
150
+ }
151
+ ```
152
+
153
+ Run the following to generate the Prisma client:
154
+
155
+ ```bash
156
+ npx prisma generate
157
+ ```
158
+
159
+ After all there will be routes for
160
+
161
+ - Find many, GET: /api/posts
162
+ - Find one, GET: /api/posts/:id
163
+ - Create one POST: /api/posts
164
+ - Update one, PATCH: /api/posts/:id
165
+ - Delete one, DELETE: /api/posts/:id
166
+
167
+ ---
168
+
169
+ ### Recap
170
+
171
+ - You need `prisma` properly set up.
172
+ - Once `arkos.init()` is invoked with your `express` app the package will handle routing, authentication, file uploads, etc., automatically.
173
+ - Ensure you have all dependencies installed (`arkos`, `prisma`, `express`, etc.) before running the app.
174
+
175
+ ---
176
+
177
+ ## 📝 License
178
+
179
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
180
+
181
+ ---
182
+
183
+ ## 📫 Contact
184
+
185
+ For any issues or questions, please open an issue or contact [Uanela Como](mailto:uanelaluiswayne@gmail.com).
186
+
187
+ Feel free to reach out for questions, suggestions, or contributions ❤️.
188
+
189
+ ---
190
+
191
+ ### **Origin of the Name "Arkos"**
192
+
193
+ The name **"Arkos"** is derived from the Greek word **ἀρχή (Arkhē)**, which means **"beginning"** or **"foundation"**. This interpretation perfectly aligns with the core purpose of the package — to serve as a **foundational layer** for quickly setting up backend systems. Just as **ἀρχή** represents the starting point or origin, Arkos is designed to **initiate** and **structure** backend projects, providing developers with a robust base to build upon.
194
+
195
+ This makes Arkos an essential tool for **bootstrapping** and organizing backend applications, helping developers focus on features rather than repetitive setup tasks.
196
+
197
+ ---
198
+
199
+ ### NB: More documentation coming soon
package/dist/app.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  import express from "express";
2
+ import { ClassValidatorInitConfigsOptions } from "./utils/validate-dto";
2
3
  export type InitConfigs = {
3
4
  port?: number;
4
5
  authentication?: boolean;
6
+ validation: ClassValidatorInitConfigsOptions | {
7
+ resolver: "zod";
8
+ validationOptions: Record<string, any>;
9
+ } | boolean;
5
10
  };
6
11
  declare let prisma: any;
7
12
  export declare function bootstrap(app: express.Express, configs: InitConfigs): Promise<express.Express>;
package/dist/app.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AA+B9B,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAGF,QAAA,IAAI,MAAM,EAAE,GAAG,CAAC;AAMhB,wBAAsB,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,4BA+DzE;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAiB9B,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AA0BxE,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,EACN,gCAAgC,GAChC;QACE,QAAQ,EAAE,KAAK,CAAC;QAChB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACxC,GACD,OAAO,CAAC;CACb,CAAC;AAGF,QAAA,IAAI,MAAM,EAAE,GAAG,CAAC;AAMhB,wBAAsB,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,4BA+DzE;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
package/dist/app.js CHANGED
@@ -1,79 +1,51 @@
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.prisma = 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/helpers/prisma.helpers");
1
+ import express from "express";
2
+ import bodyParser from "body-parser";
3
+ import cors from "cors";
4
+ import cookieParser from "cookie-parser";
5
+ import { queryParser } from "express-query-parser";
6
+ import authRouter from "./modules/auth/auth.router";
7
+ import baseRouter from "./modules/base/base.router";
8
+ import errorHandler from "./modules/error-handler/error-handler.controller";
9
+ import { rateLimit } from "express-rate-limit";
10
+ import path from "path";
11
+ import * as dotenv from "dotenv";
12
+ import compression from "compression";
13
+ import { handleRequestLogs } from "./modules/base/base.middlewares";
14
+ import { checkDatabaseConnection, loadPrismaModule, } from "./utils/helpers/prisma.helpers";
55
15
  const ENV = process.env.NODE_ENV;
56
16
  let envPath = ".env";
17
+ // Default to `.env.local` if available in any environment
57
18
  if (ENV === "production") {
58
- envPath = path_1.default.resolve(process.cwd(), ".env.production");
19
+ envPath = path.resolve(process.cwd(), ".env.production");
59
20
  }
60
21
  else if (ENV === "staging") {
61
- envPath = path_1.default.resolve(process.cwd(), ".env.staging");
22
+ envPath = path.resolve(process.cwd(), ".env.staging");
62
23
  }
63
24
  else if (ENV === "development") {
64
- envPath = path_1.default.resolve(process.cwd(), ".env.development");
25
+ envPath = path.resolve(process.cwd(), ".env.development");
26
+ }
27
+ else if (ENV === "local") {
28
+ // For local development, .env.local can be used
29
+ envPath = path.resolve(process.cwd(), ".env.local");
30
+ }
31
+ // Optionally, add support for `.env.test`, `.env.qa`, or other environments if required
32
+ else if (ENV === "test") {
33
+ envPath = path.resolve(process.cwd(), ".env.test");
34
+ }
35
+ else if (ENV === "qa") {
36
+ envPath = path.resolve(process.cwd(), ".env.qa");
65
37
  }
66
38
  dotenv.config({ path: envPath });
67
39
  let initConfigs;
68
40
  let prisma;
69
41
  (async () => {
70
- exports.prisma = prisma = await (0, prisma_helpers_1.loadPrismaModule)();
42
+ prisma = await loadPrismaModule();
71
43
  })();
72
- async function bootstrap(app, configs) {
73
- exports.prisma = prisma = await (0, prisma_helpers_1.loadPrismaModule)();
44
+ export async function bootstrap(app, configs) {
45
+ prisma = await loadPrismaModule();
74
46
  initConfigs = configs;
75
- app.use((0, compression_1.default)());
76
- const limiter = (0, express_rate_limit_1.rateLimit)({
47
+ app.use(compression());
48
+ const limiter = rateLimit({
77
49
  windowMs: 60 * 1000,
78
50
  limit: 1000,
79
51
  standardHeaders: "draft-7",
@@ -81,7 +53,7 @@ async function bootstrap(app, configs) {
81
53
  });
82
54
  app.use(limiter);
83
55
  app.set("trust proxy", 1);
84
- app.use("/api/uploads", express_1.default.static(path_1.default.join("uploads"), {
56
+ app.use("/api/uploads", express.static(path.join("uploads"), {
85
57
  maxAge: "1y",
86
58
  etag: true,
87
59
  lastModified: true,
@@ -90,7 +62,7 @@ async function bootstrap(app, configs) {
90
62
  index: false,
91
63
  cacheControl: true,
92
64
  }));
93
- app.use((0, cors_1.default)({
65
+ app.use(cors({
94
66
  origin: (origin, callback) => {
95
67
  callback(null, true);
96
68
  },
@@ -98,21 +70,22 @@ async function bootstrap(app, configs) {
98
70
  allowedHeaders: ["Content-Type", "Authorization", "Connection"],
99
71
  credentials: true,
100
72
  }));
101
- app.use(express_1.default.json());
102
- app.use(body_parser_1.default.json());
103
- app.use((0, cookie_parser_1.default)());
104
- app.use((0, express_query_parser_1.queryParser)({
73
+ app.use(express.json());
74
+ app.use(bodyParser.json());
75
+ app.use(cookieParser());
76
+ app.use(queryParser({
105
77
  parseNull: true,
106
78
  parseUndefined: true,
107
79
  parseBoolean: true,
108
80
  parseNumber: true,
109
81
  }));
110
- app.use((0, prisma_helpers_1.checkDatabaseConnection)(prisma));
111
- app.use(base_middlewares_1.handleRequestLogs);
82
+ app.use(checkDatabaseConnection(prisma));
83
+ app.use(handleRequestLogs);
112
84
  if (configs.authentication)
113
- app.use("/api", auth_router_1.default);
114
- app.use("/api", base_router_1.default);
115
- app.use(error_handler_controller_1.default);
85
+ app.use("/api", authRouter);
86
+ app.use("/api", baseRouter);
87
+ app.use(errorHandler);
116
88
  return app;
117
89
  }
90
+ export { prisma };
118
91
  //# sourceMappingURL=app.js.map
package/dist/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;;;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G,CAAC,GAAG,CACL,WAAW,CAAC;QACV,SAAS,EAAE,IAAI;QACf,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;QAClB,WAAW,EAAE,IAAI;KAClB,CAAC,CACH,CAAC;IAEF,GAAG,CAAC,GAAG,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC;IAEzC,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAE3B,IAAI,OAAO,CAAC,cAAc;QAAE,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxD,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC5B,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAEtB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import AppError from "../../modules/error-handler/utils/app-error";
2
+ /**
3
+ * A collection of error handling utilities.
4
+ *
5
+ * @namespace errorHandler
6
+ * @property {Function} catchAsync - A function to catch asynchronous errors.
7
+ * @property {Class} AppError - The AppError class to handle errors.
8
+ */
9
+ export declare const errorHandler: {
10
+ catchAsync: (fn: import("express").RequestHandler) => (req: import("express").Request, res: import("express").Response, next: import("express").NextFunction) => void;
11
+ AppError: typeof AppError;
12
+ };
13
+ export default errorHandler;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exports/error-handler/index.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,6CAA6C,CAAC;AAEnE;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;2DAMqL,8BAAY,EAAC,+BAAc,EAAC,oCAAmB;;CAH5P,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,15 @@
1
+ import catchAsync from "../../modules/error-handler/utils/catch-async";
2
+ import AppError from "../../modules/error-handler/utils/app-error";
3
+ /**
4
+ * A collection of error handling utilities.
5
+ *
6
+ * @namespace errorHandler
7
+ * @property {Function} catchAsync - A function to catch asynchronous errors.
8
+ * @property {Class} AppError - The AppError class to handle errors.
9
+ */
10
+ export const errorHandler = {
11
+ catchAsync,
12
+ AppError,
13
+ };
14
+ export default errorHandler;
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exports/error-handler/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,+CAA+C,CAAC;AACvE,OAAO,QAAQ,MAAM,6CAA6C,CAAC;AAEnE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,UAAU;IACV,QAAQ;CACT,CAAC;AAEF,eAAe,YAAY,CAAC"}