# egg-pubsub

> provide google cloud pubsub for egg.js

Latest version **0.0.3-beta** (published 2020-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install egg-pubsub
pnpm add egg-pubsub
yarn add egg-pubsub
bun add egg-pubsub
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3-beta |
| Published | 2020-08-17 |
| First published | 2020-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 2 |
| Unpacked size | 14.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | coffeeSouffle |
| Maintainers | coffeesouffle |
| Keywords | egg, eggPlugin, egg-plugin, pubsub |

## Links

- npm: https://www.npmjs.com/package/egg-pubsub
- Repository: https://github.com/coffeeSouffle/egg-pubsub
- Homepage: https://github.com/coffeeSouffle/egg-pubsub#readme
- Issues: https://github.com/coffeeSouffle/egg-pubsub/issues
- npm.io page: https://npm.io/package/egg-pubsub

## Dependencies (2)

- [@google-cloud/pubsub](https://npm.io/package/@google-cloud/pubsub.md) 2.3.0
- [is-generator-function](https://npm.io/package/is-generator-function.md) 1.0.7

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 0.0.3-beta (latest) — 2020-08-17
- 0.0.1 — 2020-08-13

## README

# egg-pubsub

[![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-pubsub.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-pubsub
[travis-image]: https://img.shields.io/travis/eggjs/egg-pubsub.svg?style=flat-square
[travis-url]: https://travis-ci.org/eggjs/egg-pubsub
[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-pubsub.svg?style=flat-square
[codecov-url]: https://codecov.io/github/eggjs/egg-pubsub?branch=master
[david-image]: https://img.shields.io/david/eggjs/egg-pubsub.svg?style=flat-square
[david-url]: https://david-dm.org/eggjs/egg-pubsub
[snyk-image]: https://snyk.io/test/npm/egg-pubsub/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/egg-pubsub
[download-image]: https://img.shields.io/npm/dm/egg-pubsub.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-pubsub

<!--
Description here.
-->

## Install

```bash
$ npm i egg-pubsub --save
```

## Usage

```js
// {app_root}/config/plugin.js
exports.pubsub = {
  enable: true,
  package: 'egg-pubsub',
};
```

## Configuration

```js
// {app_root}/config/config.default.js
exports.pubsub = {
  client: {
    name: 'pubsubName',
    /**
     * @var topic google cloud topic name, it is optional.
     */
    topic: 'topic name',
    /**
     * @var subscription google cloud subscription name, it is optional.
     */
    subscription: 'subscribe name',

    /**
     * the document contains more detailed information about the settings of pubsub
     * https://cloud.google.com/nodejs/docs/reference/pubsub/0.28.x/PubSub
     */
  }
};
```

```js
// {app_root}/pubsub/pubsubName.js
module.exports = pubsubApp => {
  pubsubApp.router.register('test', async context => {
    console.log(context.cmd);
  });
}
```

```js
// {app_root}/app/controller/home.js
const controller = require('egg').Controller;

class HomeController extends Controller {
  async index() {
    await this.app.pubsub.publish('test');
  }
}

module.exports = HomeController;
```

see [config/config.default.js](config/config.default.js) for more detail.

## Example

<!-- example here -->

## Questions & Suggestions

Please open an issue [here](https://github.com/coffeeSouffle/egg-pubsub/issues).

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/egg-pubsub · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
