All Projects → die-welle → Koa Weixin Jssdk

die-welle / Koa Weixin Jssdk

Licence: mit
koa weixin jssdk middleware

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Koa Weixin Jssdk

Miniweather
基于koa的微信公众号开发
Stars: ✭ 67 (+857.14%)
Mutual labels:  koa, wechat, weixin
Koa Helmet
Important security headers for koa
Stars: ✭ 595 (+8400%)
Mutual labels:  koa, koa2
Weixin Java Miniapp Demo
基于Spring Boot 和 WxJava 实现的微信小程序Java后端Demo
Stars: ✭ 779 (+11028.57%)
Mutual labels:  wechat, weixin
Quietweather
☀️ Develop a weather wechat mini program application in two days - 两天撸一个天气应用微信小程序
Stars: ✭ 677 (+9571.43%)
Mutual labels:  wechat, weixin
Wecron
✔️ 微信上的定时提醒 - Cron on WeChat
Stars: ✭ 537 (+7571.43%)
Mutual labels:  wechat, weixin
Wechat Jssdk
🐧WeChat JS-SDK integration with NodeJS
Stars: ✭ 571 (+8057.14%)
Mutual labels:  wechat, weixin
Wechat Miniprogram Examples
WeChat mini program examples. 微信小程序示例
Stars: ✭ 634 (+8957.14%)
Mutual labels:  wechat, weixin
Koa2 Note
《Koa2进阶学习笔记》已完结🎄🎄🎄
Stars: ✭ 4,725 (+67400%)
Mutual labels:  koa, koa2
Iview Weapp
一套高质量的微信小程序 UI 组件库
Stars: ✭ 6,145 (+87685.71%)
Mutual labels:  wechat, weixin
Vue Koa Demo
🔰A simple full stack demo(CSR & SSR & Docker Support) written by Vue2 & Koa2(Koa1 verson also completed)
Stars: ✭ 730 (+10328.57%)
Mutual labels:  koa, koa2
Node Typescript Koa Rest
REST API boilerplate using NodeJS and KOA2, typescript. Logging and JWT as middlewares. TypeORM with class-validator, SQL CRUD. Docker included. Swagger docs, actions CI and valuable README
Stars: ✭ 739 (+10457.14%)
Mutual labels:  koa, koa2
Sns auth
通用第三方登录SDK,支持微信,微信扫码,QQ,微博登录,支付宝登录,Facebook,Line,Twitter,Google
Stars: ✭ 520 (+7328.57%)
Mutual labels:  wechat, weixin
Koajs Design Note
《Koa.js 设计模式-学习笔记》已完结 😆
Stars: ✭ 520 (+7328.57%)
Mutual labels:  koa, koa2
Ocbarrage
iOS 弹幕库 OCBarrage, 同时渲染5000条弹幕也不卡, 轻量, 可拓展, 高度自定义动画, 超高性能, 简单易上手; A barrage render-engine with high performance for iOS. At the same time, rendering 5000 barrages is also very smooth, lightweight, scalable, highly custom animation, ultra high performance, simple and easy to use!
Stars: ✭ 589 (+8314.29%)
Mutual labels:  wechat, weixin
Planmaster
套餐助手:手机套餐对比选购小程序
Stars: ✭ 487 (+6857.14%)
Mutual labels:  wechat, weixin
Wechattweak Macos
A dynamic library tweak for WeChat macOS - 首款微信 macOS 客户端撤回拦截与多开
Stars: ✭ 6,505 (+92828.57%)
Mutual labels:  wechat, weixin
Koa Passport
Passport middleware for Koa
Stars: ✭ 748 (+10585.71%)
Mutual labels:  koa, koa2
Weindex
微信相关资源汇总索引
Stars: ✭ 466 (+6557.14%)
Mutual labels:  wechat, weixin
Wechat sender
随时随地发送消息到微信
Stars: ✭ 474 (+6671.43%)
Mutual labels:  wechat, weixin
Koa2 Api Scaffold
一个基于Koa2的轻量级RESTful API Server脚手架。
Stars: ✭ 694 (+9814.29%)
Mutual labels:  koa, koa2

koa-weixin-jssdk

Build Status

koa weixin jssdk middleware

Quick Start

import koa from 'koa';
import weixinJSSDK from '../src';

const port = process.env.PORT || 3000;
const app = koa();

app.use(weixinJSSDK({
    appId: '<YOUR_APP_ID>', // [required] weixin-jssdk app id
    
    secret: '<YOUR_SECRET>', // weixin-jssdk secret
 
    pathName: '/jssdk', // [optional] eg: http://imyourfather.com/jssdk

    onError: (err, ctx, next) => {
        console.error(err);
        ctx.body = 'error';
    },
}));

app.listen(port);

Advanced Usage

Custom store access_token and ticket

By default, it would cache access_token and ticket in runtime memory, but you can store them in somewhere else.

app.use(weixinJSSDK({
    appId: '<YOUR_APP_ID>',
    secret: '<YOUR_SECRET>',
    async onGetToken(url) {
        return redis.getAsync('ACCESS_TOKEN'); // this is an example
    },
    async onSetToken(token, expiresIn) {
        return redis.setSync('ACCESS_TOKEN', token, { expiresIn });
    },
    async onGetTicket(url) {
        return redis.getAsync('TICKET');
    },
    async onSetTicket(ticket, expiresIn) {
        return redis.setSync('TICKET', ticket, { expiresIn });
    },
    // other configs...
}));
Third-party weixin service

Maybe you already have a Third-party weixin service and have a access token, you could use custom fetchTicket or fetchToken function instead of secret.

app.use(weixinJSSDK({
    appId: '<YOUR_APP_ID>', // [required]
    async fetchToken() {
        // await fetch(...)
        return { access_token: '<MY_ACCESS_TOKEN>', expires_in: 7200 };
    },
    // other configs...
}));

Or fetchTicket

app.use(weixinJSSDK({
    appId: '<YOUR_APP_ID>', // [required]
    async fetchTicket() {
        // await fetch(...)
        return { ticket: 'TICKET', expires_in: 7200 };
    },
    // other configs...
}));

Installation

Using npm:

$ npm install koa-weixin-jssdk --save

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].