• Stars
    star
    139
  • Rank 262,954 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿš€ A dependency injection web framework for Node.js.

SActive Web

๐Ÿš€ A dependency injection web framework for Node.js.

Build Status Build Status License NPM version NPM Download License

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

More Repositories

1

sactive-bot

๐Ÿ˜ˆ An extensible chat bot framework. sactive-bot is an evolution of the open source hubot project. - https://www.shipengqi.top/sactive-bot .
JavaScript
209
star
2

frontend-learn

๐Ÿ“š Frontend learning ...
Shell
127
star
3

golang-learn

๐Ÿ“š Go language learning ...
Shell
127
star
4

apiserver

ๅŸบไบŽ Go ๅฎž็Žฐ็š„ API server
Go
107
star
5

go-packages-docs-awesome

Go ้กน็›ฎไธ€ไบ›ๅธธ็”จๅŒ…็š„ไธญๆ–‡ๆ–‡ๆกฃ๏ผŒๅŒ…ๆ‹ฌ Gin๏ผŒDep๏ผŒCobra ็ญ‰ใ€‚
48
star
6

PM2-docs-Zh-CN

๐Ÿ“˜ PM2 ๆ–‡ๆกฃ็š„ไธญๆ–‡็‰ˆๆœฌ
35
star
7

go-fips

FIPS 140-2-compliant Golang images based on Alpine.
Dockerfile
16
star
8

blog-src

๐Ÿ™ˆ ๐Ÿ“š My blog source code, builded by Hugo.
JavaScript
10
star
9

vault-docs-Zh-CN

HashiCorp Vault ไธญๆ–‡ๆ–‡ๆกฃ
Shell
8
star
10

kube

A simple Kubernetes client, based on client-go.
Go
4
star
11

jcli

A package for building Go applications.
Go
2
star
12

db-learn

๐Ÿ“š Database learning ...
Shell
2
star
13

crt

Certificates generator.
Go
2
star
14

jaguar

A scaffold that makes it easy to create amazing Go applications.
Go
2
star
15

commitizen

The commitizen command line utility, without nodejs. Forked from commitizen-go, fixes some issues of commitizen-go and supports more new features.
Go
2
star
16

log

A structured logger for Go, based on zap.
Go
1
star
17

action

Inspired by Cobra. Cobra is a library for creating powerful modern CLI applications. "action" can be used to create a more fine-grained behavior of a command.
Go
1
star
18

kubernetes-learn

๐Ÿ“š Kubernetes learning ...
Shell
1
star
19

vc

Compare version strings to find greater, equal or lesser. Inspired by Masterminds/semver.
Go
1
star
20

errors

Go
1
star
21

resume

My resume template.
HTML
1
star
22

gosh

A simple SSH client for Go. Inspired by melbahja/goph.
Go
1
star
23

component-base

Shared code for core components
Go
1
star
24

golib

Common libraries for Go.
Go
1
star
25

network-protocol-learn

Network protocol learning ...
1
star
26

sactive-di

๐Ÿ’ฅ ๐Ÿ’ฅ Dependency injector for Node.js.
JavaScript
1
star