tspace-spear 1.2.8 → 1.2.9

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.
Files changed (74) hide show
  1. package/README.md +253 -71
  2. package/dist/cli/generators/app/index.js.map +1 -1
  3. package/dist/cli/generators/controller/template.d.ts +1 -1
  4. package/dist/cli/generators/controller/template.js +15 -8
  5. package/dist/cli/generators/controller/template.js.map +1 -1
  6. package/dist/cli/generators/dto/index.js +5 -3
  7. package/dist/cli/generators/dto/index.js.map +1 -1
  8. package/dist/cli/generators/module/index.js +3 -3
  9. package/dist/cli/generators/service/template.d.ts +1 -1
  10. package/dist/cli/generators/service/template.js +17 -17
  11. package/dist/cli/index.js +1 -0
  12. package/dist/cli/index.js.map +1 -1
  13. package/dist/lib/core/client/index.d.ts +13 -43
  14. package/dist/lib/core/client/index.js +47 -26
  15. package/dist/lib/core/client/index.js.map +1 -1
  16. package/dist/lib/core/{compiler → client}/types.d.ts +29 -0
  17. package/dist/lib/core/client/types.js.map +1 -0
  18. package/dist/lib/core/compiler/generator.d.ts +4 -6
  19. package/dist/lib/core/compiler/generator.js +168 -39
  20. package/dist/lib/core/compiler/generator.js.map +1 -1
  21. package/dist/lib/core/compiler/index.d.ts +2 -2
  22. package/dist/lib/core/compiler/index.js +2 -2
  23. package/dist/lib/core/compiler/index.js.map +1 -1
  24. package/dist/lib/core/compiler/pre-routes.d.ts +170 -34
  25. package/dist/lib/core/compiler/pre-routes.js +45 -25
  26. package/dist/lib/core/compiler/pre-routes.js.map +1 -1
  27. package/dist/lib/core/decorators/context.js +23 -15
  28. package/dist/lib/core/decorators/context.js.map +1 -1
  29. package/dist/lib/core/decorators/statusCode.js +3 -1
  30. package/dist/lib/core/decorators/statusCode.js.map +1 -1
  31. package/dist/lib/core/server/fast-router.d.ts +2 -2
  32. package/dist/lib/core/server/fast-router.js +17 -3
  33. package/dist/lib/core/server/fast-router.js.map +1 -1
  34. package/dist/lib/core/server/index.js +2 -2
  35. package/dist/lib/core/server/index.js.map +1 -1
  36. package/dist/lib/core/server/response.js +21 -1
  37. package/dist/lib/core/server/response.js.map +1 -1
  38. package/dist/lib/core/types/index.d.ts +32 -27
  39. package/package.json +6 -3
  40. package/dist/cli/app.d.ts +0 -1
  41. package/dist/cli/app.js +0 -32
  42. package/dist/cli/app.js.map +0 -1
  43. package/dist/cli/client.d.ts +0 -1
  44. package/dist/cli/client.js +0 -30
  45. package/dist/cli/client.js.map +0 -1
  46. package/dist/cli/controller.d.ts +0 -1
  47. package/dist/cli/controller.js +0 -169
  48. package/dist/cli/controller.js.map +0 -1
  49. package/dist/cli/middleware.d.ts +0 -1
  50. package/dist/cli/middleware.js +0 -16
  51. package/dist/cli/middleware.js.map +0 -1
  52. package/dist/client.d.ts +0 -1
  53. package/dist/client.js +0 -17
  54. package/dist/client.js.map +0 -1
  55. package/dist/common/middlewares/log.middleware.d.ts +0 -2
  56. package/dist/common/middlewares/log.middleware.js +0 -12
  57. package/dist/common/middlewares/log.middleware.js.map +0 -1
  58. package/dist/index.d.ts +0 -4
  59. package/dist/index.js +0 -32
  60. package/dist/index.js.map +0 -1
  61. package/dist/lib/core/compiler/types.js.map +0 -1
  62. package/dist/modules/cats/cat.controller.d.ts +0 -58
  63. package/dist/modules/cats/cat.controller.js +0 -90
  64. package/dist/modules/cats/cat.controller.js.map +0 -1
  65. package/dist/modules/cats/cat.dto.d.ts +0 -8
  66. package/dist/modules/cats/cat.dto.js +0 -44
  67. package/dist/modules/cats/cat.dto.js.map +0 -1
  68. package/dist/modules/cats/cat.service.d.ts +0 -23
  69. package/dist/modules/cats/cat.service.js +0 -56
  70. package/dist/modules/cats/cat.service.js.map +0 -1
  71. package/dist/tests/e2e..test.d.ts +0 -1
  72. package/dist/tests/e2e..test.js +0 -16
  73. package/dist/tests/e2e..test.js.map +0 -1
  74. /package/dist/lib/core/{compiler → client}/types.js +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/cli/client.ts"],"names":[],"mappings":";;;AACa,QAAA,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;CAyBrB,CAAA"}
