|
|
const express = require('express')
|
|
|
const modelsRoute = require('./routes/models')
|
|
|
const chatRoute = require('./routes/chat')
|
|
|
require('dotenv').config()
|
|
|
|
|
|
|
|
|
const app = express()
|
|
|
|
|
|
|
|
|
app.use(express.json({ limit: "50mb" }))
|
|
|
app.use(express.urlencoded({ limit: "50mb", extended: true }))
|
|
|
|
|
|
|
|
|
|
|
|
app.use((err, req, res, next) => {
|
|
|
console.error(err.stack)
|
|
|
res.status(500).send('服务器错误')
|
|
|
})
|
|
|
|
|
|
|
|
|
app.use(modelsRoute)
|
|
|
app.use(chatRoute)
|
|
|
|
|
|
|
|
|
const PORT = process.env.PORT || 3000
|
|
|
|
|
|
|
|
|
app.listen(PORT, () => {
|
|
|
console.log(`服务器运行在 http://localhost:${PORT}`)
|
|
|
})
|
|
|
|
|
|
|
|
|
module.exports = app |