All files / src app.ts

88% Statements 22/25
0% Branches 0/1
0% Functions 0/2
95.65% Lines 22/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 374x 4x 4x 4x 4x       4x 4x 4x 4x   4x   4x 4x 4x 4x 4x         4x 4x 4x 4x   4x       4x   4x  
import express from 'express'
import 'express-async-errors'
import { json } from 'body-parser'
import cookieSession from 'cookie-session'
import { errorHandler, NotFoundError } from '@next-k8s/common'
 
import User from './models/user'
 
import currentUserRouter from './routes/current-user'
import signinRouter from './routes/signin'
import signoutRouter from './routes/signout'
import signupRouter from './routes/signup'
 
Iif (!process.env.JWT_KEY) throw new Error('JWT_KEY secret not set')
 
const app = express()
app.disable('x-powered-by')
app.set('trust proxy', true)
app.use(json())
app.use(cookieSession({
  signed: false,
  secure: process.env.NODE_ENV !== 'test'
}))
 
app.use(currentUserRouter)
app.use(signinRouter)
app.use(signoutRouter)
app.use(signupRouter)
 
app.use('*', async (req, res) => {
  throw new NotFoundError()
})
 
app.use(errorHandler)
 
export default app