Skip to content

Instantly share code, notes, and snippets.

@mikaelhadler
Created January 31, 2020 14:06
Show Gist options
  • Save mikaelhadler/82479e153392519afc4c1f8df4d78609 to your computer and use it in GitHub Desktop.
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
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
{
"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