@@ -1 +0,0 @@
1
- export declare const CatController = "\nimport {\n type T,\n Controller,\n Middleware,\n Get,\n Post,\n Put,\n Delete\n} from \"tspace-spear\";\n\nimport { CatMiddleware } from \"../middlewares/cat.middleware\";\n\ntype Cat = {\n id: number;\n name: string;\n age: number;\n};\n\nlet cats: Cat[] = [\n {\n id: 1,\n name: \"cat 1\",\n age: 2\n },\n {\n id: 2,\n name: \"cat 2\",\n age: 4\n }\n];\n\n@Controller(\"/cats\")\nclass CatController {\n\n @Get(\"/\")\n @Middleware(CatMiddleware)\n async index() {\n return {\n cats\n };\n }\n\n @Get(\"/:id\")\n @Middleware(CatMiddleware)\n async show({\n res,\n params\n }: T.Context<{\n params: {\n id: number;\n };\n }>) {\n\n const cat = cats.find(\n d => d.id === Number(params.id)\n );\n\n if (!cat) {\n throw res.notFound(\n \"Cat not found\"\n );\n }\n\n return {\n cat\n };\n }\n\n @Post(\"/\")\n @Middleware(CatMiddleware)\n async create({\n body\n }: T.Context<{\n body: {\n name: string;\n age: number;\n };\n }>) {\n\n const cat: Cat = {\n id: cats.length + 1,\n name: body.name,\n age: body.age\n };\n\n cats.push(cat);\n\n return {\n message: \"Created\",\n cat\n };\n }\n\n @Put(\"/:id\")\n @Middleware(CatMiddleware)\n async update({\n res,\n params,\n body\n }: T.Context<{\n params: {\n id: number;\n };\n body: Partial<{\n name: string;\n age: number;\n }>;\n }>) {\n\n const index = cats.findIndex(\n d => d.id === Number(params.id)\n );\n\n if (index === -1) {\n throw res.notFound(\n \"Cat not found\"\n );\n }\n\n cats[index] = {\n ...cats[index],\n ...body\n };\n\n return {\n message: \"Updated\",\n cat: cats[index]\n };\n }\n\n @Delete(\"/:id\")\n @Middleware(CatMiddleware)\n async remove({\n res,\n params\n }: T.Context<{\n params: {\n id: number;\n };\n }>) {\n\n const index = cats.findIndex(\n d => d.id === Number(params.id)\n );\n\n if (index === -1) {\n throw res.notFound(\n \"Cat not found\"\n );\n }\n\n cats = cats.filter(\n d => d.id !== Number(params.id)\n );\n\n return {\n message: \"Deleted\"\n };\n }\n}\n\nexport { CatController };\nexport default CatController;\n";
@@ -1,169 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CatController = void 0;
4
- exports.CatController = `
5
- import {
6
- type T,
7
- Controller,
8
- Middleware,
9
- Get,
10
- Post,
11
- Put,
12
- Delete
13
- } from "tspace-spear";
14
-
15
- import { CatMiddleware } from "../middlewares/cat.middleware";
16
-
17
- type Cat = {
18
- id: number;
19
- name: string;
20
- age: number;
21
- };
22
-
23
- let cats: Cat[] = [
24
- {
25
- id: 1,
26
- name: "cat 1",
27
- age: 2
28
- },
29
- {
30
- id: 2,
31
- name: "cat 2",
32
- age: 4
33
- }
34
- ];
35
-
36
- @Controller("/cats")
37
- class CatController {
38
-
39
- @Get("/")
40
- @Middleware(CatMiddleware)
41
- async index() {
42
- return {
43
- cats
44
- };
45
- }
46
-
47
- @Get("/:id")
48
- @Middleware(CatMiddleware)
49
- async show({
50
- res,
51
- params
52
- }: T.Context<{
53
- params: {
54
- id: number;
55
- };
56
- }>) {
57
-
58
- const cat = cats.find(
59
- d => d.id === Number(params.id)
60
- );
61
-
62
- if (!cat) {
63
- throw res.notFound(
64
- "Cat not found"
65
- );
66
- }
67
-
68
- return {
69
- cat
70
- };
71
- }
72
-
73
- @Post("/")
74
- @Middleware(CatMiddleware)
75
- async create({
76
- body
77
- }: T.Context<{
78
- body: {
79
- name: string;
80
- age: number;
81
- };
82
- }>) {
83
-
84
- const cat: Cat = {
85
- id: cats.length + 1,
86
- name: body.name,
87
- age: body.age
88
- };
89
-
90
- cats.push(cat);
91
-
92
- return {
93
- message: "Created",
94
- cat
95
- };
96
- }
97
-
98
- @Put("/:id")
99
- @Middleware(CatMiddleware)
100
- async update({
101
- res,
102
- params,
103
- body
104
- }: T.Context<{
105
- params: {
106
- id: number;
107
- };
108
- body: Partial<{
109
- name: string;
110
- age: number;
111
- }>;
112
- }>) {
113
-
114
- const index = cats.findIndex(
115
- d => d.id === Number(params.id)
116
- );
117
-
118
- if (index === -1) {
119
- throw res.notFound(
120
- "Cat not found"
121
- );
122
- }
123
-
124
- cats[index] = {
125
- ...cats[index],
126
- ...body
127
- };
128
-
129
- return {
130
- message: "Updated",
131
- cat: cats[index]
132
- };
133
- }
134
-
135
- @Delete("/:id")
136
- @Middleware(CatMiddleware)
137
- async remove({
138
- res,
139
- params
140
- }: T.Context<{
141
- params: {
142
- id: number;
143
- };
144
- }>) {
145
-
146
- const index = cats.findIndex(
147
- d => d.id === Number(params.id)
148
- );
149
-
150
- if (index === -1) {
151
- throw res.notFound(
152
- "Cat not found"
153
- );
154
- }
155
-
156
- cats = cats.filter(
157
- d => d.id !== Number(params.id)
158
- );
159
-
160
- return {
161
- message: "Deleted"
162
- };
163
- }
164
- }
165
-
166
- export { CatController };
167
- export default CatController;
168
- `;
169
- //# sourceMappingURL=controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../src/cli/controller.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoK5B,CAAC"}
@@ -1 +0,0 @@
1
- export declare const CatMiddleware = "\nimport { type T } from \"tspace-spear\";\n\nconst sleep = async (ms : number) => new Promise(resolve => setTimeout(resolve, ms))\n\nexport const CatMiddleware = async (ctx : T.Context, next: T.NextFunction) =>{\n await sleep(100);\n console.log('after logging middleware Meow!');\n ctx.req.cat = 'Meow!';\n return next()\n}\n";
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CatMiddleware = void 0;
4
- exports.CatMiddleware = `
5
- import { type T } from "tspace-spear";
6
-
7
- const sleep = async (ms : number) => new Promise(resolve => setTimeout(resolve, ms))
8
-
9
- export const CatMiddleware = async (ctx : T.Context, next: T.NextFunction) =>{
10
- await sleep(100);
11
- console.log('after logging middleware Meow!');
12
- ctx.req.cat = 'Meow!';
13
- return next()
14
- }
15
- `;
16
- //# sourceMappingURL=middleware.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/cli/middleware.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;;;;;;;;;;;CAW5B,CAAA"}
package/dist/client.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/client.js DELETED
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const client_1 = require("tspace-spear/client");
4
- const client = new client_1.ApiClient("http://localhost:8000/api");
5
- async function main() {
6
- const res = await client.get("/cats");
7
- res.data.cats = 1; // Type error: Type 'number' is not assignable to type '{ id: number; name: string; age: number; }[]'
8
- res.data.cats[0].name = 1; // Type error: Type 'number' is not assignable to type 'string'
9
- res.data.cats[0].age = "1.6"; // Type error: Type 'string' is not assignable to type 'number'
10
- console.log(res);
11
- // res.ok -> boolean
12
- // res.status -> number
13
- // res.data -> { cats: [{ id: 1, name: 'cat1', age: 1.6 },{ id: 2, name: 'cat2', age: 1.8 }] }
14
- await client.get("/catsq"); // Type error: Argument of type '"/catsq"' is not assignable to parameter of type '"/cats" | "/cats/:id" | ... 3 more
15
- }
16
- main();
17
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;AAGA,gDAAgD;AAEhD,MAAM,MAAM,GAAyB,IAAI,kBAAS,CAChD,2BAA2B,CAC5B,CAAC;AAEF,KAAK,UAAU,IAAI;IAEf,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAA,CAAC,qGAAqG;IACvH,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAA,CAAC,+DAA+D;IACzF,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAA,CAAC,+DAA+D;IAE5F,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAChB,oBAAoB;IACpB,uBAAuB;IACvB,8FAA8F;IAE9F,MAAM,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,qHAAqH;AAErJ,CAAC;AACD,IAAI,EAAE,CAAA"}
@@ -1,2 +0,0 @@
1
- import { type T } from "tspace-spear";
2
- export declare const LogMiddleware: (ctx: T.Context, next: T.NextFunction) => Promise<any>;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LogMiddleware = void 0;
4
- const sleep = async (ms) => new Promise(resolve => setTimeout(resolve, ms));
5
- const LogMiddleware = async (ctx, next) => {
6
- await sleep(100);
7
- console.log('after logging middleware Meow!');
8
- ctx.req.cat = 'Meow!';
9
- return next();
10
- };
11
- exports.LogMiddleware = LogMiddleware;
12
- //# sourceMappingURL=log.middleware.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"log.middleware.js","sourceRoot":"","sources":["../../../src/common/middlewares/log.middleware.ts"],"names":[],"mappings":";;;AAGA,MAAM,KAAK,GAAG,KAAK,EAAE,EAAW,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAE7E,MAAM,aAAa,GAAG,KAAK,EAAE,GAAe,EAAE,IAAoB,EAAE,EAAE;IACzE,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IACjB,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAC9C,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,OAAO,CAAC;IACtB,OAAO,IAAI,EAAE,CAAA;AACjB,CAAC,CAAA;AALY,QAAA,aAAa,iBAKzB"}
package/dist/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- declare const app: any;
2
- type AppRouter = typeof app.contract;
3
- export { AppRouter };
4
- export { app };
package/dist/index.js DELETED
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.app = void 0;
7
- const tspace_spear_1 = __importDefault(require("tspace-spear"));
8
- const app = new tspace_spear_1.default({
9
- logger: true,
10
- controllers: {
11
- folder: `${__dirname}/modules/*`,
12
- name: /controller\.(ts|js)$/i,
13
- // don't forget to set this option for auto-generate route metadata for type-safe E2E usage,
14
- // and swagger documentation. By default if use .useSwagger() in app no need to set any description
15
- preRouteTypes: true
16
- }
17
- });
18
- exports.app = app;
19
- app.cors({
20
- origins: [
21
- /^http:/ / localhost, d + $ /
22
- ],
23
- credentials: true
24
- });
25
- app.useGlobalPrefix("api");
26
- app.useSwagger();
27
- app.useBodyParser();
28
- app.listen(8000, ({ port, server }) => {
29
- console.log(`Server listening on : http://localhost:${port}`);
30
- console.log(`Docs listening on : http://localhost:${port}/api/docs`);
31
- });
32
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA,gEAAiC;AAEjC,MAAM,GAAG,GAAG,IAAI,sBAAK,CAAC;IACpB,MAAM,EAAE,IAAI;IACZ,WAAW,EAAE;QACX,MAAM,EAAE,GAAG,SAAS,YAAY;QAChC,IAAI,EAAE,uBAAuB;QAE7B,6FAA6F;QAC7F,mGAAmG;QACnG,aAAa,EAAE,IAAI;KACpB;CACF,CAAC,CAAA;AAoBO,kBAAG;AAlBZ,GAAG,CAAC,IAAI,CAAC;IACP,OAAO,EAAE;QACP,QAAQ,GAAC,SAAS,EAAC,CAAC,GAAC,CAAC;YACxB,AADyB,JAAA,HACxB;IACD,WAAW,EAAE,IAAI;CAClB,CAAC,CAAC;AAEH,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;AAC3B,GAAG,CAAC,UAAU,EAAE,CAAC;AACjB,GAAG,CAAC,aAAa,EAAE,CAAC;AAEpB,GAAG,CAAC,MAAM,CAAC,IAAI,EAAG,CAAC,EAAE,IAAI,EAAG,MAAM,EAAE,EAAE,EAAE;IACtC,OAAO,CAAC,GAAG,CAAC,0CAA0C,IAAI,EAAE,CAAC,CAAA;IAC7D,OAAO,CAAC,GAAG,CAAC,wCAAwC,IAAI,WAAW,CAAC,CAAA;AACtE,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/core/compiler/types.ts"],"names":[],"mappings":""}
@@ -1,58 +0,0 @@
1
- import { type T } from "tspace-spear";
2
- import { CatService } from "./cat.service.ts";
3
- import { CreateCatDto, UpdateCatDto } from "./cat.dto.ts";
4
- declare class CatController {
5
- private catService;
6
- constructor(catService?: CatService);
7
- index(): Promise<{
8
- id: number;
9
- name: string;
10
- age: number;
11
- }[]>;
12
- show({ params }: T.Context<{
13
- params: {
14
- id: number;
15
- };
16
- }>): Promise<{
17
- id: number;
18
- name: string;
19
- age: number;
20
- } | undefined>;
21
- create({ body }: T.Context<{
22
- body: CreateCatDto;
23
- }>): Promise<{
24
- message: string;
25
- cat: {
26
- id: number;
27
- name: string;
28
- age: number;
29
- };
30
- }>;
31
- update({ params, body }: T.Context<{
32
- params: {
33
- id: number;
34
- };
35
- body: UpdateCatDto;
36
- }>): Promise<{
37
- message: string;
38
- cat: {
39
- id: number;
40
- name: string;
41
- age: number;
42
- };
43
- }>;
44
- remove({ params }: T.Context<{
45
- params: {
46
- id: number;
47
- };
48
- }>): Promise<{
49
- message: string;
50
- cat: {
51
- id: number;
52
- name: string;
53
- age: number;
54
- };
55
- }>;
56
- }
57
- export { CatController };
58
- export default CatController;
@@ -1,90 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.CatController = void 0;
13
- const tspace_spear_1 = require("tspace-spear");
14
- const cat_service_ts_1 = require("./cat.service.ts");
15
- const cat_dto_ts_1 = require("./cat.dto.ts");
16
- const log_middleware_1 = require("../../common/middlewares/log.middleware");
17
- let CatController = class CatController {
18
- catService;
19
- constructor(catService = new cat_service_ts_1.CatService()) {
20
- this.catService = catService;
21
- }
22
- async index() {
23
- return this.catService.index();
24
- }
25
- async show({ params }) {
26
- return this.catService.show(params.id);
27
- }
28
- async create({ body }) {
29
- return this.catService
30
- .create({
31
- name: body.name,
32
- age: body.age
33
- });
34
- }
35
- async update({ params, body }) {
36
- return this.catService
37
- .update(params.id, {
38
- name: body.name,
39
- age: body.age
40
- });
41
- }
42
- async remove({ params }) {
43
- return this.catService
44
- .remove(params.id);
45
- }
46
- };
47
- exports.CatController = CatController;
48
- __decorate([
49
- (0, tspace_spear_1.Get)("/"),
50
- (0, tspace_spear_1.Middleware)(log_middleware_1.LogMiddleware),
51
- __metadata("design:type", Function),
52
- __metadata("design:paramtypes", []),
53
- __metadata("design:returntype", Promise)
54
- ], CatController.prototype, "index", null);
55
- __decorate([
56
- (0, tspace_spear_1.Get)("/:id"),
57
- (0, tspace_spear_1.Middleware)(log_middleware_1.LogMiddleware),
58
- __metadata("design:type", Function),
59
- __metadata("design:paramtypes", [Object]),
60
- __metadata("design:returntype", Promise)
61
- ], CatController.prototype, "show", null);
62
- __decorate([
63
- (0, tspace_spear_1.Post)("/"),
64
- (0, tspace_spear_1.ValidateDto)(cat_dto_ts_1.CreateCatDto),
65
- (0, tspace_spear_1.Middleware)(log_middleware_1.LogMiddleware),
66
- __metadata("design:type", Function),
67
- __metadata("design:paramtypes", [Object]),
68
- __metadata("design:returntype", Promise)
69
- ], CatController.prototype, "create", null);
70
- __decorate([
71
- (0, tspace_spear_1.Put)("/:id"),
72
- (0, tspace_spear_1.ValidateDto)(cat_dto_ts_1.UpdateCatDto),
73
- (0, tspace_spear_1.Middleware)(log_middleware_1.LogMiddleware),
74
- __metadata("design:type", Function),
75
- __metadata("design:paramtypes", [Object]),
76
- __metadata("design:returntype", Promise)
77
- ], CatController.prototype, "update", null);
78
- __decorate([
79
- (0, tspace_spear_1.Delete)("/:id"),
80
- (0, tspace_spear_1.Middleware)(log_middleware_1.LogMiddleware),
81
- __metadata("design:type", Function),
82
- __metadata("design:paramtypes", [Object]),
83
- __metadata("design:returntype", Promise)
84
- ], CatController.prototype, "remove", null);
85
- exports.CatController = CatController = __decorate([
86
- (0, tspace_spear_1.Controller)("/cats"),
87
- __metadata("design:paramtypes", [cat_service_ts_1.CatService])
88
- ], CatController);
89
- exports.default = CatController;
90
- //# sourceMappingURL=cat.controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cat.controller.js","sourceRoot":"","sources":["../../../src/modules/cats/cat.controller.ts"],"names":[],"mappings":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AAA,mBAAI,EAAC,GAAG,CAAC;IACT,IAAA,0BAAW,EAAC,yBAAY,CAAC;IACzB,IAAA,yBAAU,EAAC,8BAAa,CAAC;;;;2CAYzB;AAKK;IAHL,IAAA,kBAAG,EAAC,MAAM,CAAC;IACX,IAAA,0BAAW,EAAC,yBAAY,CAAC;IACzB,IAAA,yBAAU,EAAC,8BAAa,CAAC;;;;2CAgBzB;AAIK;IAFL,IAAA,qBAAM,EAAC,MAAM,CAAC;IACd,IAAA,yBAAU,EAAC,8BAAa,CAAC;;;;2CAWzB;wBAzEG,aAAa;IADlB,IAAA,yBAAU,EAAC,OAAO,CAAC;qCAII,2BAAU;GAH5B,aAAa,CA0ElB;AAGD,kBAAe,aAAa,CAAC"}
@@ -1,8 +0,0 @@
1
- export declare class CreateCatDto {
2
- name: string;
3
- age: number;
4
- }
5
- export declare class UpdateCatDto {
6
- name: string;
7
- age: number;
8
- }
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.UpdateCatDto = exports.CreateCatDto = void 0;
13
- const class_validator_1 = require("class-validator");
14
- class CreateCatDto {
15
- name;
16
- age;
17
- }
18
- exports.CreateCatDto = CreateCatDto;
19
- __decorate([
20
- (0, class_validator_1.IsString)(),
21
- (0, class_validator_1.IsNotEmpty)(),
22
- __metadata("design:type", String)
23
- ], CreateCatDto.prototype, "name", void 0);
24
- __decorate([
25
- (0, class_validator_1.IsNumber)(),
26
- (0, class_validator_1.Min)(0.1),
27
- __metadata("design:type", Number)
28
- ], CreateCatDto.prototype, "age", void 0);
29
- class UpdateCatDto {
30
- name;
31
- age;
32
- }
33
- exports.UpdateCatDto = UpdateCatDto;
34
- __decorate([
35
- (0, class_validator_1.IsString)(),
36
- (0, class_validator_1.IsNotEmpty)(),
37
- __metadata("design:type", String)
38
- ], UpdateCatDto.prototype, "name", void 0);
39
- __decorate([
40
- (0, class_validator_1.IsNumber)(),
41
- (0, class_validator_1.Min)(0.1),
42
- __metadata("design:type", Number)
43
- ], UpdateCatDto.prototype, "age", void 0);
44
- //# sourceMappingURL=cat.dto.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cat.dto.js","sourceRoot":"","sources":["../../../src/modules/cats/cat.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qDAKyB;AAEzB,MAAa,YAAY;IAGvB,IAAI,CAAU;IAId,GAAG,CAAU;CACd;AARD,oCAQC;AALC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;0CACC;AAId;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,GAAG,CAAC;;yCACI;AAGf,MAAa,YAAY;IAGvB,IAAI,CAAU;IAId,GAAG,CAAU;CACd;AARD,oCAQC;AALC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;0CACC;AAId;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAG,EAAC,GAAG,CAAC;;yCACI"}
@@ -1,23 +0,0 @@
1
- type Cat = {
2
- id: number;
3
- name: string;
4
- age: number;
5
- };
6
- export declare class CatService {
7
- private cats;
8
- index(): Promise<Cat[]>;
9
- show(id: number): Promise<Cat | undefined>;
10
- create({ name, age }: Omit<Cat, "id">): Promise<{
11
- message: string;
12
- cat: Cat;
13
- }>;
14
- update(id: number, { name, age }: Omit<Cat, "id">): Promise<{
15
- message: string;
16
- cat: Cat;
17
- }>;
18
- remove(id: number): Promise<{
19
- message: string;
20
- cat: Cat;
21
- }>;
22
- }
23
- export {};
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CatService = void 0;
4
- class CatService {
5
- cats = [
6
- { id: 1, name: 'cat1', age: 1.6 },
7
- { id: 2, name: 'cat2', age: 1.8 },
8
- ];
9
- async index() {
10
- return this.cats;
11
- }
12
- ;
13
- async show(id) {
14
- return this.cats.find(cat => cat.id === id);
15
- }
16
- ;
17
- async create({ name, age }) {
18
- const cat = {
19
- id: this.cats.length + 1,
20
- name: name,
21
- age: age
22
- };
23
- this.cats.push(cat);
24
- return {
25
- message: "Created",
26
- cat
27
- };
28
- }
29
- async update(id, { name, age }) {
30
- const index = this.cats.findIndex(d => d.id === id);
31
- if (index === -1) {
32
- throw new Error("Cat not found");
33
- }
34
- this.cats[index] = {
35
- ...this.cats[index],
36
- ...{ name, age }
37
- };
38
- return {
39
- message: "Updated",
40
- cat: this.cats[index]
41
- };
42
- }
43
- async remove(id) {
44
- const index = this.cats.findIndex(d => d.id === id);
45
- if (index === -1) {
46
- throw new Error("Cat not found");
47
- }
48
- const [removedCat] = this.cats.splice(index, 1);
49
- return {
50
- message: "Deleted",
51
- cat: removedCat
52
- };
53
- }
54
- }
55
- exports.CatService = CatService;
56
- //# sourceMappingURL=cat.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cat.service.js","sourceRoot":"","sources":["../../../src/modules/cats/cat.service.ts"],"names":[],"mappings":";;;AAOA,MAAa,UAAU;IACX,IAAI,GAAU;QAClB,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE;QACjC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE;KACpC,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,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAEpD,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;QACrC,CAAC;QAED,MAAM,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAEhD,OAAO;YACH,OAAO,EAAE,SAAS;YAClB,GAAG,EAAE,UAAU;SAClB,CAAC;IACN,CAAC;CACJ;AA7DD,gCA6DC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const chai_1 = __importDefault(require("chai"));
7
- const mocha_1 = require("mocha");
8
- const chai_json_schema_1 = __importDefault(require("chai-json-schema"));
9
- chai_1.default.use(chai_json_schema_1.default);
10
- (0, mocha_1.describe)('Testing Driver', function () {
11
- /* ##################################################### */
12
- (0, mocha_1.it)(`Driver: Using driver in ['mysql','postgres' ,'mariadb','mssql','sqlite'] ?`, async function () {
13
- });
14
- /* ###################################################### */
15
- });
16
- //# sourceMappingURL=e2e..test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"e2e..test.js","sourceRoot":"","sources":["../../src/tests/e2e..test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAoC;AACpC,iCAAoC;AACpC,wEAA6C;AAE7C,cAAI,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAA;AAExB,IAAA,gBAAQ,EAAC,gBAAgB,EAAE;IACzB,2DAA2D;IAC3D,IAAA,UAAE,EAAC,4EAA4E,EAC/E,KAAK;IACL,CAAC,CAAC,CAAA;IACF,4DAA4D;AAC9D,CAAC,CAAC,CAAA"}
File without changes