Skip to content

Commit

Permalink
assignment3
Browse files Browse the repository at this point in the history
  • Loading branch information
zoe-1 committed Dec 25, 2017
1 parent 7630cda commit 7cd9e61
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Version = require('./version');
const internals = {};

internals.customPlugins = [
{ plugin: Version, options: { message: 'lesson2' } }
{ plugin: Version, options: { message: 'lesson3' } }
];

internals.init = async (serverOptions) => {
Expand Down
50 changes: 29 additions & 21 deletions lib/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,33 @@ internals.serverOptions = {
port: process.env.PORT || 8000
};

// @todo clean this up
// Server.init(internals.serverOptions,(err, server) => {
//
// console.log('server started' + server.info.uri);
// });
Server.init(internals.serverOptions)
.then((server) => {

console.log('Server started: ' + server.info.uri);
})
.catch((err) => {

console.log('Error: ' + err);
});

// @option async style
// const Start = async () => {
//
// // try {
//
// // const server = await Server.init(internals.serverOptions);
//
// // console.log('starting server ' + server.info.uri);
// // // await server.stop();
// // }
// // catch (err) {
//
// // console.log('WATCHER ' + err);
// // }
//
//
// };
//
// Start();

const Start = async () => {

try {

const server = await Server.init(internals.serverOptions);

console.log('starting server ' + server.info.uri);
// await server.stop();
}
catch (err) {

console.log('WATCHER ' + err);
}
};

Start();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "university-v1.0.0",
"version": "1.0.0",
"version": "1.0.3",
"description": "rewrite of the university",
"main": "lib/index.js",
"directories": {
Expand Down
11 changes: 2 additions & 9 deletions test/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,19 @@ const it = lab.test;

const internals = {};

// server options

internals.serverOptions = {
port: process.env.PORT || 8000
};


describe('/version', () => {

it('/version success', { parallel: false }, async () => {

const University = require('../lib');

const server = await University.init(internals.serverOptions);
const server = await University.init({});

expect(server).to.be.an.object();

const res = await server.inject('/version');

expect(res.result).to.equal('version 1.0.0 lesson2');
expect(res.result).to.equal('version 1.0.3 lesson3');
await server.stop();
});
});

0 comments on commit 7cd9e61

Please sign in to comment.