@things-factory/integration-sellercraft 4.2.8 → 4.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.
@@ -41,28 +41,37 @@ exports.sellercraftRouter.post('/sellercraft/store/update-product-price', async
41
41
  accessToken: (_h = (_g = store.shop) === null || _g === void 0 ? void 0 : _g.credential) === null || _h === void 0 ? void 0 : _h.access_token,
42
42
  channelShopId: (_j = store.shop) === null || _j === void 0 ? void 0 : _j.channel_shop_id
43
43
  };
44
- if (requestBody[i].native_variant_id != requestBody[i].native_product_id) {
45
- const req = {
46
- costPrice: requestBody[i].full_price,
47
- sellPrice: requestBody[i].sale_price,
48
- productId: requestBody[i].native_product_id,
49
- variationId: requestBody[i].native_variant_id,
50
- variationSku: requestBody[i].sku
51
- };
52
- result = await integration_marketplace_1.StoreAPI.updateStoreProductVariationPrice(mappedStore, req);
44
+ try {
45
+ if (requestBody[i].native_variant_id != requestBody[i].native_product_id) {
46
+ const req = {
47
+ costPrice: requestBody[i].full_price,
48
+ sellPrice: requestBody[i].sale_price,
49
+ productId: requestBody[i].native_product_id,
50
+ variationId: requestBody[i].native_variant_id,
51
+ variationSku: requestBody[i].sku
52
+ };
53
+ result = await integration_marketplace_1.StoreAPI.updateStoreProductVariationPrice(mappedStore, req);
54
+ }
55
+ else {
56
+ const req = {
57
+ costPrice: requestBody[i].full_price,
58
+ sellPrice: requestBody[i].sale_price,
59
+ productId: requestBody[i].native_product_id,
60
+ variationSku: requestBody[i].sku
61
+ };
62
+ result = await integration_marketplace_1.StoreAPI.updateStoreProductPrice(mappedStore, req);
63
+ }
64
+ debug(result);
65
+ context.type = 'application/json';
66
+ context.status = 200;
67
+ context.body = 'Succeeded';
53
68
  }
54
- else {
55
- const req = {
56
- costPrice: requestBody[i].full_price,
57
- sellPrice: requestBody[i].sale_price,
58
- productId: requestBody[i].native_product_id,
59
- variationSku: requestBody[i].sku
60
- };
61
- result = await integration_marketplace_1.StoreAPI.updateStoreProductPrice(mappedStore, req);
69
+ catch (e) {
70
+ context.type = 'application/json';
71
+ context.status = 500;
72
+ context.body = e.message;
62
73
  }
63
- debug(result);
64
74
  }
65
- context.status = 200;
66
75
  });
