deco-express 0.1.0 → 0.1.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 +8 -8
- package/package.json +50 -50
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ npm install deco-express reflect-metadata
|
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
18
|
// src/main.ts
|
|
19
|
-
import
|
|
19
|
+
import 'reflect-metadata';
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
Also ensure your `tsconfig.json` includes:
|
|
@@ -35,25 +35,25 @@ Also ensure your `tsconfig.json` includes:
|
|
|
35
35
|
## Quick Start
|
|
36
36
|
|
|
37
37
|
```ts
|
|
38
|
-
import
|
|
39
|
-
import express from
|
|
40
|
-
import Joi from
|
|
41
|
-
import { Controller, Route, Validate, defineRoutes } from
|
|
38
|
+
import 'reflect-metadata';
|
|
39
|
+
import express from 'express';
|
|
40
|
+
import Joi from 'joi';
|
|
41
|
+
import { Controller, Route, Validate, defineRoutes } from 'deco-express';
|
|
42
42
|
|
|
43
43
|
const createUserSchema = Joi.object({
|
|
44
44
|
name: Joi.string().required(),
|
|
45
45
|
email: Joi.string().email().required(),
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
@Controller(
|
|
48
|
+
@Controller('/users')
|
|
49
49
|
class UserController {
|
|
50
|
-
@Route(
|
|
50
|
+
@Route('get', '/list')
|
|
51
51
|
async list(req, res) {
|
|
52
52
|
res.json({ users: [] });
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
@Validate(createUserSchema)
|
|
56
|
-
@Route(
|
|
56
|
+
@Route('post', '/create')
|
|
57
57
|
async create(req, res) {
|
|
58
58
|
res.status(201).json({ created: req.body });
|
|
59
59
|
}
|
package/package.json
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
2
|
+
"name": "deco-express",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"author": "ndrolp",
|
|
5
|
+
"description": "Decorator-based utilities for building Express.js REST APIs in TypeScript",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsup",
|
|
11
|
+
"test": "vitest run",
|
|
12
|
+
"test:watch": "vitest",
|
|
13
|
+
"test:coverage": "vitest run --coverage",
|
|
14
|
+
"lint": "eslint src",
|
|
15
|
+
"lint:fix": "eslint src --fix",
|
|
16
|
+
"format": "prettier --write src",
|
|
17
|
+
"format:check": "prettier --check src"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"express",
|
|
21
|
+
"typescript",
|
|
22
|
+
"decorators",
|
|
23
|
+
"rest",
|
|
24
|
+
"api",
|
|
25
|
+
"controller",
|
|
26
|
+
"routing",
|
|
27
|
+
"joi",
|
|
28
|
+
"validation"
|
|
29
|
+
],
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@eslint/js": "^10.0.1",
|
|
36
|
+
"@types/express": "^5.0.1",
|
|
37
|
+
"@types/node": "^22.15.17",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^8.57.0",
|
|
39
|
+
"@typescript-eslint/parser": "^8.57.0",
|
|
40
|
+
"eslint": "^10.0.3",
|
|
41
|
+
"eslint-config-prettier": "^10.1.8",
|
|
42
|
+
"prettier": "^3.8.1",
|
|
43
|
+
"tsup": "^8.4.0",
|
|
44
|
+
"typescript": "^5.8.3",
|
|
45
|
+
"vitest": "^3.1.1"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"express": "^5.1.0",
|
|
49
|
+
"joi": "^17.13.3",
|
|
50
|
+
"reflect-metadata": "^0.2.2"
|
|
51
|
+
}
|
|
52
52
|
}
|