@creator.co/wapi 1.2.0-beta2 → 1.2.0-beta4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator.co/wapi",
3
- "version": "1.2.0-beta1",
3
+ "version": "1.2.0-beta4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -5,5 +5,5 @@ export default class Server {
5
5
  constructor(config: RouterConfig);
6
6
  getExport(): CallableFunction;
7
7
  handleServerlessEvent(event: APIGatewayProxyEvent, context: Context): Promise<void>;
8
- private routeMatches;
8
+ private static routeMatches;
9
9
  }
@@ -60,56 +60,58 @@ var Server = /** @class */ (function () {
60
60
  };
61
61
  Server.prototype.handleServerlessEvent = function (event, context) {
62
62
  return __awaiter(this, void 0, void 0, function () {
63
+ var config;
63
64
  var _this = this;
64
65
  return __generator(this, function (_a) {
65
66
  switch (_a.label) {
66
- case 0:
67
- // init transaction
68
- return [4 /*yield*/, new Transaction_1.default(event, context, this.config).execute(function (transaction) { return __awaiter(_this, void 0, void 0, function () {
69
- var _a, _b, route, handler, validationResp, e_1_1;
70
- var e_1, _c;
71
- return __generator(this, function (_d) {
72
- switch (_d.label) {
73
- case 0:
74
- _d.trys.push([0, 5, 6, 7]);
75
- _a = __values(this.config.routes), _b = _a.next();
76
- _d.label = 1;
77
- case 1:
78
- if (!!_b.done) return [3 /*break*/, 4];
79
- route = _b.value;
80
- handler = this.routeMatches(route.path, route.method, event);
81
- if (!handler) return [3 /*break*/, 3];
82
- transaction.logger.log("Router accepted route:", route);
83
- // Validate input
84
- if (route.inputSchema) {
85
- validationResp = Validator_1.default.validateSchema(transaction.request.getBody(), route.inputSchema);
86
- if (validationResp && validationResp instanceof Response_1.default)
87
- return [2 /*return*/, validationResp];
88
- }
89
- return [4 /*yield*/, route.handler(transaction)];
90
- case 2:
91
- // Continue to route handler
92
- return [2 /*return*/, _d.sent()];
93
- case 3:
94
- _b = _a.next();
95
- return [3 /*break*/, 1];
96
- case 4: return [3 /*break*/, 7];
97
- case 5:
98
- e_1_1 = _d.sent();
99
- e_1 = { error: e_1_1 };
100
- return [3 /*break*/, 7];
101
- case 6:
102
- try {
103
- if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
104
- }
105
- finally { if (e_1) throw e_1.error; }
106
- return [7 /*endfinally*/];
107
- case 7:
108
- //No route found :/
109
- return [2 /*return*/, new Response_1.default(404, { err: "Route not found!" })];
110
- }
111
- });
112
- }); })];
67
+ case 0:
68
+ config = this.config;
69
+ // init transaction
70
+ return [4 /*yield*/, new Transaction_1.default(event, context, config).execute(function (transaction) { return __awaiter(_this, void 0, void 0, function () {
71
+ var _a, _b, route, handler, validationResp, e_1_1;
72
+ var e_1, _c;
73
+ return __generator(this, function (_d) {
74
+ switch (_d.label) {
75
+ case 0:
76
+ _d.trys.push([0, 5, 6, 7]);
77
+ _a = __values(config.routes), _b = _a.next();
78
+ _d.label = 1;
79
+ case 1:
80
+ if (!!_b.done) return [3 /*break*/, 4];
81
+ route = _b.value;
82
+ handler = Server.routeMatches(route.path, route.method, event);
83
+ if (!handler) return [3 /*break*/, 3];
84
+ transaction.logger.log("Router accepted route:", route.path);
85
+ // Validate input
86
+ if (route.inputSchema) {
87
+ validationResp = Validator_1.default.validateSchema(transaction.request.getBody(), route.inputSchema);
88
+ if (validationResp && validationResp instanceof Response_1.default)
89
+ return [2 /*return*/, validationResp];
90
+ }
91
+ return [4 /*yield*/, route.handler(transaction)];
92
+ case 2:
93
+ // Continue to route handler
94
+ return [2 /*return*/, _d.sent()];
95
+ case 3:
96
+ _b = _a.next();
97
+ return [3 /*break*/, 1];
98
+ case 4: return [3 /*break*/, 7];
99
+ case 5:
100
+ e_1_1 = _d.sent();
101
+ e_1 = { error: e_1_1 };
102
+ return [3 /*break*/, 7];
103
+ case 6:
104
+ try {
105
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
106
+ }
107
+ finally { if (e_1) throw e_1.error; }
108
+ return [7 /*endfinally*/];
109
+ case 7:
110
+ //No route found :/
111
+ return [2 /*return*/, new Response_1.default(404, { err: "Route not found!" })];
112
+ }
113
+ });
114
+ }); })];
113
115
  case 1:
114
116
  // init transaction
115
117
  _a.sent();
@@ -119,7 +121,7 @@ var Server = /** @class */ (function () {
119
121
  });
120
122
  };
121
123
  // Helper function to match route
122
- Server.prototype.routeMatches = function (routePath, routeMethod, event) {
124
+ Server.routeMatches = function (routePath, routeMethod, event) {
123
125
  var path = event.path;
124
126
  var keys = [];
125
127
  var result = pathToRegexp(routePath, keys).exec(path);
@@ -1 +1 @@
1
- {"version":3,"file":"Server.js","sourceRoot":"","sources":["../../../../src/Server/lib/Server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAA8C;AAE9C,+CAAyC;AACzC,2DAAqD;AACrD,wDAAkD;AAGlD;IAEE,gBAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAEM,0BAAS,GAAhB;QACE,OAAO,IAAI,CAAC,qBAAqB,CAAA;IACnC,CAAC;IAEY,sCAAqB,GAAlC,UACE,KAA2B,EAC3B,OAAgB;;;;;;oBAEhB,mBAAmB;oBACnB,qBAAM,IAAI,qBAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CACxD,UAAO,WAAW;;;;;;;wCACI,KAAA,SAAA,IAAI,CAAC,MAAM,CAAC,MAAM,CAAA;;;;wCAA3B,KAAK;wCAER,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;6CAC9D,OAAO,EAAP,wBAAO;wCACT,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,wBAAwB,EAAE,KAAK,CAAC,C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AClB,mBAAY,GAA3B,UACE,SAAiB,EACjB,WAAmB,EACnB,KAA2B;QAE3B,IAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;QACvB,IAAM,IAAI,GAAG,EAAE,CAAA;QACf,IAAM,MAAM,GAAG,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvD,IAAI,MAAM,EAAE;YACV,IAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAA;YAClC,IAAI,SAAS,CAAC,WAAW,EAAE,IAAI,WAAW,CAAC,WAAW,EAAE,EAAE;gBACxD,OAAO,IAAI,CAAA;aACZ;SACF;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IACH,aAAC;AAAD,CAAC,AA1DD,IA0DC"}
@@ -84,6 +84,7 @@ exports.default = (function (serverlessHandler) {
84
84
  case 3:
85
85
  e_1 = _a.sent();
86
86
  console.error("[Proxy] - Exception during execution!", e_1);
87
+ console.error(e_1.stack);
87
88
  resp = res.status(Globals_1.default.Resp_STATUSCODE_EXCEPTION).json(__assign(__assign({}, e_1), { err: Globals_1.default.Resp_MSG_EXCEPTION, errCode: Globals_1.default.Resp_CODE_EXCEPTION }));
88
89
  return [3 /*break*/, 4];
89
90
  case 4:
@@ -1 +1 @@
1
- {"version":3,"file":"GenericHandler.js","sourceRoot":"","sources":["../../../../../src/Server/lib/container/GenericHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6DAE8B;AAC9B,4CAAsC;AACtC,4CAAsC;AAGtC,mBAAe,UAAC,iBAAkD;IAChE,OAAO,UAAO,OAAgB,EAAE,GAAa;;;;;oBACrC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;oBACxB,IAAI,GAAG,IAAI,CAAA;;;;oBAGP,UAAQ,IAAI,6BAAmB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAA;oBA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AAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;aAClC,IAAI,CAAC,eAAK,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QACjE,OAAO,QAAQ,CAAA;KAChB;AACH,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator.co/wapi",
3
- "version": "1.2.0-beta2",
3
+ "version": "1.2.0-beta4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,14 +20,15 @@ export default class Server {
20
20
  event: APIGatewayProxyEvent,
21
21
  context: Context,
22
22
  ) {
23
+ const config = this.config
23
24
  // init transaction
24
- await new Transaction(event, context, this.config).execute(
25
+ await new Transaction(event, context, config).execute(
25
26
  async (transaction) => {
26
- for (const route of this.config.routes) {
27
+ for (const route of config.routes) {
27
28
  // Check for possible paths
28
- const handler = this.routeMatches(route.path, route.method, event)
29
+ const handler = Server.routeMatches(route.path, route.method, event)
29
30
  if (handler) {
30
- transaction.logger.log("Router accepted route:", route)
31
+ transaction.logger.log("Router accepted route:", route.path)
31
32
  // Validate input
32
33
  if (route.inputSchema) {
33
34
  const validationResp = Validator.validateSchema(
@@ -47,7 +48,7 @@ export default class Server {
47
48
  )
48
49
  }
49
50
  // Helper function to match route
50
- private routeMatches(
51
+ private static routeMatches(
51
52
  routePath: string,
52
53
  routeMethod: string,
53
54
  event: APIGatewayProxyEvent,
@@ -20,6 +20,7 @@ export default (serverlessHandler: Server["handleServerlessEvent"]) => {
20
20
  resp = processServerlessResponse(invokationResp, res)
21
21
  } catch (e) {
22
22
  console.error("[Proxy] - Exception during execution!", e)
23
+ console.error(e.stack)
23
24
  resp = res.status(Globals.Resp_STATUSCODE_EXCEPTION).json({
24
25
  ...e,
25
26
  err: Globals.Resp_MSG_EXCEPTION,