@tsed/common 6.100.3 → 6.102.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/package.json +24 -16
- package/readme.md +54 -41
- package/tsconfig.compile.esm.json +1 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/common",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.102.2",
|
|
4
4
|
"description": "A TypeScript Framework on top of Express",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -59,22 +59,21 @@
|
|
|
59
59
|
}
|
|
60
60
|
],
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@tsed/components-scan": "6.
|
|
63
|
-
"@tsed/core": "6.
|
|
64
|
-
"@tsed/di": "6.
|
|
65
|
-
"@tsed/exceptions": "6.
|
|
66
|
-
"@tsed/json-mapper": "6.
|
|
62
|
+
"@tsed/components-scan": "6.102.2",
|
|
63
|
+
"@tsed/core": "6.102.2",
|
|
64
|
+
"@tsed/di": "6.102.2",
|
|
65
|
+
"@tsed/exceptions": "6.102.2",
|
|
66
|
+
"@tsed/json-mapper": "6.102.2",
|
|
67
67
|
"@tsed/logger": "^6.0.0",
|
|
68
68
|
"@tsed/logger-file": "^6.0.0",
|
|
69
|
-
"@tsed/
|
|
70
|
-
"@tsed/platform-
|
|
71
|
-
"@tsed/platform-
|
|
72
|
-
"@tsed/platform-
|
|
73
|
-
"@tsed/platform-
|
|
74
|
-
"@tsed/platform-
|
|
75
|
-
"@tsed/platform-
|
|
76
|
-
"@tsed/
|
|
77
|
-
"@tsed/schema": "6.100.3",
|
|
69
|
+
"@tsed/platform-cache": "6.102.2",
|
|
70
|
+
"@tsed/platform-exceptions": "6.102.2",
|
|
71
|
+
"@tsed/platform-log-middleware": "6.102.2",
|
|
72
|
+
"@tsed/platform-middlewares": "6.102.2",
|
|
73
|
+
"@tsed/platform-params": "6.102.2",
|
|
74
|
+
"@tsed/platform-response-filter": "6.102.2",
|
|
75
|
+
"@tsed/platform-views": "6.102.2",
|
|
76
|
+
"@tsed/schema": "6.102.2",
|
|
78
77
|
"@types/json-schema": "7.0.7",
|
|
79
78
|
"on-finished": "2.3.0",
|
|
80
79
|
"tslib": "2.2.0",
|
|
@@ -83,5 +82,14 @@
|
|
|
83
82
|
"devDependencies": {
|
|
84
83
|
"rxjs": "^6.5.2"
|
|
85
84
|
},
|
|
86
|
-
"peerDependencies": {
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"@tsed/components-scan": ">=6.102.1",
|
|
87
|
+
"@tsed/core": ">=6.102.1",
|
|
88
|
+
"@tsed/di": ">=6.102.1",
|
|
89
|
+
"@tsed/exceptions": ">=6.102.1",
|
|
90
|
+
"@tsed/json-mapper": ">=6.102.1",
|
|
91
|
+
"@tsed/logger": ">=6.0.0",
|
|
92
|
+
"@tsed/logger-file": ">=6.0.0",
|
|
93
|
+
"@tsed/schema": ">=6.102.1"
|
|
94
|
+
}
|
|
87
95
|
}
|
package/readme.md
CHANGED
|
@@ -31,32 +31,32 @@
|
|
|
31
31
|
|
|
32
32
|
## What it is
|
|
33
33
|
|
|
34
|
-
Ts.ED is a framework on top of Express that helps you to write your application in TypeScript (or in ES6). It provides a lot of decorators
|
|
34
|
+
Ts.ED is a framework on top of Express that helps you to write your application in TypeScript (or in ES6). It provides a lot of decorators
|
|
35
35
|
to make your code more readable and less error-prone.
|
|
36
36
|
|
|
37
37
|
## Features
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
- Use our CLI to create a new project https://cli.tsed.io
|
|
40
|
+
- Support TypeORM, Mongoose, GraphQL, Socket.io, Swagger-ui, Passport.js, etc...
|
|
41
|
+
- Define class as Controller,
|
|
42
|
+
- Define class as Service (IoC),
|
|
43
|
+
- Define class as Middleware and MiddlewareError,
|
|
44
|
+
- Define class as Converter (POJ to Model and Model to POJ),
|
|
45
|
+
- Define root path for an entire controller and versioning your Rest API,
|
|
46
|
+
- Define as sub-route path for a method,
|
|
47
|
+
- Define routes on GET, POST, PUT, DELETE and HEAD verbs,
|
|
48
|
+
- Define middlewares on routes,
|
|
49
|
+
- Define required parameters,
|
|
50
|
+
- Inject data from query string, path parameters, entire body, cookies, session or header,
|
|
51
|
+
- Inject Request, Response, Next object from Express request,
|
|
52
|
+
- Template (View),
|
|
53
|
+
- Testing.
|
|
54
54
|
|
|
55
55
|
## Documentation
|
|
56
56
|
|
|
57
57
|
Documentation is available on [https://tsed.io](https://tsed.io)
|
|
58
58
|
|
|
59
|
-
## Getting started
|
|
59
|
+
## Getting started
|
|
60
60
|
|
|
61
61
|
See our [getting started here](https://tsed.io/getting-started/) to create new Ts.ED project or use
|
|
62
62
|
our [CLI](https://cli.tsed.io)
|
|
@@ -65,8 +65,8 @@ our [CLI](https://cli.tsed.io)
|
|
|
65
65
|
|
|
66
66
|
Examples are available on [https://tsed.io/tutorials/](https://tsed.io/tutorials/)
|
|
67
67
|
|
|
68
|
-
|
|
69
68
|
## Overview
|
|
69
|
+
|
|
70
70
|
### Server example
|
|
71
71
|
|
|
72
72
|
Here an example to create a Server with Ts.ED:
|
|
@@ -75,7 +75,7 @@ Here an example to create a Server with Ts.ED:
|
|
|
75
75
|
import {Configuration, Inject} from "@tsed/di";
|
|
76
76
|
import {PlatformApplication} from "@tsed/common";
|
|
77
77
|
import "@tsed/platform-express";
|
|
78
|
-
import * as Path from "path";
|
|
78
|
+
import * as Path from "path";
|
|
79
79
|
|
|
80
80
|
export const rootDir = Path.resolve(__dirname);
|
|
81
81
|
|
|
@@ -88,24 +88,26 @@ export class Server {
|
|
|
88
88
|
app: PlatformApplication;
|
|
89
89
|
|
|
90
90
|
public $beforeRoutesInit() {
|
|
91
|
-
const cookieParser = require(
|
|
92
|
-
bodyParser = require(
|
|
93
|
-
compress = require(
|
|
94
|
-
methodOverride = require(
|
|
95
|
-
|
|
91
|
+
const cookieParser = require("cookie-parser"),
|
|
92
|
+
bodyParser = require("body-parser"),
|
|
93
|
+
compress = require("compression"),
|
|
94
|
+
methodOverride = require("method-override");
|
|
95
|
+
|
|
96
96
|
this.app
|
|
97
97
|
.use(cookieParser())
|
|
98
98
|
.use(compress({}))
|
|
99
99
|
.use(methodOverride())
|
|
100
100
|
.use(bodyParser.json())
|
|
101
|
-
.use(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
.use(
|
|
102
|
+
bodyParser.urlencoded({
|
|
103
|
+
extended: true
|
|
104
|
+
})
|
|
105
|
+
);
|
|
106
|
+
}
|
|
105
107
|
}
|
|
106
108
|
```
|
|
107
109
|
|
|
108
|
-
To run your server, you have to use Platform API to bootstrap your application with the expected
|
|
110
|
+
To run your server, you have to use Platform API to bootstrap your application with the expected
|
|
109
111
|
platform like Express.
|
|
110
112
|
|
|
111
113
|
```typescript
|
|
@@ -137,10 +139,23 @@ This is a simple controller to expose user resource. It use decorators to build
|
|
|
137
139
|
```typescript
|
|
138
140
|
import {Inject} from "@tsed/di";
|
|
139
141
|
import {Summary} from "@tsed/swagger";
|
|
140
|
-
import {
|
|
142
|
+
import {
|
|
143
|
+
Returns,
|
|
144
|
+
ReturnsArray,
|
|
145
|
+
Controller,
|
|
146
|
+
Get,
|
|
147
|
+
QueryParams,
|
|
148
|
+
PathParams,
|
|
149
|
+
Delete,
|
|
150
|
+
Post,
|
|
151
|
+
Required,
|
|
152
|
+
BodyParams,
|
|
153
|
+
Status,
|
|
154
|
+
Put
|
|
155
|
+
} from "@tsed/common";
|
|
141
156
|
import {BadRequest} from "@tsed/exceptions";
|
|
142
157
|
import {UsersService} from "../services/UsersService";
|
|
143
|
-
import {User} from "../models/User";
|
|
158
|
+
import {User} from "../models/User";
|
|
144
159
|
|
|
145
160
|
@Controller("/users")
|
|
146
161
|
export class UsersCtrl {
|
|
@@ -151,7 +166,7 @@ export class UsersCtrl {
|
|
|
151
166
|
@Summary("Get a user from his Id")
|
|
152
167
|
@Returns(User)
|
|
153
168
|
async getUser(@PathParams("id") id: string): Promise<User> {
|
|
154
|
-
|
|
169
|
+
return this.usersService.findById(id);
|
|
155
170
|
}
|
|
156
171
|
|
|
157
172
|
@Post("/")
|
|
@@ -168,41 +183,40 @@ export class UsersCtrl {
|
|
|
168
183
|
@Returns(User)
|
|
169
184
|
async putUser(@PathParams("id") id: string, @Required() @BodyParams() user: User): Promise<User> {
|
|
170
185
|
if (user.id !== id) {
|
|
171
|
-
throw new BadRequest("ID mismatch with the given payload")
|
|
186
|
+
throw new BadRequest("ID mismatch with the given payload");
|
|
172
187
|
}
|
|
173
188
|
|
|
174
189
|
return this.usersService.save(user);
|
|
175
190
|
}
|
|
176
|
-
|
|
191
|
+
|
|
177
192
|
@Delete("/:id")
|
|
178
193
|
@Summary("Remove a user")
|
|
179
194
|
@Status(204)
|
|
180
|
-
async deleteUser(@PathParams("id") @Required() id: string
|
|
181
|
-
|
|
195
|
+
async deleteUser(@PathParams("id") @Required() id: string): Promise<User> {
|
|
196
|
+
await this.usersService.delete(user);
|
|
182
197
|
}
|
|
183
|
-
|
|
198
|
+
|
|
184
199
|
@Get("/")
|
|
185
200
|
@Summary("Get all users")
|
|
186
201
|
@ReturnsArray(User)
|
|
187
|
-
async findUser(@QueryParams("name") name: string){
|
|
202
|
+
async findUser(@QueryParams("name") name: string) {
|
|
188
203
|
return this.usersService.find({name});
|
|
189
204
|
}
|
|
190
205
|
}
|
|
191
206
|
```
|
|
192
207
|
|
|
193
208
|
## Contributors
|
|
209
|
+
|
|
194
210
|
Please read [contributing guidelines here](./CONTRIBUTING.md).
|
|
195
211
|
|
|
196
212
|
<a href="https://github.com/tsedio/tsed/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
|
|
197
213
|
|
|
198
|
-
|
|
199
214
|
## Backers
|
|
200
215
|
|
|
201
216
|
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
|
|
202
217
|
|
|
203
218
|
<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/tiers/backer.svg?width=890"></a>
|
|
204
219
|
|
|
205
|
-
|
|
206
220
|
## Sponsors
|
|
207
221
|
|
|
208
222
|
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
|
|
@@ -220,4 +234,3 @@ The above copyright notice and this permission notice shall be included in all c
|
|
|
220
234
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
221
235
|
|
|
222
236
|
[travis]: https://travis-ci.org/
|
|
223
|
-
|
|
@@ -8,16 +8,5 @@
|
|
|
8
8
|
"declaration": true,
|
|
9
9
|
"declarationDir": "./lib/types"
|
|
10
10
|
},
|
|
11
|
-
"exclude": [
|
|
12
|
-
"node_modules",
|
|
13
|
-
"test",
|
|
14
|
-
"lib",
|
|
15
|
-
"benchmark",
|
|
16
|
-
"coverage",
|
|
17
|
-
"spec",
|
|
18
|
-
"**/*.benchmark.ts",
|
|
19
|
-
"**/*.spec.ts",
|
|
20
|
-
"keys",
|
|
21
|
-
"jest.config.js"
|
|
22
|
-
]
|
|
11
|
+
"exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
|
|
23
12
|
}
|