'use strict';

import bunyan from 'bunyan';
import http from 'http';
import { createApp } from './app.js';

const logger = bunyan.createLogger({name: "Graphql-Swapi"});

logger.info('Server initialisation...');
createApp()
	.then((app) => {
		logger.info('Starting HTTP server');
		const server = http.createServer(app);
		server.listen(8000, ()=> { logger.info('Server is up and running'); });
	})
	.catch((err) => { logger.error(err); });

@@ -99,16 +99,72 @@
 app.js';
+%0Aimport eventsToAnyPromise from 'events-to-any-promise';
 %0A%0Aconst 
@@ -223,80 +223,42 @@
 );%0A%0A
-logger.info('Server initialisation...');%0AcreateApp()%0A%09.then((
+function startServer(port, 
 app)
- =%3E
  %7B%0A
-%09
 %09log
@@ -291,17 +291,16 @@
 rver');%0A
-%09
 %09const s
@@ -331,17 +331,16 @@
 r(app);%0A
-%09
 %09server.
@@ -350,21 +350,78 @@
 ten(
-8000, 
+port);%0A%09return eventsToAnyPromise(server, 'listening').then(
 ()
+ 
 =%3E %7B
- 
+%0A%09%09
 logg
@@ -460,15 +460,125 @@
 g');
- %7D);%0A%09%7D
+%0A%09%09return server;%0A%09%7D);%0A%7D%0A%0Alogger.info('Server initialisation...');%0AcreateApp()%0A%09.then((app) =%3E startServer(8000, app)
 )%0A%09.

Use my new lib events-to-any-promise