forked from plouc/nivo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
44 lines (39 loc) · 1.06 KB
/
app.ts
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
37
38
39
40
41
42
43
44
import express from 'express'
import cors from 'cors'
import bodyParser from 'body-parser'
import compression from 'compression'
import winston from 'winston'
import expressWinston from 'express-winston'
import { nivo } from '@nivo/express'
const app = express()
app.enable('trust proxy')
app.set('json spaces', 4)
app.use(cors())
app.use(bodyParser.json())
app.use(
expressWinston.logger({
transports: [new winston.transports.Console()],
format: winston.format.combine(winston.format.colorize(), winston.format.simple()),
meta: false,
expressFormat: true,
colorize: true,
})
)
app.use(compression())
app.get('/status', (req, res) => {
res.status(200).json({
status: 'ok',
uptime: `${process.uptime()} second(s)`,
protocol: req.protocol,
host: req.get('host'),
env: {
// @ts-ignore
NODE_ENV: process.NODE_ENV,
},
})
})
app.use('/nivo', nivo)
const port = process.env.PORT || 3030
app.listen(port, () => {
console.log(`nivo api listening on ${port}`)
})