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.
- package/README.md +199 -199
- package/dist/app.d.ts +5 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +46 -73
- package/dist/app.js.map +1 -1
- package/dist/exports/error-handler/index.d.ts +14 -0
- package/dist/exports/error-handler/index.d.ts.map +1 -0
- package/dist/exports/error-handler/index.js +15 -0
- package/dist/exports/error-handler/index.js.map +1 -0
- package/dist/exports/index.d.ts +21 -0
- package/dist/exports/index.d.ts.map +1 -0
- package/dist/exports/index.js +21 -0
- package/dist/exports/index.js.map +1 -0
- package/dist/exports/services/index.d.ts +22 -0
- package/dist/exports/services/index.d.ts.map +1 -0
- package/dist/exports/services/index.js +21 -0
- package/dist/exports/services/index.js.map +1 -0
- package/dist/exports/utils/index.d.ts +16 -0
- package/dist/exports/utils/index.d.ts.map +1 -0
- package/dist/exports/utils/index.js +16 -0
- package/dist/exports/utils/index.js.map +1 -0
- package/dist/exports/validation/index.d.ts +13 -0
- package/dist/exports/validation/index.d.ts.map +1 -0
- package/dist/exports/validation/index.js +13 -0
- package/dist/exports/validation/index.js.map +1 -0
- package/dist/modules/auth/auth.controller.d.ts.map +1 -1
- package/dist/modules/auth/auth.controller.js +68 -77
- package/dist/modules/auth/auth.controller.js.map +1 -1
- package/dist/modules/auth/auth.router.js +30 -35
- package/dist/modules/auth/auth.router.js.map +1 -1
- package/dist/modules/auth/auth.service.d.ts +73 -3
- package/dist/modules/auth/auth.service.d.ts.map +1 -1
- package/dist/modules/auth/auth.service.js +101 -33
- package/dist/modules/auth/auth.service.js.map +1 -1
- package/dist/modules/base/base.controller.d.ts +1 -1
- package/dist/modules/base/base.controller.d.ts.map +1 -1
- package/dist/modules/base/base.controller.js +62 -68
- package/dist/modules/base/base.controller.js.map +1 -1
- package/dist/modules/base/base.middlewares.js +5 -12
- package/dist/modules/base/base.middlewares.js.map +1 -1
- package/dist/modules/base/base.router.d.ts.map +1 -1
- package/dist/modules/base/base.router.js +44 -50
- package/dist/modules/base/base.router.js.map +1 -1
- package/dist/modules/base/base.service.d.ts +78 -5
- package/dist/modules/base/base.service.d.ts.map +1 -1
- package/dist/modules/base/base.service.js +148 -55
- package/dist/modules/base/base.service.js.map +1 -1
- package/dist/modules/base/utils/base.helpers.js +5 -8
- package/dist/modules/base/utils/base.helpers.js.map +1 -1
- package/dist/modules/email/email.service.d.ts +26 -5
- package/dist/modules/email/email.service.d.ts.map +1 -1
- package/dist/modules/email/email.service.js +33 -19
- package/dist/modules/email/email.service.js.map +1 -1
- package/dist/modules/error-handler/error-handler.controller.d.ts +15 -0
- package/dist/modules/error-handler/error-handler.controller.d.ts.map +1 -1
- package/dist/modules/error-handler/error-handler.controller.js +103 -129
- package/dist/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/modules/error-handler/utils/app-error.d.ts +40 -0
- package/dist/modules/error-handler/utils/app-error.d.ts.map +1 -1
- package/dist/modules/error-handler/utils/app-error.js +42 -4
- package/dist/modules/error-handler/utils/app-error.js.map +1 -1
- package/dist/modules/error-handler/utils/catch-async.d.ts +15 -1
- package/dist/modules/error-handler/utils/catch-async.d.ts.map +1 -1
- package/dist/modules/error-handler/utils/catch-async.js +15 -3
- package/dist/modules/error-handler/utils/catch-async.js.map +1 -1
- package/dist/modules/error-handler/utils/error-handler.helpers.js +71 -111
- package/dist/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
- package/dist/modules/file-uploader/file-uploader.service.d.ts +51 -2
- package/dist/modules/file-uploader/file-uploader.service.d.ts.map +1 -1
- package/dist/modules/file-uploader/file-uploader.service.js +74 -36
- package/dist/modules/file-uploader/file-uploader.service.js.map +1 -1
- package/dist/paths.js +2 -8
- package/dist/paths.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +7 -11
- package/dist/server.js.map +1 -1
- package/dist/utils/arkos-env.d.ts +7 -0
- package/dist/utils/arkos-env.d.ts.map +1 -0
- package/dist/utils/arkos-env.js +7 -0
- package/dist/utils/arkos-env.js.map +1 -0
- package/dist/utils/features/api.features.js +16 -22
- package/dist/utils/features/api.features.js.map +1 -1
- package/dist/utils/helpers/api.features.helpers.js +1 -4
- package/dist/utils/helpers/api.features.helpers.js.map +1 -1
- package/dist/utils/helpers/fs.helpers.d.ts +2 -0
- package/dist/utils/helpers/fs.helpers.d.ts.map +1 -0
- package/dist/utils/helpers/fs.helpers.js +37 -0
- package/dist/utils/helpers/fs.helpers.js.map +1 -0
- package/dist/utils/helpers/models.helpers.d.ts +37 -1
- package/dist/utils/helpers/models.helpers.d.ts.map +1 -1
- package/dist/utils/helpers/models.helpers.js +109 -97
- package/dist/utils/helpers/models.helpers.js.map +1 -1
- package/dist/utils/helpers/prisma.helpers.js +7 -48
- package/dist/utils/helpers/prisma.helpers.js.map +1 -1
- package/dist/utils/helpers/text.helpers.d.ts +8 -0
- package/dist/utils/helpers/text.helpers.d.ts.map +1 -1
- package/dist/utils/helpers/text.helpers.js +12 -7
- package/dist/utils/helpers/text.helpers.js.map +1 -1
- package/dist/utils/permissions/index.js +1 -4
- package/dist/utils/permissions/index.js.map +1 -1
- package/dist/utils/scripts/export-prisma-types.js +2 -37
- package/dist/utils/scripts/export-prisma-types.js.map +1 -1
- package/dist/utils/scripts/generate-zod-schemas.js +4 -9
- package/dist/utils/scripts/generate-zod-schemas.js.map +1 -1
- package/dist/utils/scripts/prisma-db-push.js +8 -13
- package/dist/utils/scripts/prisma-db-push.js.map +1 -1
- package/dist/utils/validate-dto.d.ts +37 -2
- package/dist/utils/validate-dto.d.ts.map +1 -1
- package/dist/utils/validate-dto.js +44 -13
- package/dist/utils/validate-dto.js.map +1 -1
- package/package.json +106 -106
- package/dist/index.d.ts +0 -44
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -75
- package/dist/index.js.map +0 -1
- package/dist/modules/email/utils/helpers/email.helpers.d.ts +0 -9
- package/dist/modules/email/utils/helpers/email.helpers.d.ts.map +0 -1
- package/dist/modules/email/utils/helpers/email.helpers.js +0 -25
- package/dist/modules/email/utils/helpers/email.helpers.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,199 +1,199 @@
|
|
|
1
|
-

