@steedos/service-api 3.0.0-beta.2 → 3.0.0-beta.8
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/index.js +62 -33
- package/package.json +7 -7
package/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const ApiGateway = require("moleculer-web");
|
|
4
|
+
const cors = require('cors');
|
|
5
|
+
|
|
4
6
|
const steedosAuth = require('@steedos/auth');
|
|
5
|
-
const { ApolloService } = require("moleculer-apollo-server");
|
|
7
|
+
const { ApolloService } = require("@steedos/moleculer-apollo-server");
|
|
6
8
|
const { MoleculerServerError } = require("moleculer").Errors;
|
|
7
9
|
const GraphQLJSON = require('graphql-type-json');
|
|
8
10
|
const {
|
|
@@ -93,6 +95,37 @@ const mixinOptions = {
|
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
const ObjectDataLoaderMapKeys = {};
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
// const startServer = (broker)=>{
|
|
101
|
+
// broker.waitForServices('api').then(() => {
|
|
102
|
+
// const port = process.env.PORT || 5000;
|
|
103
|
+
// const express = require('express');
|
|
104
|
+
// const app = express();
|
|
105
|
+
// app.use(cors());
|
|
106
|
+
|
|
107
|
+
// const session = require('express-session');
|
|
108
|
+
// app.use(session({
|
|
109
|
+
// secret: process.env.STEEDOS_SESSION_SECRET || 'steedos',
|
|
110
|
+
// resave: false,
|
|
111
|
+
// saveUninitialized: true,
|
|
112
|
+
// cookie: { secure: false, maxAge: 800000 },
|
|
113
|
+
// name: 'ivan'
|
|
114
|
+
// }))
|
|
115
|
+
// app.use((req, res, next)=>{
|
|
116
|
+
// next();
|
|
117
|
+
// });
|
|
118
|
+
// app.use(require('@steedos/router').staticRouter());
|
|
119
|
+
|
|
120
|
+
// app.use(SteedosApi.express());
|
|
121
|
+
|
|
122
|
+
// app.listen(port, () => {
|
|
123
|
+
// console.log(`Project is running at ${port}`);
|
|
124
|
+
// });
|
|
125
|
+
// })
|
|
126
|
+
// }
|
|
127
|
+
|
|
128
|
+
|
|
96
129
|
/**
|
|
97
130
|
* @typedef {import('moleculer').Context} Context Moleculer's Context
|
|
98
131
|
* @typedef {import('http').IncomingMessage} IncomingRequest Incoming HTTP Request
|
|
@@ -113,7 +146,7 @@ module.exports = {
|
|
|
113
146
|
server: false,
|
|
114
147
|
|
|
115
148
|
// Exposed port
|
|
116
|
-
port: process.env.PORT ||
|
|
149
|
+
port: process.env.PORT || 5000,
|
|
117
150
|
|
|
118
151
|
// Exposed IP
|
|
119
152
|
// ip: "0.0.0.0",
|
|
@@ -122,12 +155,12 @@ module.exports = {
|
|
|
122
155
|
use: [
|
|
123
156
|
function (req, res, next) {
|
|
124
157
|
// 如果service-object-grapqhl未结算完成,则提示服务未就绪,刷新重试
|
|
125
|
-
if (!this.projectStarted) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
158
|
+
// if (!this.projectStarted) {
|
|
159
|
+
// const message = 'service is not ready, please refresh later.';
|
|
160
|
+
// res.writeHead(503, { 'Content-Type': 'application/json' });
|
|
161
|
+
// res.end(JSON.stringify({ status: 1, msg: message, data: {}, errors: [{ message: message }] }));
|
|
162
|
+
// return;
|
|
163
|
+
// }
|
|
131
164
|
next();
|
|
132
165
|
}
|
|
133
166
|
],
|
|
@@ -1021,33 +1054,30 @@ module.exports = {
|
|
|
1021
1054
|
'service-ui.started': function () {
|
|
1022
1055
|
this.app.use("/", this.express());
|
|
1023
1056
|
},
|
|
1024
|
-
"$packages.changed": function () {
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
}
|
|
1057
|
+
// "$packages.changed": function (ctx) {
|
|
1058
|
+
// if (!this.projectStarted) {
|
|
1059
|
+
// this.projectStarted = true
|
|
1060
|
+
// // 开发环境, 显示耗时
|
|
1061
|
+
// if (process.env.NODE_ENV == 'development' && global.__startDate) {
|
|
1062
|
+
// console.log('耗时: ' + (new Date().getTime() - global.__startDate.getTime()) + ' ms');
|
|
1063
|
+
// }
|
|
1064
|
+
// startServer(ctx.broker);
|
|
1065
|
+
// if (process.env.STEEDOS_AUTO_OPEN_BROWSER != 'false') { // 默认打开,如果不想打开,设置STEEDOS_AUTO_OPEN_BROWSER=false
|
|
1066
|
+
// setTimeout(function () {
|
|
1067
|
+
// try {
|
|
1068
|
+
// openBrowser(process.env.ROOT_URL);
|
|
1069
|
+
// } catch (error) {
|
|
1070
|
+
// console.error(error);
|
|
1071
|
+
// console.error('auto open browser failed.');
|
|
1072
|
+
// }
|
|
1073
|
+
// }, 100)
|
|
1074
|
+
|
|
1075
|
+
// }
|
|
1076
|
+
// }
|
|
1077
|
+
// }
|
|
1046
1078
|
},
|
|
1047
1079
|
async started() {
|
|
1048
|
-
|
|
1049
1080
|
this.broker.createService(require("@steedos/service-ui"));
|
|
1050
|
-
|
|
1051
1081
|
// if (this.settings.server != true && this.settings.steedos_api_port){
|
|
1052
1082
|
// /* istanbul ignore next */
|
|
1053
1083
|
// await new this.Promise((resolve, reject) => {
|
|
@@ -1063,7 +1093,6 @@ module.exports = {
|
|
|
1063
1093
|
this.broker.waitForServices('~packages-@steedos/service-ui').then(() => {
|
|
1064
1094
|
this.app.use("/", this.express());
|
|
1065
1095
|
})
|
|
1066
|
-
|
|
1067
1096
|
global.SteedosApi = {
|
|
1068
1097
|
express: this.express
|
|
1069
1098
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-api",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.8",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@steedos/auth": "3.0.0-beta.
|
|
8
|
-
"@steedos/
|
|
9
|
-
"@steedos/
|
|
10
|
-
"@steedos/service-
|
|
7
|
+
"@steedos/auth": "3.0.0-beta.8",
|
|
8
|
+
"@steedos/moleculer-apollo-server": "3.0.0-beta.8",
|
|
9
|
+
"@steedos/router": "3.0.0-beta.8",
|
|
10
|
+
"@steedos/service-object-graphql": "3.0.0-beta.8",
|
|
11
|
+
"@steedos/service-ui": "3.0.0-beta.8",
|
|
11
12
|
"graphql": "^15.8.0",
|
|
12
13
|
"graphql-iso-date": "^3.6.1",
|
|
13
14
|
"graphql-type-json": "^0.3.2",
|
|
14
15
|
"lru_map": "^0.4.1",
|
|
15
16
|
"moleculer": "^0.14.25",
|
|
16
|
-
"moleculer-apollo-server": "^0.3.6",
|
|
17
17
|
"moleculer-web": "^0.10.4",
|
|
18
18
|
"react-dev-utils": "12.0.1",
|
|
19
19
|
"validator": "^13.6.0"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "723d92765db5342a374c7aacb5b835e69f77ca4b",
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/graphql-iso-date": "^3.4.0",
|
|
28
28
|
"@types/react-dev-utils": "^9.0.11"
|