-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.js
47 lines (43 loc) · 1.22 KB
/
server.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
39
40
41
42
43
44
45
46
47
import 'dotenv/config'
import chalk from 'chalk'
import morgan from 'morgan'
import ngrok from 'ngrok'
import express from 'express'
import {syncDB} from './helpers/index.js'
import candidatesRouter from './routes/candidates.js'
import accountsRouter from './routes/accounts.js'
import embedsSessionTokensRouter from './routes/embeds-session-tokens.js'
import oauthRouter from './routes/oauth.js'
const port = process.env.PORT || 8000
const app = express()
.use(morgan('tiny'))
.use(express.json())
.use(candidatesRouter)
.use(accountsRouter)
.use(oauthRouter)
.use(embedsSessionTokensRouter)
if (process.env.NODE_ENV === 'production') {
const reactBuild = './client/build'
app.use(express.static(reactBuild))
app.get('*', (_, res) => {
res.sendFile('index.html', {root: reactBuild})
})
} else {
;(async () => {
const url = await ngrok.connect(port)
console.log(
chalk.black.bgGreen(' OAuth webhook URL '),
chalk.blue(`${url}/api/checkr/webhooks`),
)
console.log(
chalk.black.bgGreen(' OAuth redirect URL '),
chalk.blue(`${url}/api/checkr/oauth`),
)
})()
}
await syncDB()
app.listen(port)
console.log(
chalk.black.bgWhite(' Private API URL '),
`http://localhost:${port}`,
)