lapeh 2.6.17 → 3.0.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/.env.example +1 -6
- package/README.md +19 -85
- package/bin/index.js +84 -180
- package/dist/lib/bootstrap.d.ts.map +1 -1
- package/dist/lib/bootstrap.js +17 -16
- package/dist/lib/core/store.d.ts +55 -0
- package/dist/lib/core/store.d.ts.map +1 -0
- package/dist/lib/core/store.js +66 -0
- package/dist/lib/middleware/error.d.ts.map +1 -1
- package/dist/lib/middleware/error.js +1 -20
- package/dist/lib/utils/validator.d.ts.map +1 -1
- package/dist/lib/utils/validator.js +3 -32
- package/dist/src/modules/Auth/auth.controller.d.ts.map +1 -1
- package/dist/src/modules/Auth/auth.controller.js +118 -105
- package/dist/src/modules/Rbac/rbac.controller.d.ts.map +1 -1
- package/dist/src/modules/Rbac/rbac.controller.js +141 -140
- package/dist/src/routes/index.d.ts.map +1 -1
- package/dist/src/routes/index.js +0 -5
- package/doc/en/CHEATSHEET.md +3 -7
- package/doc/en/CLI.md +16 -41
- package/doc/en/DEPLOYMENT.md +171 -245
- package/doc/en/GETTING_STARTED.md +1 -25
- package/doc/en/PACKAGES.md +2 -3
- package/doc/en/STRUCTURE.md +1 -11
- package/doc/en/TUTORIAL.md +61 -119
- package/doc/id/CHANGELOG.md +16 -0
- package/doc/id/CHEATSHEET.md +0 -4
- package/doc/id/CLI.md +19 -54
- package/doc/id/DEPLOYMENT.md +171 -245
- package/doc/id/GETTING_STARTED.md +91 -115
- package/doc/id/PACKAGES.md +0 -1
- package/doc/id/STRUCTURE.md +1 -11
- package/doc/id/TUTORIAL.md +51 -109
- package/gitignore.template +0 -10
- package/lib/bootstrap.ts +39 -38
- package/lib/core/store.ts +116 -0
- package/lib/middleware/error.ts +1 -21
- package/lib/utils/validator.ts +3 -39
- package/package.json +4 -18
- package/scripts/init-project.js +2 -108
- package/scripts/make-module.js +1 -12
- package/scripts/seed-json.js +158 -0
- package/src/modules/Auth/auth.controller.ts +156 -106
- package/src/modules/Rbac/rbac.controller.ts +193 -138
- package/src/routes/index.ts +0 -3
- package/src/routes/rbac.ts +42 -42
- package/storage/logs/.0337f5062fe676994d1dc340156e089444e3d6e0-audit.json +5 -10
- package/storage/logs/lapeh-2025-12-30.log +1093 -0
- package/tsconfig.build.json +1 -3
- package/tsconfig.json +0 -1
- package/lib/core/database.ts +0 -5
- package/prisma/base.prisma.template +0 -8
- package/prisma/migrations/20251225163737_init/migration.sql +0 -236
- package/prisma/migrations/20251226000329_create_pets_table/migration.sql +0 -11
- package/prisma/migrations/20251226001249_create_pets_table/migration.sql +0 -82
- package/prisma/migrations/20251226001717_restore_core_models/migration.sql +0 -236
- package/prisma/migrations/migration_lock.toml +0 -3
- package/prisma/schema.prisma +0 -197
- package/prisma/seed.ts +0 -411
- package/scripts/compile-schema.js +0 -64
- package/src/modules/Auth/auth.prisma +0 -106
- package/src/modules/Pets/pets.controller.ts +0 -238
- package/src/modules/Pets/pets.prisma +0 -9
- package/src/modules/Rbac/rbac.prisma +0 -68
- package/src/routes/pets.ts +0 -13
- package/storage/logs/lapeh-2025-12-26.log +0 -88
- package/storage/logs/lapeh-2025-12-27.log +0 -217
package/doc/en/TUTORIAL.md
CHANGED
|
@@ -1,74 +1,51 @@
|
|
|
1
|
-
# Tutorial:
|
|
1
|
+
# Tutorial: Building a Library API
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
1. **CLI**
|
|
5
|
-
2. **Validator**
|
|
6
|
-
3. **Fast Serialization**
|
|
7
|
-
4. **RBAC** untuk proteksi delete (Admin only).
|
|
3
|
+
In this tutorial, we will build a simple "Book Management" feature using Lapeh Framework's core features:
|
|
4
|
+
1. **CLI** for code generation.
|
|
5
|
+
2. **Validator** for input validation.
|
|
6
|
+
3. **Fast Serialization** for high-performance responses.
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
> **Note**: This tutorial uses an in-memory array for data storage to keep things simple. Lapeh v3.0.0 is database-agnostic, so you can easily swap this with Prisma, TypeORM, or any other DB library.
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
## Step 1: Generate Module (Controller & Route)
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
npm run make:model Book
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
File baru akan muncul di `src/models/book.prisma`. Edit file tersebut:
|
|
18
|
-
|
|
19
|
-
```prisma
|
|
20
|
-
// src/models/book.prisma
|
|
21
|
-
|
|
22
|
-
model Book {
|
|
23
|
-
id BigInt @id @default(autoincrement())
|
|
24
|
-
title String
|
|
25
|
-
author String
|
|
26
|
-
isbn String @unique
|
|
27
|
-
publishedAt DateTime
|
|
28
|
-
stock Int @default(0)
|
|
29
|
-
created_at DateTime @default(now())
|
|
30
|
-
updated_at DateTime @updatedAt
|
|
31
|
-
|
|
32
|
-
@@map("books")
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Terapkan perubahan ke database:
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npm run prisma:migrate
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Langkah 2: Generate Module (Controller & Route)
|
|
43
|
-
|
|
44
|
-
Kita buat controller dan route sekaligus.
|
|
12
|
+
We will create a controller and route for our Book feature.
|
|
45
13
|
|
|
46
14
|
```bash
|
|
47
15
|
npm run make:module Book
|
|
48
16
|
```
|
|
49
17
|
|
|
50
|
-
|
|
18
|
+
The framework will generate:
|
|
51
19
|
- `src/controllers/bookController.ts`
|
|
52
20
|
- `src/routes/book.ts`
|
|
53
21
|
|
|
54
|
-
##
|
|
22
|
+
## Step 2: Implement Controller
|
|
55
23
|
|
|
56
|
-
|
|
24
|
+
Open `src/controllers/bookController.ts` and let's implement **Create** and **List** features.
|
|
57
25
|
|
|
58
|
-
### Setup Import &
|
|
26
|
+
### Setup Import & Data Store
|
|
59
27
|
|
|
60
28
|
```typescript
|
|
61
29
|
import { Request, Response } from "express";
|
|
62
|
-
import { prisma } from "@/core/database";
|
|
63
30
|
import { sendFastSuccess, sendError } from "@/utils/response";
|
|
64
31
|
import { Validator } from "@/utils/validator";
|
|
65
32
|
import { getSerializer, createResponseSchema } from "@/core/serializer";
|
|
66
33
|
|
|
67
|
-
//
|
|
34
|
+
// Simple in-memory store
|
|
35
|
+
interface Book {
|
|
36
|
+
id: string;
|
|
37
|
+
title: string;
|
|
38
|
+
author: string;
|
|
39
|
+
isbn: string;
|
|
40
|
+
stock: number;
|
|
41
|
+
}
|
|
42
|
+
const books: Book[] = [];
|
|
43
|
+
|
|
44
|
+
// 1. Define Output Schema (for Fastify Serialization)
|
|
68
45
|
const bookSchema = {
|
|
69
46
|
type: "object",
|
|
70
47
|
properties: {
|
|
71
|
-
id: { type: "string" },
|
|
48
|
+
id: { type: "string" },
|
|
72
49
|
title: { type: "string" },
|
|
73
50
|
author: { type: "string" },
|
|
74
51
|
isbn: { type: "string" },
|
|
@@ -76,7 +53,7 @@ const bookSchema = {
|
|
|
76
53
|
}
|
|
77
54
|
};
|
|
78
55
|
|
|
79
|
-
// 2.
|
|
56
|
+
// 2. Create Serializer
|
|
80
57
|
const bookDetailSerializer = getSerializer("book-detail", createResponseSchema(bookSchema));
|
|
81
58
|
const bookListSerializer = getSerializer("book-list", createResponseSchema({
|
|
82
59
|
type: "array",
|
|
@@ -84,109 +61,74 @@ const bookListSerializer = getSerializer("book-list", createResponseSchema({
|
|
|
84
61
|
}));
|
|
85
62
|
```
|
|
86
63
|
|
|
87
|
-
###
|
|
64
|
+
### Implement Create (with Validation)
|
|
88
65
|
|
|
89
66
|
```typescript
|
|
90
67
|
export async function createBook(req: Request, res: Response) {
|
|
91
|
-
// 1.
|
|
68
|
+
// 1. Validate Input
|
|
92
69
|
const validator = await Validator.make(req.body, {
|
|
93
70
|
title: "required|string|min:3",
|
|
94
71
|
author: "required|string",
|
|
95
|
-
isbn: "required|string
|
|
96
|
-
stock: "required|number|min:1"
|
|
97
|
-
publishedAt: "required|string" // Format tanggal ISO
|
|
72
|
+
isbn: "required|string",
|
|
73
|
+
stock: "required|number|min:1"
|
|
98
74
|
});
|
|
99
75
|
|
|
100
76
|
if (validator.fails()) {
|
|
101
77
|
return sendError(res, 400, "Validation Error", validator.errors());
|
|
102
78
|
}
|
|
103
79
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
author: data.author,
|
|
111
|
-
isbn: data.isbn,
|
|
112
|
-
stock: data.stock,
|
|
113
|
-
publishedAt: new Date(data.publishedAt)
|
|
114
|
-
}
|
|
115
|
-
});
|
|
80
|
+
// 2. Save Data (In-Memory)
|
|
81
|
+
const newBook: Book = {
|
|
82
|
+
id: Date.now().toString(),
|
|
83
|
+
...validator.validated()
|
|
84
|
+
};
|
|
85
|
+
books.push(newBook);
|
|
116
86
|
|
|
117
|
-
// 3.
|
|
118
|
-
return sendFastSuccess(res,
|
|
119
|
-
status: "success",
|
|
120
|
-
message: "Buku berhasil ditambahkan",
|
|
121
|
-
data: { ...book, id: book.id.toString() } // Konversi BigInt manual jika perlu
|
|
122
|
-
});
|
|
87
|
+
// 3. Send Response (Serialized)
|
|
88
|
+
return sendFastSuccess(res, bookDetailSerializer(newBook), 201);
|
|
123
89
|
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Implementasi List (High Performance)
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
export async function getBooks(req: Request, res: Response) {
|
|
130
|
-
const books = await prisma.book.findMany({
|
|
131
|
-
take: 50, // Limit 50
|
|
132
|
-
orderBy: { created_at: "desc" }
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
// Convert BigInt to string sebelum passing ke serializer (opsional, tapi aman)
|
|
136
|
-
const safeBooks = books.map(b => ({ ...b, id: b.id.toString() }));
|
|
137
90
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
data: safeBooks
|
|
142
|
-
});
|
|
91
|
+
export async function listBooks(req: Request, res: Response) {
|
|
92
|
+
// Return all books
|
|
93
|
+
return sendFastSuccess(res, bookListSerializer(books));
|
|
143
94
|
}
|
|
144
95
|
```
|
|
145
96
|
|
|
146
|
-
##
|
|
97
|
+
## Step 3: Register Route
|
|
147
98
|
|
|
148
|
-
|
|
99
|
+
Open `src/routes/book.ts`. The CLI has already generated the basic structure. We just need to connect it to our controller functions.
|
|
149
100
|
|
|
150
101
|
```typescript
|
|
151
102
|
import { Router } from "express";
|
|
152
|
-
import { createBook,
|
|
153
|
-
import { requireAuth, requireAdmin } from "../middleware/auth";
|
|
103
|
+
import { createBook, listBooks } from "../controllers/bookController";
|
|
154
104
|
|
|
155
|
-
|
|
105
|
+
const router = Router();
|
|
156
106
|
|
|
157
|
-
|
|
158
|
-
|
|
107
|
+
router.post("/", createBook);
|
|
108
|
+
router.get("/", listBooks);
|
|
159
109
|
|
|
160
|
-
|
|
161
|
-
bookRouter.post("/", requireAuth, requireAdmin, createBook);
|
|
110
|
+
export default router;
|
|
162
111
|
```
|
|
163
112
|
|
|
164
|
-
|
|
113
|
+
## Step 4: Test Your API
|
|
165
114
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
router.use("/books", bookRouter);
|
|
115
|
+
Run the server:
|
|
116
|
+
```bash
|
|
117
|
+
npm run dev
|
|
170
118
|
```
|
|
171
119
|
|
|
172
|
-
|
|
120
|
+
Test with curl or Postman:
|
|
173
121
|
|
|
174
|
-
|
|
122
|
+
**Create Book:**
|
|
175
123
|
```bash
|
|
176
|
-
|
|
124
|
+
curl -X POST http://localhost:4000/api/book \
|
|
125
|
+
-H "Content-Type: application/json" \
|
|
126
|
+
-d '{"title":"Lapeh Guide", "author":"Team", "isbn":"12345", "stock":10}'
|
|
177
127
|
```
|
|
178
128
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
4. **POST /api/books** (Token Admin + Data Valid) -> 201 Created.
|
|
184
|
-
5. **GET /api/books** -> 200 OK (Super Cepat).
|
|
185
|
-
|
|
186
|
-
## Kesimpulan
|
|
129
|
+
**List Books:**
|
|
130
|
+
```bash
|
|
131
|
+
curl http://localhost:4000/api/book
|
|
132
|
+
```
|
|
187
133
|
|
|
188
|
-
|
|
189
|
-
- **Aman** (Validasi, Auth, RBAC).
|
|
190
|
-
- **Cepat** (Fast Serialization).
|
|
191
|
-
- **Rapi** (Struktur terstandarisasi).
|
|
192
|
-
- **Mudah** (CLI Generator).
|
|
134
|
+
Congratulations! You have built a fast, validated API without getting bogged down in database configuration.
|
package/doc/id/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
File ini mencatat semua perubahan, pembaruan, dan perbaikan yang dilakukan pada framework Lapeh, diurutkan berdasarkan tanggal.
|
|
4
4
|
|
|
5
|
+
## [2025-12-30] - Selasa, 30 Desember 2025 - Major Release v3.0.0 (No-ORM)
|
|
6
|
+
|
|
7
|
+
### ⚠️ Perubahan Besar (Breaking Changes)
|
|
8
|
+
|
|
9
|
+
- **Penghapusan Prisma ORM**: Lapeh Framework kini **tidak lagi menyertakan ORM bawaan** (seperti Prisma). Kami memberikan kebebasan penuh kepada pengguna untuk memilih stack database mereka sendiri (Prisma, TypeORM, Drizzle, dll).
|
|
10
|
+
- **Update CLI**:
|
|
11
|
+
- `init`: Tidak lagi menanyakan konfigurasi database.
|
|
12
|
+
- `make:module`: Tidak lagi membuat file `.prisma`.
|
|
13
|
+
- Penghapusan script `compile-schema.js` dan logika terkait split-schema Prisma.
|
|
14
|
+
|
|
15
|
+
### 🚀 Fitur & Refactor
|
|
16
|
+
|
|
17
|
+
- **In-Memory Mock Data**: Modul bawaan (Auth, RBAC, Pets) kini menggunakan data dummy in-memory untuk demonstrasi tanpa perlu setup database.
|
|
18
|
+
- **Redis Caching**: Implementasi caching Redis pada Pets controller.
|
|
19
|
+
- **Dokumentasi**: Pembaruan menyeluruh pada dokumentasi untuk mencerminkan filosofi agnostik database.
|
|
20
|
+
|
|
5
21
|
## [2025-12-29] - Senin, 29 Desember 2025 - Perbaikan Bug CLI Init (v2.6.7)
|
|
6
22
|
|
|
7
23
|
### 🛠️ Perbaikan Bug
|
package/doc/id/CHEATSHEET.md
CHANGED
|
@@ -12,11 +12,7 @@ Referensi cepat untuk perintah dan kode yang sering digunakan.
|
|
|
12
12
|
| **`npm run lint:fix`** | Perbaiki kode kotor otomatis. |
|
|
13
13
|
| **`npm run make:module <Name>`** | Buat Controller, Route, & Model sekaligus. |
|
|
14
14
|
| **`npm run make:controller <Name>`** | Buat Controller saja. |
|
|
15
|
-
| **`npm run make:model <Name>`** | Buat Model Prisma saja. |
|
|
16
|
-
| **`npm run prisma:migrate`** | Apply perubahan schema ke DB lokal. |
|
|
17
|
-
| **`npm run db:studio`** | Buka GUI Database. |
|
|
18
15
|
| **`npm run db:seed`** | Isi data dummy. |
|
|
19
|
-
| **`npm run db:reset`** | Hapus DB & mulai dari nol. |
|
|
20
16
|
|
|
21
17
|
## 🛡️ Validator Rules (Simple Syntax)
|
|
22
18
|
|
package/doc/id/CLI.md
CHANGED
|
@@ -11,6 +11,7 @@ Semua perintah dijalankan menggunakan `npm run <command>`.
|
|
|
11
11
|
Perintah utama untuk menjalankan aplikasi:
|
|
12
12
|
|
|
13
13
|
### 1. Inisialisasi Project (`init`)
|
|
14
|
+
|
|
14
15
|
Membuat project baru dari awal.
|
|
15
16
|
|
|
16
17
|
```bash
|
|
@@ -18,11 +19,13 @@ npx lapeh@latest init <nama-project> [flags]
|
|
|
18
19
|
```
|
|
19
20
|
|
|
20
21
|
**Flag Tersedia:**
|
|
22
|
+
|
|
21
23
|
- `--full`: Inisialisasi dengan setup lengkap (termasuk dummy user, role, permission).
|
|
22
24
|
- `--default`: Inisialisasi dengan konfigurasi default (PostgreSQL) melewati prompt interaktif.
|
|
23
25
|
- `--y`: Alias untuk `--default`.
|
|
24
26
|
|
|
25
27
|
**Contoh:**
|
|
28
|
+
|
|
26
29
|
```bash
|
|
27
30
|
# Mode Interaktif
|
|
28
31
|
npx lapeh init my-app
|
|
@@ -35,17 +38,21 @@ npx lapeh init my-app --y
|
|
|
35
38
|
```
|
|
36
39
|
|
|
37
40
|
### 2. Upgrade Framework (`upgrade`)
|
|
41
|
+
|
|
38
42
|
Memperbarui framework Lapeh ke versi terbaru di project yang sudah ada.
|
|
39
43
|
|
|
40
44
|
```bash
|
|
41
45
|
npx lapeh upgrade
|
|
42
46
|
```
|
|
47
|
+
|
|
43
48
|
**Fitur:**
|
|
49
|
+
|
|
44
50
|
- Secara otomatis memperbarui dependensi `package.json`.
|
|
45
51
|
- Menyinkronkan file inti framework sambil menjaga kode kustom Anda.
|
|
46
52
|
- **Smart Dependency Handling**: Mempertahankan dependensi `file:` lokal jika Anda mengembangkan framework secara lokal, jika tidak akan mengupdate ke versi npm terbaru.
|
|
47
53
|
|
|
48
54
|
### 3. Development Server (`dev`)
|
|
55
|
+
|
|
49
56
|
Menjalankan server dalam mode development dengan fitur hot-reload.
|
|
50
57
|
|
|
51
58
|
```bash
|
|
@@ -55,6 +62,7 @@ npx lapeh dev
|
|
|
55
62
|
```
|
|
56
63
|
|
|
57
64
|
### 2. Production Server (`start`)
|
|
65
|
+
|
|
58
66
|
Menjalankan server dalam mode production (pastikan sudah dibuild).
|
|
59
67
|
|
|
60
68
|
```bash
|
|
@@ -64,6 +72,7 @@ npx lapeh start
|
|
|
64
72
|
```
|
|
65
73
|
|
|
66
74
|
### 3. Build Project (`build`)
|
|
75
|
+
|
|
67
76
|
Mengompilasi kode TypeScript ke JavaScript di folder `dist`.
|
|
68
77
|
|
|
69
78
|
```bash
|
|
@@ -77,89 +86,44 @@ npx lapeh build
|
|
|
77
86
|
Gunakan perintah ini untuk membuat file boilerplate secara otomatis.
|
|
78
87
|
|
|
79
88
|
### 1. Membuat Module Lengkap (`make:module`)
|
|
80
|
-
|
|
89
|
+
|
|
90
|
+
Membuat Controller dan Route sekaligus.
|
|
81
91
|
|
|
82
92
|
```bash
|
|
83
93
|
npm run make:module <nama-module>
|
|
84
94
|
```
|
|
95
|
+
|
|
85
96
|
**Contoh:** `npm run make:module Product`
|
|
86
97
|
|
|
87
98
|
Output:
|
|
99
|
+
|
|
88
100
|
- `src/controllers/productController.ts`
|
|
89
101
|
- `src/routes/product.ts`
|
|
90
|
-
- `src/models/product.prisma`
|
|
91
102
|
|
|
92
103
|
### 2. Membuat Controller (`make:controller`)
|
|
104
|
+
|
|
93
105
|
Hanya membuat file controller dengan method CRUD dasar.
|
|
94
106
|
|
|
95
107
|
```bash
|
|
96
108
|
npm run make:controller <nama-controller>
|
|
97
109
|
```
|
|
98
|
-
**Contoh:** `npm run make:controller Order` (Akan membuat `src/controllers/orderController.ts`)
|
|
99
|
-
|
|
100
|
-
### 3. Membuat Model Database (`make:model`)
|
|
101
|
-
Hanya membuat file schema Prisma baru.
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
npm run make:model <nama-model>
|
|
105
|
-
```
|
|
106
|
-
**Contoh:** `npm run make:model Transaction` (Akan membuat `src/models/transaction.prisma`)
|
|
107
|
-
|
|
108
|
-
## Database Management (Prisma)
|
|
109
|
-
|
|
110
|
-
Framework ini menggunakan sistem **Multi-File Schema**. Anda tidak mengedit `schema.prisma` secara langsung, melainkan mengedit file kecil di `src/models/*.prisma`.
|
|
111
|
-
|
|
112
|
-
### 1. Migrasi Database (`prisma:migrate`)
|
|
113
|
-
Jalankan setiap kali Anda mengubah definisi model di `src/models/*.prisma`.
|
|
114
|
-
|
|
115
|
-
```bash
|
|
116
|
-
npm run prisma:migrate
|
|
117
|
-
```
|
|
118
|
-
Perintah ini akan:
|
|
119
|
-
1. Menggabungkan semua file `.prisma` di `src/models/` menjadi satu `prisma/schema.prisma`.
|
|
120
|
-
2. Membuat file migrasi SQL.
|
|
121
|
-
3. Menerapkan perubahan ke database lokal.
|
|
122
|
-
4. Men-generate ulang Prisma Client (Type Definitions).
|
|
123
|
-
|
|
124
|
-
### 2. Deploy ke Production (`prisma:deploy`)
|
|
125
|
-
Gunakan di server production. Hanya menerapkan migrasi yang sudah ada tanpa reset data.
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
npm run prisma:deploy
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### 3. Database Studio (`db:studio`)
|
|
132
|
-
Membuka GUI di browser untuk melihat dan mengedit data database.
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
npm run db:studio
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### 4. Seeding Data (`db:seed`)
|
|
139
|
-
Mengisi database dengan data awal yang didefinisikan di `prisma/seed.ts`.
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
npm run db:seed
|
|
143
|
-
```
|
|
144
110
|
|
|
145
|
-
|
|
146
|
-
**PERINGATAN:** Menghapus semua data dan tabel, lalu menjalankan migrasi dari awal.
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
npm run db:reset
|
|
150
|
-
```
|
|
111
|
+
**Contoh:** `npm run make:controller Order` (Akan membuat `src/controllers/orderController.ts`)
|
|
151
112
|
|
|
152
113
|
## Code Quality & Utilities
|
|
153
114
|
|
|
154
115
|
### 1. Linting (`lint`)
|
|
116
|
+
|
|
155
117
|
Memeriksa kode dari error, variabel tidak terpakai, dan gaya penulisan.
|
|
156
118
|
|
|
157
119
|
```bash
|
|
158
120
|
npm run lint
|
|
159
121
|
```
|
|
122
|
+
|
|
160
123
|
Gunakan `npm run lint:fix` untuk memperbaiki error otomatis.
|
|
161
124
|
|
|
162
125
|
### 2. Type Check (`typecheck`)
|
|
126
|
+
|
|
163
127
|
Memeriksa error tipe data TypeScript tanpa melakukan compile.
|
|
164
128
|
|
|
165
129
|
```bash
|
|
@@ -167,6 +131,7 @@ npm run typecheck
|
|
|
167
131
|
```
|
|
168
132
|
|
|
169
133
|
### 3. Generate JWT Secret (`generate:jwt`)
|
|
134
|
+
|
|
170
135
|
Membuat random string aman untuk `JWT_SECRET` di file `.env`.
|
|
171
136
|
|
|
172
137
|
```bash
|