25 lines
824 B
JavaScript
25 lines
824 B
JavaScript
const express = require('express')
|
|
const xmlparser = require('express-xml-bodyparser');
|
|
require("express-async-errors")
|
|
const db = require('./src/utils/dbUitls')
|
|
const rest = require('./src/rest')
|
|
const ws = require('./src/websocket')
|
|
const ews = require('express-ws')
|
|
const chalk = require("chalk");
|
|
const log = console.log
|
|
const app = express();
|
|
ews(app)
|
|
const port = 12525
|
|
chalk.level = 1
|
|
app.listen(port, () => {
|
|
db.init()
|
|
app.use(express.json()) // for parsing application/json
|
|
app.use(xmlparser()); // for parsing application/xml
|
|
app.use(express.urlencoded({extended: true, limit: '50mb'})) // for parsing application/x-www-form-urlencoded
|
|
//启动服务并监听
|
|
Promise.all([rest.init(app)]).then(() => {
|
|
log(`${chalk.bgGreen.black(" DONE ")} serve is listening on ${port}`)
|
|
ws.init(app)
|
|
})
|
|
})
|