@steedos/service-api 2.5.3-beta.11 → 2.5.3-beta.13

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 +30 -3
  2. package/package.json +6 -6
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 open = require('open');
17
+
16
18
 
17
19
  const mixinOptions = {
18
20
 
@@ -90,6 +92,7 @@ const mixinOptions = {
90
92
  */
91
93
  module.exports = {
92
94
  name: "api",
95
+ projectStarted: false,
93
96
  mixins: [ApiGateway,
94
97
  // GraphQL Apollo Server
95
98
  ApolloService(mixinOptions),
@@ -729,6 +732,30 @@ module.exports = {
729
732
  created() {
730
733
  this.app = SteedosRouter.staticRouter();
731
734
  },
735
+ events:{
736
+ 'service-ui.started': function(){
737
+ this.app.use("/", this.express());
738
+ },
739
+ "$packages.changed": function(){
740
+ if (!this.projectStarted) {
741
+ this.projectStarted = true
742
+ // 开发环境, 显示耗时
743
+ if(process.env.NODE_ENV == 'development' && global.__startDate){
744
+ console.log('耗时: ' + (new Date().getTime() - global.__startDate.getTime()) + ' ms');
745
+ }
746
+ console.log(`Project is running at ${process.env.ROOT_URL}`);
747
+ console.log('');
748
+ if (process.env.STEEDOS_AUTO_OPEN_BROWSER != 'false') { // 默认打开,如果不想打开,设置STEEDOS_AUTO_OPEN_BROWSER=false
749
+ try {
750
+ open(process.env.ROOT_URL);
751
+ } catch (error) {
752
+ console.error(error);
753
+ console.error('auto open browser failed.');
754
+ }
755
+ }
756
+ }
757
+ }
758
+ },
732
759
  async started() {
733
760
 
734
761
  this.broker.createService(require("@steedos/service-ui"));
@@ -745,9 +772,9 @@ module.exports = {
745
772
  // });
746
773
  // }
747
774
 
748
- this.broker.waitForServices('~packages-@steedos/service-ui').then(() => {
749
- this.app.use("/", this.express());
750
- })
775
+ // this.broker.waitForServices('~packages-@steedos/service-ui').then(() => {
776
+ // this.app.use("/", this.express());
777
+ // })
751
778
 
752
779
  global.SteedosApi = {
753
780
  express: this.express
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@steedos/service-api",
3
- "version": "2.5.3-beta.11",
3
+ "version": "2.5.3-beta.13",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
- "@steedos/auth": "2.5.3-beta.11",
8
- "@steedos/router": "2.5.3-beta.11",
9
- "@steedos/service-object-graphql": "2.5.3-beta.11",
10
- "@steedos/service-ui": "2.5.3-beta.11",
7
+ "@steedos/auth": "2.5.3-beta.13",
8
+ "@steedos/router": "2.5.3-beta.13",
9
+ "@steedos/service-object-graphql": "2.5.3-beta.13",
10
+ "@steedos/service-ui": "2.5.3-beta.13",
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": "90a5790974f858323e534c321f96643da576d260"
22
+ "gitHead": "293a5a23b2a4ab86f037368b0f450c8b2fba4e44"
23
23
  }