speexjs 0.2.0 → 0.2.2
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 +43 -43
- package/dist/cli/index.js +48 -48
- package/dist/cli/index.js.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/server/auth/index.js +1 -1
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/middleware/index.js +2 -2
- package/dist/server/middleware/index.js.map +1 -1
- package/package.json +135 -137
package/README.md
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# speexjs 🚀
|
|
2
2
|
|
|
3
3
|
**Fullstack JavaScript/TypeScript Framework — Server + Client + RPC + Schema + Database + Auth**
|
|
4
4
|
**🇮🇩 Indonesia First, Built for the World**
|
|
5
5
|
|
|
6
6
|
```bash
|
|
7
|
-
npm install
|
|
7
|
+
npm install speexjs
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
> Zero external dependencies. Only Node.js built-in modules.
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
## 📦 Kenapa
|
|
14
|
+
## 📦 Kenapa speexjs?
|
|
15
15
|
|
|
16
|
-
| Masalah | Solusi
|
|
16
|
+
| Masalah | Solusi speexjs |
|
|
17
17
|
|---------|---------------|
|
|
18
|
-
| Next.js terlalu berat & vendor lock-in |
|
|
19
|
-
| Express terlalu minimalis |
|
|
20
|
-
| Laravel pakai PHP |
|
|
18
|
+
| Next.js terlalu berat & vendor lock-in | speexjs ringan, zero-dep, engine-swappable |
|
|
19
|
+
| Express terlalu minimalis | speexjs Laravel-like: routing, middleware, controller, DI, ORM |
|
|
20
|
+
| Laravel pakai PHP | speexjs TypeScript native, end-to-end type safe |
|
|
21
21
|
| Fetch API ribet | SuperRequest/SuperResponse wrapper sendiri — lebih mudah |
|
|
22
22
|
| Framework asing untuk Indonesia | 🇮🇩 NIK, NPWP, Phone, Rupiah, terbilang built-in |
|
|
23
23
|
| React/Vue dependency berat | Signal-based VDOM sendiri — ringan, cepat |
|
|
@@ -68,7 +68,7 @@ npm install speedx
|
|
|
68
68
|
| **Signals** | `signal()`, `computed()`, `effect()`, `batch()`, `untracked()` |
|
|
69
69
|
| **VDOM** | `h()`, `render()`, `patch()`, `hydrate()` — Virtual DOM sendiri |
|
|
70
70
|
| **SSR** | `renderToString()`, `renderToStream()`, `ServerRenderer` |
|
|
71
|
-
| **JSX** | Full JSX support via `jsxImportSource: \"@
|
|
71
|
+
| **JSX** | Full JSX support via `jsxImportSource: \"@SpeexJS/vdom\"` |
|
|
72
72
|
| **Router** | File-based routing, guards, reactive current/params/query |
|
|
73
73
|
| **Adapters** | `FrameworkAdapter` interface — React/Vue integration |
|
|
74
74
|
|
|
@@ -84,12 +84,12 @@ npm install speedx
|
|
|
84
84
|
|
|
85
85
|
| Perintah | Fungsi |
|
|
86
86
|
|----------|--------|
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
87
|
+
| `speexjs init [name]` | Scaffold project baru (blank/fullstack/api-only) |
|
|
88
|
+
| `speexjs make:controller <name>` | Generate controller |
|
|
89
|
+
| `speexjs make:middleware <name>` | Generate middleware |
|
|
90
|
+
| `speexjs make:schema <name>` | Generate schema |
|
|
91
|
+
| `speexjs list-routes` | Lihat semua route yang terdaftar |
|
|
92
|
+
| `speexjs serve` | Jalankan development server |
|
|
93
93
|
|
|
94
94
|
---
|
|
95
95
|
|
|
@@ -98,32 +98,32 @@ npm install speedx
|
|
|
98
98
|
### 1. Install
|
|
99
99
|
|
|
100
100
|
```bash
|
|
101
|
-
npm install
|
|
101
|
+
npm install speexjs
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
### 2. Buat File Server
|
|
105
105
|
|
|
106
106
|
```typescript
|
|
107
107
|
// src/index.ts
|
|
108
|
-
import {
|
|
108
|
+
import { speexjs } from 'speexjs/server'
|
|
109
109
|
|
|
110
|
-
const app =
|
|
110
|
+
const app = speexjs()
|
|
111
111
|
|
|
112
112
|
app.get('/', async ({ response }) => {
|
|
113
|
-
return response.html('<h1>
|
|
113
|
+
return response.html('<h1>speexjs 🚀</h1>')
|
|
114
114
|
})
|
|
115
115
|
|
|
116
116
|
app.get('/api/hello', async ({ response }) => {
|
|
117
117
|
return response.json({ message: 'Halo Dunia!' })
|
|
118
118
|
})
|
|
119
119
|
|
|
120
|
-
app.listen(3000, () => console.log('
|
|
120
|
+
app.listen(3000, () => console.log('speexjs running on http://localhost:3000'))
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
### 3. Jalankan
|
|
124
124
|
|
|
125
125
|
```bash
|
|
126
|
-
npx
|
|
126
|
+
npx speexjs serve
|
|
127
127
|
# atau
|
|
128
128
|
node --loader ts-node src/index.ts
|
|
129
129
|
```
|
|
@@ -135,9 +135,9 @@ node --loader ts-node src/index.ts
|
|
|
135
135
|
### Server Routing
|
|
136
136
|
|
|
137
137
|
```typescript
|
|
138
|
-
import {
|
|
138
|
+
import { speexjs } from 'speexjs/server'
|
|
139
139
|
|
|
140
|
-
const app =
|
|
140
|
+
const app = speexjs()
|
|
141
141
|
|
|
142
142
|
// Basic routes
|
|
143
143
|
app.get('/users', handler)
|
|
@@ -170,7 +170,7 @@ app.get('/users/:id', handler).name('users.show')
|
|
|
170
170
|
### Controller
|
|
171
171
|
|
|
172
172
|
```typescript
|
|
173
|
-
import { Controller, get, post, put, del } from '
|
|
173
|
+
import { Controller, get, post, put, del } from 'speexjs/server'
|
|
174
174
|
|
|
175
175
|
@controller('/api/users')
|
|
176
176
|
export class UserController extends Controller {
|
|
@@ -211,7 +211,7 @@ export class UserController extends Controller {
|
|
|
211
211
|
### Schema Validation
|
|
212
212
|
|
|
213
213
|
```typescript
|
|
214
|
-
import { s } from '
|
|
214
|
+
import { s } from 'speexjs/schema'
|
|
215
215
|
|
|
216
216
|
// Buat schema
|
|
217
217
|
const UserSchema = s.object({
|
|
@@ -237,7 +237,7 @@ if (!result.success) {
|
|
|
237
237
|
### Database Query Builder
|
|
238
238
|
|
|
239
239
|
```typescript
|
|
240
|
-
import { DatabaseConnection } from '
|
|
240
|
+
import { DatabaseConnection } from 'speexjs/server/database'
|
|
241
241
|
|
|
242
242
|
const db = new DatabaseConnection({
|
|
243
243
|
driver: 'mysql', // mysql | sqlite | postgresql
|
|
@@ -282,16 +282,16 @@ const result = await db.raw('SELECT * FROM users WHERE age > ?', [18])
|
|
|
282
282
|
### Authentication
|
|
283
283
|
|
|
284
284
|
```typescript
|
|
285
|
-
import {
|
|
286
|
-
import { AuthManager, SessionGuard } from '
|
|
285
|
+
import { speexjs } from 'speexjs/server'
|
|
286
|
+
import { AuthManager, SessionGuard } from 'speexjs/server/auth'
|
|
287
287
|
|
|
288
|
-
const app =
|
|
288
|
+
const app = speexjs()
|
|
289
289
|
|
|
290
290
|
// Setup auth
|
|
291
291
|
const auth = new AuthManager()
|
|
292
292
|
auth.guard('session', new SessionGuard({
|
|
293
293
|
table: 'users',
|
|
294
|
-
cookieName: '
|
|
294
|
+
cookieName: 'speexjs_session',
|
|
295
295
|
}))
|
|
296
296
|
|
|
297
297
|
// Login route
|
|
@@ -312,7 +312,7 @@ app.get('/profile', async ({ response }, next) => {
|
|
|
312
312
|
}).middleware(['auth'])
|
|
313
313
|
|
|
314
314
|
// Authorization Gate
|
|
315
|
-
import { Gate } from '
|
|
315
|
+
import { Gate } from 'speexjs/server/gate'
|
|
316
316
|
|
|
317
317
|
const gate = new Gate()
|
|
318
318
|
gate.define('update-post', (user, post) => user.id === post.user_id)
|
|
@@ -327,7 +327,7 @@ app.put('/posts/:id', async ({ params, response }) => {
|
|
|
327
327
|
### Client — Signals + VDOM
|
|
328
328
|
|
|
329
329
|
```typescript
|
|
330
|
-
import { signal, computed, effect, h, render } from '
|
|
330
|
+
import { signal, computed, effect, h, render } from 'speexjs/client'
|
|
331
331
|
|
|
332
332
|
function Counter() {
|
|
333
333
|
const count = signal(0)
|
|
@@ -352,7 +352,7 @@ Dengan JSX (`tsconfig.json`):
|
|
|
352
352
|
{
|
|
353
353
|
"compilerOptions": {
|
|
354
354
|
"jsx": "react-jsx",
|
|
355
|
-
"jsxImportSource": "@
|
|
355
|
+
"jsxImportSource": "@SpeexJS/vdom"
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
```
|
|
@@ -372,7 +372,7 @@ function Counter() {
|
|
|
372
372
|
### Cache
|
|
373
373
|
|
|
374
374
|
```typescript
|
|
375
|
-
import { Cache } from '
|
|
375
|
+
import { Cache } from 'speexjs/server/cache'
|
|
376
376
|
|
|
377
377
|
const cache = new Cache({ store: 'memory', ttl: 3600 })
|
|
378
378
|
|
|
@@ -392,7 +392,7 @@ await cache.increment('visits')
|
|
|
392
392
|
### File Storage
|
|
393
393
|
|
|
394
394
|
```typescript
|
|
395
|
-
import { createStorage } from '
|
|
395
|
+
import { createStorage } from 'speexjs/server/storage'
|
|
396
396
|
|
|
397
397
|
const storage = createStorage({
|
|
398
398
|
defaultDisk: 'local',
|
|
@@ -415,7 +415,7 @@ const exists = await storage.exists('images/photo.jpg')
|
|
|
415
415
|
### Events
|
|
416
416
|
|
|
417
417
|
```typescript
|
|
418
|
-
import { event } from '
|
|
418
|
+
import { event } from 'speexjs/server/events'
|
|
419
419
|
|
|
420
420
|
// Listen
|
|
421
421
|
event.on('user.registered', async (user) => {
|
|
@@ -435,9 +435,9 @@ await event.emit('user.registered', { id: 1, email: 'john@test.com' })
|
|
|
435
435
|
|
|
436
436
|
```typescript
|
|
437
437
|
// === SERVER ===
|
|
438
|
-
import {
|
|
439
|
-
import { rpc } from '
|
|
440
|
-
import { s } from '
|
|
438
|
+
import { speexjs } from 'speexjs/server'
|
|
439
|
+
import { rpc } from 'speexjs/rpc'
|
|
440
|
+
import { s } from 'speexjs/schema'
|
|
441
441
|
|
|
442
442
|
const api = rpc.create({
|
|
443
443
|
procedures: {
|
|
@@ -456,12 +456,12 @@ const api = rpc.create({
|
|
|
456
456
|
},
|
|
457
457
|
})
|
|
458
458
|
|
|
459
|
-
const app =
|
|
459
|
+
const app = speexjs()
|
|
460
460
|
app.post('/api/rpc', api.toHandler())
|
|
461
461
|
app.listen(3000)
|
|
462
462
|
|
|
463
463
|
// === CLIENT ===
|
|
464
|
-
import { createClient } from '
|
|
464
|
+
import { createClient } from 'speexjs/rpc'
|
|
465
465
|
|
|
466
466
|
const client = createClient({ baseUrl: 'http://localhost:3000/api' })
|
|
467
467
|
const users = await client.call('users.list', { page: 1 })
|
|
@@ -491,7 +491,7 @@ const users = await client.call('users.list', { page: 1 })
|
|
|
491
491
|
## 🏗️ Arsitektur
|
|
492
492
|
|
|
493
493
|
```
|
|
494
|
-
|
|
494
|
+
speexjs/
|
|
495
495
|
├── src/
|
|
496
496
|
│ ├── index.ts # Barrel export
|
|
497
497
|
│ ├── native/ # Zero-dep utilities
|
|
@@ -519,7 +519,7 @@ speedx/
|
|
|
519
519
|
|
|
520
520
|
## 📋 Perbandingan dengan Framework Lain
|
|
521
521
|
|
|
522
|
-
| Fitur |
|
|
522
|
+
| Fitur | speexjs | Next.js | Express | AdonisJS | Laravel |
|
|
523
523
|
|-------|---------|---------|---------|----------|---------|
|
|
524
524
|
| Bahasa | TS/JS | TS/JS | JS | TS/JS | PHP |
|
|
525
525
|
| Dependencies | **0** | Ratusan | Puluhan | Puluhan | Ratusan |
|
|
@@ -551,5 +551,5 @@ MIT — bebas digunakan, dimodifikasi, dan didistribusikan.
|
|
|
551
551
|
|
|
552
552
|
---
|
|
553
553
|
|
|
554
|
-
**
|
|
554
|
+
**speexjs — Fullstack JavaScript/TypeScript Framework**
|
|
555
555
|
**🇮🇩 Dibuat oleh developer Indonesia, untuk developer dunia.**
|
package/dist/cli/index.js
CHANGED
|
@@ -133,12 +133,12 @@ var TEMPLATES = {
|
|
|
133
133
|
type: "module",
|
|
134
134
|
private: true,
|
|
135
135
|
scripts: {
|
|
136
|
-
dev: "
|
|
137
|
-
build: "
|
|
136
|
+
dev: "SpeexJS serve",
|
|
137
|
+
build: "SpeexJS build",
|
|
138
138
|
start: "node dist/index.js"
|
|
139
139
|
},
|
|
140
140
|
dependencies: {
|
|
141
|
-
|
|
141
|
+
SpeexJS: "latest"
|
|
142
142
|
},
|
|
143
143
|
devDependencies: {
|
|
144
144
|
"@types/node": "^26.0.1",
|
|
@@ -169,24 +169,24 @@ var TEMPLATES = {
|
|
|
169
169
|
null,
|
|
170
170
|
2
|
|
171
171
|
),
|
|
172
|
-
"src/index.ts": `import {
|
|
172
|
+
"src/index.ts": `import { SpeexJS } from 'speexjs/server'
|
|
173
173
|
|
|
174
|
-
const app =
|
|
174
|
+
const app = SpeexJS()
|
|
175
175
|
|
|
176
176
|
const PORT = Number(process.env.PORT) || 3000
|
|
177
177
|
|
|
178
178
|
app.get('/', async ({ response }) => {
|
|
179
|
-
return response.html('<h1>
|
|
179
|
+
return response.html('<h1>SpeexJS \u{1F680}</h1>')
|
|
180
180
|
})
|
|
181
181
|
|
|
182
182
|
app.listen(PORT, () => {
|
|
183
|
-
console.log(\`
|
|
183
|
+
console.log(\`SpeexJS running on http://localhost:\${PORT}\`)
|
|
184
184
|
})
|
|
185
185
|
`,
|
|
186
|
-
"src/app.ts": `import {
|
|
186
|
+
"src/app.ts": `import { SpeexJS } from 'speexjs/server'
|
|
187
187
|
|
|
188
188
|
export function createApp() {
|
|
189
|
-
const app =
|
|
189
|
+
const app = SpeexJS()
|
|
190
190
|
return app
|
|
191
191
|
}
|
|
192
192
|
`,
|
|
@@ -219,12 +219,12 @@ dist/
|
|
|
219
219
|
type: "module",
|
|
220
220
|
private: true,
|
|
221
221
|
scripts: {
|
|
222
|
-
dev: "
|
|
222
|
+
dev: "SpeexJS serve",
|
|
223
223
|
build: "tsc",
|
|
224
224
|
start: "node dist/server/index.js"
|
|
225
225
|
},
|
|
226
226
|
dependencies: {
|
|
227
|
-
|
|
227
|
+
SpeexJS: "latest"
|
|
228
228
|
},
|
|
229
229
|
devDependencies: {
|
|
230
230
|
"@types/node": "^26.0.1",
|
|
@@ -247,7 +247,7 @@ dist/
|
|
|
247
247
|
isolatedModules: true,
|
|
248
248
|
resolveJsonModule: true,
|
|
249
249
|
jsx: "react-jsx",
|
|
250
|
-
jsxImportSource: "@
|
|
250
|
+
jsxImportSource: "@SpeexJS/vdom",
|
|
251
251
|
outDir: "./dist",
|
|
252
252
|
rootDir: "./src"
|
|
253
253
|
},
|
|
@@ -257,12 +257,12 @@ dist/
|
|
|
257
257
|
null,
|
|
258
258
|
2
|
|
259
259
|
),
|
|
260
|
-
"src/server/index.ts": `import {
|
|
260
|
+
"src/server/index.ts": `import { SpeexJS } from 'speexjs/server'
|
|
261
261
|
import { UserController } from './controllers/user.controller.js'
|
|
262
262
|
|
|
263
263
|
const PORT = Number(process.env.PORT) || 3000
|
|
264
264
|
|
|
265
|
-
const app =
|
|
265
|
+
const app = SpeexJS()
|
|
266
266
|
|
|
267
267
|
app.controller(UserController)
|
|
268
268
|
|
|
@@ -273,7 +273,7 @@ app.get('/', async ({ response }) => {
|
|
|
273
273
|
<head>
|
|
274
274
|
<meta charset="UTF-8" />
|
|
275
275
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
276
|
-
<title>
|
|
276
|
+
<title>SpeexJS Fullstack</title>
|
|
277
277
|
</head>
|
|
278
278
|
<body>
|
|
279
279
|
<div id="root"></div>
|
|
@@ -284,10 +284,10 @@ app.get('/', async ({ response }) => {
|
|
|
284
284
|
})
|
|
285
285
|
|
|
286
286
|
app.listen(PORT, () => {
|
|
287
|
-
console.log(\`
|
|
287
|
+
console.log(\`SpeexJS running on http://localhost:\${PORT}\`)
|
|
288
288
|
})
|
|
289
289
|
`,
|
|
290
|
-
"src/server/controllers/user.controller.ts": `import { Controller, get, post } from '
|
|
290
|
+
"src/server/controllers/user.controller.ts": `import { Controller, get, post } from 'speexjs/server'
|
|
291
291
|
|
|
292
292
|
export class UserController extends Controller {
|
|
293
293
|
@get('/users')
|
|
@@ -317,8 +317,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
317
317
|
}
|
|
318
318
|
root.innerHTML = \`
|
|
319
319
|
<div style="text-align:center;padding:2rem">
|
|
320
|
-
<h1>
|
|
321
|
-
<p>Welcome to
|
|
320
|
+
<h1>SpeexJS Fullstack</h1>
|
|
321
|
+
<p>Welcome to SpeexJS!</p>
|
|
322
322
|
</div>
|
|
323
323
|
\`
|
|
324
324
|
}
|
|
@@ -372,12 +372,12 @@ dist/
|
|
|
372
372
|
type: "module",
|
|
373
373
|
private: true,
|
|
374
374
|
scripts: {
|
|
375
|
-
dev: "
|
|
375
|
+
dev: "SpeexJS serve",
|
|
376
376
|
build: "tsc",
|
|
377
377
|
start: "node dist/index.js"
|
|
378
378
|
},
|
|
379
379
|
dependencies: {
|
|
380
|
-
|
|
380
|
+
SpeexJS: "latest"
|
|
381
381
|
},
|
|
382
382
|
devDependencies: {
|
|
383
383
|
"@types/node": "^26.0.1",
|
|
@@ -408,21 +408,21 @@ dist/
|
|
|
408
408
|
null,
|
|
409
409
|
2
|
|
410
410
|
),
|
|
411
|
-
"src/index.ts": `import {
|
|
411
|
+
"src/index.ts": `import { SpeexJS } from 'speexjs/server'
|
|
412
412
|
|
|
413
413
|
const PORT = Number(process.env.PORT) || 3000
|
|
414
414
|
|
|
415
|
-
const app =
|
|
415
|
+
const app = SpeexJS()
|
|
416
416
|
|
|
417
417
|
app.get('/api/health', async ({ response }) => {
|
|
418
418
|
return response.json({ status: 'ok', timestamp: new Date().toISOString() })
|
|
419
419
|
})
|
|
420
420
|
|
|
421
421
|
app.listen(PORT, () => {
|
|
422
|
-
console.log(\`
|
|
422
|
+
console.log(\`SpeexJS API running on http://localhost:\${PORT}\`)
|
|
423
423
|
})
|
|
424
424
|
`,
|
|
425
|
-
"src/controllers/health.controller.ts": `import { Controller, get } from '
|
|
425
|
+
"src/controllers/health.controller.ts": `import { Controller, get } from 'speexjs/server'
|
|
426
426
|
|
|
427
427
|
export class HealthController extends Controller {
|
|
428
428
|
@get('/health')
|
|
@@ -434,7 +434,7 @@ export class HealthController extends Controller {
|
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
436
|
`,
|
|
437
|
-
"src/middleware/auth.ts": `import type { RouteContext } from '
|
|
437
|
+
"src/middleware/auth.ts": `import type { RouteContext } from 'speexjs/server/router'
|
|
438
438
|
|
|
439
439
|
export function auth() {
|
|
440
440
|
return async (ctx: RouteContext, next: () => Promise<void>) => {
|
|
@@ -521,7 +521,7 @@ async function initProject(name, options) {
|
|
|
521
521
|
const packageManager = String(options["package-manager"] || options.packageManager || "npm");
|
|
522
522
|
console.log();
|
|
523
523
|
console.log(`${colors.bold("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")}`);
|
|
524
|
-
console.log(`${colors.bold("\u2551")} ${colors.green("
|
|
524
|
+
console.log(`${colors.bold("\u2551")} ${colors.green("SpeexJS \u{1F680} Project Created")}${colors.bold(" \u2551")}`);
|
|
525
525
|
console.log(`${colors.bold("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")}`);
|
|
526
526
|
console.log();
|
|
527
527
|
console.log(` ${colors.bold("Name:")} ${toPascalCase(name)}`);
|
|
@@ -556,8 +556,8 @@ function makeController(name) {
|
|
|
556
556
|
process.exit(1);
|
|
557
557
|
}
|
|
558
558
|
mkdirSync2(targetDir, { recursive: true });
|
|
559
|
-
const content = `import { Controller, get, post, put, del } from '
|
|
560
|
-
import type { RouteContext } from '
|
|
559
|
+
const content = `import { Controller, get, post, put, del } from 'speexjs/server'
|
|
560
|
+
import type { RouteContext } from 'speexjs/server/router'
|
|
561
561
|
|
|
562
562
|
export class ${className} extends Controller {
|
|
563
563
|
@get('/')
|
|
@@ -619,7 +619,7 @@ function makeMiddleware(name) {
|
|
|
619
619
|
process.exit(1);
|
|
620
620
|
}
|
|
621
621
|
mkdirSync3(targetDir, { recursive: true });
|
|
622
|
-
const content = `import type { RouteContext } from '
|
|
622
|
+
const content = `import type { RouteContext } from 'speexjs/server/router'
|
|
623
623
|
|
|
624
624
|
export function ${functionName}(options?: Record<string, unknown>) {
|
|
625
625
|
return async (ctx: RouteContext, next: () => Promise<void>) => {
|
|
@@ -658,7 +658,7 @@ function makeSchema(name) {
|
|
|
658
658
|
process.exit(1);
|
|
659
659
|
}
|
|
660
660
|
mkdirSync4(targetDir, { recursive: true });
|
|
661
|
-
const content = `import { s, type Infer } from '
|
|
661
|
+
const content = `import { s, type Infer } from 'speexjs/schema'
|
|
662
662
|
|
|
663
663
|
export const ${schemaName} = s.object({
|
|
664
664
|
id: s.string().uuid(),
|
|
@@ -702,7 +702,7 @@ function listRoutes() {
|
|
|
702
702
|
console.log(
|
|
703
703
|
` ${colors.yellow("!")} Tidak ada route terdaftar. Buat controller dulu:`
|
|
704
704
|
);
|
|
705
|
-
console.log(` ${colors.cyan("
|
|
705
|
+
console.log(` ${colors.cyan("speexjs make:controller <name>")}`);
|
|
706
706
|
return;
|
|
707
707
|
}
|
|
708
708
|
const files = readdirSync(routesDir).filter((f) => f.endsWith(".ts"));
|
|
@@ -710,7 +710,7 @@ function listRoutes() {
|
|
|
710
710
|
console.log(
|
|
711
711
|
` ${colors.yellow("!")} Tidak ada route terdaftar. Buat controller dulu:`
|
|
712
712
|
);
|
|
713
|
-
console.log(` ${colors.cyan("
|
|
713
|
+
console.log(` ${colors.cyan("speexjs make:controller <name>")}`);
|
|
714
714
|
return;
|
|
715
715
|
}
|
|
716
716
|
let total = 0;
|
|
@@ -887,7 +887,7 @@ async function serve(options) {
|
|
|
887
887
|
}
|
|
888
888
|
app.listen(port, host, () => {
|
|
889
889
|
console.log();
|
|
890
|
-
console.log(` ${colors.bold("
|
|
890
|
+
console.log(` ${colors.bold("SpeexJS")} ${colors.green("running")}`);
|
|
891
891
|
console.log(` ${colors.dim("\u2192")} ${colors.cyan(`http://${host}:${port}`)}`);
|
|
892
892
|
console.log();
|
|
893
893
|
});
|
|
@@ -908,7 +908,7 @@ async function serve(options) {
|
|
|
908
908
|
}
|
|
909
909
|
app.listen(port, host, () => {
|
|
910
910
|
console.log();
|
|
911
|
-
console.log(` ${colors.bold("
|
|
911
|
+
console.log(` ${colors.bold("SpeexJS")} ${colors.green("running")}`);
|
|
912
912
|
console.log(` ${colors.dim("\u2192")} ${colors.cyan(`http://${host}:${port}`)}`);
|
|
913
913
|
console.log();
|
|
914
914
|
});
|
|
@@ -921,20 +921,20 @@ async function serve(options) {
|
|
|
921
921
|
|
|
922
922
|
// src/cli/index.ts
|
|
923
923
|
function showHelp() {
|
|
924
|
-
console.log(`${colors.bold("
|
|
924
|
+
console.log(`${colors.bold("SpeexJS")} ${colors.cyan("v0.2.0")}`);
|
|
925
925
|
console.log("Fullstack JavaScript/TypeScript Framework");
|
|
926
926
|
console.log();
|
|
927
927
|
console.log(`${colors.bold("Usage:")}`);
|
|
928
|
-
console.log("
|
|
929
|
-
console.log("
|
|
930
|
-
console.log("
|
|
931
|
-
console.log("
|
|
932
|
-
console.log("
|
|
933
|
-
console.log("
|
|
934
|
-
console.log("
|
|
928
|
+
console.log(" SpeexJS init [name] [options] Buat project baru");
|
|
929
|
+
console.log(" SpeexJS make:controller <name> Generate controller");
|
|
930
|
+
console.log(" SpeexJS make:middleware <name> Generate middleware");
|
|
931
|
+
console.log(" SpeexJS make:schema <name> Generate schema");
|
|
932
|
+
console.log(" SpeexJS list-routes Lihat semua route");
|
|
933
|
+
console.log(" SpeexJS serve [options] Jalankan server");
|
|
934
|
+
console.log(" SpeexJS --help Bantuan ini");
|
|
935
935
|
console.log();
|
|
936
936
|
console.log(`${colors.bold("Aliases:")}`);
|
|
937
|
-
console.log("
|
|
937
|
+
console.log(" SpeexJS -v, --version Lihat versi");
|
|
938
938
|
console.log();
|
|
939
939
|
console.log(`${colors.bold("Options:")}`);
|
|
940
940
|
console.log(" --template <type> blank, fullstack, api-only");
|
|
@@ -953,7 +953,7 @@ async function main() {
|
|
|
953
953
|
case "make:controller": {
|
|
954
954
|
if (!parsed.args[0]) {
|
|
955
955
|
console.error(colors.red("Nama controller diperlukan"));
|
|
956
|
-
console.log(` ${colors.cyan("
|
|
956
|
+
console.log(` ${colors.cyan("SpeexJS make:controller <name>")}`);
|
|
957
957
|
process.exit(1);
|
|
958
958
|
}
|
|
959
959
|
await makeController(parsed.args[0]);
|
|
@@ -962,7 +962,7 @@ async function main() {
|
|
|
962
962
|
case "make:middleware": {
|
|
963
963
|
if (!parsed.args[0]) {
|
|
964
964
|
console.error(colors.red("Nama middleware diperlukan"));
|
|
965
|
-
console.log(` ${colors.cyan("
|
|
965
|
+
console.log(` ${colors.cyan("SpeexJS make:middleware <name>")}`);
|
|
966
966
|
process.exit(1);
|
|
967
967
|
}
|
|
968
968
|
await makeMiddleware(parsed.args[0]);
|
|
@@ -971,7 +971,7 @@ async function main() {
|
|
|
971
971
|
case "make:schema": {
|
|
972
972
|
if (!parsed.args[0]) {
|
|
973
973
|
console.error(colors.red("Nama schema diperlukan"));
|
|
974
|
-
console.log(` ${colors.cyan("
|
|
974
|
+
console.log(` ${colors.cyan("SpeexJS make:schema <name>")}`);
|
|
975
975
|
process.exit(1);
|
|
976
976
|
}
|
|
977
977
|
await makeSchema(parsed.args[0]);
|
|
@@ -997,7 +997,7 @@ async function main() {
|
|
|
997
997
|
case "version":
|
|
998
998
|
case "--version":
|
|
999
999
|
case "-v": {
|
|
1000
|
-
console.log("
|
|
1000
|
+
console.log("SpeexJS v0.2.0");
|
|
1001
1001
|
break;
|
|
1002
1002
|
}
|
|
1003
1003
|
default: {
|