Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thonatos/egg-wechat-api
Wechat Api for Egg.js
https://github.com/thonatos/egg-wechat-api
egg-plugin wechat-api
Last synced: 19 days ago
JSON representation
Wechat Api for Egg.js
- Host: GitHub
- URL: https://github.com/thonatos/egg-wechat-api
- Owner: eggjs-community
- License: mit
- Created: 2017-07-17T09:09:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-09T02:52:09.000Z (over 6 years ago)
- Last Synced: 2024-07-31T21:08:58.249Z (4 months ago)
- Topics: egg-plugin, wechat-api
- Language: JavaScript
- Homepage:
- Size: 30.3 KB
- Stars: 71
- Watchers: 19
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
- awesome-egg - egg-wechat-api - WechatApi for egg (Plugins)
- awesome-egg - egg-wechat-api - WechatApi for egg ![](https://img.shields.io/github/stars/thonatos/egg-wechat-api.svg?style=social&label=Star) ![](https://img.shields.io/npm/dm/egg-wechat-api.svg?style=flat-square) (仓库 / 插件)
README
# egg-wechat-api
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url][npm-image]: https://img.shields.io/npm/v/egg-wechat-api.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-wechat-api
[travis-image]: https://img.shields.io/travis/eggjs-community/egg-wechat-api.svg?style=flat-square
[travis-url]: https://travis-ci.org/eggjs-community/egg-wechat-api
[codecov-image]: https://img.shields.io/codecov/c/github/eggjs-community/egg-wechat-api.svg?style=flat-square
[codecov-url]: https://codecov.io/github/eggjs-community/egg-wechat-api?branch=master
[david-image]: https://img.shields.io/david/eggjs-community/egg-wechat-api.svg?style=flat-square
[david-url]: https://david-dm.org/eggjs-community/egg-wechat-api
[snyk-image]: https://snyk.io/test/npm/egg-wechat-api/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/egg-wechat-api
[download-image]: https://img.shields.io/npm/dm/egg-wechat-api.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-wechat-apiegg plugin for [wechat-api](https://github.com/node-webot/co-wechat-api)
## Install
```bash
$ npm i egg-wechat-api --save
```## Prerequisite
Node.js >= 7.x
## Usage
- [co-wechat-api](https://github.com/node-webot/co-wechat-api)
## Dependencies
- egg
- [egg-redis](https://github.com/eggjs/egg-redis)
- other
- [co-wechat-api](https://github.com/node-webot/co-wechat-api)## Configuration
```js
// {app_root}/config/plugin.js
exports.wechatApi = {
enable: true,
package: 'egg-wechat-api',
};
```
> if redis is single client```js
// {app_root}/config/config.default.js
exports.wechatApi = {
appId: '',
appSecret: '',
};
```
> if redis is multi clients```js
// {app_root}/config/config.default.js
exports.wechatApi = {
appId: '',
appSecret: '',
redisInstance: '', // select instance of redis
};
```> __Redis is required !__
see [config/config.default.js](config/config.default.js) for more detail.
## Example
```
'use strict';module.exports = app => {
app.get('/', function* () {
const { wechatApi } = app;
try {
const ticket = yield wechatApi.getTicket();
this.status = 200;
this.body = ticket;} catch (error) {
this.status = 500;
this.body = error;
}
});};
```## Questions & Suggestions
Please open an issue [here](https://github.com/eggjs/egg/issues).
## License
[MIT](LICENSE)