67
76
  exports.sellercraftRouter.post('/sellercraft/store/update-product-stock', async (context, next) => {
68
77
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
@@ -95,69 +104,90 @@ exports.sellercraftRouter.post('/sellercraft/store/update-product-stock', async
95
104
  accessToken: (_h = (_g = store.shop) === null || _g === void 0 ? void 0 : _g.credential) === null || _h === void 0 ? void 0 : _h.access_token,
96
105
  channelShopId: (_j = store.shop) === null || _j === void 0 ? void 0 : _j.channel_shop_id
97
106
  };
98
- if (requestBody[i].native_variant_id != requestBody[i].native_product_id) {
99
- const req = {
100
- qty: requestBody[i].stock,
101
- itemId: requestBody[i].native_product_id,
102
- variationId: requestBody[i].native_variant_id,
103
- distributors: requestBody[i].distributors || [],
104
- variationSku: requestBody[i].sku
105
- };
106
- result = await integration_marketplace_1.StoreAPI.updateStoreProductVariationStock(mappedStore, req);
107
+ try {
108
+ if (requestBody[i].native_variant_id != requestBody[i].native_product_id) {
109
+ const req = {
110
+ qty: requestBody[i].stock,
111
+ itemId: requestBody[i].native_product_id,
112
+ variationId: requestBody[i].native_variant_id,
113
+ distributors: requestBody[i].distributors || [],
114
+ variationSku: requestBody[i].sku
115
+ };
116
+ result = await integration_marketplace_1.StoreAPI.updateStoreProductVariationStock(mappedStore, req);
117
+ }
118
+ else {
119
+ const req = {
120
+ qty: requestBody[i].stock,
121
+ itemId: requestBody[i].native_product_id,
122
+ distributors: requestBody[i].distributors || [],
123
+ variationSku: requestBody[i].sku
124
+ };
125
+ result = await integration_marketplace_1.StoreAPI.updateStoreProductStock(mappedStore, req);
126
+ }
127
+ debug(result);
128
+ context.type = 'application/json';
129
+ context.status = 200;
130
+ context.body = 'Succeeded';
107
131
  }
108
- else {
109
- const req = {
110
- qty: requestBody[i].stock,
111
- itemId: requestBody[i].native_product_id,
112
- distributors: requestBody[i].distributors || [],
113
- variationSku: requestBody[i].sku
114
- };
115
- result = await integration_marketplace_1.StoreAPI.updateStoreProductStock(mappedStore, req);
132
+ catch (e) {
133
+ context.type = 'application/json';
134
+ context.status = 500;
135
+ context.body = e.message;
116
136
  }
117
- debug(result);
118
137
  }
119
- context.status = 200;
120
138
  });
121
139
  exports.sellercraftRouter.post('/sellercraft/store/update-order-status', async (context, next) => {
122
140
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
123
- const sellercraftChannelIntegrationConfig = env_1.config.get('sellercraftChannelIntegrationConfig', {});
124
- const { tokenCraftApiKey: apiKey, tokenCraftUrl } = sellercraftChannelIntegrationConfig;
125
- const xApiKey = context.headers['x-api-key'];
126
- if (apiKey !== xApiKey)
127
- context.throw(400, 'api key validation failed');
128
- const requestBody = context.request.body;
129
- var result;
130
- var store = {};
131
- // https://staging-tokencraft.sellercraft.co/v1/get-shop?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=dd9cf3b7-114f-4d74-a7e2-7b524ae086f2
132
- var fullPath = `${tokenCraftUrl}?channel_id=${requestBody.channel_id}&shop_id=${requestBody.shop_id}`;
133
- const response = await fetch(fullPath, {
134
- method: 'get',
135
- headers: {
136
- 'Content-Type': 'application/json',
137
- 'x-api-key': apiKey
141
+ try {
142
+ const sellercraftChannelIntegrationConfig = env_1.config.get('sellercraftChannelIntegrationConfig', {});
143
+ const { tokenCraftApiKey: apiKey, tokenCraftUrl } = sellercraftChannelIntegrationConfig;
144
+ const xApiKey = context.headers['x-api-key'];
145
+ if (apiKey !== xApiKey)
146
+ context.throw(400, 'api key validation failed');
147
+ const requestBody = context.request.body;
148
+ var result;
149
+ var store = {};
150
+ // https://staging-tokencraft.sellercraft.co/v1/get-shop?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=dd9cf3b7-114f-4d74-a7e2-7b524ae086f2
151
+ var fullPath = `${tokenCraftUrl}?channel_id=${requestBody.channel_id}&shop_id=${requestBody.shop_id}`;
152
+ const response = await fetch(fullPath, {
153
+ method: 'get',
154
+ headers: {
155
+ 'Content-Type': 'application/json',
156
+ 'x-api-key': apiKey
157
+ }
158
+ });
159
+ if (response.ok) {
160
+ store = await response.json();
161
+ }
162
+ let mappedStore = {
163
+ accessKey: ((_b = (_a = store.shop) === null || _a === void 0 ? void 0 : _a.credential) === null || _b === void 0 ? void 0 : _b.consumer_key) || '',
164
+ accessSecret: ((_d = (_c = store.shop) === null || _c === void 0 ? void 0 : _c.credential) === null || _d === void 0 ? void 0 : _d.consumer_secret) || '',
165
+ storeURL: (_f = (_e = store.shop) === null || _e === void 0 ? void 0 : _e.credential) === null || _f === void 0 ? void 0 : _f.store_url,
166
+ platform: constants_1.PLATFORM[`${store.shop.org_prefix}`],
167
+ accessToken: (_h = (_g = store.shop) === null || _g === void 0 ? void 0 : _g.credential) === null || _h === void 0 ? void 0 : _h.access_token,
168
+ channelShopId: (_j = store.shop) === null || _j === void 0 ? void 0 : _j.channel_shop_id
169
+ };
170
+ const reqBody = {
171
+ orderId: requestBody.native_order_id,
172
+ status: requestBody.order_status,
173
+ carrier: requestBody === null || requestBody === void 0 ? void 0 : requestBody.shipper_last_mile,
174
+ trackingNo: requestBody === null || requestBody === void 0 ? void 0 : requestBody.tracking_number,
175
+ orderItems: requestBody === null || requestBody === void 0 ? void 0 : requestBody.order_item_ids
176
+ };
177
+ try {
178
+ result = await integration_marketplace_1.StoreAPI.updateOrderStatus(mappedStore, reqBody);
179
+ debug(result);
180
+ context.type = 'application/json';
181
+ context.status = 200;
182
+ context.body = 'Succeeded';
183
+ }
184
+ catch (e) {
185
+ context.type = 'application/json';
186
+ context.status = 500;
187
+ context.body = e.message;
138
188
  }
139
- });
140
- if (response.ok) {
141
- store = await response.json();
142
189
  }
143
- let mappedStore = {
144
- accessKey: ((_b = (_a = store.shop) === null || _a === void 0 ? void 0 : _a.credential) === null || _b === void 0 ? void 0 : _b.consumer_key) || '',
145
- accessSecret: ((_d = (_c = store.shop) === null || _c === void 0 ? void 0 : _c.credential) === null || _d === void 0 ? void 0 : _d.consumer_secret) || '',
146
- storeURL: (_f = (_e = store.shop) === null || _e === void 0 ? void 0 : _e.credential) === null || _f === void 0 ? void 0 : _f.store_url,
147
- platform: constants_1.PLATFORM[`${store.shop.org_prefix}`],
148
- accessToken: (_h = (_g = store.shop) === null || _g === void 0 ? void 0 : _g.credential) === null || _h === void 0 ? void 0 : _h.access_token,
149
- channelShopId: (_j = store.shop) === null || _j === void 0 ? void 0 : _j.channel_shop_id
150
- };
151
- const reqBody = {
152
- orderId: requestBody.native_order_id,
153
- status: requestBody.order_status,
154
- carrier: requestBody === null || requestBody === void 0 ? void 0 : requestBody.shipper_last_mile,
155
- trackingNo: requestBody === null || requestBody === void 0 ? void 0 : requestBody.tracking_number,
156
- orderItems: requestBody === null || requestBody === void 0 ? void 0 : requestBody.order_item_ids
157
- };
158
- result = await integration_marketplace_1.StoreAPI.updateOrderStatus(mappedStore, reqBody);
159
- debug(result);
160
- context.status = 200;
190
+ catch (e) { }
161
191
  });
162
192
  exports.sellercraftRouter.post('/sellercraft/store/update-product-attribute', async (context, next) => {
163
193
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
@@ -206,9 +236,18 @@ exports.sellercraftRouter.post('/sellercraft/store/update-product-attribute', as
206
236
  };
207
237
  });
208
238
  for (var i = 0; i < variants.length; i++) {
209
- let variant = variants[i];
210
- await integration_marketplace_1.StoreAPI.updateProductAttribute(mappedStore, { productSku, itemId, variant });
239
+ try {
240
+ let variant = variants[i];
241
+ await integration_marketplace_1.StoreAPI.updateProductAttribute(mappedStore, { productSku, itemId, variant });
242
+ context.type = 'application/json';
243
+ context.status = 200;
244
+ context.body = 'Succeeded';
245
+ }
246
+ catch (e) {
247
+ context.type = 'application/json';
248
+ context.status = 500;
249
+ context.body = e.message;
250
+ }
211
251
  }
212
- context.status = 200;
213
252
  });
214
253
  //# sourceMappingURL=sellercraft-router.js.map
@@ -1 +1 @@
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AA;QAEF,OAAO;YACL,UAAU;YACV,SAAS;YACT,UAAU;SACX,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACxC,IAAI;YACF,IAAI,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;YACzB,MAAM,kCAAQ,CAAC,sBAAsB,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;YACnF,OAAO,CAAC,IAAI,GAAG,kBAAkB,CAAA;YACjC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAA;YACpB,OAAO,CAAC,IAAI,GAAG,WAAW,CAAA;SAC3B;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,IAAI,GAAG,kBAAkB,CAAA;YACjC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAA;YACpB,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,OAAO,CAAA;SACzB;KACF;AACH,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-sellercraft",
3
- "version": "4.2.8",
3
+ "version": "4.2.9",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -31,7 +31,7 @@
31
31
  "@things-factory/context-ui": "^4.1.40",
32
32
  "@things-factory/grist-ui": "^4.1.40",
33
33
  "@things-factory/i18n-base": "^4.1.40",
34
- "@things-factory/integration-marketplace": "^4.2.8",
34
+ "@things-factory/integration-marketplace": "^4.2.9",
35
35
  "@things-factory/integration-ui": "^4.1.40",
36
36
  "@things-factory/more-ui": "^4.1.40",
37
37
  "@things-factory/resource-ui": "^4.1.40",
@@ -51,5 +51,5 @@
51
51
  "nock": "^13.0.2",
52
52
  "should": "^13.2.3"
53
53
  },
