mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
refactor: avoid automatic execution of app.ts
Move the execution of configureApp to CLI file Related to #2
This commit is contained in:
committed by
Rainer Killinger
parent
9adc0b88d7
commit
59ea7a5ba6
10
src/app.ts
10
src/app.ts
@@ -46,7 +46,7 @@ export const app = express();
|
|||||||
/**
|
/**
|
||||||
* Configure the backend
|
* Configure the backend
|
||||||
*/
|
*/
|
||||||
async function configureApp() {
|
export async function configureApp() {
|
||||||
// request loggers have to be the first middleware to be set in express
|
// request loggers have to be the first middleware to be set in express
|
||||||
app.use(morgan('dev'));
|
app.use(morgan('dev'));
|
||||||
|
|
||||||
@@ -206,11 +206,3 @@ async function configureApp() {
|
|||||||
|
|
||||||
// TODO: implement a route to register plugins
|
// TODO: implement a route to register plugins
|
||||||
}
|
}
|
||||||
|
|
||||||
configureApp()
|
|
||||||
.then(() => {
|
|
||||||
Logger.ok('Sucessfully configured express server');
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
throw err;
|
|
||||||
});
|
|
||||||
|
|||||||
10
src/cli.ts
10
src/cli.ts
@@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
import {Logger} from '@openstapps/logger';
|
import {Logger} from '@openstapps/logger';
|
||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
import {app} from './app';
|
import {app, configureApp} from './app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get port from environment and store in Express.
|
* Get port from environment and store in Express.
|
||||||
@@ -94,3 +94,11 @@ function onListening() {
|
|||||||
: `port ${addr.port}`;
|
: `port ${addr.port}`;
|
||||||
Logger.ok(`Listening on ${bind}`);
|
Logger.ok(`Listening on ${bind}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configureApp()
|
||||||
|
.then(() => {
|
||||||
|
Logger.ok('Sucessfully configured express server');
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user