-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
38 lines (33 loc) · 1023 Bytes
/
app.js
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
import express from 'express'
const bodyParser = require('body-parser')
const path = require('path')
const cors = require('cors')
const portastic = require('portastic')
import { getPair, wallet, order, exchangeInfo, account } from './routes'
const app = express()
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
if (process.env.NODE_ENV === 'development') {
app.use(express.static(path.join(__dirname, 'public')))
const responseTime = require('response-time')
app.use(responseTime())
} else {
app.use(express.static(path.join(__dirname, './')))
}
app.use(cors())
// routes
app.use(account)
app.use(getPair)
app.use(wallet)
app.use(order)
app.use(exchangeInfo)
// dynamic port
export const getOpenPort = async (_) => {
const openPort = await portastic.filter([5000, 5001, 5002, 5003, 5004, 5005])
return openPort
}
;(async () => {
const port = await getOpenPort()
app.listen(port[0], () => console.log(`App listening at port ${port[0]}`))
global.openPort = port[0]
})()