put factor creation in function
This commit is contained in:
parent
26f549c928
commit
76e6bee411
1 changed files with 26 additions and 19 deletions
11
src/app.js
11
src/app.js
|
|
@ -1,3 +1,4 @@
|
|||
function createApp() {
|
||||
const express = require('express');
|
||||
const cookieParser = require('cookie-parser');
|
||||
const path = require('path');
|
||||
|
|
@ -5,6 +6,8 @@ const path = require('path');
|
|||
const app = express();
|
||||
const port = 3000;
|
||||
|
||||
app.set('port', port);
|
||||
|
||||
app.use(cookieParser());
|
||||
|
||||
app.use(express.json());
|
||||
|
|
@ -26,6 +29,10 @@ app.use(express.static(path.join(__dirname, 'public')));
|
|||
|
||||
app.disable('etag'); //avoids 304 responses
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server started on port ${port}`);
|
||||
return app;
|
||||
}
|
||||
|
||||
const app = createApp();
|
||||
app.listen(app.get('port'), () => {
|
||||
console.log(`Server started on port ${app.get('port')}`);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue