3.0.0-rc6 • Published 4 years ago

sactive-web v3.0.0-rc6

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Installation

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.
  • Interceptors.
  • Based on Koa2.

Example

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

Babel setup

If you're not using node v7.6+, you can refer koa installation.

Debugging

sactive-web along with many of the libraries it's built with support the DEBUG environment variable from 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.

  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:

npm install
npm test

# coverage
npm run test:cov

TODO

  • Benchmark test
3.0.0-rc6

4 years ago

2.2.15

4 years ago

2.2.13

5 years ago

2.2.12

5 years ago

2.2.11

5 years ago

2.2.10

6 years ago

2.2.9

6 years ago

2.2.8

6 years ago

2.2.7

6 years ago

2.2.6

6 years ago

2.2.5

6 years ago

2.2.4

6 years ago

2.2.3

6 years ago

2.2.0

6 years ago

2.0.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago