import express from 'express'
import bodyParser from 'body-parser'
import api from 'routes'
import timeout from 'connect-timeout'
import haltOnTimeout from 'middlewares/haltOnTimeout'
import compression from 'compression'
import helmet from 'helmet'
import path from 'path'
const app = express()
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(timeout(3000))
app.use(haltOnTimeout)
app.use(compression()) // production
app.use(helmet()) // production
app.use('/api', api)
app.use(express.static(path.resolve(`${__dirname}/../../client/build`))) // production
export default app
I have my app.js
like this.
now I'm going to deploy my app on aws.
In order to do this,
I want to divide my middlewares into array and execute it based on environment.
For example,
const middlewares = [
bodyParser.json(),
bodyParser.urlencoded({ extended: false }),
timeout(3000),
...
]
const productionMiddlewares = [
compression(),
helmet()
...
]
Any workaround for this?