lapeh 2.4.7 → 2.4.8

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.
@@ -10,11 +10,11 @@ export declare class Validator {
10
10
  /**
11
11
  * Create a new Validator instance
12
12
  * @param data The input data to validate
13
- * @param schema Zod schema or object of Zod schemas / Laravel-style rules
14
- * @param messages Optional custom error messages (Laravel style: 'field.rule' => 'message')
13
+ * @param schema Zod schema or object of Zod schemas / string-based rules
14
+ * @param messages Optional custom error messages (style: 'field.rule' => 'message')
15
15
  */
16
16
  static make(data: any, schema: ZodSchema<any> | Record<string, any>, messages?: Record<string, string>): Validator;
17
- private static parseLaravelRule;
17
+ private static parseStringRule;
18
18
  /**
19
19
  * Check if validation fails
20
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../lib/utils/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,SAAS,EAAsB,MAAM,KAAK,CAAC;AAGvD,qBAAa,SAAS;IACpB,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,MAAM,CAAkB;gBAG9B,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5C,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAavC;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CACT,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5C,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAiDvC,OAAO,CAAC,MAAM,CAAC,gBAAg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,8 @@ class Validator {
21
21
  /**
22
22
  * Create a new Validator instance
23
23
  * @param data The input data to validate
24
- * @param schema Zod schema or object of Zod schemas / Laravel-style rules
25
- * @param messages Optional custom error messages (Laravel style: 'field.rule' => 'message')
24
+ * @param schema Zod schema or object of Zod schemas / string-based rules
25
+ * @param messages Optional custom error messages (style: 'field.rule' => 'message')
26
26
  */
27
27
  static make(data, schema, messages = {}) {
28
28
  if (schema instanceof zod_1.ZodSchema) {
@@ -44,7 +44,7 @@ class Validator {
44
44
  sameRules.push({ field: key, target: args });
45
45
  }
46
46
  }
47
- parsedSchema[key] = Validator.parseLaravelRule(rule);
47
+ parsedSchema[key] = Validator.parseStringRule(rule);
48
48
  }
49
49
  else {
50
50
  parsedSchema[key] = rule;
@@ -66,7 +66,7 @@ class Validator {
66
66
  }
67
67
  return new Validator(data, objectSchema, messages);
68
68
  }
69
- static parseLaravelRule(rule) {
69
+ static parseStringRule(rule) {
70
70
  const rules = Array.isArray(rule)
71
71
  ? rule
72
72
  : rule.split("|").map((r) => r.trim());
@@ -61,8 +61,8 @@ File ini mencatat semua perubahan, pembaruan, dan perbaikan yang dilakukan pada
61
61
 
62
62
  ### 🚀 Fitur Baru
63
63
 
64
- - **Laravel-style Validator**:
65
- - Implementasi utility `Validator` baru di `src/utils/validator.ts` yang meniru gaya validasi Laravel.
64
+ - **Expressive Validator**:
65
+ - Implementasi utility `Validator` baru di `src/utils/validator.ts` dengan gaya validasi yang lebih ekspresif.
66
66
  - Mendukung rule string seperti `required|string|min:3|email`.
67
67
  - Penambahan rule `unique` untuk pengecekan database otomatis (Prisma).
68
68
  - Penambahan rule `mimes`, `image`, `max` (file size) untuk validasi upload file.
@@ -18,7 +18,7 @@ Referensi cepat untuk perintah dan kode yang sering digunakan.
18
18
  | **`npm run db:seed`** | Isi data dummy. |
19
19
  | **`npm run db:reset`** | Hapus DB & mulai dari nol. |
20
20
 
21
- ## 🛡️ Validator Rules (Laravel-Style)
21
+ ## 🛡️ Validator Rules (Simple Syntax)
22
22
 
23
23
  Gunakan di `Validator.make(data, rules)`.
24
24
 
@@ -2,9 +2,9 @@
2
2
 
3
3
  This document explains the key features of Lapeh Framework and how to use them in depth.
4
4
 
5
- ## 1. Data Validation (Laravel-Style)
5
+ ## 1. Data Validation (Simple & Powerful)
6
6
 
7
- The framework provides a `Validator` utility inspired by Laravel, using `zod` behind the scenes but with an API that is more string-based and readable.
7
+ The framework provides a `Validator` utility inspired by expressive modern validation styles, using `zod` behind the scenes but with an API that is more string-based and readable.
8
8
 
9
9
  **Location:** `@lapeh/utils/validator`
10
10
 
@@ -42,7 +42,7 @@ export async function createProduct(req: Request, res: Response) {
42
42
  - `image`: File must be an image (jpg, png, webp, etc).
43
43
  - `mimes:types`: File must be a specific type (e.g., `mimes:pdf,docx`).
44
44
 
45
- ## 2. High Performance Response (Fastify-Style)
45
+ ## 2. High Performance Response (Fastify-Like)
46
46
 
47
47
  For endpoints requiring high performance (e.g., large data lists), use schema-based serialization. This is much faster than standard Express `res.json`.
48
48
 
@@ -4,33 +4,35 @@
4
4
 
5
5
  **Lapeh** is a Backend Framework for Node.js built on top of **Express** and **TypeScript**.
6
6
 
7
- If you have ever used **Laravel** (PHP) or **NestJS** (Node.js), you will feel very familiar. Lapeh adopts the philosophy of ease-of-use & clean structure from Laravel, while maintaining the flexibility and speed of Express.
7
+ If you have ever used other modern frameworks, you will feel very familiar. Lapeh adopts the philosophy of ease-of-use & clean structure, while maintaining the flexibility and speed of Express.
8
8
 
9
9
  The name "Lapeh" comes from the Minang language which means "Loose" or "Free", symbolizing the freedom for developers to build applications quickly without being burdened by complicated configurations.
10
10
 
11
11
  ## Why was Lapeh Created?
12
12
 
13
13
  In the Node.js ecosystem, developers often experience "Decision Fatigue":
14
+
14
15
  - "Which ORM to use? Prisma, TypeORM, or Drizzle?"
15
16
  - "Validation using Joi, Zod, or express-validator?"
16
17
  - "How about the folder structure? MVC? Clean Architecture?"
17
18
  - "How to handle Auth?"
18
19
 
19
20
  Lapeh answers all of that with **Opinionated Defaults**:
21
+
20
22
  1. **ORM**: Prisma (Current industry standard).
21
- 2. **Validation**: Zod (with Laravel-style wrapper syntax).
23
+ 2. **Validation**: Zod (Powerful and readable schema validation).
22
24
  3. **Structure**: Modular MVC (Controller, Model, Route separated but cohesive).
23
25
  4. **Auth**: Ready-to-use JWT + RBAC (Role Based Access Control).
24
26
 
25
27
  ## Comparison with Other Frameworks
26
28
 
27
- | Feature | Express (Raw) | NestJS | Lapeh Framework |
28
- | :--- | :--- | :--- | :--- |
29
+ | Feature | Express (Raw) | NestJS | Lapeh Framework |
30
+ | :----------------- | :---------------------------- | :------------------------------- | :------------------------------------- |
29
31
  | **Learning Curve** | Low (but confusing structure) | High (Angular-style, Decorators) | **Medium** (Express + Clear Structure) |
30
- | **Boilerplate** | Empty | Very Heavy | **Just Right (Ready to use)** |
31
- | **Type Safety** | Manual | Strict | **Strict (Native TypeScript)** |
32
- | **Dev Speed** | Slow (manual setup) | Medium | **Fast (CLI Generator)** |
33
- | **Flexibility** | Very High | Rigid | **High** |
32
+ | **Boilerplate** | Empty | Very Heavy | **Just Right (Ready to use)** |
33
+ | **Type Safety** | Manual | Strict | **Strict (Native TypeScript)** |
34
+ | **Dev Speed** | Slow (manual setup) | Medium | **Fast (CLI Generator)** |
35
+ | **Flexibility** | Very High | Rigid | **High** |
34
36
 
35
37
  ## "The Lapeh Way" Philosophy
36
38
 
@@ -67,7 +67,7 @@ Built-in framework middleware.
67
67
 
68
68
  Built-in Helper functions.
69
69
 
70
- - `validator.ts`: Laravel-style input validation.
70
+ - `validator.ts`: Powerful and expressive input validation.
71
71
  - `response.ts`: Standard JSON response format (`sendFastSuccess`, `sendError`).
72
72
  - `logger.ts`: Logging system (Winston).
73
73
 
@@ -61,8 +61,8 @@ File ini mencatat semua perubahan, pembaruan, dan perbaikan yang dilakukan pada
61
61
 
62
62
  ### 🚀 Fitur Baru
63
63
 
64
- - **Laravel-style Validator**:
65
- - Implementasi utility `Validator` baru di `src/utils/validator.ts` yang meniru gaya validasi Laravel.
64
+ - **Expressive Validator**:
65
+ - Implementasi utility `Validator` baru di `src/utils/validator.ts` dengan gaya validasi yang lebih ekspresif.
66
66
  - Mendukung rule string seperti `required|string|min:3|email`.
67
67
  - Penambahan rule `unique` untuk pengecekan database otomatis (Prisma).
68
68
  - Penambahan rule `mimes`, `image`, `max` (file size) untuk validasi upload file.
@@ -18,7 +18,7 @@ Referensi cepat untuk perintah dan kode yang sering digunakan.
18
18
  | **`npm run db:seed`** | Isi data dummy. |
19
19
  | **`npm run db:reset`** | Hapus DB & mulai dari nol. |
20
20
 
21
- ## 🛡️ Validator Rules (Laravel-Style)
21
+ ## 🛡️ Validator Rules (Simple Syntax)
22
22
 
23
23
  Gunakan di `Validator.make(data, rules)`.
24
24
 
@@ -2,9 +2,11 @@
2
2
 
3
3
  Dokumen ini menjelaskan fitur-fitur utama Lapeh Framework dan cara penggunaannya secara mendalam.
4
4
 
5
- ## 1. Validasi Data (Laravel-Style)
5
+ 3. **Explicit is Better than Implicit**: Tidak ada "sihir" yang terlalu gelap. Kode controller Anda adalah kode Express biasa yang Anda mengerti.
6
6
 
7
- Framework ini menyediakan utility `Validator` yang terinspirasi dari Laravel, menggunakan `zod` di belakang layar namun dengan API yang lebih string-based dan mudah dibaca.
7
+ ## 1. Validasi Data (Simple & Powerful)
8
+
9
+ Framework ini menyediakan utility `Validator` yang terinspirasi dari gaya validasi modern yang ekspresif, menggunakan `zod` di belakang layar namun dengan API yang lebih string-based dan mudah dibaca.
8
10
 
9
11
  **Lokasi:** `@lapeh/utils/validator`
10
12
 
@@ -42,7 +44,7 @@ export async function createProduct(req: Request, res: Response) {
42
44
  - `image`: File harus berupa gambar (jpg, png, webp, dll).
43
45
  - `mimes:types`: File harus tipe tertentu (misal: `mimes:pdf,docx`).
44
46
 
45
- ## 2. High Performance Response (Fastify-Style)
47
+ ## 2. High Performance Response (Fastify-Like)
46
48
 
47
49
  Untuk endpoint yang membutuhkan performa tinggi (misalnya list data besar), gunakan serialisasi berbasis schema. Ini jauh lebih cepat daripada `res.json` standar Express.
48
50
 
@@ -4,33 +4,35 @@
4
4
 
5
5
  **Lapeh** adalah framework Backend untuk Node.js yang dibangun di atas **Express** dan **TypeScript**.
6
6
 
7
- Jika Anda pernah menggunakan **Laravel** (PHP) atau **NestJS** (Node.js), Anda akan merasa sangat familiar. Lapeh mengambil filosofi kemudahan & struktur rapi dari Laravel, namun tetap mempertahankan fleksibilitas dan kecepatan Express.
7
+ Jika Anda pernah menggunakan framework modern lainnya, Anda akan merasa sangat familiar. Lapeh mengambil filosofi kemudahan & struktur rapi, namun tetap mempertahankan fleksibilitas dan kecepatan Express.
8
8
 
9
9
  Nama "Lapeh" diambil dari bahasa Minang yang berarti "Lepas" atau "Bebas", melambangkan kebebasan developer untuk membangun aplikasi dengan cepat tanpa terbebani konfigurasi yang rumit.
10
10
 
11
11
  ## Mengapa Lapeh Dibuat?
12
12
 
13
13
  Di ekosistem Node.js, developer sering mengalami "Decision Fatigue" (Kelelahan memilih):
14
+
14
15
  - "Pakai ORM apa? Prisma, TypeORM, atau Drizzle?"
15
16
  - "Validasi pakai Joi, Zod, atau express-validator?"
16
17
  - "Struktur foldernya gimana? MVC? Clean Architecture?"
17
18
  - "Auth-nya gimana?"
18
19
 
19
20
  Lapeh menjawab semua itu dengan **Opinionated Defaults**:
21
+
20
22
  1. **ORM**: Prisma (Standar industri saat ini).
21
- 2. **Validasi**: Zod (dengan wrapper syntax ala Laravel).
23
+ 2. **Validasi**: Zod (Validasi skema yang kuat dan mudah dibaca).
22
24
  3. **Struktur**: MVC Modular (Controller, Model, Route terpisah tapi kohesif).
23
25
  4. **Auth**: JWT + RBAC (Role Based Access Control) siap pakai.
24
26
 
25
27
  ## Perbandingan dengan Framework Lain
26
28
 
27
- | Fitur | Express (Raw) | NestJS | Lapeh Framework |
28
- | :--- | :--- | :--- | :--- |
29
+ | Fitur | Express (Raw) | NestJS | Lapeh Framework |
30
+ | :----------------- | :----------------------------- | :--------------------------------- | :------------------------------------ |
29
31
  | **Learning Curve** | Rendah (tapi bingung struktur) | Tinggi (Angular-style, Decorators) | **Sedang** (Express + Struktur Jelas) |
30
- | **Boilerplate** | Kosong | Sangat Banyak | **Pas (Ready to use)** |
31
- | **Type Safety** | Manual | Strict | **Strict (TypeScript Native)** |
32
- | **Kecepatan Dev** | Lambat (setup manual) | Sedang | **Cepat (CLI Generator)** |
33
- | **Fleksibilitas** | Sangat Tinggi | Kaku | **Tinggi** |
32
+ | **Boilerplate** | Kosong | Sangat Banyak | **Pas (Ready to use)** |
33
+ | **Type Safety** | Manual | Strict | **Strict (TypeScript Native)** |
34
+ | **Kecepatan Dev** | Lambat (setup manual) | Sedang | **Cepat (CLI Generator)** |
35
+ | **Fleksibilitas** | Sangat Tinggi | Kaku | **Tinggi** |
34
36
 
35
37
  ## Filosofi "The Lapeh Way"
36
38
 
@@ -67,7 +67,7 @@ Middleware bawaan framework.
67
67
 
68
68
  Fungsi bantuan (Helper) bawaan.
69
69
 
70
- - `validator.ts`: Validasi input ala Laravel.
70
+ - `validator.ts`: Validasi input yang kuat dan ekspresif.
71
71
  - `response.ts`: Standar format JSON response (`sendFastSuccess`, `sendError`).
72
72
  - `logger.ts`: Sistem logging (Winston).
73
73
 
@@ -28,8 +28,8 @@ export class Validator {
28
28
  /**
29
29
  * Create a new Validator instance
30
30
  * @param data The input data to validate
31
- * @param schema Zod schema or object of Zod schemas / Laravel-style rules
32
- * @param messages Optional custom error messages (Laravel style: 'field.rule' => 'message')
31
+ * @param schema Zod schema or object of Zod schemas / string-based rules
32
+ * @param messages Optional custom error messages (style: 'field.rule' => 'message')
33
33
  */
34
34
  static make(
35
35
  data: any,
@@ -58,7 +58,7 @@ export class Validator {
58
58
  }
59
59
  }
60
60
 
61
- parsedSchema[key] = Validator.parseLaravelRule(rule);
61
+ parsedSchema[key] = Validator.parseStringRule(rule);
62
62
  } else {
63
63
  parsedSchema[key] = rule as ZodSchema;
64
64
  }
@@ -83,7 +83,7 @@ export class Validator {
83
83
  return new Validator(data, objectSchema, messages);
84
84
  }
85
85
 
86
- private static parseLaravelRule(rule: string | string[]): ZodSchema {
86
+ private static parseStringRule(rule: string | string[]): ZodSchema {
87
87
  const rules = Array.isArray(rule)
88
88
  ? rule
89
89
  : rule.split("|").map((r) => r.trim());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lapeh",
3
- "version": "2.4.7",
3
+ "version": "2.4.8",
4
4
  "description": "Framework API Express yang siap pakai (Standardized)",
5
5
  "main": "dist/lib/bootstrap.js",
6
6
  "bin": {
@@ -77,10 +77,10 @@
77
77
  "lapeh",
78
78
  "roby-ajo",
79
79
  "ajo-roby",
80
- "roby-karti-s",
80
+ "robyajo",
81
81
  "lapeh"
82
82
  ],
83
- "author": "Roby Karti S <robyfull.dev@gmail.com>",
83
+ "author": "robyajo <robyfull.dev@gmail.com>",
84
84
  "license": "MIT",
85
85
  "type": "commonjs",
86
86
  "dependencies": {
package/readme.md CHANGED
@@ -9,7 +9,7 @@ Cocok untuk developer yang mencari **Express boilerplate** dengan fitur lengkap:
9
9
  - **Production Ready**: Struktur folder modular (MVC) yang mudah dikembangkan.
10
10
  - **TypeScript First**: Full type-safety untuk mengurangi runtime error.
11
11
  - **Prisma ORM Integration**: Database modern dengan dukungan PostgreSQL dan MySQL.
12
- - **Laravel-style Structure**: Controller, Service, dan Route yang terpisah rapi.
12
+ - **Standardized Structure**: Controller, Service, dan Route yang terpisah rapi.
13
13
  - **Auto CLI Generator**: Buat modul, model, dan controller dengan satu perintah.
14
14
  - **Smart Caching**: Otomatis menggunakan Redis jika tersedia, fallback ke in-memory jika tidak.
15
15
  - **Secure by Default**: Dilengkapi Helmet, Rate Limiting, CORS, dan JWT Auth.