54
- "gitHead": "7ea97fd646fe004e409d3d3ff781cd5301e15140"
54
+ "gitHead": "1d2a0b987ce31cc207e1c70e75d53ba65acee61a"
55
55
  }
@@ -45,29 +45,37 @@ sellercraftRouter.post('/sellercraft/store/update-product-price', async (context
45
45
  channelShopId: store.shop?.channel_shop_id
46
46
  }
47
47
 
48
- if (requestBody[i].native_variant_id != requestBody[i].native_product_id) {
49
- const req = {
50
- costPrice: requestBody[i].full_price,
51
- sellPrice: requestBody[i].sale_price,
52
- productId: requestBody[i].native_product_id,
53
- variationId: requestBody[i].native_variant_id,
54
- variationSku: requestBody[i].sku
48
+ try {
49
+ if (requestBody[i].native_variant_id != requestBody[i].native_product_id) {
50
+ const req = {
51
+ costPrice: requestBody[i].full_price,
52
+ sellPrice: requestBody[i].sale_price,
53
+ productId: requestBody[i].native_product_id,
54
+ variationId: requestBody[i].native_variant_id,
55
+ variationSku: requestBody[i].sku
56
+ }
57
+ result = await StoreAPI.updateStoreProductVariationPrice(mappedStore, req)
58
+ } else {
59
+ const req = {
60
+ costPrice: requestBody[i].full_price,
61
+ sellPrice: requestBody[i].sale_price,
62
+ productId: requestBody[i].native_product_id,
63
+ variationSku: requestBody[i].sku
64
+ }
65
+ result = await StoreAPI.updateStoreProductPrice(mappedStore, req)
55
66
  }
56
- result = await StoreAPI.updateStoreProductVariationPrice(mappedStore, req)
57
- } else {
58
- const req = {
59
- costPrice: requestBody[i].full_price,
60
- sellPrice: requestBody[i].sale_price,
61
- productId: requestBody[i].native_product_id,
62
- variationSku: requestBody[i].sku
63
- }
64
- result = await StoreAPI.updateStoreProductPrice(mappedStore, req)
65
- }
66
67
 
67
- debug(result)
68
- }
68
+ debug(result)
69
69
 
70
- context.status = 200
70
+ context.type = 'application/json'
71
+ context.status = 200
72
+ context.body = 'Succeeded'
73
+ } catch (e) {
74
+ context.type = 'application/json'
75
+ context.status = 500
76
+ context.body = e.message
77
+ }
78
+ }
71
79
  })
