@trapi/metadata 0.1.2 → 0.1.6
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/dist/cache/driver.js +1 -2
- package/dist/cache/driver.js.map +1 -1
- package/dist/cache/utils.d.ts.map +1 -1
- package/dist/cache/utils.js +12 -12
- package/dist/cache/utils.js.map +1 -1
- package/dist/decorator/index.d.ts +1 -1
- package/dist/decorator/index.d.ts.map +1 -1
- package/dist/decorator/index.js +1 -3
- package/dist/decorator/index.js.map +1 -1
- package/dist/decorator/mapper/index.js +1 -2
- package/dist/decorator/mapper/index.js.map +1 -1
- package/dist/decorator/representation/index.js +2 -4
- package/dist/decorator/representation/index.js.map +1 -1
- package/dist/decorator/representation/property/utils.js +4 -3
- package/dist/decorator/representation/property/utils.js.map +1 -1
- package/dist/generator/controller.js +1 -1
- package/dist/generator/controller.js.map +1 -1
- package/dist/generator/endpoint.js +0 -3
- package/dist/generator/endpoint.js.map +1 -1
- package/dist/generator/index.d.ts +5 -33
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +15 -151
- package/dist/generator/index.js.map +1 -1
- package/dist/generator/method.js +0 -2
- package/dist/generator/method.js.map +1 -1
- package/dist/generator/module.d.ts +41 -0
- package/dist/generator/module.d.ts.map +1 -0
- package/dist/generator/module.js +166 -0
- package/dist/generator/module.js.map +1 -0
- package/dist/generator/parameter.js +1 -9
- package/dist/generator/parameter.js.map +1 -1
- package/dist/resolver/type-node.js +28 -61
- package/dist/resolver/type-node.js.map +1 -1
- package/dist/resolver/utils/initializer.d.ts.map +1 -1
- package/dist/resolver/utils/initializer.js +2 -1
- package/dist/resolver/utils/initializer.js.map +1 -1
- package/dist/resolver/utils/validator.js +2 -1
- package/dist/resolver/utils/validator.js.map +1 -1
- package/dist/type.d.ts +5 -0
- package/dist/type.d.ts.map +1 -1
- package/dist/utils/generator.js +1 -1
- package/dist/utils/generator.js.map +1 -1
- package/dist/utils/js-doc.js +1 -1
- package/dist/utils/js-doc.js.map +1 -1
- package/package.json +18 -12
- package/src/cache/driver.ts +0 -97
- package/src/cache/index.ts +0 -10
- package/src/cache/type.ts +0 -43
- package/src/cache/utils.ts +0 -49
- package/src/config/index.ts +0 -8
- package/src/config/path.ts +0 -29
- package/src/decorator/functions.ts +0 -142
- package/src/decorator/index.ts +0 -13
- package/src/decorator/mapper/index.ts +0 -153
- package/src/decorator/mapper/maps/decorators-express.ts +0 -117
- package/src/decorator/mapper/maps/internal.ts +0 -95
- package/src/decorator/mapper/maps/typescript-rest.ts +0 -150
- package/src/decorator/mapper/utils.ts +0 -88
- package/src/decorator/representation/index.ts +0 -82
- package/src/decorator/representation/property/utils.ts +0 -146
- package/src/decorator/type.ts +0 -235
- package/src/decorator/utils/index.ts +0 -9
- package/src/decorator/utils/node.ts +0 -59
- package/src/decorator/utils/validator.ts +0 -104
- package/src/generator/controller.ts +0 -65
- package/src/generator/endpoint.ts +0 -212
- package/src/generator/index.ts +0 -219
- package/src/generator/method.ts +0 -198
- package/src/generator/parameter.ts +0 -392
- package/src/index.ts +0 -13
- package/src/resolver/error.ts +0 -38
- package/src/resolver/index.ts +0 -11
- package/src/resolver/type-node.ts +0 -1287
- package/src/resolver/type.ts +0 -257
- package/src/resolver/utils/index.ts +0 -9
- package/src/resolver/utils/initializer.ts +0 -81
- package/src/resolver/utils/validator.ts +0 -144
- package/src/type.ts +0 -185
- package/src/utils/generator.ts +0 -42
- package/src/utils/index.ts +0 -10
- package/src/utils/js-doc.ts +0 -125
- package/src/utils/validator.ts +0 -43
- package/test/data/library/@decorators-express/decorators.ts +0 -7
- package/test/data/library/self/api.ts +0 -37
- package/test/data/library/type.ts +0 -138
- package/test/data/library/typescript-rest/api.ts +0 -366
- package/test/data/library/typescript-rest/decorators/index.ts +0 -10
- package/test/data/library/typescript-rest/decorators/methods.ts +0 -34
- package/test/data/library/typescript-rest/decorators/parameters.ts +0 -62
- package/test/data/library/typescript-rest/decorators/services.ts +0 -47
- package/test/data/library/typescript-rest/return-types.ts +0 -94
- package/test/data/library/utils.ts +0 -7
- package/test/jest.config.js +0 -49
- package/test/unit/cache.spec.ts +0 -48
- package/test/unit/decorator/mapper/index.spec.ts +0 -83
- package/test/unit/decorator/representation/index.spec.ts +0 -102
- package/test/unit/decorator/utils/node.spec.ts +0 -47
- package/test/unit/library/typescript-rest.spec.ts +0 -342
- package/test/unit/resolver/type.spec.ts +0 -134
- package/test/unit/utils/generator.spec.ts +0 -41
- package/test/unit/utils/js-doc.spec.ts +0 -95
- package/tsconfig.build.json +0 -11
- package/tsconfig.json +0 -9
- package/writable/.gitignore +0 -3
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021.
|
|
3
|
-
* Author Peter Placzek (tada5hi)
|
|
4
|
-
* For the full copyright and license information,
|
|
5
|
-
* view the LICENSE file that was distributed with this source code.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
Accept, DELETE, FormParam, GET, Path,
|
|
12
|
-
PathParam, POST, PUT, QueryParam,
|
|
13
|
-
Security
|
|
14
|
-
} from './decorators';
|
|
15
|
-
import * as Return from './return-types';
|
|
16
|
-
import * as swagger from '../../../../src/decorator';
|
|
17
|
-
import {
|
|
18
|
-
BasicModel,
|
|
19
|
-
MyDataType2,
|
|
20
|
-
MyTypeWithUnion,
|
|
21
|
-
NamedEntity,
|
|
22
|
-
Person,
|
|
23
|
-
PrimitiveClassModel,
|
|
24
|
-
PrimitiveInterfaceModel,
|
|
25
|
-
ResponseBody,
|
|
26
|
-
SimpleHelloType,
|
|
27
|
-
TestEnum,
|
|
28
|
-
TestInterface,
|
|
29
|
-
TestMixedEnum,
|
|
30
|
-
TestNumericEnum
|
|
31
|
-
} from "../type";
|
|
32
|
-
|
|
33
|
-
@Path('unionTypes')
|
|
34
|
-
export class TestUnionType {
|
|
35
|
-
@POST
|
|
36
|
-
public post(body: MyTypeWithUnion): string {
|
|
37
|
-
return '42';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@Accept('text/plain')
|
|
42
|
-
@Path('mypath')
|
|
43
|
-
@swagger.SwaggerTags('My Services')
|
|
44
|
-
export class MyService {
|
|
45
|
-
@swagger.ResponseDescription<string>('default', 'Error')
|
|
46
|
-
@swagger.ResponseDescription<string>(400, 'The request format was incorrect.')
|
|
47
|
-
@swagger.ResponseDescription<string>(500, 'There was an unexpected error.')
|
|
48
|
-
@GET
|
|
49
|
-
@Accept('text/html')
|
|
50
|
-
public test(): string {
|
|
51
|
-
return 'OK';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* This is the method description
|
|
56
|
-
* @param test This is the test param description
|
|
57
|
-
* @param test2
|
|
58
|
-
* @param test3
|
|
59
|
-
* @param test4
|
|
60
|
-
* @param test5
|
|
61
|
-
* @param test6
|
|
62
|
-
*/
|
|
63
|
-
@GET
|
|
64
|
-
@Path('secondpath')
|
|
65
|
-
@swagger.ResponseExample<Person>({
|
|
66
|
-
name: 'Joe'
|
|
67
|
-
})
|
|
68
|
-
@swagger.ResponseDescription<Person>(200, 'The success test.')
|
|
69
|
-
public test2(
|
|
70
|
-
@QueryParam('testRequired') test: string,
|
|
71
|
-
@QueryParam('testDefault') test2: string = 'value',
|
|
72
|
-
@QueryParam('testOptional') test3?: string,
|
|
73
|
-
@QueryParam('testEnum') test4?: TestEnum,
|
|
74
|
-
@QueryParam('testNumericEnum') test5?: TestNumericEnum,
|
|
75
|
-
@QueryParam('testMixedEnum') test6?: TestMixedEnum
|
|
76
|
-
): Person {
|
|
77
|
-
return { name: 'OK' };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@POST
|
|
81
|
-
@swagger.ResponseExample<Person[]>([{
|
|
82
|
-
name: 'Joe'
|
|
83
|
-
}])
|
|
84
|
-
public testPostString(body: string): Person[] {
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
@Path('obj')
|
|
89
|
-
@POST
|
|
90
|
-
public testPostObject(data: object) {
|
|
91
|
-
return data;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
@GET
|
|
95
|
-
@Path('multi-query')
|
|
96
|
-
public testMultiQuery(
|
|
97
|
-
@QueryParam('id') ids: string[],
|
|
98
|
-
@QueryParam('name'/*, { collectionFormat: 'multi', allowEmptyValue: true }*/) names?: string | string[]
|
|
99
|
-
) {
|
|
100
|
-
return { ids: ids, names: names };
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
@GET
|
|
104
|
-
@Path('default-query')
|
|
105
|
-
public testDefaultQuery(
|
|
106
|
-
@QueryParam('num') num: number = 5,
|
|
107
|
-
@QueryParam('str') str: string = 'default value',
|
|
108
|
-
@QueryParam('bool1') bool1: boolean = true,
|
|
109
|
-
@QueryParam('bool2') bool2: boolean = false,
|
|
110
|
-
@QueryParam('arr') arr: string[] = ['a', 'b', 'c']
|
|
111
|
-
) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
@POST
|
|
116
|
-
@Path('test-compiler-options')
|
|
117
|
-
public async testCompilerOptions(payload: TestInterface): Promise<TestInterface> {
|
|
118
|
-
return { a: 'string', b: 123 };
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
@POST
|
|
122
|
-
@Path('test-form-param')
|
|
123
|
-
public testFormParam(@FormParam('id') id: string): string {
|
|
124
|
-
return id;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
class BaseService {
|
|
129
|
-
@DELETE
|
|
130
|
-
@Path(':id')
|
|
131
|
-
public testDelete(@PathParam('id') id: string): Promise<void> {
|
|
132
|
-
return new Promise<void>((resolve, reject) => {
|
|
133
|
-
resolve();
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
@Path('promise')
|
|
139
|
-
export class PromiseService extends BaseService {
|
|
140
|
-
/**
|
|
141
|
-
* Esta eh a da classe
|
|
142
|
-
* @param test Esta eh a description do param teste
|
|
143
|
-
*/
|
|
144
|
-
@swagger.ResponseDescription<string>(401, 'Unauthorized')
|
|
145
|
-
@GET
|
|
146
|
-
public test(@QueryParam('testParam') test?: string): Promise<Person> {
|
|
147
|
-
return new Promise<Person>((resolve, reject) => {
|
|
148
|
-
resolve({ name: 'OK' });
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
@swagger.ResponseDescription<Person>(200, 'All Good')
|
|
153
|
-
@swagger.ResponseDescription<string>(401, 'Unauthorized')
|
|
154
|
-
@swagger.ResponseExample<Person>({ name: 'Test Person' })
|
|
155
|
-
@GET
|
|
156
|
-
@Path(':id')
|
|
157
|
-
public testGetSingle(@PathParam('id') id: string): Promise<Person> {
|
|
158
|
-
return new Promise<Person>((resolve, reject) => {
|
|
159
|
-
resolve({ name: 'OK' });
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
@swagger.ResponseDescription<Person>(201, 'Person Created', { name: 'Test Person' })
|
|
164
|
-
@swagger.ResponseDescription<string>(401, 'Unauthorized')
|
|
165
|
-
@swagger.ResponseExample<Person>({ name: 'Example Person' }) // NOTE: this is here to test that it doesn't overwrite the example in the @Response above
|
|
166
|
-
@POST
|
|
167
|
-
public testPost(obj: Person): Promise<Return.NewResource<Person>> {
|
|
168
|
-
return new Promise<Return.NewResource<Person>>((resolve, reject) => {
|
|
169
|
-
resolve(new Return.NewResource<Person>('id', { name: 'OK' }));
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
@GET
|
|
174
|
-
@Path('myFile')
|
|
175
|
-
@swagger.ResponseProduces('application/pdf')
|
|
176
|
-
public testFile(@QueryParam('testParam') test?: string): Promise<Return.DownloadBinaryData> {
|
|
177
|
-
return new Promise<Return.DownloadBinaryData>((resolve, reject) => {
|
|
178
|
-
resolve(null);
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export class BasicEndpoint<T extends BasicModel> {
|
|
184
|
-
|
|
185
|
-
protected list(@QueryParam('full') full?: boolean): Promise<T[]> {
|
|
186
|
-
return new Promise((resolve, reject) => {
|
|
187
|
-
// todo
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
@POST
|
|
192
|
-
protected save(entity: T): Promise<Return.NewResource<number>> {
|
|
193
|
-
return new Promise((resolve, reject) => {
|
|
194
|
-
// todo
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
@PUT
|
|
199
|
-
@Path('/:id')
|
|
200
|
-
protected update(@PathParam('id') id: number, entity: T): Promise<void> {
|
|
201
|
-
return new Promise((resolve, reject) => {
|
|
202
|
-
// todo
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
@DELETE
|
|
207
|
-
@Path('/:id')
|
|
208
|
-
protected remove(@PathParam('id') id: string): Promise<void> {
|
|
209
|
-
return new Promise((resolve, reject) => {
|
|
210
|
-
// todo
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
@GET
|
|
215
|
-
@Path('/:id')
|
|
216
|
-
protected get(@PathParam('id') id: string): Promise<T> {
|
|
217
|
-
return new Promise((resolve, reject) => {
|
|
218
|
-
// todo
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export interface MyDatatype extends BasicModel {
|
|
224
|
-
property1: string;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
@Path('generics1')
|
|
228
|
-
export class DerivedEndpoint extends BasicEndpoint<MyDatatype> {
|
|
229
|
-
|
|
230
|
-
@GET
|
|
231
|
-
@Path(':param')
|
|
232
|
-
protected test(@PathParam('param') param: string): Promise<void> {
|
|
233
|
-
return new Promise<void>((resolve, reject) => {
|
|
234
|
-
// content
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
@Path('generics2')
|
|
240
|
-
export class DerivedEndpoint2 {
|
|
241
|
-
|
|
242
|
-
@GET
|
|
243
|
-
@Path(':param')
|
|
244
|
-
protected test(@PathParam('param') param: string): Promise<MyDataType2> {
|
|
245
|
-
return new Promise<MyDataType2>((resolve, reject) => {
|
|
246
|
-
// content
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
@Path('type')
|
|
252
|
-
export class TypeEndpoint {
|
|
253
|
-
|
|
254
|
-
@GET
|
|
255
|
-
@Path(':param')
|
|
256
|
-
public test(@PathParam('param') param: string): Promise<MyDataType2> {
|
|
257
|
-
return new Promise<MyDataType2>((resolve, reject) => {
|
|
258
|
-
// content
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
@GET
|
|
263
|
-
@Path(':param/2')
|
|
264
|
-
public test2(@PathParam('param') param: string): Promise<SimpleHelloType> {
|
|
265
|
-
return new Promise<SimpleHelloType>((resolve, reject) => {
|
|
266
|
-
// content
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
@Path('primitives')
|
|
272
|
-
export class PrimitiveEndpoint {
|
|
273
|
-
|
|
274
|
-
@Path('/class')
|
|
275
|
-
@GET
|
|
276
|
-
public getClass(): PrimitiveClassModel {
|
|
277
|
-
return new PrimitiveClassModel();
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
@Path('/interface')
|
|
281
|
-
@GET
|
|
282
|
-
public testInterface(): PrimitiveInterfaceModel {
|
|
283
|
-
return {};
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
@Path(':id')
|
|
287
|
-
@GET
|
|
288
|
-
public getById(@PathParam('id') @swagger.IsLong id: number) {
|
|
289
|
-
// ...
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
@Path('/arrayNative')
|
|
293
|
-
@GET
|
|
294
|
-
// tslint:disable-next-line:array-type
|
|
295
|
-
public getArrayNative(): ResponseBody<string[]> {
|
|
296
|
-
return { data: ['hello', 'world'] };
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
@Path('/array')
|
|
300
|
-
@GET
|
|
301
|
-
public getArray(): ResponseBody<string[]> {
|
|
302
|
-
return { data: ['hello', 'world'] };
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
@Path('parameterized/:objectId')
|
|
307
|
-
export class ParameterizedEndpoint {
|
|
308
|
-
|
|
309
|
-
@Path('/test')
|
|
310
|
-
@GET
|
|
311
|
-
public test(@PathParam('objectId') objectId: string): PrimitiveClassModel {
|
|
312
|
-
return new PrimitiveClassModel();
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
@Path('abstract')
|
|
317
|
-
export class AbstractEntityEndpoint {
|
|
318
|
-
@GET
|
|
319
|
-
public get(): NamedEntity {
|
|
320
|
-
return new NamedEntity();
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
@Path('secure')
|
|
325
|
-
@Security(['ROLE_1', 'ROLE_2'], 'access_token')
|
|
326
|
-
export class SecureEndpoint {
|
|
327
|
-
@GET
|
|
328
|
-
public get(): string {
|
|
329
|
-
return 'Access Granted';
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
@POST
|
|
333
|
-
@Security([], 'user_email')
|
|
334
|
-
public post(): string {
|
|
335
|
-
return 'Posted';
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
@Path('supersecure')
|
|
340
|
-
@Security('access_token')
|
|
341
|
-
@Security('user_email')
|
|
342
|
-
@Security()
|
|
343
|
-
export class SuperSecureEndpoint {
|
|
344
|
-
@GET
|
|
345
|
-
public get(): string {
|
|
346
|
-
return 'Access Granted';
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
@Path('response')
|
|
351
|
-
@swagger.ResponseDescription<string>(400, 'The request format was incorrect.')
|
|
352
|
-
@swagger.ResponseDescription<string>(500, 'There was an unexpected error.')
|
|
353
|
-
export class ResponseController {
|
|
354
|
-
@GET
|
|
355
|
-
public get(): string {
|
|
356
|
-
return '42';
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
@swagger.ResponseDescription<string>(401, 'Unauthorized.')
|
|
360
|
-
@swagger.ResponseDescription<string>(502, 'Internal server error.')
|
|
361
|
-
@GET
|
|
362
|
-
@Path('/test')
|
|
363
|
-
public test(): string {
|
|
364
|
-
return 'OK';
|
|
365
|
-
}
|
|
366
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021.
|
|
3
|
-
* Author Peter Placzek (tada5hi)
|
|
4
|
-
* For the full copyright and license information,
|
|
5
|
-
* view the LICENSE file that was distributed with this source code.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export * from './methods';
|
|
9
|
-
export * from './parameters';
|
|
10
|
-
export * from './services';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021.
|
|
3
|
-
* Author Peter Placzek (tada5hi)
|
|
4
|
-
* For the full copyright and license information,
|
|
5
|
-
* view the LICENSE file that was distributed with this source code.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export function GET(target: any, propertyKey: string) {
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function POST(target: any, propertyKey: string) {
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function PUT(target: any, propertyKey: string) {
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function DELETE(target: any, propertyKey: string) {
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function HEAD(target: any, propertyKey: string) {
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function OPTIONS(target: any, propertyKey: string) {
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function PATCH(target: any, propertyKey: string) {
|
|
33
|
-
|
|
34
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021.
|
|
3
|
-
* Author Peter Placzek (tada5hi)
|
|
4
|
-
* For the full copyright and license information,
|
|
5
|
-
* view the LICENSE file that was distributed with this source code.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export function Context(...args: Array<any>) {
|
|
9
|
-
return () => { return; };
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function ContextRequest(...args: Array<any>) {
|
|
13
|
-
return () => { return; };
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function ContextResponse(...args: Array<any>) {
|
|
17
|
-
return () => { return; };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function ContextNext(...args: Array<any>) {
|
|
21
|
-
return () => { return; };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function ContextLanguage(...args: Array<any>) {
|
|
25
|
-
return () => { return; };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function ContextAccept(...args: Array<any>) {
|
|
29
|
-
return () => { return; };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function PathParam(name: string) {
|
|
33
|
-
return (...args) => { return; };
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function FileParam(name: string) {
|
|
37
|
-
return (...args) => { return; };
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function FilesParam(name: string) {
|
|
41
|
-
return (...args) => { return; };
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function QueryParam(name: string) {
|
|
45
|
-
return (...args) => { return; };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function HeaderParam(name: string) {
|
|
49
|
-
return (...args) => { return; };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function CookieParam(name: string) {
|
|
53
|
-
return (...args) => { return; };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function FormParam(name: string) {
|
|
57
|
-
return (...args) => { return; };
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function Param(name: string) {
|
|
61
|
-
return (...args) => { return; };
|
|
62
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021.
|
|
3
|
-
* Author Peter Placzek (tada5hi)
|
|
4
|
-
* For the full copyright and license information,
|
|
5
|
-
* view the LICENSE file that was distributed with this source code.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export function Path(path: string) {
|
|
9
|
-
return (...args) => { return; };
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function Security(roles?: string | Array<string>, name?: string) {
|
|
13
|
-
return (...args) => { return; };
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function PreProcessor<T>(preprocessor: T) {
|
|
17
|
-
return () => { return; };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function PostProcessor<T>(preprocessor: T) {
|
|
21
|
-
return () => { return; };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function AcceptLanguage(...languages: Array<string>) {
|
|
25
|
-
return () => { return; };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function Accept(...accepts: Array<string>) {
|
|
29
|
-
return (...args) => { return; };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function BodyOptions(options: any) {
|
|
33
|
-
return () => { return; };
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function BodyType<T>(type: T) {
|
|
37
|
-
return () => { return; };
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function IgnoreNextMiddlewares(...args: Array<any>) {
|
|
41
|
-
return () => { return; };
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// like SWAGGER_HIDDEN
|
|
45
|
-
export function Abstract(...args: Array<any>) {
|
|
46
|
-
return () => { return; };
|
|
47
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021.
|
|
3
|
-
* Author Peter Placzek (tada5hi)
|
|
4
|
-
* For the full copyright and license information,
|
|
5
|
-
* view the LICENSE file that was distributed with this source code.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export abstract class ReferencedResource<T> {
|
|
9
|
-
/**
|
|
10
|
-
* the body to be sent
|
|
11
|
-
*/
|
|
12
|
-
public body: T;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Constructor. Receives the location of the resource.
|
|
16
|
-
* @param location To be added to the Location header on response
|
|
17
|
-
* @param statusCode the response status code to be sent
|
|
18
|
-
*/
|
|
19
|
-
protected constructor(public location: string, public statusCode: number) { }
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export class NewResource<T> extends ReferencedResource<T> {
|
|
23
|
-
/**
|
|
24
|
-
* Constructor. Receives the location of the new resource created.
|
|
25
|
-
* @param location To be added to the Location header on response
|
|
26
|
-
* @param body To be added to the response body
|
|
27
|
-
*/
|
|
28
|
-
constructor(location: string, body?: T) {
|
|
29
|
-
super(location, 201);
|
|
30
|
-
this.body = body;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Inform that the request was accepted but is not completed.
|
|
36
|
-
* A Location header should inform the location where the user
|
|
37
|
-
* can monitor his request processing status.
|
|
38
|
-
*/
|
|
39
|
-
export class RequestAccepted<T> extends ReferencedResource<T> {
|
|
40
|
-
/**
|
|
41
|
-
* Constructor. Receives the location where information about the
|
|
42
|
-
* request processing can be found.
|
|
43
|
-
* @param location To be added to the Location header on response
|
|
44
|
-
* @param body To be added to the response body
|
|
45
|
-
*/
|
|
46
|
-
constructor(location: string, body?: T) {
|
|
47
|
-
super(location, 202);
|
|
48
|
-
this.body = body;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Inform that the resource has permanently
|
|
54
|
-
* moved to a new location, and that future references should use a
|
|
55
|
-
* new URI with their requests.
|
|
56
|
-
*/
|
|
57
|
-
export class MovedPermanently<T> extends ReferencedResource<T> {
|
|
58
|
-
/**
|
|
59
|
-
* Constructor. Receives the location where the resource can be found.
|
|
60
|
-
* @param location To be added to the Location header on response
|
|
61
|
-
* @param body To be added to the response body
|
|
62
|
-
*/
|
|
63
|
-
constructor(location: string, body?: T) {
|
|
64
|
-
super(location, 301);
|
|
65
|
-
this.body = body;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Inform that the resource has temporarily
|
|
71
|
-
* moved to another location, but that future references should
|
|
72
|
-
* still use the original URI to access the resource.
|
|
73
|
-
*/
|
|
74
|
-
export class MovedTemporarily<T> extends ReferencedResource<T> {
|
|
75
|
-
/**
|
|
76
|
-
* Constructor. Receives the location where the resource can be found.
|
|
77
|
-
* @param location To be added to the Location header on response
|
|
78
|
-
* @param body To be added to the response body
|
|
79
|
-
*/
|
|
80
|
-
constructor(location: string, body?: T) {
|
|
81
|
-
super(location, 302);
|
|
82
|
-
this.body = body;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export class DownloadResource {
|
|
87
|
-
constructor(public filePath: string, public fileName: string) { }
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export class DownloadBinaryData {
|
|
91
|
-
constructor(public content: Buffer, public mimeType: string, public fileName?: string) { }
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export const NoResponse = {};
|
package/test/jest.config.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021.
|
|
3
|
-
* Author Peter Placzek (tada5hi)
|
|
4
|
-
* For the full copyright and license information,
|
|
5
|
-
* view the LICENSE file that was distributed with this source code.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
testEnvironment: 'node',
|
|
10
|
-
transform: {
|
|
11
|
-
"^.+\\.tsx?$": "ts-jest"
|
|
12
|
-
},
|
|
13
|
-
moduleFileExtensions: [
|
|
14
|
-
"ts",
|
|
15
|
-
"tsx",
|
|
16
|
-
"js",
|
|
17
|
-
"jsx",
|
|
18
|
-
"json",
|
|
19
|
-
"node",
|
|
20
|
-
],
|
|
21
|
-
testRegex: '(/unit/.*|(\\.|/)(test|spec))\\.(ts|js)x?$',
|
|
22
|
-
testPathIgnorePatterns: [
|
|
23
|
-
"writable",
|
|
24
|
-
"dist",
|
|
25
|
-
"/unit/mock-util.ts"
|
|
26
|
-
],
|
|
27
|
-
coverageDirectory: 'writable/coverage',
|
|
28
|
-
collectCoverageFrom: [
|
|
29
|
-
'src/**/*.{ts,tsx,js,jsx}',
|
|
30
|
-
'!src/**/*.d.ts',
|
|
31
|
-
'!src/decorator/functions.ts',
|
|
32
|
-
'!src/decorator/mapper/maps/**/*.{ts,js,json,yml}',
|
|
33
|
-
'!src/decorator/utils/validator.ts',
|
|
34
|
-
// the resolver actually uses exclusive typescript functions
|
|
35
|
-
// and to debug them, we need to rebuild the compiler ^^.
|
|
36
|
-
'!src/resolver/**/*.ts',
|
|
37
|
-
'!src/utils/validator.ts'
|
|
38
|
-
],
|
|
39
|
-
coverageThreshold: {
|
|
40
|
-
global: {
|
|
41
|
-
branches: 58,
|
|
42
|
-
functions: 77,
|
|
43
|
-
lines: 73,
|
|
44
|
-
statements: 73
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
rootDir: '../',
|
|
48
|
-
verbose: true
|
|
49
|
-
};
|