GithubHelp home page GithubHelp logo

hhy5277 / wafer-node-server-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tencentyun/wafer-node-server-demo

0.0 1.0 0.0 18 KB

Wafer - 企业级微信小程序全栈方案

Home Page: https://github.com/tencentyun/wafer

License: Other

JavaScript 100.00%

wafer-node-server-demo's Introduction

Wafer 服务端 Demo - Node.js

本项目是 腾讯云微信小程序服务端 SDK - Node.js 的使用示例。示例需要和 微信小程序客户端示例 配合一起使用。

运行示例

按照小程序创建资源配置指引进行操作,可以得到运行本示例所需的资源和服务,其中包括已部署好的示例代码及自动下发的 SDK 配置文件 /etc/qcloud/sdk.config

  • 示例代码部署目录:/data/release/node-weapp-demo
  • 运行示例的 Node 版本:v4.6.0
  • Node 进程管理工具:pm2

项目结构

Demo
├── README.md
├── app.js
├── business
│   └── chat-tunnel-handler.js
├── config.js
├── globals.js
├── package.json
├── process.json
├── routes
│   ├── index.js
│   ├── welcome.js
│   ├── login.js
│   ├── user.js
│   └── tunnel.js
└── setup-qcloud-sdk.js

其中,app.js 是 启动文件,config.js 配置了启动服务监听的端口号,process.json 是运行本示例 的 pm2 配置文件。

setup-qcloud-sdk.js 用于初始化 SDK 配置,配置从文件 /etc/qcloud/sdk.config 中读取。 配置文件包含如下配置项:

{
    "serverHost": "业务服务器的主机名",
    "authServerUrl": "鉴权服务器地址",
    "tunnelServerUrl": "信道服务器地址",
    "tunnelSignatureKey": "和信道服务器通信的签名密钥"
}

routes/ 目录包含了示例用到的4个路由,路由和处理文件映射关系如下:

// 首页指引
/ => routes/welcome.js

// 登录
/login => routes/login.js

// 获取微信用户信息
/user => routes/user.js

// 处理信道请求
/tunnel => routes/tunnel.js

business/chat-tunnel-handler.js 是业务处理信道请求的示例代码。

如何在demo基础上进行开发

进入目录 /data/release/node-weapp-demo,将写好的代码上传到routes目录下

重启服务:  pm2 restart all

更新 SDK 版本

进入目录 /data/release/node-weapp-demo,然后先后执行命令 npm updatepm2 restart process.json 即可。

wafer-node-server-demo's People

Contributors

liamhuang avatar miusuncle avatar techird avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.