Created
January 31, 2020 14:06
-
-
Save mikaelhadler/82479e153392519afc4c1f8df4d78609 to your computer and use it in GitHub Desktop.
Configure instance express only in development or production - Express + Testing Routes + address already in use :::3000
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { env, port } from './config/vars' | |
import app from './config/express' | |
const development = env === 'development' | |
if (process.env.NODE_ENV !== 'test') | |
app.listen( | |
port, | |
() => development && console.log(`Server started on port ${port} (${env})`), | |
) | |
module.exports = app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "example", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "NODE_ENV=test jest" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment