1 Star 0 Fork 0

Ethan/wxapp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.js 2.44 KB
一键复制 编辑 原始数据 按行查看 历史
Shiwenke 提交于 2018-02-04 01:34 . 改变服务配置
// const https = require('https');
const https = require('http');
const fs = require('fs');
const express = require('express')
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const app = express();
const queryString = require('querystring');
const URL = require('url');
const socket = require('./service/socket');
const router = require('./routes/router').router;
//获取认证证书
// var key = fs.readFileSync('./key/2_www.liudongtushuguan.cn.key');
// var cert = fs.readFileSync('./key/1_www.liudongtushuguan.cn_bundle.crt');
// var options = {
// key : key,
// cert : cert,
// };
//配置小程序二维码生成文件
app.use('/index', express.static('index'));
app.use(cookieParser());
app.use(bodyParser.json());
// const httpsServer = https.createServer(options,app);
const httpsServer = https.createServer(app);
httpsServer.listen(8080,() =>{
console.log('listening 443 port');
});
socket(httpsServer);
app.use(router);
// app.get('/', (req , res) =>{
// console.log('someone requested!');
// res.cookie('mycookie','value',{time : new Date()});
// res.status(200).send('Welcome to liudongtushuguan!');
// });
// app.get('/cookie',(req , res) => {
// console.log(req.cookies);
// //var mycookie = req.cookies.mycookie;
// res.end('mycookie');
// });
// const wss = new WebSocket.Server({server : httpsServer});
// wss.on('connection',(ws, req) => {
// let sessionId = queryString.parse(URL.parse(req.url).query).sessionId;
// ws.id = sessionId;
// console.log('someone connect');
// console.log(wss.clients);
// wss.clients.forEach((client) => {
// console.log(Object.keys(client));
// });
// ws.on('message' , (msg) => {
// let msgObj = JSON.parse(msg);
// if(sessions[msgObj.targetId]){
// wss.clients.forEach((client) => {
// if(client.id === msgObj.targetId){
// let data = {
// time : msgObj.time,
// borrower :msgObj.nickName,
// book :msgObj.bookName,
// borrowerId : sessions[sessionId],
// bookId : msgObj.bookId,
// wxNum : msgObj.wxNum,
// phoneNum : msgObj.phoneNum,
// msg : msgObj.msg
// };
// client.send(JSON.stringify(data));
// }
// });
// }
// console.log(msg);
// //ws.send('you send '+msg);
// });
// //ws.send('hello');
// });
// app.get('/login',(req,res) => {
// res.status(200);
// console.log(req.query);
// res.json({"code" : req.query});
// });
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/ethan1788/wxapp.git
[email protected]:ethan1788/wxapp.git
ethan1788
wxapp
wxapp
master

搜索帮助