23 lines
1 KiB
JavaScript
23 lines
1 KiB
JavaScript
const express = require('express')
|
|
const app = express()
|
|
const bodyParser = require('body-parser')
|
|
const api = require('./api')
|
|
const cors = require('cors')
|
|
const path = require('path')
|
|
const config = require('./config')
|
|
const port = process.env.PORT || 9000
|
|
|
|
app.set('views', path.join(__dirname, 'views'))
|
|
app.use(bodyParser.urlencoded({ extended: false }))
|
|
app.use(bodyParser.json())
|
|
app.use(cors())
|
|
app.use('/static', express.static(path.join(__dirname, '..', 'uploads')))
|
|
app.use('/uploads', express.static(path.join(__dirname, '..', 'uploads')))
|
|
app.use('/api', api)
|
|
app.use('/', express.static(path.join(__dirname, '..', 'client', 'dist')))
|
|
app.use('/css', express.static(path.join(__dirname, '..', 'client', 'dist', 'css')))
|
|
app.use('/js', express.static(path.join(__dirname, '..', 'client', 'dist', 'js')))
|
|
app.use('*', express.static(path.join(__dirname, '..', 'client', 'dist', 'index.html')))
|
|
|
|
app.listen(port)
|
|
console.log(`[${config.title}] Started ${process.env.NODE_ENV} mode at ${config.baseurl} (api @ ${config.apiurl})`, config)
|