forked from SilenceHVK/wechatByNode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
27 lines (21 loc) · 729 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const express = require('express'), //express 框架
wechat = require('./wechat/wechat'),
config = require('./config');//引入配置文件
var app = express();//实例express框架
var wechatApp = new wechat(config); //实例wechat 模块
//用于处理所有进入 3000 端口 get 的连接请求
app.get('/',function(req,res){
wechatApp.auth(req,res);
});
//用于处理所有进入 3000 端口 post 的连接请求
app.post('/',function(req,res){
wechatApp.handleMsg(req,res);
});
//用于请求获取 access_token
app.get('/getAccessToken',function(req,res){
wechatApp.getAccessToken().then(function(data){
res.send(data);
});
});
//监听3000端口
app.listen(3000);