From 59ea7a5ba60f1fcaa5f4e4301f6cc33b9493a2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jovan=20Kruni=C4=87?= Date: Thu, 4 Jul 2019 11:30:49 +0200 Subject: [PATCH] refactor: avoid automatic execution of app.ts Move the execution of configureApp to CLI file Related to #2 --- src/app.ts | 10 +--------- src/cli.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app.ts b/src/app.ts index f0ea9373..51c80f8d 100644 --- a/src/app.ts +++ b/src/app.ts @@ -46,7 +46,7 @@ export const app = express(); /** * Configure the backend */ -async function configureApp() { +export async function configureApp() { // request loggers have to be the first middleware to be set in express app.use(morgan('dev')); @@ -206,11 +206,3 @@ async function configureApp() { // TODO: implement a route to register plugins } - -configureApp() - .then(() => { - Logger.ok('Sucessfully configured express server'); - }) - .catch((err) => { - throw err; -}); diff --git a/src/cli.ts b/src/cli.ts index d13880e3..cc3807bd 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -15,7 +15,7 @@ */ import {Logger} from '@openstapps/logger'; import * as http from 'http'; -import {app} from './app'; +import {app, configureApp} from './app'; /** * Get port from environment and store in Express. @@ -94,3 +94,11 @@ function onListening() { : `port ${addr.port}`; Logger.ok(`Listening on ${bind}`); } + +configureApp() + .then(() => { + Logger.ok('Sucessfully configured express server'); + }) + .catch((err) => { + throw err; + });