|
|
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
|
+

|
|
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;
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 =
|
|
19
|
+
envPath = path.resolve(process.cwd(), ".env.production");
|
|
59
20
|
}
|
|
60
21
|
else if (ENV === "staging") {
|
|
61
|
-
envPath =
|
|
22
|
+
envPath = path.resolve(process.cwd(), ".env.staging");
|
|
62
23
|
}
|
|
63
24
|
else if (ENV === "development") {
|
|
64
|
-
envPath =
|
|
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
|
-
|
|
42
|
+
prisma = await loadPrismaModule();
|
|
71
43
|
})();
|
|
72
|
-
async function bootstrap(app, configs) {
|
|
73
|
-
|
|
44
|
+
export async function bootstrap(app, configs) {
|
|
45
|
+
prisma = await loadPrismaModule();
|
|
74
46
|
initConfigs = configs;
|
|
75
|
-
app.use((
|
|
76
|
-
const limiter =
|
|
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",
|
|
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((
|
|
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(
|
|
102
|
-
app.use(
|
|
103
|
-
app.use((
|
|
104
|
-
app.use(
|
|
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(
|
|
111
|
-
app.use(
|
|
82
|
+
app.use(checkDatabaseConnection(prisma));
|
|
83
|
+
app.use(handleRequestLogs);
|
|
112
84
|
if (configs.authentication)
|
|
113
|
-
app.use("/api",
|
|
114
|
-
app.use("/api",
|
|
115
|
-
app.use(
|
|
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":"
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"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"}
|
|
@@ -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"}
|