mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-16 06:16:53 +08:00
Initial commit
This commit is contained in:
42
mock-server/app.js
Normal file
42
mock-server/app.js
Normal file
@@ -0,0 +1,42 @@
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
const bodyParser = require('body-parser')
|
||||
var cors = require('cors')
|
||||
|
||||
const commonAPI = require('./api/common')
|
||||
const demoAPI = require('./api/demo')
|
||||
const appsApi = require('./api/apps')
|
||||
const debugAPI = require('./api/debug')
|
||||
const datasetsAPI = require('./api/datasets')
|
||||
|
||||
const port = 3001
|
||||
|
||||
app.use(bodyParser.json()) // for parsing application/json
|
||||
app.use(bodyParser.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded
|
||||
|
||||
const corsOptions = {
|
||||
origin: true,
|
||||
credentials: true,
|
||||
}
|
||||
app.use(cors(corsOptions)) // for cross origin
|
||||
app.options('*', cors(corsOptions)) // include before other routes
|
||||
|
||||
|
||||
demoAPI(app)
|
||||
commonAPI(app)
|
||||
appsApi(app)
|
||||
debugAPI(app)
|
||||
datasetsAPI(app)
|
||||
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.send('rootpath')
|
||||
})
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Mock run on port ${port}`)
|
||||
})
|
||||
|
||||
const sleep = (ms) => {
|
||||
return new Promise(resolve => setTimeout(resolve, ms))
|
||||
}
|
||||
Reference in New Issue
Block a user