Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

restana

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restana - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

2

index.js

@@ -20,3 +20,3 @@ const http = require("http");

let app = {
use: (middleware, context) => {
use: (middleware, context = {}) => {
middlewares.push({

@@ -23,0 +23,0 @@ handler: middleware,

const next = (middlewares, req, res, cb) => {
let middleware = middlewares.shift();
return () => {
return (err) => {
if (err) return res.send(err);
if (res.statusCode == 200 && !res.finished) {

@@ -9,3 +10,3 @@ if (!middleware) return cb();

try {
let result = middleware.handler.call(middleware.context || {}, req, res, next(middlewares, req, res, cb));
let result = middleware.handler.call(middleware.context, req, res, next(middlewares, req, res, cb));
if (result instanceof Promise) { // async support

@@ -12,0 +13,0 @@ result.catch(res.send);

@@ -9,3 +9,3 @@ module.exports.send = (req, res) => (data = 200, code = 200, headers = {}) => {

if (data instanceof Error) {
code = data.code || 500;
code = data.status || data.code || 500;
data = {

@@ -30,3 +30,4 @@ code,

req,
data
data,
code
}

@@ -33,0 +34,0 @@ res.emit('response', params);

{
"name": "restana",
"version": "0.2.1",
"version": "0.3.0",
"description": "Super fast and minimalist web framework for building REST micro-services.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -52,3 +52,3 @@ # REST-Ana

```
Middleware usage:
### Middleware usage:
```js

@@ -75,2 +75,21 @@ const service = require('restana')({});

service.start();
```
```
Third party middlewares support:
> Almost all middlewares using the *function (req, res, next)* signature format should work. With the consideration that they don't use any custom framework feature.
Examples :
* **raw-body**: [https://www.npmjs.com/package/raw-body](https://www.npmjs.com/package/raw-body). See demo: [raw-body.js](demos/raw-body.js)
* **express-jwt**: [https://www.npmjs.com/package/express-jwt](https://www.npmjs.com/package/express-jwt). See demo: [express-jwt.js](demos/express-jwt.js)
* **body-parser**: [https://www.npmjs.com/package/body-parser](https://www.npmjs.com/package/body-parser). See demo: [body-parser.js](demos/body-parser.js)
## Performance comparison
Performance comparison for a basic *Hello World!* response in cluster mode with 4 processes:
```bash
ab -n 10000 -c 1000 http://localhost:3000/v1/welcome
```
Results:
* restana: ~1300ms
* koa: ~1500ms
* hapi: ~4200ms
* express: ~1800ms
* restify: ~2000ms
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc