# pomelo-json-plugin

> a config data(.json) plugin for pomelo

Latest version **1.0.0** (published 2022-10-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install pomelo-json-plugin
pnpm add pomelo-json-plugin
yarn add pomelo-json-plugin
bun add pomelo-json-plugin
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-10-07 |
| First published | 2019-12-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | yunmin |
| Maintainers | yunmin |
| Keywords | pomelo-json-plugin |

## Links

- npm: https://www.npmjs.com/package/pomelo-json-plugin
- Repository: https://github.com/yunmin97/pomelo-json-plugin
- Homepage: https://github.com/yunmin97/pomelo-json-plugin#readme
- Issues: https://github.com/yunmin97/pomelo-json-plugin/issues
- npm.io page: https://npm.io/package/pomelo-json-plugin

## Dependencies (1)

- [pomelo-logger](https://npm.io/package/pomelo-logger.md) ^0.1.7

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.0 (latest) — 2022-10-07
- 0.0.8 — 2020-02-22
- 0.0.6 — 2019-12-27
- 0.0.5 — 2019-12-27
- 0.0.4 — 2019-12-27
- 0.0.3 — 2019-12-27
- 0.0.2 — 2019-12-26
- 0.0.1 — 2019-12-26

## README

## pomelo-json-plugin       

Config data plugin for [Pomelo](https://github.com/NetEase/pomelo) (a fast,scalable,distributed game server framework for [Node.js](https://nodejs.org), it can be used in Pomelo(>=0.7.0)).

pomelo-json-plugin is a config data(.json) plugin for Pomelo. pomelo-json-plugin can watch all config files in the given dir and reload the file automatically and asynchronous when it is modified. 

## Installation     

```
npm install pomelo-json-plugin
```

## Usage        

```javascript
let plugin = require('pomelo-json-plugin');
// ... ...
// ... ...
// a file loaded callback
let fileLoaded = function (name) {
    // log the file name
    console.log(name);    
};
// ... ...
// all files loaded down callback
let allLoaded = function () {
    // do other things here..
};
// ... ...
// ... ...
app.configure('production|development', function() {
//   ...
  app.use(plugin, {
    watcher: {
      dir: __dirname + '/config/data',
      interval: 3000,
      // onLoaded: fileLoaded    // option
      // onAllLoaded: allLoaded  // option
    }
  });
//   ...
});
// ... ...
// ... ...
let service = app.get('jsonService');
// check if the config exists 
if (!service.has('card')) {
    return;
}
// get config by name if exists
let data = service.get('card');
// ... ...
// ... ...
```

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