@steedos/service-api 2.5.0-beta.3 → 2.5.0-beta.33

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 +27 -3
  2. package/package.json +6 -6
package/index.js CHANGED
@@ -238,7 +238,10 @@ module.exports = {
238
238
  * @param {IncomingRequest} req
239
239
  * @returns {Promise}
240
240
  */
241
- async authenticate(ctx, route, req, res) {
241
+ async authenticate(ctx, route, req, res, alias) {
242
+ if(alias.authentication === false){
243
+ return null;
244
+ }
242
245
  let user = await steedosAuth.auth(req, res);
243
246
  if (user && user.userId) {
244
247
  return user;
@@ -255,7 +258,10 @@ module.exports = {
255
258
  * @param {IncomingRequest} req
256
259
  * @returns {Promise}
257
260
  */
258
- async authorize(ctx, route, req, res) {
261
+ async authorize(ctx, route, req, res, alias) {
262
+ if(alias.authorization === false){
263
+ return ;
264
+ }
259
265
  // Get the authenticated user.
260
266
  const user = ctx.meta.user;
261
267
 
@@ -690,8 +696,26 @@ module.exports = {
690
696
  typeDefs.push(str);
691
697
  }
692
698
 
693
- return this.makeExecutableSchema({ typeDefs, resolvers, schemaDirectives });
699
+ try {
700
+ return this.makeExecutableSchema({ typeDefs, resolvers, schemaDirectives });
701
+ } catch (error) {
702
+ this.logger.error(error);
703
+ return this.graphqlSchema
704
+ }
694
705
  } catch (err) {
706
+ // 用于调试异常GraphQL schema
707
+ // const fs = require('fs');
708
+ // // 写入的文件路径
709
+ // const filePath = `UNABLE_COMPILE_GRAPHQL_SCHEMA.${new Date().getTime()}.txt`;
710
+ // // 使用fs.writeFile方法写入文件
711
+ // fs.writeFile(filePath, str, (err) => {
712
+ // if (err) {
713
+ // console.error(err);
714
+ // return;
715
+ // }
716
+ // console.log('文件已写入');
717
+ // });
718
+
695
719
  throw new MoleculerServerError(
696
720
  "Unable to compile GraphQL schema",
697
721
  500,
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@steedos/service-api",
3
- "version": "2.5.0-beta.3",
3
+ "version": "2.5.0-beta.33",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
- "@steedos/auth": "2.5.0-beta.3",
8
- "@steedos/router": "2.5.0-beta.3",
9
- "@steedos/service-object-graphql": "2.5.0-beta.3",
10
- "@steedos/service-ui": "2.5.0-beta.3",
7
+ "@steedos/auth": "2.5.0-beta.33",
8
+ "@steedos/router": "2.5.0-beta.33",
9
+ "@steedos/service-object-graphql": "2.5.0-beta.33",
10
+ "@steedos/service-ui": "2.5.0-beta.33",
11
11
  "graphql": "^15.8.0",
12
12
  "graphql-iso-date": "^3.6.1",
13
13
  "graphql-type-json": "^0.3.2",
@@ -19,5 +19,5 @@
19
19
  "publishConfig": {
20
20
  "access": "public"
21
21
  },
22
- "gitHead": "48546b91b2a44dd6f6673af7f5ab707faff6e07c"
22
+ "gitHead": "370c9eaa707a6932f3eb12fb3d711e679bcd2484"
23
23
  }