72
80
 
73
81
  sellercraftRouter.post('/sellercraft/store/update-product-stock', async (context, next) => {
@@ -105,76 +113,95 @@ sellercraftRouter.post('/sellercraft/store/update-product-stock', async (context
105
113
  channelShopId: store.shop?.channel_shop_id
106
114
  }
107
115
 
108
- if (requestBody[i].native_variant_id != requestBody[i].native_product_id) {
109
- const req = {
110
- qty: requestBody[i].stock,
111
- itemId: requestBody[i].native_product_id,
112
- variationId: requestBody[i].native_variant_id,
113
- distributors: requestBody[i].distributors || [], // for Magento
114
- variationSku: requestBody[i].sku
115
- }
116
- result = await StoreAPI.updateStoreProductVariationStock(mappedStore, req)
117
- } else {
118
- const req = {
119
- qty: requestBody[i].stock,
120
- itemId: requestBody[i].native_product_id,
121
- distributors: requestBody[i].distributors || [], // for Magento
122
- variationSku: requestBody[i].sku
116
+ try {
117
+ if (requestBody[i].native_variant_id != requestBody[i].native_product_id) {
118
+ const req = {
119
+ qty: requestBody[i].stock,
120
+ itemId: requestBody[i].native_product_id,
121
+ variationId: requestBody[i].native_variant_id,
122
+ distributors: requestBody[i].distributors || [], // for Magento
123
+ variationSku: requestBody[i].sku
124
+ }
125
+ result = await StoreAPI.updateStoreProductVariationStock(mappedStore, req)
126
+ } else {
127
+ const req = {
128
+ qty: requestBody[i].stock,
129
+ itemId: requestBody[i].native_product_id,
130
+ distributors: requestBody[i].distributors || [], // for Magento
131
+ variationSku: requestBody[i].sku
132
+ }
133
+ result = await StoreAPI.updateStoreProductStock(mappedStore, req)
123
134
  }
124
- result = await StoreAPI.updateStoreProductStock(mappedStore, req)
125
- }
126
135
 
127
- debug(result)
136
+ debug(result)
137
+
138
+ context.type = 'application/json'
139
+ context.status = 200
140
+ context.body = 'Succeeded'
141
+ } catch (e) {
142
+ context.type = 'application/json'
143
+ context.status = 500
144
+ context.body = e.message
145
+ }
128
146
  }
129
- context.status = 200
130
147
  })
131
148
 
132
149
  sellercraftRouter.post('/sellercraft/store/update-order-status', async (context, next) => {
133
- const sellercraftChannelIntegrationConfig = config.get('sellercraftChannelIntegrationConfig', {})
134
- const { tokenCraftApiKey: apiKey, tokenCraftUrl } = sellercraftChannelIntegrationConfig
150
+ try {
151
+ const sellercraftChannelIntegrationConfig = config.get('sellercraftChannelIntegrationConfig', {})
152
+ const { tokenCraftApiKey: apiKey, tokenCraftUrl } = sellercraftChannelIntegrationConfig
135
153
 
136
- const xApiKey = context.headers['x-api-key']
154
+ const xApiKey = context.headers['x-api-key']
137
155
 
138
- if (apiKey !== xApiKey) context.throw(400, 'api key validation failed')
156
+ if (apiKey !== xApiKey) context.throw(400, 'api key validation failed')
139
157
 
140
- const requestBody = context.request.body
141
- var result
142
- var store: any = {}
158
+ const requestBody = context.request.body
159
+ var result
160
+ var store: any = {}
143
161
 
144
- // https://staging-tokencraft.sellercraft.co/v1/get-shop?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=dd9cf3b7-114f-4d74-a7e2-7b524ae086f2
145
- var fullPath = `${tokenCraftUrl}?channel_id=${requestBody.channel_id}&shop_id=${requestBody.shop_id}`
146
- const response: any = await fetch(fullPath, {
147
- method: 'get',
148
- headers: {
149
- 'Content-Type': 'application/json',
150
- 'x-api-key': apiKey
162
+ // https://staging-tokencraft.sellercraft.co/v1/get-shop?channel_id=4bfb3362-d57c-47f8-8781-007316d179bf&shop_id=dd9cf3b7-114f-4d74-a7e2-7b524ae086f2
163
+ var fullPath = `${tokenCraftUrl}?channel_id=${requestBody.channel_id}&shop_id=${requestBody.shop_id}`
164
+ const response: any = await fetch(fullPath, {
165
+ method: 'get',
166
+ headers: {
167
+ 'Content-Type': 'application/json',
168
+ 'x-api-key': apiKey
169
+ }
170
+ })
171
+ if (response.ok) {
172
+ store = await response.json()
151
173
  }
152
- })
153
- if (response.ok) {
154
- store = await response.json()
155
- }
156
174
 
157
- let mappedStore: any = {
158
- accessKey: store.shop?.credential?.consumer_key || '',
159
- accessSecret: store.shop?.credential?.consumer_secret || '',
160
- storeURL: store.shop?.credential?.store_url,
161
- platform: PLATFORM[`${store.shop.org_prefix}`],
162
- accessToken: store.shop?.credential?.access_token,
163
- channelShopId: store.shop?.channel_shop_id
164
- }
165
-
166
- const reqBody = {
167
- orderId: requestBody.native_order_id,
168
- status: requestBody.order_status,
169
- carrier: requestBody?.shipper_last_mile,
170
- trackingNo: requestBody?.tracking_number,
171
- orderItems: requestBody?.order_item_ids
172
- }
175
+ let mappedStore: any = {
176
+ accessKey: store.shop?.credential?.consumer_key || '',
177
+ accessSecret: store.shop?.credential?.consumer_secret || '',
178
+ storeURL: store.shop?.credential?.store_url,
179
+ platform: PLATFORM[`${store.shop.org_prefix}`],
180
+ accessToken: store.shop?.credential?.access_token,
181
+ channelShopId: store.shop?.channel_shop_id
182
+ }
173
183
 
174
- result = await StoreAPI.updateOrderStatus(mappedStore, reqBody)
175
- debug(result)
184
+ const reqBody = {
185
+ orderId: requestBody.native_order_id,
186
+ status: requestBody.order_status,
187
+ carrier: requestBody?.shipper_last_mile,
188
+ trackingNo: requestBody?.tracking_number,
189
+ orderItems: requestBody?.order_item_ids
190
+ }
176
191
 
177
- context.status = 200
192
+ try {
193
+ result = await StoreAPI.updateOrderStatus(mappedStore, reqBody)
194
+ debug(result)
195
+
196
+ context.type = 'application/json'
197
+ context.status = 200
198
+ context.body = 'Succeeded'
199
+ } catch (e) {
200
+ context.type = 'application/json'
201
+ context.status = 500
202
+ context.body = e.message
203
+ }
204
+ } catch (e) {}
178
205
  })
179
206
 
180
207
  sellercraftRouter.post('/sellercraft/store/update-product-attribute', async (context, next) => {
@@ -233,9 +260,16 @@ sellercraftRouter.post('/sellercraft/store/update-product-attribute', async (con
233
260
  })
234
261
 
235
262
  for (var i = 0; i < variants.length; i++) {
236
- let variant = variants[i]
237
- await StoreAPI.updateProductAttribute(mappedStore, { productSku, itemId, variant })
263
+ try {
264
+ let variant = variants[i]
265
+ await StoreAPI.updateProductAttribute(mappedStore, { productSku, itemId, variant })
266
+ context.type = 'application/json'
267
+ context.status = 200
268
+ context.body = 'Succeeded'
269
+ } catch (e) {
270
+ context.type = 'application/json'
271
+ context.status = 500
272
+ context.body = e.message
273
+ }
238
274
  }
239
-
240
- context.status = 200
241
275
  })