@galeh/chuka 1.0.8 → 1.0.10
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 +27 -58
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,77 +1,46 @@
|
|
|
1
|
-
#
|
|
2
|
-
This package aims at making the API programming much easier, using the expressjs as underlying library, it creates fast API's. It adds leverages expressjs by adding strong types, dependency injection and profound validation.
|
|
1
|
+
# @galeh/chuka
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
🚀 **Introducing @galeh/chuka - Empowering Express.js for Effortless API Development!**
|
|
5
4
|
|
|
5
|
+
@galeh/chuka is a powerful package designed to enhance your Express.js experience, making API development faster, stronger, and more straightforward. 🌐✨
|
|
6
|
+
|
|
7
|
+
## Key Features
|
|
8
|
+
|
|
9
|
+
- ✅ **Strong Types:** Say goodbye to runtime errors with strong typing for a more robust development experience.
|
|
10
|
+
- 🔄 **Dependency Injection:** Streamline your application's architecture by effortlessly injecting dependencies.
|
|
11
|
+
- 🔍 **Profound Validation:** Simplify data validation with expressive and comprehensive validation capabilities.
|
|
12
|
+
|
|
13
|
+
## Getting Started
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @galeh/chuka
|
|
17
|
+
```
|
|
6
18
|
```typescript
|
|
7
19
|
// main.ts
|
|
20
|
+
import { createApp, json } from '@galeh/chuka';
|
|
21
|
+
import { CatsController, CatsService } from './your-modules'; // Customize based on your project structure
|
|
22
|
+
|
|
8
23
|
const app = createApp({
|
|
9
24
|
dependencies: [
|
|
10
|
-
{
|
|
11
|
-
|
|
12
|
-
useClass: CatsService
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
routes: [
|
|
16
|
-
{
|
|
17
|
-
path: '/cats',
|
|
18
|
-
controller: CatsController
|
|
19
|
-
}
|
|
25
|
+
{ provide: 'catservice', useClass: CatsService },
|
|
26
|
+
// Add more dependencies as needed
|
|
20
27
|
],
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
]
|
|
28
|
+
routes: [{ path: '/cats', controller: CatsController }],
|
|
29
|
+
middlewares: [json()],
|
|
24
30
|
});
|
|
25
31
|
|
|
26
32
|
app.use((error: any, req: any, res: any, next: any) => {
|
|
27
33
|
res.status(400).json(error);
|
|
28
|
-
})
|
|
34
|
+
});
|
|
29
35
|
|
|
30
36
|
app.listen(8080, () => {
|
|
31
|
-
console.log('
|
|
37
|
+
console.log('🚀 Running @galeh/chuka application on port 8080!');
|
|
32
38
|
});
|
|
33
39
|
|
|
34
40
|
```
|
|
41
|
+
Explore the possibilities and experience a new level of Express.js development with [@galeh/chuka](https://www.npmjs.com/package/@galeh/chuka). 🌟
|
|
35
42
|
|
|
36
|
-
```typescript
|
|
37
|
-
// example for a controller
|
|
38
|
-
|
|
39
|
-
@injectable()
|
|
40
|
-
export class CatsController extends Controller {
|
|
41
|
-
constructor(@inject('catservice') service: CatsServiceInterface) {
|
|
42
|
-
super();
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
createLogger()
|
|
46
|
-
);
|
|
44
|
+
GitHub Repository | npm Package
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
bodyValidator<CatModel>({
|
|
50
|
-
name: and(isDefined(), isString()),
|
|
51
|
-
country: isNumber(),
|
|
52
|
-
age: custom(model => Promise.resolve(!!(model.age && model.age > 2))),
|
|
53
|
-
parents: {
|
|
54
|
-
name: isString(),
|
|
55
|
-
parents: {
|
|
56
|
-
country: isString(),
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
).post('/', async (req, res) => {{
|
|
61
|
-
const allcats = await service.add(req.body.name);
|
|
62
|
-
res.send(allcats);
|
|
63
|
-
}});
|
|
64
|
-
|
|
65
|
-
intercepted.get('/', async (req, res) => {{
|
|
66
|
-
const allcats = await service.findAll();
|
|
67
|
-
res.send(allcats);
|
|
68
|
-
}});
|
|
69
|
-
|
|
70
|
-
intercepted.get('/:id', async (req, res) => {
|
|
71
|
-
const onecat = await service.findOne(+req.params.id);
|
|
72
|
-
res.send(onecat);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
```
|
|
46
|
+
Feel the power of Chuka in your Express.js applications! 🔥🚀
|