Skip to content

Commit

Permalink
Added server startup progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukhu committed Aug 1, 2018
1 parent 7421200 commit 44f1675
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
19 changes: 12 additions & 7 deletions packages/nxp-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@
"clean": "rimraf build",
"prepare": "yarn run compile",
"compile": "cross-env NODE_ENV=production node build.js && backpack build",
"compile:dev": "cross-env NODE_ENV=development node build.js && backpack build",
"start": "cross-env NODE_ENV=development node build.js && backpack dev",
"serve": "cross-var wait-port localhost:$npm_package_config_swapi_port && node build/main.js",
"serve":
"cross-var wait-port -t 5000 localhost:$npm_package_config_swapi_port && node build/main.js",
"serve:standalone": "node build/main.js",
"dev:debug": "cross-env NODE_ENV=development node build.js && cross-env DEBUG=express:* backpack dev",
"dev:debug":
"cross-env NODE_ENV=development node build.js && cross-env DEBUG=express:* backpack dev",
"dash": "nodejs-dashboard -- node -r nodejs-dashboard build/main",
"test": "cross-env NODE_ENV=test node build.js && jest --forceExit --config unit.config.json --detectOpenHandles",
"test:dev": "cross-env NODE_ENV=test node build.js && jest --forceExit --config unit.config.json --detectOpenHandles",
"itest:build": "cross-env NODE_ENV=test node build.js && cross-env NODE_ENV=test backpack build",
"itest:run": "concurrent --kill-others --success first \"cd build && node main\" \"wait-port localhost:3000 && jest --forceExit --config itest.config.json\"",
"test":
"cross-env NODE_ENV=test node build.js && jest --forceExit --config unit.config.json --detectOpenHandles",
"test:dev":
"cross-env NODE_ENV=test node build.js && jest --forceExit --config unit.config.json --detectOpenHandles",
"itest:build":
"cross-env NODE_ENV=test node build.js && cross-env NODE_ENV=test backpack build",
"itest:run":
"concurrent --kill-others --success first \"cd build && node main\" \"wait-port localhost:3000 && jest --forceExit --config itest.config.json\"",
"itest": "yarn itest:build && yarn itest:run",
"wait-port": "wait-port",
"jest": "jest --config unit.config.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/nxp-server/src/graphql/setupSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const getMergedSchemas = async () => {
schemas: [localSchema, remoteSchema]
});
} catch (e) {
console.log('Remote Schema error' + e);
console.log('\nRemote Schema error' + e);
return localSchema;
}
};
Expand Down
14 changes: 9 additions & 5 deletions packages/nxp-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ const welcome = port =>
);

export const setupServer = async () => {
const bar = new ProgressBar(':current :token', { total: 4 });
const bar = new ProgressBar('Server Startup [:bar] :percent :elapseds', {
total: 5
});

// initialize the IOC container (1)
bar.tick();
const container = IOCContainer.getInstance().getContainer();
const logger = container.get<ILogger>(SERVICE_IDENTIFIER.LOGGER);
const serverPort = process.env.PORT || 3000;
bar.tick({ token: 'initialized Container\n' });
bar.tick();
// create the inversify enabled express server (2)
const app = new ExpressServer(
container,
Expand All @@ -38,10 +42,10 @@ export const setupServer = async () => {
)
.getServer()
.build();
bar.tick({ token: 'created inversify enabled express server\n' });
bar.tick();
// Get Stiched Schema (3)
const graphqlConfig: Config = await getGraphQLConfig();
bar.tick({ token: 'created graphql schema\n' });
bar.tick();
// Create the apollo server
const apolloServer: ApolloServer = createApolloServer(app, graphqlConfig);
// Create Server so that it can be reused for the
Expand All @@ -63,7 +67,7 @@ export const setupServer = async () => {
// configure Hystrix Support
configHystrix();
}
bar.tick({ token: 'startup complete\n' });
bar.tick();
welcome(serverPort);
});
};
Expand Down
16 changes: 10 additions & 6 deletions packages/nxp-swapi-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
"clean": "rimraf build",
"prepare": "yarn run compile",
"compile": "cross-env NODE_ENV=production node build.js && backpack build",
"compile:dev": "cross-env NODE_ENV=development node build.js && backpack build",
"start": "cross-env NODE_ENV=development node build.js && backpack dev",
"serve": "node build/main.js",
"dev:debug": "cross-env NODE_ENV=development node build.js && cross-env DEBUG=express:* backpack dev",
"dev:debug":
"cross-env NODE_ENV=development node build.js && cross-env DEBUG=express:* backpack dev",
"dash": "nodejs-dashboard -- node -r nodejs-dashboard build/main",
"test": "cross-env NODE_ENV=test node build.js && jest --forceExit --config unit.config.json --detectOpenHandles",
"test:dev": "cross-env NODE_ENV=test node build.js && jest --forceExit --config unit.config.json --detectOpenHandles",
"itest:build": "cross-env NODE_ENV=test node build.js && cross-env NODE_ENV=test backpack build",
"itest:run": "concurrent --kill-others --success first \"cd build && node main\" \"wait-port localhost:4000 && jest --forceExit --config itest.config.json\"",
"test":
"cross-env NODE_ENV=test node build.js && jest --forceExit --config unit.config.json --detectOpenHandles",
"test:dev":
"cross-env NODE_ENV=test node build.js && jest --forceExit --config unit.config.json --detectOpenHandles",
"itest:build":
"cross-env NODE_ENV=test node build.js && cross-env NODE_ENV=test backpack build",
"itest:run":
"concurrent --kill-others --success first \"cd build && node main\" \"wait-port localhost:4000 && jest --forceExit --config itest.config.json\"",
"itest": "yarn itest:build && yarn itest:run",
"wait-port": "wait-port",
"jest": "jest --config unit.config.json"
Expand Down

0 comments on commit 44f1675

Please sign in to comment.