@darkstar-cli/cli 0.0.13 → 0.0.15
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 +400 -0
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +113 -46
- package/dist/commands/new.js.map +1 -1
- package/package.json +1 -1
- package/templates/project/.env.example +0 -90
- package/templates/project/darkstar.config.ts +0 -0
- package/templates/project/database/seeders/DatabaseSeeder.ts +0 -13
- package/templates/project/database/seeders/Seeder.ts +0 -3
- package/templates/project/src/controllers/controller.stub +0 -32
- package/templates/project/src/core/app.ts +0 -5
- package/templates/project/src/models/model.stub +0 -5
- package/templates/project/src/repositories/repository.stub +0 -9
- package/templates/project/src/services/service.stub +0 -11
- package/templates/project/src/utils/omitSecret.stub +0 -0
- package/templates/project/src/utils/omitpassword.stub +0 -0
- package/templates/project/tsconfig.json +0 -15
package/README.md
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
> [!CAUTION]
|
|
2
|
+
> ## ⚠️ ALPHA VERSION — DO NOT USE IN PRODUCTION
|
|
3
|
+
> DarkStar is in **early alpha**. APIs will change without notice. The package is not stable — use at your own risk.
|
|
4
|
+
|
|
5
|
+
> [!WARNING]
|
|
6
|
+
> ## 🧪 CUSTOM ORM — NO RELATIONSHIP SUPPORT
|
|
7
|
+
> DarkStar uses a **custom ORM** inspired by Eloquent, built from scratch for Node.js. It is **not Prisma, TypeORM or Sequelize**. Relationships (`hasOne`, `hasMany`, `belongsTo`), eager loading and transactions are **not yet implemented**. Check the Known Limitations section before using.
|
|
8
|
+
|
|
9
|
+
> [!NOTE]
|
|
10
|
+
> 📦 DarkStar is published on npm as **`@darkstar-cli/cli`**. Install with `npm install -g @darkstar-cli/cli`.
|
|
11
|
+
|
|
12
|
+
# 🪐 DarkStar — Backend Framework for Node.js
|
|
13
|
+
|
|
14
|
+
> *"Forged in the void. Built to last."*
|
|
15
|
+
|
|
16
|
+
> Inspired by the elegance of **Laravel** — reimagined for the **Node.js** universe.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Why does DarkStar exist?
|
|
21
|
+
|
|
22
|
+
I'm a PHP fan. The first time I saw Laravel I couldn't wrap my head around it — but once I did, I thought: *"this is brilliant"*.
|
|
23
|
+
|
|
24
|
+
NestJS tries to bring that experience to Node, but in practice it's verbose, decorator-heavy and hard to read. Plain Express is too flexible — you end up building the same boilerplate from scratch on every project.
|
|
25
|
+
|
|
26
|
+
**DarkStar** was born to solve this: a Node.js framework with the clarity and productivity of Laravel, without the ecosystem mess.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Philosophy
|
|
31
|
+
|
|
32
|
+
- **Convention over configuration** — ready-made structure, no unnecessary decisions
|
|
33
|
+
- **MVC as a first-class citizen** — Controller → Service → Repository is the standard, not an opinion
|
|
34
|
+
- **CLI that does the heavy lifting** — one command generates the entire layer
|
|
35
|
+
- **Centralized dependencies** — you update DarkStar, not 40 separate packages
|
|
36
|
+
- **Expressive custom ORM** — fluent Eloquent-style query builder, built from scratch for Node.js, no decorators
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install -g @darkstar-cli/cli
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Creating a project
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
darkstar new my-project
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The CLI will ask:
|
|
55
|
+
- Which database? (MySQL · PostgreSQL)
|
|
56
|
+
|
|
57
|
+
Generated structure:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
my-project/
|
|
61
|
+
├── src/
|
|
62
|
+
│ ├── controllers/
|
|
63
|
+
│ ├── services/
|
|
64
|
+
│ ├── repositories/
|
|
65
|
+
│ ├── models/
|
|
66
|
+
│ ├── routes/
|
|
67
|
+
│ ├── schemas/
|
|
68
|
+
│ ├── middlewares/
|
|
69
|
+
│ ├── utils/
|
|
70
|
+
│ └── core/
|
|
71
|
+
│ └── app.ts
|
|
72
|
+
├── database/
|
|
73
|
+
│ ├── migrations/
|
|
74
|
+
│ └── seeders/
|
|
75
|
+
│ ├── Seeder.ts
|
|
76
|
+
│ └── DatabaseSeeder.ts
|
|
77
|
+
├── .env
|
|
78
|
+
├── darkstar.config.ts
|
|
79
|
+
└── package.json
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## CLI — DarkStar Forge
|
|
85
|
+
|
|
86
|
+
| Command | Description |
|
|
87
|
+
|---|---|
|
|
88
|
+
| `darkstar new <name>` | Creates a new project |
|
|
89
|
+
| `darkstar serve` | Starts the development server |
|
|
90
|
+
| `darkstar forge make:api <Name>` | Generates controller + service + repository + model + routes + schema + middleware |
|
|
91
|
+
| `darkstar forge make:controller <Name>` | Generates a Controller |
|
|
92
|
+
| `darkstar forge make:service <Name>` | Generates a Service |
|
|
93
|
+
| `darkstar forge make:repository <Name>` | Generates a Repository |
|
|
94
|
+
| `darkstar forge make:model <Name>` | Generates a Model |
|
|
95
|
+
| `darkstar forge make:migration <Name>` | Generates a Migration |
|
|
96
|
+
| `darkstar forge make:seeder <Name>` | Generates a Seeder (automatically reads fields from the migration) |
|
|
97
|
+
| `darkstar forge make:schema <Name>` | Generates a Schema |
|
|
98
|
+
| `darkstar forge make:middleware <Name>` | Generates a Middleware |
|
|
99
|
+
| `darkstar forge make:util <Name>` | Generates omitPassword and twoFactor utils |
|
|
100
|
+
| `darkstar forge make:security` | Generates RateLimitMiddleware with ready-made limiters |
|
|
101
|
+
| `darkstar forge db:create` | Creates the database |
|
|
102
|
+
| `darkstar forge db:migrate` | Runs pending migrations |
|
|
103
|
+
| `darkstar forge db:rollback` | Rolls back the last migration |
|
|
104
|
+
| `darkstar forge db:seed` | Seeds the database |
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Recommended workflow from scratch
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# 1. Create the database
|
|
112
|
+
darkstar forge db:create
|
|
113
|
+
|
|
114
|
+
# 2. Generate the migration
|
|
115
|
+
darkstar forge make:migration CreateUsersTable
|
|
116
|
+
|
|
117
|
+
# 3. Edit the generated file in database/migrations/ with the desired fields
|
|
118
|
+
|
|
119
|
+
# 4. Run the migration
|
|
120
|
+
darkstar forge db:migrate
|
|
121
|
+
|
|
122
|
+
# 5. Generate the full API
|
|
123
|
+
darkstar forge make:api User
|
|
124
|
+
|
|
125
|
+
# 6. Generate the seeder (automatically reads fields from the migration)
|
|
126
|
+
darkstar forge make:seeder User
|
|
127
|
+
|
|
128
|
+
# 7. Seed the database
|
|
129
|
+
darkstar forge db:seed
|
|
130
|
+
|
|
131
|
+
# 8. Generate utils
|
|
132
|
+
darkstar forge make:util User
|
|
133
|
+
|
|
134
|
+
# 9. Generate security rate limiters
|
|
135
|
+
darkstar forge make:security
|
|
136
|
+
|
|
137
|
+
# 10. Start the server
|
|
138
|
+
darkstar serve
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Structure generated by `make:api`
|
|
144
|
+
|
|
145
|
+
A single `darkstar forge make:api User` command generates the entire MVC chain:
|
|
146
|
+
|
|
147
|
+
**`UserController.ts`**
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { DarkstarRequest, DarkstarResponse } from '@darkstar-cli/core'
|
|
151
|
+
import { UserService } from '../services/UserService'
|
|
152
|
+
|
|
153
|
+
export class UserController {
|
|
154
|
+
constructor(private userService: UserService) {}
|
|
155
|
+
|
|
156
|
+
async index(req: DarkstarRequest, res: DarkstarResponse) {
|
|
157
|
+
const data = await this.userService.findAll()
|
|
158
|
+
return res.ok(data)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async show(req: DarkstarRequest, res: DarkstarResponse) {
|
|
162
|
+
const data = await this.userService.findById(req.param('id')!)
|
|
163
|
+
if (!data) return res.notFound('User not found')
|
|
164
|
+
return res.ok(data)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async store(req: DarkstarRequest, res: DarkstarResponse) {
|
|
168
|
+
const data = await this.userService.create(req.all())
|
|
169
|
+
return res.created(data)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async update(req: DarkstarRequest, res: DarkstarResponse) {
|
|
173
|
+
const data = await this.userService.update(req.param('id')!, req.all())
|
|
174
|
+
return res.ok(data)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async destroy(req: DarkstarRequest, res: DarkstarResponse) {
|
|
178
|
+
await this.userService.delete(req.param('id')!)
|
|
179
|
+
return res.noContent()
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**`UserService.ts`**
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
import { UserRepository } from '../repositories/UserRepository'
|
|
188
|
+
|
|
189
|
+
export class UserService {
|
|
190
|
+
constructor(private userRepository: UserRepository) {}
|
|
191
|
+
|
|
192
|
+
findAll() { return this.userRepository.findAll() }
|
|
193
|
+
findById(id: string) { return this.userRepository.findById(id) }
|
|
194
|
+
create(data: Record<string, any>) { return this.userRepository.create(data) }
|
|
195
|
+
update(id: string, data: Record<string, any>) { return this.userRepository.update(id, data) }
|
|
196
|
+
delete(id: string) { return this.userRepository.delete(id) }
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**`UserRepository.ts`**
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
import { User } from '../models/User'
|
|
204
|
+
|
|
205
|
+
export class UserRepository {
|
|
206
|
+
findAll() { return User.all() }
|
|
207
|
+
findById(id: string) { return User.find(id) }
|
|
208
|
+
create(data: Record<string, any>) { return User.create(data) }
|
|
209
|
+
update(id: string, data: Record<string, any>) { return User.where('id', id).update(data) }
|
|
210
|
+
delete(id: string) { return User.where('id', id).delete() }
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**`User.ts`**
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
import { Model } from '@darkstar-cli/orm'
|
|
218
|
+
|
|
219
|
+
export class User extends Model {
|
|
220
|
+
static table = 'users'
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**`UserSchema.ts`**
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
export const UserSchema = {}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**`UserMiddleware.ts`**
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
import { DarkstarRequest, DarkstarResponse, NextFunction } from '@darkstar-cli/core'
|
|
234
|
+
|
|
235
|
+
export class UserMiddleware {
|
|
236
|
+
handle(req: DarkstarRequest, res: DarkstarResponse, next: NextFunction) {
|
|
237
|
+
next()
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Utils — `make:util`
|
|
245
|
+
|
|
246
|
+
The `darkstar forge make:util User` command generates ready-made utilities in `src/utils/user/`:
|
|
247
|
+
|
|
248
|
+
**`omitPassword.ts`**
|
|
249
|
+
|
|
250
|
+
Strips the `password` field from any object before returning it to the client — useful in service and controller responses.
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
export function omitUserPassword<T extends Record<string, any>>(obj: T): Omit<T, 'password'> {
|
|
254
|
+
const { password, ...rest } = obj
|
|
255
|
+
return rest
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**`twoFactor.ts`**
|
|
260
|
+
|
|
261
|
+
Generates and validates a 6-digit numeric code. See Known Limitations for production caveats.
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
import * as crypto from 'crypto'
|
|
265
|
+
|
|
266
|
+
export function generateUserTwoFactorCode(): string {
|
|
267
|
+
const code = crypto.randomInt(100000, 999999)
|
|
268
|
+
return code.toString()
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function validateUserTwoFactorCode(inputCode: string, expectedCode: string): boolean {
|
|
272
|
+
return inputCode.trim() === expectedCode.trim()
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Security — `make:security`
|
|
279
|
+
|
|
280
|
+
The `darkstar forge make:security` command generates `src/middlewares/RateLimitMiddleware.ts` with 22 ready-made limiters covering:
|
|
281
|
+
|
|
282
|
+
- **Auth** — login, register, forgot/reset password, refresh token, verify email, two-factor
|
|
283
|
+
- **CRUD** — read, write, delete
|
|
284
|
+
- **Files** — upload, download
|
|
285
|
+
- **Real-time** — SSE, WebSocket
|
|
286
|
+
- **Communication** — email, SMS, webhook
|
|
287
|
+
- **Search & reports** — search, stats, report
|
|
288
|
+
- **Admin** — general and destructive actions
|
|
289
|
+
- **Payments** — checkout, refund
|
|
290
|
+
|
|
291
|
+
Usage in routes:
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
import { loginLimiter, registerLimiter, globalLimiter } from '../middlewares/RateLimitMiddleware'
|
|
295
|
+
|
|
296
|
+
router.post('/auth/login', loginLimiter, ...)
|
|
297
|
+
router.post('/auth/register', registerLimiter, ...)
|
|
298
|
+
router.use('/api', globalLimiter)
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Routes
|
|
304
|
+
|
|
305
|
+
All routes are prefixed with `/api` by default. Example with `make:api User`:
|
|
306
|
+
|
|
307
|
+
```
|
|
308
|
+
GET /api/users
|
|
309
|
+
GET /api/users/:id
|
|
310
|
+
POST /api/users
|
|
311
|
+
PUT /api/users/:id
|
|
312
|
+
DELETE /api/users/:id
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
The prefix can be changed when booting the application:
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
await app.boot('/') // no prefix
|
|
319
|
+
await app.boot('/v1') // versioned
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## Custom ORM — Eloquent-style Query Builder
|
|
325
|
+
|
|
326
|
+
> [!WARNING]
|
|
327
|
+
> DarkStar's ORM is an independent package (`@darkstar-cli/orm`), built from scratch. Do not confuse it with Prisma, TypeORM or Sequelize. Check the Known Limitations section before using in production.
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
// fetch all
|
|
331
|
+
const users = await User.all()
|
|
332
|
+
|
|
333
|
+
// fetch by id
|
|
334
|
+
const user = await User.find(1)
|
|
335
|
+
|
|
336
|
+
// chained filters
|
|
337
|
+
const admins = await User
|
|
338
|
+
.where('role', 'admin')
|
|
339
|
+
.where('active', true)
|
|
340
|
+
.orderBy('name')
|
|
341
|
+
.get()
|
|
342
|
+
|
|
343
|
+
// create
|
|
344
|
+
const user = await User.create({ name: 'Test', email: 'test@email.com' })
|
|
345
|
+
|
|
346
|
+
// update
|
|
347
|
+
await User.where('id', 1).update({ name: 'Test' })
|
|
348
|
+
|
|
349
|
+
// delete
|
|
350
|
+
await User.where('id', 1).delete()
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## Known Limitations
|
|
356
|
+
|
|
357
|
+
DarkStar is in **early alpha**. The limitations below are known and will be addressed in future releases.
|
|
358
|
+
|
|
359
|
+
### ORM
|
|
360
|
+
|
|
361
|
+
- **No relationship support** — `hasOne`, `hasMany`, `belongsTo`, `belongsToMany` are not implemented. Queries with JOINs must be written in raw SQL for now.
|
|
362
|
+
- **Schema builder is MySQL/MariaDB only** — `Schema.create()`, `hasTable()`, `addColumn()` and `dropColumn()` generate MySQL syntax. PostgreSQL and SQLite migrations must use raw SQL inside the `up()` function.
|
|
363
|
+
- **No eager loading** — there is no equivalent to Laravel's `with()`. Related models must be fetched in separate queries.
|
|
364
|
+
- **`update()` returns the number of affected rows, not the updated record** — `Model.update(id, data)` returns `number`, not the updated instance. Re-fetch the record after updating if you need the new values.
|
|
365
|
+
- **No transaction API** — there is no `DB.transaction(callback)` helper. Transactions must be managed manually through the raw driver.
|
|
366
|
+
- **SQLite has no advisory locks** — `db:migrate` uses `GET_LOCK` (MySQL) and `pg_advisory_lock` (PostgreSQL) to prevent concurrent migrations. SQLite has no equivalent, so running migrations in parallel on SQLite is unsafe.
|
|
367
|
+
- **`hasTable()` uses `SHOW TABLES`, which is MySQL only** — will fail on PostgreSQL and SQLite.
|
|
368
|
+
|
|
369
|
+
### IoC Container
|
|
370
|
+
|
|
371
|
+
- **Dependency resolution is based on constructor parameter names** — the container parses the constructor source code as a string to infer dependencies. This breaks when code is minified, bundled or compiled in a way that renames parameters. Do not use with bundlers that mangle variable names (e.g. esbuild with `minifyIdentifiers: true`).
|
|
372
|
+
- **No circular dependency detection** — circular dependencies will cause a stack overflow with no useful error message.
|
|
373
|
+
|
|
374
|
+
### CLI
|
|
375
|
+
|
|
376
|
+
- **`darkstar new` uses local `file:` paths** — the generated `package.json` references `@darkstar-cli/core` and `@darkstar-cli/orm` as `file:` paths pointing to the monorepo. This will be updated to npm versions on release.
|
|
377
|
+
- **`make:model` generates a stub with `createModel` that does not exist in `@darkstar-cli/orm`** — the standalone `make:model` command generates `import { createModel, Model }`, which is not exported by the ORM. Use `make:api` instead or copy the model stub from it.
|
|
378
|
+
- **`make:middleware` generates imports with `TanisRequest`/`TanisResponse`** — the standalone `make:middleware` command still uses the old `Tanis*` aliases. They work at runtime but are inconsistent with the `Darkstar*` naming used everywhere else.
|
|
379
|
+
- **`darkstar serve` runs `npm run dev`** — assumes the project has a `dev` script in `package.json`. If you rename it, `darkstar serve` will fail.
|
|
380
|
+
- **Automatic seeder registration depends on the comment `// register your seeders here`** — if this comment is removed or modified in `DatabaseSeeder.ts`, `make:seeder` will not register the new seeder automatically.
|
|
381
|
+
|
|
382
|
+
### Validation
|
|
383
|
+
|
|
384
|
+
- **`UserSchema` is an empty object** — schemas generated by `make:schema` and `make:api` are stubs with no validation logic. Integrate [Zod](https://zod.dev) or [Joi](https://joi.dev) manually for now.
|
|
385
|
+
|
|
386
|
+
### Two-Factor Authentication
|
|
387
|
+
|
|
388
|
+
- **`twoFactor.ts` is not RFC 6238 compliant** — the generated util uses `crypto.randomInt` to produce a one-time code, but has no time window, HMAC or shared secret. It is suitable only as a placeholder. For production 2FA, use [`otplib`](https://github.com/yeojz/otplib).
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## Inspirations
|
|
393
|
+
|
|
394
|
+
- **Laravel** — for the elegance and productivity
|
|
395
|
+
- **Pandorum** — for the idea of forging something new in the void of space
|
|
396
|
+
- **Constellation CLI** — same spirit of automating what is repetitive
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
> 🪐 DarkStar — Open Source
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":"AAiKA,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,iBA8BxC"}
|
package/dist/commands/new.js
CHANGED
|
@@ -45,46 +45,110 @@ function log(msg) { console.log(msg); }
|
|
|
45
45
|
function success(msg) { log(kleur_1.default.green(' ✔ ') + msg); }
|
|
46
46
|
function info(msg) { log(kleur_1.default.cyan(' → ') + msg); }
|
|
47
47
|
function error(msg) { log(kleur_1.default.red(' ✘ ') + msg); }
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
48
|
+
function write(filePath, content) {
|
|
49
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
50
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
51
|
+
}
|
|
52
|
+
function generateStructure(projectPath, projectName) {
|
|
53
|
+
// Diretórios vazios (com .gitkeep)
|
|
54
|
+
const dirs = [
|
|
55
|
+
'src/controllers',
|
|
56
|
+
'src/services',
|
|
57
|
+
'src/repositories',
|
|
58
|
+
'src/models',
|
|
59
|
+
'src/routes',
|
|
60
|
+
'src/schemas',
|
|
61
|
+
'src/middlewares',
|
|
62
|
+
'src/utils',
|
|
63
|
+
'database/migrations',
|
|
64
|
+
'database/seeders',
|
|
65
|
+
];
|
|
66
|
+
for (const dir of dirs) {
|
|
67
|
+
const full = path.join(projectPath, dir);
|
|
68
|
+
fs.mkdirSync(full, { recursive: true });
|
|
69
|
+
fs.writeFileSync(path.join(full, '.gitkeep'), '');
|
|
67
70
|
}
|
|
71
|
+
// src/core/app.ts
|
|
72
|
+
write(path.join(projectPath, 'src/core/app.ts'), `import 'dotenv/config'
|
|
73
|
+
import { DarkstarApp } from '@darkstar-cli/core'
|
|
74
|
+
|
|
75
|
+
const app = new DarkstarApp()
|
|
76
|
+
|
|
77
|
+
app.boot('/api').then(() => {
|
|
78
|
+
const port = process.env.PORT ?? 3000
|
|
79
|
+
app.listen(Number(port), () => {
|
|
80
|
+
console.log(\`🪐 DarkStar rodando em http://localhost:\${port}\`)
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
`);
|
|
84
|
+
// database/seeders/Seeder.ts
|
|
85
|
+
write(path.join(projectPath, 'database/seeders/Seeder.ts'), `export abstract class Seeder {
|
|
86
|
+
abstract run(): Promise<void>
|
|
68
87
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
`);
|
|
89
|
+
// database/seeders/DatabaseSeeder.ts
|
|
90
|
+
write(path.join(projectPath, 'database/seeders/DatabaseSeeder.ts'), `import { Seeder } from './Seeder'
|
|
91
|
+
|
|
92
|
+
export class DatabaseSeeder extends Seeder {
|
|
93
|
+
async run(): Promise<void> {
|
|
94
|
+
// registre seus seeders aqui
|
|
95
|
+
}
|
|
77
96
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
`);
|
|
98
|
+
// darkstar.config.ts
|
|
99
|
+
write(path.join(projectPath, 'darkstar.config.ts'), `import type { DarkstarConfig } from '@darkstar-cli/core'
|
|
100
|
+
|
|
101
|
+
const config: DarkstarConfig = {
|
|
102
|
+
db: {
|
|
103
|
+
client: process.env.DB_CLIENT as 'mysql' | 'pg' | 'sqlite3' ?? 'mysql',
|
|
104
|
+
host: process.env.DB_HOST ?? '127.0.0.1',
|
|
105
|
+
port: Number(process.env.DB_PORT ?? 3306),
|
|
106
|
+
user: process.env.DB_USER ?? 'root',
|
|
107
|
+
password: process.env.DB_PASSWORD ?? '',
|
|
108
|
+
database: process.env.DB_DATABASE ?? '${projectName}',
|
|
109
|
+
},
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default config
|
|
113
|
+
`);
|
|
114
|
+
// tsconfig.json
|
|
115
|
+
write(path.join(projectPath, 'tsconfig.json'), JSON.stringify({
|
|
116
|
+
compilerOptions: {
|
|
117
|
+
target: 'ES2020',
|
|
118
|
+
module: 'commonjs',
|
|
119
|
+
lib: ['ES2020'],
|
|
120
|
+
outDir: './dist',
|
|
121
|
+
rootDir: './src',
|
|
122
|
+
strict: true,
|
|
123
|
+
esModuleInterop: true,
|
|
124
|
+
skipLibCheck: true,
|
|
125
|
+
forceConsistentCasingInFileNames: true,
|
|
126
|
+
resolveJsonModule: true,
|
|
127
|
+
emitDecoratorMetadata: false,
|
|
128
|
+
experimentalDecorators: false,
|
|
129
|
+
},
|
|
130
|
+
include: ['src/**/*', 'darkstar.config.ts'],
|
|
131
|
+
exclude: ['node_modules', 'dist'],
|
|
132
|
+
}, null, 2));
|
|
133
|
+
// .gitignore
|
|
134
|
+
write(path.join(projectPath, '.gitignore'), `node_modules/
|
|
135
|
+
dist/
|
|
136
|
+
.env
|
|
137
|
+
*.log
|
|
138
|
+
`);
|
|
139
|
+
// .env.example / .env
|
|
140
|
+
const env = `DB_CLIENT=mysql
|
|
141
|
+
DB_HOST=127.0.0.1
|
|
142
|
+
DB_PORT=3306
|
|
143
|
+
DB_USER=root
|
|
144
|
+
DB_PASSWORD=
|
|
145
|
+
DB_DATABASE=${projectName}
|
|
146
|
+
PORT=3000
|
|
147
|
+
`;
|
|
148
|
+
write(path.join(projectPath, '.env.example'), env);
|
|
149
|
+
write(path.join(projectPath, '.env'), env);
|
|
150
|
+
}
|
|
151
|
+
function generatePackageJson(projectPath, projectName) {
|
|
88
152
|
const pkg = {
|
|
89
153
|
name: projectName,
|
|
90
154
|
version: '0.0.1',
|
|
@@ -95,7 +159,14 @@ function configurePackageJson(projectPath, projectName) {
|
|
|
95
159
|
build: 'tsc',
|
|
96
160
|
start: 'node dist/core/app.js',
|
|
97
161
|
},
|
|
98
|
-
dependencies:
|
|
162
|
+
dependencies: {
|
|
163
|
+
'@darkstar-cli/core': 'latest',
|
|
164
|
+
'@darkstar-cli/orm': 'latest',
|
|
165
|
+
'dotenv': 'latest',
|
|
166
|
+
'express': 'latest',
|
|
167
|
+
'express-rate-limit': 'latest',
|
|
168
|
+
'zod': 'latest',
|
|
169
|
+
},
|
|
99
170
|
devDependencies: {
|
|
100
171
|
'@types/express': 'latest',
|
|
101
172
|
'@types/express-rate-limit': 'latest',
|
|
@@ -104,7 +175,7 @@ function configurePackageJson(projectPath, projectName) {
|
|
|
104
175
|
'typescript': 'latest',
|
|
105
176
|
},
|
|
106
177
|
};
|
|
107
|
-
|
|
178
|
+
write(path.join(projectPath, 'package.json'), JSON.stringify(pkg, null, 2));
|
|
108
179
|
}
|
|
109
180
|
function installDeps(projectPath) {
|
|
110
181
|
info('Instalando dependências...');
|
|
@@ -125,15 +196,11 @@ async function runNew(name) {
|
|
|
125
196
|
error(`A pasta "${name}" já existe.`);
|
|
126
197
|
process.exit(1);
|
|
127
198
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
copyTemplate(templatePath, projectPath);
|
|
199
|
+
info('Gerando estrutura do projeto...');
|
|
200
|
+
generateStructure(projectPath, name);
|
|
131
201
|
success('Estrutura criada');
|
|
132
|
-
info('Configurando .env...');
|
|
133
|
-
configureEnv(projectPath, name);
|
|
134
|
-
success('.env configurado');
|
|
135
202
|
info('Configurando package.json...');
|
|
136
|
-
|
|
203
|
+
generatePackageJson(projectPath, name);
|
|
137
204
|
success('package.json configurado');
|
|
138
205
|
installDeps(projectPath);
|
|
139
206
|
console.log('');
|
package/dist/commands/new.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAyB;AACzB,MAAY,EAAE,+BAAU;AACxB,MAAY,IAAI,iCAAY;AAC5B,iDAAwC;AAExC,SAAS,GAAG,CAAC,GAAW,IAAQ,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA,CAAC,CAAC;AAClD,SAAS,OAAO,CAAC,GAAW,IAAI,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAA,CAAC,CAAC;AAChE,SAAS,IAAI,CAAC,GAAW,IAAO,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAA,CAAC,CAAC;AAC/D,SAAS,KAAK,CAAC,GAAW,IAAM,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,MAAM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AAC,6BAA6B,CAAC,CAAA;IACtC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACf,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAA;IAC7C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,CAAA;IACzC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAA;IAC7C,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# -----------------------------------------------
|
|
2
|
-
# TANIS — Environment Configuration
|
|
3
|
-
# -----------------------------------------------
|
|
4
|
-
# Copie este arquivo para .env e preencha os valores
|
|
5
|
-
# cp .env.example .env
|
|
6
|
-
# -----------------------------------------------
|
|
7
|
-
|
|
8
|
-
# App
|
|
9
|
-
APP_NAME=DarkStar
|
|
10
|
-
APP_ENV=local # local | development | staging | production
|
|
11
|
-
APP_DEBUG=true
|
|
12
|
-
APP_URL=http://localhost
|
|
13
|
-
APP_PORT=3000
|
|
14
|
-
APP_KEY= # gerado pelo: tanis artisan key:generate
|
|
15
|
-
|
|
16
|
-
# Locale
|
|
17
|
-
APP_LOCALE=pt_BR
|
|
18
|
-
APP_TIMEZONE=America/Sao_Paulo
|
|
19
|
-
|
|
20
|
-
# -----------------------------------------------
|
|
21
|
-
# Database
|
|
22
|
-
# -----------------------------------------------
|
|
23
|
-
DB_CONNECTION=mysql # sqlite | mysql | postgres
|
|
24
|
-
DB_HOST=127.0.0.1
|
|
25
|
-
DB_PORT=3306 # mysql: 3306 | postgres: 5432
|
|
26
|
-
DB_DATABASE=darkstar
|
|
27
|
-
DB_USERNAME=root # Seu usuario do banco Local
|
|
28
|
-
DB_PASSWORD=root # Sua senha do banco local
|
|
29
|
-
|
|
30
|
-
# -----------------------------------------------
|
|
31
|
-
# Cache
|
|
32
|
-
# -----------------------------------------------
|
|
33
|
-
CACHE_DRIVER=memory # memory | redis
|
|
34
|
-
|
|
35
|
-
# -----------------------------------------------
|
|
36
|
-
# Session
|
|
37
|
-
# -----------------------------------------------
|
|
38
|
-
SESSION_DRIVER=memory # memory | redis | database
|
|
39
|
-
SESSION_LIFETIME=120 # em minutos
|
|
40
|
-
SESSION_SECRET= # gerado pelo: tanis artisan key:generate
|
|
41
|
-
|
|
42
|
-
# -----------------------------------------------
|
|
43
|
-
# Queue
|
|
44
|
-
# -----------------------------------------------
|
|
45
|
-
QUEUE_CONNECTION=sync # sync | redis | database
|
|
46
|
-
|
|
47
|
-
# -----------------------------------------------
|
|
48
|
-
# Redis
|
|
49
|
-
# -----------------------------------------------
|
|
50
|
-
REDIS_HOST=127.0.0.1
|
|
51
|
-
REDIS_PORT=6379
|
|
52
|
-
REDIS_PASSWORD=null
|
|
53
|
-
REDIS_DB=0
|
|
54
|
-
|
|
55
|
-
# -----------------------------------------------
|
|
56
|
-
# Auth / JWT
|
|
57
|
-
# -----------------------------------------------
|
|
58
|
-
JWT_SECRET= # gerado pelo: tanis artisan key:generate
|
|
59
|
-
JWT_EXPIRES_IN= # ex: 60s | 10m | 2h | 7d
|
|
60
|
-
JWT_REFRESH_EXPIRES_IN= # ex: 60s | 10m | 2h | 7d
|
|
61
|
-
|
|
62
|
-
# -----------------------------------------------
|
|
63
|
-
# Mail
|
|
64
|
-
# -----------------------------------------------
|
|
65
|
-
MAIL_DRIVER=log # log | smtp | ses | sendgrid
|
|
66
|
-
MAIL_HOST=127.0.0.1
|
|
67
|
-
MAIL_PORT=2525
|
|
68
|
-
MAIL_USERNAME=null
|
|
69
|
-
MAIL_PASSWORD=null
|
|
70
|
-
MAIL_FROM_ADDRESS="hello@example.com"
|
|
71
|
-
MAIL_FROM_NAME="${APP_NAME}"
|
|
72
|
-
MAIL_ENCRYPTION=null # null | tls | ssl
|
|
73
|
-
|
|
74
|
-
# -----------------------------------------------
|
|
75
|
-
# Storage / AWS S3
|
|
76
|
-
# -----------------------------------------------
|
|
77
|
-
FILESYSTEM_DISK=local # local | s3
|
|
78
|
-
|
|
79
|
-
AWS_ACCESS_KEY_ID=
|
|
80
|
-
AWS_SECRET_ACCESS_KEY=
|
|
81
|
-
AWS_DEFAULT_REGION=us-east-1
|
|
82
|
-
AWS_BUCKET=
|
|
83
|
-
AWS_ENDPOINT= # para MinIO ou S3-compatíveis
|
|
84
|
-
|
|
85
|
-
# -----------------------------------------------
|
|
86
|
-
# Logging
|
|
87
|
-
# -----------------------------------------------
|
|
88
|
-
LOG_CHANNEL=console # console | file | combined
|
|
89
|
-
LOG_LEVEL=debug # debug | info | warn | error
|
|
90
|
-
LOG_FILE=storage/logs/tanis.log
|
|
File without changes
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { TanisRequest, TanisResponse } from '@darkstar-cli/core'
|
|
2
|
-
import { {{name}}Service } from '../services/{{name}}Service'
|
|
3
|
-
|
|
4
|
-
export class {{name}}Controller {
|
|
5
|
-
constructor(private {{nameLower}}Service: {{name}}Service) {}
|
|
6
|
-
|
|
7
|
-
async index(req: TanisRequest, res: TanisResponse) {
|
|
8
|
-
const data = await this.{{nameLower}}Service.findAll()
|
|
9
|
-
return res.ok(data)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async show(req: TanisRequest, res: TanisResponse) {
|
|
13
|
-
const data = await this.{{nameLower}}Service.findById(req.param('id')!)
|
|
14
|
-
if (!data) return res.notFound('{{name}} não encontrado')
|
|
15
|
-
return res.ok(data)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async store(req: TanisRequest, res: TanisResponse) {
|
|
19
|
-
const data = await this.{{nameLower}}Service.create(req.all())
|
|
20
|
-
return res.created(data)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async update(req: TanisRequest, res: TanisResponse) {
|
|
24
|
-
const data = await this.{{nameLower}}Service.update(req.param('id')!, req.all())
|
|
25
|
-
return res.ok(data)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async destroy(req: TanisRequest, res: TanisResponse) {
|
|
29
|
-
await this.{{nameLower}}Service.delete(req.param('id')!)
|
|
30
|
-
return res.noContent()
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { {{name}} } from '../models/{{name}}'
|
|
2
|
-
|
|
3
|
-
export class {{name}}Repository {
|
|
4
|
-
findAll() { return {{name}}.findAll() }
|
|
5
|
-
findById(id: string) { return {{name}}.findById(id) }
|
|
6
|
-
create(data: Record<string, any>) { return {{name}}.create(data as any) }
|
|
7
|
-
update(id: string, data: Record<string, any>) { return {{name}}.update(id, data as any) }
|
|
8
|
-
delete(id: string) { return {{name}}.delete(id) }
|
|
9
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { {{name}}Repository } from '../repositories/{{name}}Repository'
|
|
2
|
-
|
|
3
|
-
export class {{name}}Service {
|
|
4
|
-
constructor(private {{nameLower}}Repository: {{name}}Repository) {}
|
|
5
|
-
|
|
6
|
-
findAll() { return this.{{nameLower}}Repository.findAll() }
|
|
7
|
-
findById(id: string) { return this.{{nameLower}}Repository.findById(id) }
|
|
8
|
-
create(data: Record<string, any>) { return this.{{nameLower}}Repository.create(data) }
|
|
9
|
-
update(id: string, data: Record<string, any>) { return this.{{nameLower}}Repository.update(id, data) }
|
|
10
|
-
delete(id: string) { return this.{{nameLower}}Repository.delete(id) }
|
|
11
|
-
}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "Node16",
|
|
5
|
-
"moduleResolution": "node16",
|
|
6
|
-
"outDir": "./dist",
|
|
7
|
-
"rootDir": "./src",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"resolveJsonModule": true
|
|
12
|
-
},
|
|
13
|
-
"include": ["src/**/*"],
|
|
14
|
-
"exclude": ["node_modules", "dist"]
|
|
15
|
-
}
|