@steedos/service-api 2.5.3-beta.9 → 2.5.5-beta.1

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 (2) hide show
  1. package/index.js +88 -3
  2. package/package.json +8 -7
package/index.js CHANGED
@@ -13,6 +13,8 @@ const {
13
13
  const SteedosRouter = require('@steedos/router');
14
14
  const _ = require('lodash');
15
15
  const ServiceObjectGraphql = require('@steedos/service-object-graphql')
16
+ const validator = require('validator');
17
+ const enablePlayground = validator.toBoolean(process.env.STEEDOS_GRAPHQL_ENABLE_CONSOLE || 'true', true)
16
18
 
17
19
  const mixinOptions = {
18
20
 
@@ -74,12 +76,12 @@ const mixinOptions = {
74
76
  apiKey: process.env.APOLLO_ENGINE_KEY
75
77
  },
76
78
  subscriptions: false,
77
- playground: {
79
+ playground: enablePlayground ? {
78
80
  settings: {
79
81
  'request.credentials': 'same-origin'
80
82
  }
81
- },
82
- introspection: true
83
+ } : false,
84
+ introspection: enablePlayground
83
85
  }
84
86
  }
85
87
 
@@ -207,6 +209,89 @@ module.exports = {
207
209
  res.writeHead(err.code || 500);
208
210
  res.end(JSON.stringify({ error: err.message, detail: err }));
209
211
  }
212
+ },
213
+ {
214
+ path: "/api/v1",
215
+
216
+ whitelist: [
217
+ "rest.*",
218
+ ],
219
+
220
+ // Route-level Express middlewares. More info: https://moleculer.services/docs/0.14/moleculer-web.html#Middlewares
221
+ use: [],
222
+
223
+ // Enable/disable parameter merging method. More info: https://moleculer.services/docs/0.14/moleculer-web.html#Disable-merging
224
+ mergeParams: true,
225
+
226
+ // Enable authentication. Implement the logic into `authenticate` method. More info: https://moleculer.services/docs/0.14/moleculer-web.html#Authentication
227
+ authentication: true,
228
+
229
+ // Enable authorization. Implement the logic into `authorize` method. More info: https://moleculer.services/docs/0.14/moleculer-web.html#Authorization
230
+ authorization: true,
231
+
232
+ // The auto-alias feature allows you to declare your route alias directly in your services.
233
+ // The gateway will dynamically build the full routes from service schema.
234
+ autoAliases: true,
235
+
236
+ aliases: {
237
+
238
+ },
239
+
240
+ /**
241
+ * Before call hook. You can check the request.
242
+ * @param {Context} ctx
243
+ * @param {Object} route
244
+ * @param {IncomingRequest} req
245
+ * @param {ServerResponse} res
246
+ * @param {Object} data
247
+ *
248
+ onBeforeCall(ctx, route, req, res) {
249
+ // Set request headers to context meta
250
+ ctx.meta.userAgent = req.headers["user-agent"];
251
+ }, */
252
+
253
+ /**
254
+ * After call hook. You can modify the data.
255
+ * @param {Context} ctx
256
+ * @param {Object} route
257
+ * @param {IncomingRequest} req
258
+ * @param {ServerResponse} res
259
+ * @param {Object} data
260
+ onAfterCall(ctx, route, req, res, data) {
261
+ // Async function which return with Promise
262
+ return doSomething(ctx, res, data);
263
+ }, */
264
+
265
+ // Calling options. More info: https://moleculer.services/docs/0.14/moleculer-web.html#Calling-options
266
+ callingOptions: {},
267
+
268
+ bodyParsers: {
269
+ json: {
270
+ strict: false,
271
+ limit: "10MB"
272
+ },
273
+ urlencoded: {
274
+ extended: true,
275
+ limit: "10MB"
276
+ }
277
+ },
278
+
279
+ // Mapping policy setting. More info: https://moleculer.services/docs/0.14/moleculer-web.html#Mapping-policy
280
+ mappingPolicy: "all", // Available values: "all", "restrict"
281
+
282
+ // Enable/disable logging
283
+ logging: false,
284
+
285
+ // Route error handler
286
+ onError(req, res, err) {
287
+ res.setHeader("Content-Type", "application/json; charset=utf-8");
288
+ res.writeHead(err.code || 500);
289
+ res.end(JSON.stringify({
290
+ "status": -1,
291
+ "msg": err.message,
292
+ "data": {}
293
+ }));
294
+ }
210
295
  }
211
296
  ],
212
297
 
package/package.json CHANGED
@@ -1,23 +1,24 @@
1
1
  {
2
2
  "name": "@steedos/service-api",
3
- "version": "2.5.3-beta.9",
3
+ "version": "2.5.5-beta.1",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
- "@steedos/auth": "2.5.3-beta.9",
8
- "@steedos/router": "2.5.3-beta.9",
9
- "@steedos/service-object-graphql": "2.5.3-beta.9",
10
- "@steedos/service-ui": "2.5.3-beta.9",
7
+ "@steedos/auth": "2.5.5-beta.1",
8
+ "@steedos/router": "2.5.5-beta.1",
9
+ "@steedos/service-object-graphql": "2.5.5-beta.1",
10
+ "@steedos/service-ui": "2.5.5-beta.1",
11
11
  "graphql": "^15.8.0",
12
12
  "graphql-iso-date": "^3.6.1",
13
13
  "graphql-type-json": "^0.3.2",
14
14
  "moleculer": "^0.14.25",
15
15
  "moleculer-apollo-server": "^0.3.6",
16
- "moleculer-web": "^0.10.4"
16
+ "moleculer-web": "^0.10.4",
17
+ "validator": "^13.6.0"
17
18
  },
18
19
  "private": false,
19
20
  "publishConfig": {
20
21
  "access": "public"
21
22
  },
22
- "gitHead": "94bb5ef26fa3d0504e3131d2f9d990d4545430a3"
23
+ "gitHead": "2d9b97fbe49148c4440eaf3d127e3344f10caede"
23
24
  }