Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sfantasy/pugna
An Extensible Node.js Web Architecture
https://github.com/sfantasy/pugna
Last synced: about 1 month ago
JSON representation
An Extensible Node.js Web Architecture
- Host: GitHub
- URL: https://github.com/sfantasy/pugna
- Owner: SFantasy
- License: mit
- Created: 2016-07-28T10:47:01.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-07-29T11:35:10.000Z (over 8 years ago)
- Last Synced: 2024-10-12T10:18:05.017Z (2 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Pugna
---[![NPM version][npm-image]][npm-url]
[npm-image]: https://img.shields.io/npm/v/pugna.svg?style=flat
[npm-url]: https://npmjs.org/package/pugnaAn Extensible Node.js Web Architecture
## Install
```sh
npm i pugna -S
```## Usage
Pugna extends [Koa2](https://github.com/koajs/koa#koa-v2) and you can use it same as Koa:
```js
const Pugna = require('pugna');
const app = new Pugna();app.use(ctx => {
ctx.body = 'Hello Pugna!';
});
```### `loadModules`
Pugna provides a function for dynamic loading modules:
```js
app.loadModules(app, __dirname);
```### Appointment
Using `loadModules` should have the following appointment:
- Use `koa-router`
- Each module's name would be used in the application's route rules
- Each module should have `routes` folder and exports the router:```js
const router = require('koa-router')();router.get('/', (ctx, next) => {
ctx.body = 'bar index';
});module.exports = router;
```## Example
See [example](/example).
## License
The [MIT License](LICENSE)