Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shipengqi/sactive-web
:rocket: A dependency injection web framework for Node.js.
https://github.com/shipengqi/sactive-web
dependency-injection koa koa-router koa2 webframework
Last synced: 4 days ago
JSON representation
:rocket: A dependency injection web framework for Node.js.
- Host: GitHub
- URL: https://github.com/shipengqi/sactive-web
- Owner: shipengqi
- License: mit
- Created: 2018-06-04T13:27:43.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-23T20:43:19.000Z (almost 2 years ago)
- Last Synced: 2024-12-09T06:23:28.499Z (14 days ago)
- Topics: dependency-injection, koa, koa-router, koa2, webframework
- Language: JavaScript
- Homepage: https://shipengqi.github.io/sactive-web
- Size: 1.61 MB
- Stars: 139
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
SActive Web
:rocket: A dependency injection web framework for Node.js.## Installation
```bash
npm install sactive-web
```> **Note that 3.x.x is not compatible with 2.x.x and below** !!!
## Features
- Dependency injection.
- Router, grouping routes, based on [koa-router](https://github.com/alexmingoia/koa-router).
- Interceptors.
- Based on [Koa2](https://github.com/koajs/koa).## Example
```javascript
const App = require('..');const app = new App();
app.bindAny('name', 'pooky');app.use(($ctx, $name, $next) => {
$ctx.testname1 = $name;
$next();
});app.group('v1')
.get('/users/:name', ($ctx, $next, $name) => {
$ctx.body = {'name': $ctx.params.name, 'testname1': $ctx.testname1, 'testname2': $name};
});
app.group('v2/')
.get('/users/:name', ($name, $ctx, $next) => {
$ctx.response.body = {'name': $ctx.params.name, 'testname1': $ctx.testname1, 'testname2': $name};
});
app.group('/v3/')
.get('/users/:name', ($ctx, $name, $next) => {
$ctx.body = {'name': $ctx.params.name, 'testname1': $ctx.testname1, 'testname2': $name};
});app.listen(8080);
```## Documentation
- [Usage Guide](./docs/README.md)
- [API Reference](./docs/api.md)## Babel setup
If you're not using `node v7.6+`, you can refer [koa installation](https://koajs.com/#introduction).## Debugging
sactive-web along with many of the libraries it's built with support the __DEBUG__ environment variable from [debug](https://github.com/visionmedia/debug) which provides simple conditional logging.For example
to see all sactive-web debugging information just pass `DEBUG=active:*` and upon boot you'll see the list of middleware used, among other things.
```bash
active:di bind class: injector, singleton: true +0ms
active:di bind any: age, singleton: true +1ms
active:application use - +0ms
active:application use - +0ms
active:application register get /users/:name +1ms
active:application register get /users/ +0ms
active:application use - +0ms
active:di bind any: address, singleton: true +3ms
active:di bind function: getAddress, singleton: true +1ms
active:application listen +1ms
```## Tests
Install the dependencies, then run `npm test`:
``` bash
npm install
npm test# coverage
npm run test:cov
```## TODO
- Benchmark test