aws-service-stack 0.16.219 → 0.16.221

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 (85) hide show
  1. package/dist/_examples/controller/e-order/e-order-crud-simple.js +31 -25
  2. package/dist/_examples/controller/e-order/e-order-crud-simple.js.map +1 -1
  3. package/dist/_examples/controller/e-order/e-order-crud.js +4 -17
  4. package/dist/_examples/controller/e-order/e-order-crud.js.map +1 -1
  5. package/dist/_examples/controller/e-order/e-order.controller.js +10 -29
  6. package/dist/_examples/controller/e-order/e-order.controller.js.map +1 -1
  7. package/dist/_examples/controller/entity/entity-controller.js +30 -42
  8. package/dist/_examples/controller/entity/entity-controller.js.map +1 -1
  9. package/dist/_examples/controller/entity/entity-crud.js +6 -19
  10. package/dist/_examples/controller/entity/entity-crud.js.map +1 -1
  11. package/dist/_examples/controller/index.js +10 -22
  12. package/dist/_examples/controller/index.js.map +1 -1
  13. package/dist/_examples/controller/profile/profile-crud-simple.js +31 -25
  14. package/dist/_examples/controller/profile/profile-crud-simple.js.map +1 -1
  15. package/dist/_examples/controller/profile/profile-crud.js +4 -17
  16. package/dist/_examples/controller/profile/profile-crud.js.map +1 -1
  17. package/dist/_examples/controller/profile/profile.controller.js +2 -13
  18. package/dist/_examples/controller/profile/profile.controller.js.map +1 -1
  19. package/dist/_examples/controller/supplier/supplier-controller-api.js +18 -29
  20. package/dist/_examples/controller/supplier/supplier-controller-api.js.map +1 -1
  21. package/dist/_examples/controller/supplier/supplier-crud.js +6 -19
  22. package/dist/_examples/controller/supplier/supplier-crud.js.map +1 -1
  23. package/dist/_examples/controller/supplier/supplier-streamer.js +3 -16
  24. package/dist/_examples/controller/supplier/supplier-streamer.js.map +1 -1
  25. package/dist/_examples/controller/user.controller.js +10 -29
  26. package/dist/_examples/controller/user.controller.js.map +1 -1
  27. package/dist/_examples/repositories/order/order-es.repo.js +38 -53
  28. package/dist/_examples/repositories/order/order-es.repo.js.map +1 -1
  29. package/dist/_examples/repositories/user-repo-db.js +2 -13
  30. package/dist/_examples/repositories/user-repo-db.js.map +1 -1
  31. package/dist/_examples/service/entity/entity-service.js +19 -30
  32. package/dist/_examples/service/entity/entity-service.js.map +1 -1
  33. package/dist/_examples/service/order-service.js +2 -13
  34. package/dist/_examples/service/order-service.js.map +1 -1
  35. package/dist/_examples/service/profile-service.js +106 -125
  36. package/dist/_examples/service/profile-service.js.map +1 -1
  37. package/dist/_examples/service/supplier/supplier-service-crud.js +66 -81
  38. package/dist/_examples/service/supplier/supplier-service-crud.js.map +1 -1
  39. package/dist/controller/base-controller.js +162 -182
  40. package/dist/controller/base-controller.js.map +1 -1
  41. package/dist/controller/controller-api.js +121 -130
  42. package/dist/controller/controller-api.js.map +1 -1
  43. package/dist/controller/controller-stream.js +29 -40
  44. package/dist/controller/controller-stream.js.map +1 -1
  45. package/dist/exception/errors.js +13 -0
  46. package/dist/exception/errors.js.map +1 -1
  47. package/dist/exception/exception-handler.js +2 -2
  48. package/dist/exception/exception-handler.js.map +1 -1
  49. package/dist/function/cognito/cognito.function.js +173 -194
  50. package/dist/function/cognito/cognito.function.js.map +1 -1
  51. package/dist/model/base.config.js +11 -0
  52. package/dist/model/base.config.js.map +1 -1
  53. package/dist/model/dynamodb.model.js +5 -4
  54. package/dist/model/dynamodb.model.js.map +1 -1
  55. package/dist/provider/opensearch.js +10 -7
  56. package/dist/provider/opensearch.js.map +1 -1
  57. package/dist/repositories/base-db.repo.js +398 -457
  58. package/dist/repositories/base-db.repo.js.map +1 -1
  59. package/dist/repositories/base-es.repo.js +72 -99
  60. package/dist/repositories/base-es.repo.js.map +1 -1
  61. package/dist/service/api.services/api.service.js +47 -65
  62. package/dist/service/api.services/api.service.js.map +1 -1
  63. package/dist/service/auth.service.js +38 -55
  64. package/dist/service/auth.service.js.map +1 -1
  65. package/dist/service/base.service.js +144 -196
  66. package/dist/service/base.service.js.map +1 -1
  67. package/dist/service/crud.service.js +144 -196
  68. package/dist/service/crud.service.js.map +1 -1
  69. package/dist/service/key-aws.services.js +12 -22
  70. package/dist/service/key-aws.services.js.map +1 -1
  71. package/dist/service/socket.service.js +1 -0
  72. package/dist/service/socket.service.js.map +1 -1
  73. package/dist/service/stream.service.js +3 -0
  74. package/dist/service/stream.service.js.map +1 -1
  75. package/dist/utils/dynamodb.utils.js +13 -18
  76. package/dist/utils/dynamodb.utils.js.map +1 -1
  77. package/dist/utils/file-handler.js +5 -34
  78. package/dist/utils/file-handler.js.map +1 -1
  79. package/dist/utils/http.util.js +13 -9
  80. package/dist/utils/http.util.js.map +1 -1
  81. package/dist/utils/logger.js +1 -4
  82. package/dist/utils/logger.js.map +1 -1
  83. package/dist/utils/reflection.util.js +4 -5
  84. package/dist/utils/reflection.util.js.map +1 -1
  85. package/package.json +24 -24
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.handler = void 0;
13
4
  const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
@@ -16,7 +7,7 @@ const lib_dynamodb_1 = require("@aws-sdk/lib-dynamodb");
16
7
  const client = new client_dynamodb_1.DynamoDBClient({ region: "ap-southeast-1" });
17
8
  const docClient = lib_dynamodb_1.DynamoDBDocumentClient.from(client);
18
9
  const TABLE_NAME = "Profile-s4ph7chlarhupiqw7ml47pmehq-dev";
