|
@@ -4,6 +4,7 @@ var app = express(); // define our app using express
|
|
|
var bodyParser = require('body-parser');
|
|
var bodyParser = require('body-parser');
|
|
|
var request = require("request");
|
|
var request = require("request");
|
|
|
const edurouter = require('./pbl');
|
|
const edurouter = require('./pbl');
|
|
|
|
|
+const medurouter = require('./mysql-pbl');
|
|
|
const mongo = require('./mongo');
|
|
const mongo = require('./mongo');
|
|
|
const weixin = require('./weixin');
|
|
const weixin = require('./weixin');
|
|
|
const cocoflow = require('./cocoflow');
|
|
const cocoflow = require('./cocoflow');
|
|
@@ -45,45 +46,45 @@ app.use(function (req, res, next) {
|
|
|
let local = 'mongodb://root:usestudio-1@172.16.9.240:27017?authSource=admin'
|
|
let local = 'mongodb://root:usestudio-1@172.16.9.240:27017?authSource=admin'
|
|
|
// let local = 'mongodb://root:usestudio-1@183.36.26.8:11641/cocorobo?authSource=admin'
|
|
// let local = 'mongodb://root:usestudio-1@183.36.26.8:11641/cocorobo?authSource=admin'
|
|
|
|
|
|
|
|
-mongoose.connect(local, {
|
|
|
|
|
- dbName: 'cocorobo',
|
|
|
|
|
- useNewUrlParser: true,
|
|
|
|
|
- useUnifiedTopology: true,
|
|
|
|
|
- useCreateIndex: true,
|
|
|
|
|
- useFindAndModify: true,
|
|
|
|
|
- autoIndex: false, // Don't build indexes
|
|
|
|
|
- reconnectTries: Number.MAX_VALUE, // Never stop trying to reconnect
|
|
|
|
|
- reconnectInterval: 50000, // Reconnect every 500ms
|
|
|
|
|
- poolSize: 10000, // Maintain up to 10 socket connections
|
|
|
|
|
- // If not connected, return errors immediately rather than waiting for reconnect
|
|
|
|
|
- bufferMaxEntries: 0,
|
|
|
|
|
- connectTimeoutMS: 10000, // Give up initial connection after 10 seconds
|
|
|
|
|
- socketTimeoutMS: 45000, // Close sockets after 45 seconds of inactivity
|
|
|
|
|
- family: 4 // Use IPv4, skip trying IPv6
|
|
|
|
|
- })
|
|
|
|
|
|
|
+// mongoose.connect(local, {
|
|
|
|
|
+// dbName: 'cocorobo',
|
|
|
|
|
+// useNewUrlParser: true,
|
|
|
|
|
+// useUnifiedTopology: true,
|
|
|
|
|
+// useCreateIndex: true,
|
|
|
|
|
+// useFindAndModify: true,
|
|
|
|
|
+// autoIndex: false, // Don't build indexes
|
|
|
|
|
+// reconnectTries: Number.MAX_VALUE, // Never stop trying to reconnect
|
|
|
|
|
+// reconnectInterval: 50000, // Reconnect every 500ms
|
|
|
|
|
+// poolSize: 10000, // Maintain up to 10 socket connections
|
|
|
|
|
+// // If not connected, return errors immediately rather than waiting for reconnect
|
|
|
|
|
+// bufferMaxEntries: 0,
|
|
|
|
|
+// connectTimeoutMS: 10000, // Give up initial connection after 10 seconds
|
|
|
|
|
+// socketTimeoutMS: 45000, // Close sockets after 45 seconds of inactivity
|
|
|
|
|
+// family: 4 // Use IPv4, skip trying IPv6
|
|
|
|
|
+// })
|
|
|
|
|
|
|
|
- const db = mongoose.connection;
|
|
|
|
|
|
|
+// const db = mongoose.connection;
|
|
|
|
|
|
|
|
// 配置session,使用MongoDB存储session数据
|
|
// 配置session,使用MongoDB存储session数据
|
|
|
// MongoDB连接字符串,使用与mongo.js中相同的连接方式
|
|
// MongoDB连接字符串,使用与mongo.js中相同的连接方式
|
|
|
// 注意:需要根据实际的MongoDB连接信息调整
|
|
// 注意:需要根据实际的MongoDB连接信息调整
|
|
|
-app.use(session({
|
|
|
|
|
- name: "cocorobo",
|
|
|
|
|
- secret: 'cocorobo',
|
|
|
|
|
- resave: true,
|
|
|
|
|
- saveUninitialized: true,
|
|
|
|
|
- cookie: {
|
|
|
|
|
- sameSite: "None",
|
|
|
|
|
- domain: '.cocorobo.cn',
|
|
|
|
|
- httpOnly: false,
|
|
|
|
|
- secure: false, // 根据实际情况调整,如果是HTTPS则设为true
|
|
|
|
|
- maxAge: 24 * 60 * 60000 * 365
|
|
|
|
|
- },
|
|
|
|
|
- store: new MongoStore({
|
|
|
|
|
- mongooseConnection: db,
|
|
|
|
|
- touchAfter: 24 * 3600
|
|
|
|
|
- }),
|
|
|
|
|
-}));
|
|
|
|
|
|
|
+// app.use(session({
|
|
|
|
|
+// name: "cocorobo",
|
|
|
|
|
+// secret: 'cocorobo',
|
|
|
|
|
+// resave: true,
|
|
|
|
|
+// saveUninitialized: true,
|
|
|
|
|
+// cookie: {
|
|
|
|
|
+// sameSite: "None",
|
|
|
|
|
+// domain: '.cocorobo.cn',
|
|
|
|
|
+// httpOnly: false,
|
|
|
|
|
+// secure: false, // 根据实际情况调整,如果是HTTPS则设为true
|
|
|
|
|
+// maxAge: 24 * 60 * 60000 * 365
|
|
|
|
|
+// },
|
|
|
|
|
+// store: new MongoStore({
|
|
|
|
|
+// mongooseConnection: db,
|
|
|
|
|
+// touchAfter: 24 * 3600
|
|
|
|
|
+// }),
|
|
|
|
|
+// }));
|
|
|
/*
|
|
/*
|
|
|
app.use(cors({
|
|
app.use(cors({
|
|
|
origin:[`http:${config.local.origin}`,'http://www.cocorobo.hk','https://cocorobo.hk','http://cloud.cocorobo.hk','https://cloud.cocorobo.hk'],
|
|
origin:[`http:${config.local.origin}`,'http://www.cocorobo.hk','https://cocorobo.hk','http://cloud.cocorobo.hk','https://cloud.cocorobo.hk'],
|
|
@@ -95,6 +96,7 @@ app.use(cors({
|
|
|
|
|
|
|
|
// all of our routes will be prefixed with /api
|
|
// all of our routes will be prefixed with /api
|
|
|
app.use('/api/pbl', edurouter);
|
|
app.use('/api/pbl', edurouter);
|
|
|
|
|
+app.use('/api/mysql-pbl', medurouter);
|
|
|
app.use('/api/mongo', mongo);
|
|
app.use('/api/mongo', mongo);
|
|
|
app.use('/api/weixin', weixin);
|
|
app.use('/api/weixin', weixin);
|
|
|
app.use('/api/cocoflow', cocoflow);
|
|
app.use('/api/cocoflow', cocoflow);
|