19
- const handler = (event) => __awaiter(void 0, void 0, void 0, function* () {
10
+ const handler = async (event) => {
20
11
  try {
21
12
  const httpMethod = event.httpMethod;
22
13
  const path = event.path;
@@ -43,7 +34,7 @@ const handler = (event) => __awaiter(void 0, void 0, void 0, function* () {
43
34
  TableName: TABLE_NAME,
44
35
  Key: { id: pathParameters.id }
45
36
  });
46
- const result = yield docClient.send(getCommand);
37
+ const result = await docClient.send(getCommand);
47
38
  if (!result.Item) {
48
39
  return {
49
40
  statusCode: 404,
@@ -78,7 +69,7 @@ const handler = (event) => __awaiter(void 0, void 0, void 0, function* () {
78
69
  TableName: TABLE_NAME,
79
70
  Limit: 100
80
71
  });
81
- const result = yield docClient.send(scanCommand);
72
+ const result = await docClient.send(scanCommand);
82
73
  return {
83
74
  statusCode: 200,
84
75
  headers: {
@@ -95,7 +86,7 @@ const handler = (event) => __awaiter(void 0, void 0, void 0, function* () {
95
86
  ExpressionAttributeValues: Object.fromEntries(Object.entries(cleanParams).map(([key, value]) => [`:${key}`, value])),
96
87
  Limit: 100
97
88
  });
98
- const result = yield docClient.send(scanCommand);
89
+ const result = await docClient.send(scanCommand);
99
90
  return {
100
91
  statusCode: 200,
101
92
  headers: {
@@ -111,7 +102,7 @@ const handler = (event) => __awaiter(void 0, void 0, void 0, function* () {
111
102
  TableName: TABLE_NAME,
112
103
  Limit: 100
113
104
  });
114
- const result = yield docClient.send(scanCommand);
105
+ const result = await docClient.send(scanCommand);
115
106
  return {
116
107
  statusCode: 200,
117
108
  headers: {
@@ -127,7 +118,7 @@ const handler = (event) => __awaiter(void 0, void 0, void 0, function* () {
127
118
  TableName: TABLE_NAME,
128
119
  Limit: 100
129
120
  });
130
- const result = yield docClient.send(scanCommand);
121
+ const result = await docClient.send(scanCommand);
131
122
  return {
132
123
  statusCode: 200,
133
124
  headers: {
@@ -139,12 +130,17 @@ const handler = (event) => __awaiter(void 0, void 0, void 0, function* () {
139
130
  }
140
131
  case "POST":
141
132
  // POST /profiles
142
- const newProfile = Object.assign(Object.assign({ id: body.id || `profile-${Date.now()}` }, body), { createdAt: new Date().toISOString(), updatedAt: new Date().toISOString() });
133
+ const newProfile = {
134
+ id: body.id || `profile-${Date.now()}`,
135
+ ...body,
136
+ createdAt: new Date().toISOString(),
137
+ updatedAt: new Date().toISOString()
138
+ };
143
139
  const putCommand = new lib_dynamodb_1.PutCommand({
144
140
  TableName: TABLE_NAME,
145
141
  Item: newProfile
146
142
  });
147
- yield docClient.send(putCommand);
143
+ await docClient.send(putCommand);
148
144
  return {
149
145
  statusCode: 201,
150
146
  headers: {
@@ -170,7 +166,7 @@ const handler = (event) => __awaiter(void 0, void 0, void 0, function* () {
170
166
  TableName: TABLE_NAME,
171
167
  Key: { id: pathParameters.id }
172
168
  });
173
- const existingResult = yield docClient.send(getExistingCommand);
169
+ const existingResult = await docClient.send(getExistingCommand);
174
170
  if (!existingResult.Item) {
175
171
  return {
176
172
  statusCode: 404,
@@ -181,12 +177,17 @@ const handler = (event) => __awaiter(void 0, void 0, void 0, function* () {
181
177
  body: JSON.stringify({ error: "Profile not found" }),
182
178
  };
183
179
  }
184
- const updatedProfile = Object.assign(Object.assign(Object.assign({}, existingResult.Item), body), { id: pathParameters.id, updatedAt: new Date().toISOString() });
180
+ const updatedProfile = {
181
+ ...existingResult.Item,
182
+ ...body,
183
+ id: pathParameters.id,
184
+ updatedAt: new Date().toISOString()
185
+ };
185
186
  const updateCommand = new lib_dynamodb_1.PutCommand({
186
187
  TableName: TABLE_NAME,
187
188
  Item: updatedProfile
188
189
  });
189
- yield docClient.send(updateCommand);
190
+ await docClient.send(updateCommand);
190
191
  return {
191
192
  statusCode: 200,
192
193
  headers: {
@@ -212,7 +213,7 @@ const handler = (event) => __awaiter(void 0, void 0, void 0, function* () {
212
213
  TableName: TABLE_NAME,
213
214
  Key: { id: pathParameters.id }
214
215
  });
215
- const patchResult = yield docClient.send(getPatchCommand);
216
+ const patchResult = await docClient.send(getPatchCommand);
216
217
  if (!patchResult.Item) {
217
218
  return {
218
219
  statusCode: 404,
@@ -223,12 +224,17 @@ const handler = (event) => __awaiter(void 0, void 0, void 0, function* () {
223
224
  body: JSON.stringify({ error: "Profile not found" }),
224
225
  };
225
226
  }
226
- const patchedProfile = Object.assign(Object.assign(Object.assign({}, patchResult.Item), body), { id: pathParameters.id, updatedAt: new Date().toISOString() });
227
+ const patchedProfile = {
228
+ ...patchResult.Item,
229
+ ...body,
230
+ id: pathParameters.id,
231
+ updatedAt: new Date().toISOString()
232
+ };
227
233
  const patchUpdateCommand = new lib_dynamodb_1.PutCommand({
228
234
  TableName: TABLE_NAME,
229
235
  Item: patchedProfile
230
236
  });
231
- yield docClient.send(patchUpdateCommand);
237
+ await docClient.send(patchUpdateCommand);
232
238
  return {
233
239
  statusCode: 200,
234
240
  headers: {
@@ -253,7 +259,7 @@ const handler = (event) => __awaiter(void 0, void 0, void 0, function* () {
253
259
  TableName: TABLE_NAME,
254
260
  Key: { id: pathParameters.id }
255
261
  });
256
- yield docClient.send(deleteCommand);
262
+ await docClient.send(deleteCommand);
257
263
  return {
258
264
  statusCode: 204,
259
265
  headers: {
@@ -283,6 +289,6 @@ const handler = (event) => __awaiter(void 0, void 0, void 0, function* () {
283
289
  body: JSON.stringify({ error: "Internal server error" }),
284
290
  };
285
291
  }
286
- });
292
+ };
287
293
  exports.handler = handler;
288
294
  //# sourceMappingURL=e-order-crud-simple.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"e-order-crud-simple.js","sourceRoot":"","sources":["../../../../src/_examples/controller/e-order/e-order-crud-simple.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,8DAA0D;AAC1D,wDAAmH;AAEnH,6BAA6B;AAC7B,MAAM,MAAM,GAAG,IAAI,gCAAc,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAChE,MAAM,SAAS,GAAG,qCAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAEtD,MAAM,UAAU,GAAG,wCAAwC,CAAC;AAErD,MAAM,OAAO,GAAG,CAAO,KAA2B,EAAkC,EAAE;IAC3F,IAAI,CAAC;QACH,MA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S,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC;SACzD,CAAC;IACJ,CAAC;AACH,CAAC,CAAA,CAAC;AA3TW,QAAA,OAAO,WA2TlB","sourcesContent":["import { APIGatewayProxyEvent, APIGatewayProxyResult } from \"aws-lambda\";\nimport { DynamoDBClient } from \"@aws-sdk/client-dynamodb\";\nimport { DynamoDBDocumentClient, GetCommand, PutCommand, ScanCommand, DeleteCommand } from \"@aws-sdk/lib-dynamodb\";\n\n// Initialize DynamoDB client\nconst client = new DynamoDBClient({ region: \"ap-southeast-1\" });\nconst docClient = DynamoDBDocumentClient.from(client);\n\nconst TABLE_NAME = \"Profile-s4ph7chlarhupiqw7ml47pmehq-dev\";\n\nexport const handler = async (event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> => {\n try {\n const httpMethod = event.httpMethod;\n const path = event.path;\n const pathParameters = event.pathParameters || {};\n const queryStringParameters = event.queryStringParameters || {};\n const body = event.body ? JSON.parse(event.body) : {};\n\n console.log(`Processing ${httpMethod} ${path}`);\n\n // Simple mock response for testing\n const mockProfile = {\n id: \"test-profile-1\",\n email: \"test@example.com\",\n firstName: \"Test\",\n lastName: \"User\",\n availablePoint: 100,\n note: \"Test profile\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString()\n };\n\n switch (httpMethod) {\n case \"GET\":\n if (pathParameters.id) {\n // GET /profiles/{id}\n const getCommand = new GetCommand({\n TableName: TABLE_NAME,\n Key: { id: pathParameters.id }\n });\n const result = await docClient.send(getCommand);\n \n if (!result.Item) {\n return {\n statusCode: 404,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Profile not found\" }),\n };\n }\n\n return {\n statusCode: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(result.Item),\n };\n } else if (path.includes(\"/search\")) {\n // GET /profiles/search\n const searchParams = {\n phone: queryStringParameters.phone,\n email: queryStringParameters.email,\n cardNumber: queryStringParameters.cardNumber,\n };\n \n // Remove undefined values\n const cleanParams = Object.fromEntries(\n Object.entries(searchParams).filter(([_, value]) => value !== undefined)\n );\n \n if (Object.keys(cleanParams).length === 0) {\n // No search parameters, return all profiles\n const scanCommand = new ScanCommand({\n TableName: TABLE_NAME,\n Limit: 100\n });\n const result = await docClient.send(scanCommand);\n return {\n statusCode: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(result.Items || []),\n };\n }\n \n // Use scan with filter expressions\n const scanCommand = new ScanCommand({\n TableName: TABLE_NAME,\n FilterExpression: Object.keys(cleanParams).map(key => `${key} = :${key}`).join(' AND '),\n ExpressionAttributeValues: Object.fromEntries(\n Object.entries(cleanParams).map(([key, value]) => [`:${key}`, value])\n ),\n Limit: 100\n });\n \n const result = await docClient.send(scanCommand);\n return {\n statusCode: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(result.Items || []),\n };\n } else if (path.includes(\"/scan\")) {\n // GET /profiles/scan\n const scanCommand = new ScanCommand({\n TableName: TABLE_NAME,\n Limit: 100\n });\n const result = await docClient.send(scanCommand);\n return {\n statusCode: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(result.Items || []),\n };\n } else {\n // GET /profiles\n const scanCommand = new ScanCommand({\n TableName: TABLE_NAME,\n Limit: 100\n });\n const result = await docClient.send(scanCommand);\n return {\n statusCode: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(result.Items || []),\n };\n }\n\n case \"POST\":\n // POST /profiles\n const newProfile = {\n id: body.id || `profile-${Date.now()}`,\n ...body,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString()\n };\n\n const putCommand = new PutCommand({\n TableName: TABLE_NAME,\n Item: newProfile\n });\n \n await docClient.send(putCommand);\n \n return {\n statusCode: 201,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(newProfile),\n };\n\n case \"PUT\":\n // PUT /profiles/{id}\n if (!pathParameters.id) {\n return {\n statusCode: 400,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Profile ID is required\" }),\n };\n }\n\n // First check if profile exists\n const getExistingCommand = new GetCommand({\n TableName: TABLE_NAME,\n Key: { id: pathParameters.id }\n });\n const existingResult = await docClient.send(getExistingCommand);\n \n if (!existingResult.Item) {\n return {\n statusCode: 404,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Profile not found\" }),\n };\n }\n\n const updatedProfile = {\n ...existingResult.Item,\n ...body,\n id: pathParameters.id,\n updatedAt: new Date().toISOString()\n };\n\n const updateCommand = new PutCommand({\n TableName: TABLE_NAME,\n Item: updatedProfile\n });\n \n await docClient.send(updateCommand);\n \n return {\n statusCode: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(updatedProfile),\n };\n\n case \"PATCH\":\n // PATCH /profiles/{id}\n if (!pathParameters.id) {\n return {\n statusCode: 400,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Profile ID is required\" }),\n };\n }\n\n // First check if profile exists\n const getPatchCommand = new GetCommand({\n TableName: TABLE_NAME,\n Key: { id: pathParameters.id }\n });\n const patchResult = await docClient.send(getPatchCommand);\n \n if (!patchResult.Item) {\n return {\n statusCode: 404,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Profile not found\" }),\n };\n }\n\n const patchedProfile = {\n ...patchResult.Item,\n ...body,\n id: pathParameters.id,\n updatedAt: new Date().toISOString()\n };\n\n const patchUpdateCommand = new PutCommand({\n TableName: TABLE_NAME,\n Item: patchedProfile\n });\n \n await docClient.send(patchUpdateCommand);\n \n return {\n statusCode: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(patchedProfile),\n };\n\n case \"DELETE\":\n // DELETE /profiles/{id}\n if (!pathParameters.id) {\n return {\n statusCode: 400,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Profile ID is required\" }),\n };\n }\n\n const deleteCommand = new DeleteCommand({\n TableName: TABLE_NAME,\n Key: { id: pathParameters.id }\n });\n \n await docClient.send(deleteCommand);\n \n return {\n statusCode: 204,\n headers: {\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: \"\",\n };\n\n default:\n return {\n statusCode: 405,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Method not allowed\" }),\n };\n }\n } catch (error) {\n console.error(\"Error processing request:\", error);\n \n return {\n statusCode: 500,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Internal server error\" }),\n };\n }\n};\n"]}
1
+ {"version":3,"file":"e-order-crud-simple.js","sourceRoot":"","sources":["../../../../src/_examples/controller/e-order/e-order-crud-simple.ts"],"names":[],"mappings":";;;AACA,8DAA0D;AAC1D,wDAAmH;AAEnH,6BAA6B;AAC7B,MAAM,MAAM,GAAG,IAAI,gCAAc,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAChE,MAAM,SAAS,GAAG,qCAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAEtD,MAAM,UAAU,GAAG,wCAAwC,CAAC;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AAC;QAElD,OAAO;YACL,UAAU,EAAE,GAAG;YACf,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,6BAA6B,EAAE,GAAG;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC;SACzD,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AA3TW,QAAA,OAAO,WA2TlB","sourcesContent":["import { APIGatewayProxyEvent, APIGatewayProxyResult } from \"aws-lambda\";\nimport { DynamoDBClient } from \"@aws-sdk/client-dynamodb\";\nimport { DynamoDBDocumentClient, GetCommand, PutCommand, ScanCommand, DeleteCommand } from \"@aws-sdk/lib-dynamodb\";\n\n// Initialize DynamoDB client\nconst client = new DynamoDBClient({ region: \"ap-southeast-1\" });\nconst docClient = DynamoDBDocumentClient.from(client);\n\nconst TABLE_NAME = \"Profile-s4ph7chlarhupiqw7ml47pmehq-dev\";\n\nexport const handler = async (event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> => {\n try {\n const httpMethod = event.httpMethod;\n const path = event.path;\n const pathParameters = event.pathParameters || {};\n const queryStringParameters = event.queryStringParameters || {};\n const body = event.body ? JSON.parse(event.body) : {};\n\n console.log(`Processing ${httpMethod} ${path}`);\n\n // Simple mock response for testing\n const mockProfile = {\n id: \"test-profile-1\",\n email: \"test@example.com\",\n firstName: \"Test\",\n lastName: \"User\",\n availablePoint: 100,\n note: \"Test profile\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString()\n };\n\n switch (httpMethod) {\n case \"GET\":\n if (pathParameters.id) {\n // GET /profiles/{id}\n const getCommand = new GetCommand({\n TableName: TABLE_NAME,\n Key: { id: pathParameters.id }\n });\n const result = await docClient.send(getCommand);\n \n if (!result.Item) {\n return {\n statusCode: 404,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Profile not found\" }),\n };\n }\n\n return {\n statusCode: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(result.Item),\n };\n } else if (path.includes(\"/search\")) {\n // GET /profiles/search\n const searchParams = {\n phone: queryStringParameters.phone,\n email: queryStringParameters.email,\n cardNumber: queryStringParameters.cardNumber,\n };\n \n // Remove undefined values\n const cleanParams = Object.fromEntries(\n Object.entries(searchParams).filter(([_, value]) => value !== undefined)\n );\n \n if (Object.keys(cleanParams).length === 0) {\n // No search parameters, return all profiles\n const scanCommand = new ScanCommand({\n TableName: TABLE_NAME,\n Limit: 100\n });\n const result = await docClient.send(scanCommand);\n return {\n statusCode: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(result.Items || []),\n };\n }\n \n // Use scan with filter expressions\n const scanCommand = new ScanCommand({\n TableName: TABLE_NAME,\n FilterExpression: Object.keys(cleanParams).map(key => `${key} = :${key}`).join(' AND '),\n ExpressionAttributeValues: Object.fromEntries(\n Object.entries(cleanParams).map(([key, value]) => [`:${key}`, value])\n ),\n Limit: 100\n });\n \n const result = await docClient.send(scanCommand);\n return {\n statusCode: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(result.Items || []),\n };\n } else if (path.includes(\"/scan\")) {\n // GET /profiles/scan\n const scanCommand = new ScanCommand({\n TableName: TABLE_NAME,\n Limit: 100\n });\n const result = await docClient.send(scanCommand);\n return {\n statusCode: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(result.Items || []),\n };\n } else {\n // GET /profiles\n const scanCommand = new ScanCommand({\n TableName: TABLE_NAME,\n Limit: 100\n });\n const result = await docClient.send(scanCommand);\n return {\n statusCode: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(result.Items || []),\n };\n }\n\n case \"POST\":\n // POST /profiles\n const newProfile = {\n id: body.id || `profile-${Date.now()}`,\n ...body,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString()\n };\n\n const putCommand = new PutCommand({\n TableName: TABLE_NAME,\n Item: newProfile\n });\n \n await docClient.send(putCommand);\n \n return {\n statusCode: 201,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(newProfile),\n };\n\n case \"PUT\":\n // PUT /profiles/{id}\n if (!pathParameters.id) {\n return {\n statusCode: 400,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Profile ID is required\" }),\n };\n }\n\n // First check if profile exists\n const getExistingCommand = new GetCommand({\n TableName: TABLE_NAME,\n Key: { id: pathParameters.id }\n });\n const existingResult = await docClient.send(getExistingCommand);\n \n if (!existingResult.Item) {\n return {\n statusCode: 404,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Profile not found\" }),\n };\n }\n\n const updatedProfile = {\n ...existingResult.Item,\n ...body,\n id: pathParameters.id,\n updatedAt: new Date().toISOString()\n };\n\n const updateCommand = new PutCommand({\n TableName: TABLE_NAME,\n Item: updatedProfile\n });\n \n await docClient.send(updateCommand);\n \n return {\n statusCode: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(updatedProfile),\n };\n\n case \"PATCH\":\n // PATCH /profiles/{id}\n if (!pathParameters.id) {\n return {\n statusCode: 400,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Profile ID is required\" }),\n };\n }\n\n // First check if profile exists\n const getPatchCommand = new GetCommand({\n TableName: TABLE_NAME,\n Key: { id: pathParameters.id }\n });\n const patchResult = await docClient.send(getPatchCommand);\n \n if (!patchResult.Item) {\n return {\n statusCode: 404,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Profile not found\" }),\n };\n }\n\n const patchedProfile = {\n ...patchResult.Item,\n ...body,\n id: pathParameters.id,\n updatedAt: new Date().toISOString()\n };\n\n const patchUpdateCommand = new PutCommand({\n TableName: TABLE_NAME,\n Item: patchedProfile\n });\n \n await docClient.send(patchUpdateCommand);\n \n return {\n statusCode: 200,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify(patchedProfile),\n };\n\n case \"DELETE\":\n // DELETE /profiles/{id}\n if (!pathParameters.id) {\n return {\n statusCode: 400,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Profile ID is required\" }),\n };\n }\n\n const deleteCommand = new DeleteCommand({\n TableName: TABLE_NAME,\n Key: { id: pathParameters.id }\n });\n \n await docClient.send(deleteCommand);\n \n return {\n statusCode: 204,\n headers: {\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: \"\",\n };\n\n default:\n return {\n statusCode: 405,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Method not allowed\" }),\n };\n }\n } catch (error) {\n console.error(\"Error processing request:\", error);\n \n return {\n statusCode: 500,\n headers: {\n \"Content-Type\": \"application/json\",\n \"Access-Control-Allow-Origin\": \"*\",\n },\n body: JSON.stringify({ error: \"Internal server error\" }),\n };\n }\n};\n"]}
@@ -38,15 +38,6 @@ var __importStar = (this && this.__importStar) || (function () {
38
38
  return result;
39
39
  };
40
40
  })();
41
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
42
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
43
- return new (P || (P = Promise))(function (resolve, reject) {
44
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
45
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
46
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
47
- step((generator = generator.apply(thisArg, _arguments || [])).next());
48
- });
49
- };
50
41
  Object.defineProperty(exports, "__esModule", { value: true });
51
42
  exports.handler = void 0;
52
43
  require("reflect-metadata");
@@ -55,14 +46,10 @@ require("./e-order.controller");
55
46
  const handler = (event) => typedi_1.default.get(HelperCDI).process(event);
56
47
  exports.handler = handler;
57
48
  let HelperCDI = class HelperCDI {
58
- constructor() {
59
- this.controller = typedi_1.default.get("OrderController");
60
- }
61
- process(event) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- console.log("example Processing...");
64
- return this.controller.resolveCrudRequest(event);
65
- });
49
+ controller = typedi_1.default.get("OrderController");
50
+ async process(event) {
51
+ console.log("example Processing...");
52
+ return this.controller.resolveCrudRequest(event);
66
53
  }
67
54
  };
68
55
  HelperCDI = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"e-order-crud.js","sourceRoot":"","sources":["../../../../src/_examples/controller/e-order/e-order-crud.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA0B;AAC1B,iDAA4C;AAG5C,gCAA8B;AAEvB,MAAM,OAAO,GAAG,CAAC,KAA2B,EAAE,EAAE,CAAC,gBAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAAnF,QAAA,OAAO,WAA4E;AAGhG,IAAM,SAAS,GAAf,MAAM,SAAS;IAAf;QACU,eAAU,GAAoB,gBAAS,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAMzE,CAAC;IAJO,OAAO,CAAC,KAA2B;;YACvC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;YACrC,OAAO,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACnD,CAAC;KAAA;CACF,CAAA;AAPK,SAAS;IADd,IAAA,gBAAO,GAAE;GACJ,SAAS,CAOd","sourcesContent":["import \"reflect-metadata\";\nimport Container, { Service } from \"typedi\";\nimport { APIGatewayProxyEvent } from \"aws-lambda\";\nimport { OrderController } from \"./e-order.controller\";\nimport \"./e-order.controller\";\n\nexport const handler = (event: APIGatewayProxyEvent) => Container.get(HelperCDI).process(event);\n\n@Service()\nclass HelperCDI {\n private controller: OrderController = Container.get(\"OrderController\");\n\n async process(event: APIGatewayProxyEvent) {\n console.log(\"example Processing...\");\n return this.controller.resolveCrudRequest(event);\n }\n}\n"]}
1
+ {"version":3,"file":"e-order-crud.js","sourceRoot":"","sources":["../../../../src/_examples/controller/e-order/e-order-crud.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA0B;AAC1B,iDAA4C;AAG5C,gCAA8B;AAEvB,MAAM,OAAO,GAAG,CAAC,KAA2B,EAAE,EAAE,CAAC,gBAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAAnF,QAAA,OAAO,WAA4E;AAGhG,IAAM,SAAS,GAAf,MAAM,SAAS;IACL,UAAU,GAAoB,gBAAS,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAEvE,KAAK,CAAC,OAAO,CAAC,KAA2B;QACvC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AAPK,SAAS;IADd,IAAA,gBAAO,GAAE;GACJ,SAAS,CAOd","sourcesContent":["import \"reflect-metadata\";\nimport Container, { Service } from \"typedi\";\nimport { APIGatewayProxyEvent } from \"aws-lambda\";\nimport { OrderController } from \"./e-order.controller\";\nimport \"./e-order.controller\";\n\nexport const handler = (event: APIGatewayProxyEvent) => Container.get(HelperCDI).process(event);\n\n@Service()\nclass HelperCDI {\n private controller: OrderController = Container.get(\"OrderController\");\n\n async process(event: APIGatewayProxyEvent) {\n console.log(\"example Processing...\");\n return this.controller.resolveCrudRequest(event);\n }\n}\n"]}
@@ -41,15 +41,6 @@ var __importStar = (this && this.__importStar) || (function () {
41
41
  var __metadata = (this && this.__metadata) || function (k, v) {
42
42
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
43
  };
44
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
45
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
46
- return new (P || (P = Promise))(function (resolve, reject) {
47
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
48
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
49
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
50
- step((generator = generator.apply(thisArg, _arguments || [])).next());
51
- });
52
- };
53
44
  Object.defineProperty(exports, "__esModule", { value: true });
54
45
  exports.OrderController = void 0;
55
46
  const typedi_1 = __importStar(require("typedi"));
@@ -65,30 +56,20 @@ let OrderController = class OrderController extends base_controller_1.BaseContro
65
56
  const service = typedi_1.default.get("OrderService");
66
57
  super(service, e_order_config_1.CONFIG_E_ORDER.toObject());
67
58
  }
68
- processCrudRequest(_event) {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- return undefined;
71
- });
59
+ async processCrudRequest(_event) {
60
+ return undefined;
72
61
  }
73
- processStreamEvent(_event) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- return;
76
- });
62
+ async processStreamEvent(_event) {
63
+ return;
77
64
  }
78
- processScheduledEvent(_event) {
79
- return __awaiter(this, void 0, void 0, function* () {
80
- return;
81
- });
65
+ async processScheduledEvent(_event) {
66
+ return;
82
67
  }
83
- processWebSocketEvent(_event) {
84
- return __awaiter(this, void 0, void 0, function* () {
85
- return;
86
- });
68
+ async processWebSocketEvent(_event) {
69
+ return;
87
70
  }
88
- processSQSEvent(_sqsEvent) {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- return undefined;
91
- });
71
+ async processSQSEvent(_sqsEvent) {
72
+ return undefined;
92
73
  }
93
74
  };
94
75
  exports.OrderController = OrderController;
@@ -1 +1 @@
1
- {"version":3,"file":"e-order.controller.js","sourceRoot":"","sources":["../../../../src/_examples/controller/e-order/e-order.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,iDAA4C;AAC5C,yEAAqE;AAErE,qDAAkD;AAElD,uCAAqC;AAErC;;;GAGG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,gCAA4B;IAC/D;QACE,MAAM,OAAO,GAAiB,gBAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC5D,KAAK,CAAC,OAAO,EAAE,+BAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC5C,CAAC;IAEe,kBAAkB,CAAC,MAA4B;;YAC7D,OAAO,SAAS,CAAC;QACnB,CAAC;KAAA;IAEe,kBAAkB,CAAC,MAA2B;;YAC5D,OAAO;QACT,CAAC;KAAA;IAEe,qBAAqB,CAAC,MAAsB;;YAC1D,OAAO;QACT,CAAC;KAAA;IAEe,qBAAqB,CAAC,MAAuC;;YAC3E,OAAO;QACT,CAAC;KAAA;IAEe,eAAe,CAAC,SAAmB;;YACjD,OAAO,SAAS,CAAC;QACnB,CAAC;KAAA;CACF,CAAA;AAzBY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,gBAAO,EAAC,iBAAiB,CAAC;;GACd,eAAe,CAyB3B","sourcesContent":["import {\n APIGatewayProxyEvent,\n APIGatewayProxyWebsocketEventV2,\n DynamoDBStreamEvent,\n ScheduledEvent,\n SQSEvent,\n} from \"aws-lambda\";\nimport Container, { Service } from \"typedi\";\nimport { BaseController } from \"../../../controller/base-controller\";\n\nimport { CONFIG_E_ORDER } from \"./e-order.config\";\nimport { OrderService } from \"../../service/order-service.interface\";\nimport \"../../service/order-service\";\n\n/**\n * Example Controller for Profile: Validator (Zod) is set centrally.\n * This automatically validates POST/PUT/PATCH requests.\n */\n@Service(\"OrderController\")\nexport class OrderController extends BaseController<OrderService> {\n constructor() {\n const service: OrderService = Container.get(\"OrderService\");\n super(service, CONFIG_E_ORDER.toObject());\n }\n\n protected async processCrudRequest(_event: APIGatewayProxyEvent): Promise<any> {\n return undefined;\n }\n\n protected async processStreamEvent(_event: DynamoDBStreamEvent): Promise<void> {\n return;\n }\n\n protected async processScheduledEvent(_event: ScheduledEvent): Promise<void> {\n return;\n }\n\n protected async processWebSocketEvent(_event: APIGatewayProxyWebsocketEventV2): Promise<void> {\n return;\n }\n\n protected async processSQSEvent(_sqsEvent: SQSEvent): Promise<any> {\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"e-order.controller.js","sourceRoot":"","sources":["../../../../src/_examples/controller/e-order/e-order.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,iDAA4C;AAC5C,yEAAqE;AAErE,qDAAkD;AAElD,uCAAqC;AAErC;;;GAGG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,gCAA4B;IAC/D;QACE,MAAM,OAAO,GAAiB,gBAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC5D,KAAK,CAAC,OAAO,EAAE,+BAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC5C,CAAC;IAES,KAAK,CAAC,kBAAkB,CAAC,MAA4B;QAC7D,OAAO,SAAS,CAAC;IACnB,CAAC;IAES,KAAK,CAAC,kBAAkB,CAAC,MAA2B;QAC5D,OAAO;IACT,CAAC;IAES,KAAK,CAAC,qBAAqB,CAAC,MAAsB;QAC1D,OAAO;IACT,CAAC;IAES,KAAK,CAAC,qBAAqB,CAAC,MAAuC;QAC3E,OAAO;IACT,CAAC;IAES,KAAK,CAAC,eAAe,CAAC,SAAmB;QACjD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAA;AAzBY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,gBAAO,EAAC,iBAAiB,CAAC;;GACd,eAAe,CAyB3B","sourcesContent":["import {\n APIGatewayProxyEvent,\n APIGatewayProxyWebsocketEventV2,\n DynamoDBStreamEvent,\n ScheduledEvent,\n SQSEvent,\n} from \"aws-lambda\";\nimport Container, { Service } from \"typedi\";\nimport { BaseController } from \"../../../controller/base-controller\";\n\nimport { CONFIG_E_ORDER } from \"./e-order.config\";\nimport { OrderService } from \"../../service/order-service.interface\";\nimport \"../../service/order-service\";\n\n/**\n * Example Controller for Profile: Validator (Zod) is set centrally.\n * This automatically validates POST/PUT/PATCH requests.\n */\n@Service(\"OrderController\")\nexport class OrderController extends BaseController<OrderService> {\n constructor() {\n const service: OrderService = Container.get(\"OrderService\");\n super(service, CONFIG_E_ORDER.toObject());\n }\n\n protected async processCrudRequest(_event: APIGatewayProxyEvent): Promise<any> {\n return undefined;\n }\n\n protected async processStreamEvent(_event: DynamoDBStreamEvent): Promise<void> {\n return;\n }\n\n protected async processScheduledEvent(_event: ScheduledEvent): Promise<void> {\n return;\n }\n\n protected async processWebSocketEvent(_event: APIGatewayProxyWebsocketEventV2): Promise<void> {\n return;\n }\n\n protected async processSQSEvent(_sqsEvent: SQSEvent): Promise<any> {\n return undefined;\n }\n}\n"]}
@@ -41,15 +41,6 @@ var __importStar = (this && this.__importStar) || (function () {
41
41
  var __metadata = (this && this.__metadata) || function (k, v) {
42
42
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
43
  };
44
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
45
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
46
- return new (P || (P = Promise))(function (resolve, reject) {
47
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
48
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
49
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
50
- step((generator = generator.apply(thisArg, _arguments || [])).next());
51
- });
52
- };
53
44
  Object.defineProperty(exports, "__esModule", { value: true });
54
45
  exports.EntityController = void 0;
55
46
  const typedi_1 = __importStar(require("typedi"));
@@ -66,39 +57,36 @@ let EntityController = class EntityController extends core_1.BaseController {
66
57
  processSQSEvent(sqsEvent) {
67
58
  throw new Error("Method not implemented.");
68
59
  }
69
- processCrudRequest(apiGatewayProxyEvent) {
70
- return __awaiter(this, void 0, void 0, function* () {
71
- var _a, _b;
72
- if (this.resourcePath === `GET ${entity_config_1.path}/search-entities`) {
73
- const filter = this.request.filterAndSort;
74
- filter.status = supplier_portal_model_1.Status.active;
75
- return yield this.service.find(filter);
76
- }
77
- if (this.resourcePath === `GET ${entity_config_1.path}/batch`) {
78
- const ids = (_a = this.request.filterAndSort.ids.split(",")) !== null && _a !== void 0 ? _a : [];
79
- return yield this.service.findByIds(ids);
80
- }
81
- if (this.resourcePath === `GET ${entity_config_1.path}/details/{id}`) {
82
- const { id } = this.request.pathParameters;
83
- const result = yield this.service.findById(id);
84
- if (result.status !== supplier_portal_model_1.Status.active)
85
- throw new errors_1.ErrorHttp({ code: 404, error: "NotFound" }, "Entity not found");
86
- return result;
87
- }
88
- // TODO remove later
89
- if (this.resourcePath === `GET /entities/batch`) {
90
- const ids = (_b = this.request.filterAndSort.ids.split(",")) !== null && _b !== void 0 ? _b : [];
91
- return yield this.service.searchEntityBatch(ids);
92
- }
93
- // TODO remove later
94
- if (this.resourcePath === `GET /entities/{id}`) {
95
- const { id } = this.request.pathParameters;
96
- const result = yield this.service.findById(id);
97
- if (result.status !== supplier_portal_model_1.Status.active)
98
- throw new errors_1.ErrorHttp({ code: 404, error: "NotFound" }, "Entity not found");
99
- return result;
100
- }
101
- });
60
+ async processCrudRequest(apiGatewayProxyEvent) {
61
+ if (this.resourcePath === `GET ${entity_config_1.path}/search-entities`) {
62
+ const filter = this.request.filterAndSort;
63
+ filter.status = supplier_portal_model_1.Status.active;
64
+ return await this.service.find(filter);
65
+ }
66
+ if (this.resourcePath === `GET ${entity_config_1.path}/batch`) {
67
+ const ids = this.request.filterAndSort.ids.split(",") ?? [];
68
+ return await this.service.findByIds(ids);
69
+ }
70
+ if (this.resourcePath === `GET ${entity_config_1.path}/details/{id}`) {
71
+ const { id } = this.request.pathParameters;
72
+ const result = await this.service.findById(id);
73
+ if (result.status !== supplier_portal_model_1.Status.active)
74
+ throw new errors_1.ErrorHttp({ code: 404, error: "NotFound" }, "Entity not found");
75
+ return result;
76
+ }
77
+ // TODO remove later
78
+ if (this.resourcePath === `GET /entities/batch`) {
79
+ const ids = this.request.filterAndSort.ids.split(",") ?? [];
80
+ return await this.service.searchEntityBatch(ids);
81
+ }
82
+ // TODO remove later
83
+ if (this.resourcePath === `GET /entities/{id}`) {
84
+ const { id } = this.request.pathParameters;
85
+ const result = await this.service.findById(id);
86
+ if (result.status !== supplier_portal_model_1.Status.active)
87
+ throw new errors_1.ErrorHttp({ code: 404, error: "NotFound" }, "Entity not found");
88
+ return result;
89
+ }
102
90
  }
103
91
  processStreamEvent(dynamoDBStreamEvent) {
104
92
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"entity-controller.js","sourceRoot":"","sources":["../../../../src/_examples/controller/entity/entity-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAQ5C,mDAAsD;AACtD,yCAAgD;AAChD,oFAAkE;AAClE,sDAAsD;AAGtD,+CAA6C;AAGtC,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,qBAA6B;IACjE;QACE,MAAM,aAAa,GAAkB,gBAAS,CAAC,GAAG,CA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B,IAAI,IAAI,CAAC,YAAY,KAAK,qBAAqB,EAAE,CAAC;gBAChD,MAAM,GAAG,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC;gBAC5D,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;YACnD,CAAC;YAED,oBAAoB;YACpB,IAAI,IAAI,CAAC,YAAY,KAAK,oBAAoB,EAAE,CAAC;gBAC/C,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;gBAC3C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;gBAC/C,IAAI,MAAM,CAAC,MAAM,KAAK,8BAAM,CAAC,MAAM;oBAAE,MAAM,IAAI,kBAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,kBAAkB,CAAC,CAAC;gBAC/G,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;KAAA;IAES,kBAAkB,CAAC,mBAAwC;QACnE,OAAO;IACT,CAAC;IAES,qBAAqB,CAAC,cAA8B;QAC5D,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAES,qBAAqB,CAAC,KAAsC;QACpE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF,CAAA;AAvDY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,gBAAO,EAAC,kBAAkB,CAAC;;GACf,gBAAgB,CAuD5B","sourcesContent":["import Container, { Service } from \"typedi\";\nimport {\n APIGatewayProxyEvent,\n APIGatewayProxyWebsocketEventV2,\n DynamoDBStreamEvent,\n ScheduledEvent,\n SQSEvent,\n} from \"aws-lambda\";\nimport { CONFIG_ENTITY, path } from \"./entity-config\";\nimport { BaseController } from \"@chinggis/core\";\nimport { Status } from \"../../model-shared/supplier-portal.model\";\nimport { ErrorHttp } from \"../../../exception/errors\";\n\nimport { EntityService } from \"../../service/entity/entity-service.interface\";\nimport \"../../service/entity/entity-service\";\n\n@Service(\"EntityController\")\nexport class EntityController extends BaseController<EntityService> {\n constructor() {\n const entityService: EntityService = Container.get(\"EntityService\");\n super(entityService, CONFIG_ENTITY.toObject());\n }\n\n protected processSQSEvent(sqsEvent: SQSEvent): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n\n protected async processCrudRequest(apiGatewayProxyEvent: APIGatewayProxyEvent): Promise<any> {\n if (this.resourcePath === `GET ${path}/search-entities`) {\n const filter = this.request.filterAndSort;\n filter.status = Status.active;\n return await this.service.find(filter);\n }\n\n if (this.resourcePath === `GET ${path}/batch`) {\n const ids = this.request.filterAndSort.ids.split(\",\") ?? [];\n return await this.service.findByIds(ids);\n }\n\n if (this.resourcePath === `GET ${path}/details/{id}`) {\n const { id } = this.request.pathParameters;\n const result = await this.service.findById(id);\n if (result.status !== Status.active) throw new ErrorHttp({ code: 404, error: \"NotFound\" }, \"Entity not found\");\n return result;\n }\n\n // TODO remove later\n if (this.resourcePath === `GET /entities/batch`) {\n const ids = this.request.filterAndSort.ids.split(\",\") ?? [];\n return await this.service.searchEntityBatch(ids);\n }\n\n // TODO remove later\n if (this.resourcePath === `GET /entities/{id}`) {\n const { id } = this.request.pathParameters;\n const result = await this.service.findById(id);\n if (result.status !== Status.active) throw new ErrorHttp({ code: 404, error: \"NotFound\" }, \"Entity not found\");\n return result;\n }\n }\n\n protected processStreamEvent(dynamoDBStreamEvent: DynamoDBStreamEvent): Promise<void> {\n return;\n }\n\n protected processScheduledEvent(scheduledEvent: ScheduledEvent): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n protected processWebSocketEvent(event: APIGatewayProxyWebsocketEventV2): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n}\n"]}
1
+ {"version":3,"file":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AAC;IAC7C,CAAC;CACF,CAAA;AAvDY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,gBAAO,EAAC,kBAAkB,CAAC;;GACf,gBAAgB,CAuD5B","sourcesContent":["import Container, { Service } from \"typedi\";\nimport {\n APIGatewayProxyEvent,\n APIGatewayProxyWebsocketEventV2,\n DynamoDBStreamEvent,\n ScheduledEvent,\n SQSEvent,\n} from \"aws-lambda\";\nimport { CONFIG_ENTITY, path } from \"./entity-config\";\nimport { BaseController } from \"@chinggis/core\";\nimport { Status } from \"../../model-shared/supplier-portal.model\";\nimport { ErrorHttp } from \"../../../exception/errors\";\n\nimport { EntityService } from \"../../service/entity/entity-service.interface\";\nimport \"../../service/entity/entity-service\";\n\n@Service(\"EntityController\")\nexport class EntityController extends BaseController<EntityService> {\n constructor() {\n const entityService: EntityService = Container.get(\"EntityService\");\n super(entityService, CONFIG_ENTITY.toObject());\n }\n\n protected processSQSEvent(sqsEvent: SQSEvent): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n\n protected async processCrudRequest(apiGatewayProxyEvent: APIGatewayProxyEvent): Promise<any> {\n if (this.resourcePath === `GET ${path}/search-entities`) {\n const filter = this.request.filterAndSort;\n filter.status = Status.active;\n return await this.service.find(filter);\n }\n\n if (this.resourcePath === `GET ${path}/batch`) {\n const ids = this.request.filterAndSort.ids.split(\",\") ?? [];\n return await this.service.findByIds(ids);\n }\n\n if (this.resourcePath === `GET ${path}/details/{id}`) {\n const { id } = this.request.pathParameters;\n const result = await this.service.findById(id);\n if (result.status !== Status.active) throw new ErrorHttp({ code: 404, error: \"NotFound\" }, \"Entity not found\");\n return result;\n }\n\n // TODO remove later\n if (this.resourcePath === `GET /entities/batch`) {\n const ids = this.request.filterAndSort.ids.split(\",\") ?? [];\n return await this.service.searchEntityBatch(ids);\n }\n\n // TODO remove later\n if (this.resourcePath === `GET /entities/{id}`) {\n const { id } = this.request.pathParameters;\n const result = await this.service.findById(id);\n if (result.status !== Status.active) throw new ErrorHttp({ code: 404, error: \"NotFound\" }, \"Entity not found\");\n return result;\n }\n }\n\n protected processStreamEvent(dynamoDBStreamEvent: DynamoDBStreamEvent): Promise<void> {\n return;\n }\n\n protected processScheduledEvent(scheduledEvent: ScheduledEvent): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n protected processWebSocketEvent(event: APIGatewayProxyWebsocketEventV2): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n}\n"]}
@@ -38,15 +38,6 @@ var __importStar = (this && this.__importStar) || (function () {
38
38
  return result;
39
39
  };
40
40
  })();
41
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
42
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
43
- return new (P || (P = Promise))(function (resolve, reject) {
44
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
45
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
46
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
47
- step((generator = generator.apply(thisArg, _arguments || [])).next());
48
- });
49
- };
50
41
  Object.defineProperty(exports, "__esModule", { value: true });
51
42
  exports.handler = void 0;
52
43
  require("reflect-metadata");
@@ -55,16 +46,12 @@ require("./entity-controller");
55
46
  const handler = (event) => typedi_1.default.get(HelperCDI).process(event);
56
47
  exports.handler = handler;
57
48
  let HelperCDI = class HelperCDI {
58
- constructor() {
59
- this.controller = typedi_1.default.get("EntityController");
60
- }
61
- process(event) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- log.debug("_example event start----------------------------------------\n");
64
- log.debug(JSON.stringify(event, null, 2));
65
- log.debug("_example event end ----------------------------------------\n\n");
66
- return this.controller.resolveCrudRequest(event);
67
- });
49
+ controller = typedi_1.default.get("EntityController");
50
+ async process(event) {
51
+ log.debug("_example event start----------------------------------------\n");
52
+ log.debug(JSON.stringify(event, null, 2));
53
+ log.debug("_example event end ----------------------------------------\n\n");
54
+ return this.controller.resolveCrudRequest(event);
68
55
  }
69
56
  };
70
57
  HelperCDI = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"entity-crud.js","sourceRoot":"","sources":["../../../../src/_examples/controller/entity/entity-crud.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA0B;AAC1B,iDAA4C;AAI5C,+BAA6B;AAEtB,MAAM,OAAO,GAAG,CAAC,KAA2B,EAAE,EAAE,CAAC,gBAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAAnF,QAAA,OAAO,WAA4E;AAGhG,IAAM,SAAS,GAAf,MAAM,SAAS;IAAf;QACmB,eAAU,GAAqB,gBAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAQpF,CAAC;IANO,OAAO,CAAC,KAA2B;;YACvC,GAAG,CAAC,KAAK,CAAC,gEAAgE,CAAC,CAAC;YAC5E,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAC1C,GAAG,CAAC,KAAK,CAAC,kEAAkE,CAAC,CAAC;YAC9E,OAAO,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACnD,CAAC;KAAA;CACF,CAAA;AATK,SAAS;IADd,IAAA,gBAAO,GAAE;GACJ,SAAS,CASd","sourcesContent":["import \"reflect-metadata\";\nimport Container, { Service } from \"typedi\";\nimport { APIGatewayProxyEvent } from \"aws-lambda\";\n\nimport { EntityController } from \"./entity-controller\";\nimport \"./entity-controller\";\n\nexport const handler = (event: APIGatewayProxyEvent) => Container.get(HelperCDI).process(event);\n\n@Service()\nclass HelperCDI {\n private readonly controller: EntityController = Container.get(\"EntityController\");\n\n async process(event: APIGatewayProxyEvent) {\n log.debug(\"_example event start----------------------------------------\\n\");\n log.debug(JSON.stringify(event, null, 2));\n log.debug(\"_example event end ----------------------------------------\\n\\n\");\n return this.controller.resolveCrudRequest(event);\n }\n}\n"]}
1
+ {"version":3,"file":"entity-crud.js","sourceRoot":"","sources":["../../../../src/_examples/controller/entity/entity-crud.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA0B;AAC1B,iDAA4C;AAI5C,+BAA6B;AAEtB,MAAM,OAAO,GAAG,CAAC,KAA2B,EAAE,EAAE,CAAC,gBAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAAnF,QAAA,OAAO,WAA4E;AAGhG,IAAM,SAAS,GAAf,MAAM,SAAS;IACI,UAAU,GAAqB,gBAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAElF,KAAK,CAAC,OAAO,CAAC,KAA2B;QACvC,GAAG,CAAC,KAAK,CAAC,gEAAgE,CAAC,CAAC;QAC5E,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1C,GAAG,CAAC,KAAK,CAAC,kEAAkE,CAAC,CAAC;QAC9E,OAAO,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AATK,SAAS;IADd,IAAA,gBAAO,GAAE;GACJ,SAAS,CASd","sourcesContent":["import \"reflect-metadata\";\nimport Container, { Service } from \"typedi\";\nimport { APIGatewayProxyEvent } from \"aws-lambda\";\n\nimport { EntityController } from \"./entity-controller\";\nimport \"./entity-controller\";\n\nexport const handler = (event: APIGatewayProxyEvent) => Container.get(HelperCDI).process(event);\n\n@Service()\nclass HelperCDI {\n private readonly controller: EntityController = Container.get(\"EntityController\");\n\n async process(event: APIGatewayProxyEvent) {\n log.debug(\"_example event start----------------------------------------\\n\");\n log.debug(JSON.stringify(event, null, 2));\n log.debug(\"_example event end ----------------------------------------\\n\\n\");\n return this.controller.resolveCrudRequest(event);\n }\n}\n"]}
@@ -41,15 +41,6 @@ var __importStar = (this && this.__importStar) || (function () {
41
41
  var __metadata = (this && this.__metadata) || function (k, v) {
42
42
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
43
  };
44
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
45
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
46
- return new (P || (P = Promise))(function (resolve, reject) {
47
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
48
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
49
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
50
- step((generator = generator.apply(thisArg, _arguments || [])).next());
51
- });
52
- };
53
44
  Object.defineProperty(exports, "__esModule", { value: true });
54
45
  require("reflect-metadata");
55
46
  const typedi_1 = __importStar(require("typedi"));
@@ -58,20 +49,17 @@ const user_controller_1 = require("./user.controller");
58
49
  require("./user.controller");
59
50
  require("./profile/profile.controller");
60
51
  let HelperCDI = class HelperCDI {
61
- run() {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- console.log("running");
64
- yield this.listUsers();
65
- console.log("done");
66
- });
52
+ userController;
53
+ async run() {
54
+ console.log("running");
55
+ await this.listUsers();
56
+ console.log("done");
67
57
  }
68
- listUsers() {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- const data = fs.readFileSync("../__tests__/api-request.json", "utf-8");
71
- const eventInput = JSON.parse(data);
72
- const response = yield this.userController.resolveCrudRequest(eventInput);
73
- console.log(JSON.stringify(response, null, 2));
74
- });
58
+ async listUsers() {
59
+ const data = fs.readFileSync("../__tests__/api-request.json", "utf-8");
60
+ const eventInput = JSON.parse(data);
61
+ const response = await this.userController.resolveCrudRequest(eventInput);
62
+ console.log(JSON.stringify(response, null, 2));
75
63
  }
76
64
  };
77
65
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/_examples/controller/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA0B;AAC1B,iDAAoD;AACpD,uCAAyB;AAEzB,uDAAmD;AACnD,6BAA2B;AAC3B,wCAAsC;AAItC,IAAM,SAAS,GAAf,MAAM,SAAS;IAGP,GAAG;;YACP,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACvB,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC;KAAA;IAEa,SAAS;;YACrB,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,+BAA+B,EAAE,OAAO,CAAC,CAAC;YACvE,MAAM,UAAU,GAAyB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAE1D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;YAC1E,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACjD,CAAC;KAAA;CACF,CAAA;AAf4C;IAA1C,IAAA,eAAM,EAAC,gBAAgB,CAAC;8BAAkC,gCAAc;iDAAM;AAD3E,SAAS;IADd,IAAA,gBAAO,GAAE;GACJ,SAAS,CAgBd;AAED,MAAM,IAAI,GAAG,gBAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACtC,IAAI,CAAC,GAAG,EAAE,CAAC","sourcesContent":["import \"reflect-metadata\";\nimport Container, { Inject, Service } from \"typedi\";\nimport * as fs from \"fs\";\n\nimport { UserController } from \"./user.controller\";\nimport \"./user.controller\";\nimport \"./profile/profile.controller\";\nimport { APIGatewayProxyEvent } from \"aws-lambda\";\n\n@Service()\nclass HelperCDI {\n @Inject(\"UserController\") private readonly userController: UserController<any>;\n\n async run() {\n console.log(\"running\");\n await this.listUsers();\n console.log(\"done\");\n }\n\n private async listUsers() {\n const data = fs.readFileSync(\"../__tests__/api-request.json\", \"utf-8\");\n const eventInput: APIGatewayProxyEvent = JSON.parse(data);\n\n const response = await this.userController.resolveCrudRequest(eventInput);\n console.log(JSON.stringify(response, null, 2));\n }\n}\n\nconst main = Container.get(HelperCDI);\nmain.run();\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/_examples/controller/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA0B;AAC1B,iDAAoD;AACpD,uCAAyB;AAEzB,uDAAmD;AACnD,6BAA2B;AAC3B,wCAAsC;AAItC,IAAM,SAAS,GAAf,MAAM,SAAS;IAC8B,cAAc,CAAsB;IAE/E,KAAK,CAAC,GAAG;QACP,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvB,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAEO,KAAK,CAAC,SAAS;QACrB,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,+BAA+B,EAAE,OAAO,CAAC,CAAC;QACvE,MAAM,UAAU,GAAyB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAE1D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAC1E,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;CACF,CAAA;AAf4C;IAA1C,IAAA,eAAM,EAAC,gBAAgB,CAAC;8BAAkC,gCAAc;iDAAM;AAD3E,SAAS;IADd,IAAA,gBAAO,GAAE;GACJ,SAAS,CAgBd;AAED,MAAM,IAAI,GAAG,gBAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACtC,IAAI,CAAC,GAAG,EAAE,CAAC","sourcesContent":["import \"reflect-metadata\";\nimport Container, { Inject, Service } from \"typedi\";\nimport * as fs from \"fs\";\n\nimport { UserController } from \"./user.controller\";\nimport \"./user.controller\";\nimport \"./profile/profile.controller\";\nimport { APIGatewayProxyEvent } from \"aws-lambda\";\n\n@Service()\nclass HelperCDI {\n @Inject(\"UserController\") private readonly userController: UserController<any>;\n\n async run() {\n console.log(\"running\");\n await this.listUsers();\n console.log(\"done\");\n }\n\n private async listUsers() {\n const data = fs.readFileSync(\"../__tests__/api-request.json\", \"utf-8\");\n const eventInput: APIGatewayProxyEvent = JSON.parse(data);\n\n const response = await this.userController.resolveCrudRequest(eventInput);\n console.log(JSON.stringify(response, null, 2));\n }\n}\n\nconst main = Container.get(HelperCDI);\nmain.run();\n"]}