Comparing version 2.2.1 to 2.3.0
@@ -108,3 +108,5 @@ const methods = ['get', 'delete', 'patch', 'post', 'put', 'head', 'options'] | ||
app.callback = () => app.handler | ||
return app | ||
} |
{ | ||
"name": "restana", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"description": "Super fast and minimalist web framework for building REST micro-services.", | ||
@@ -40,3 +40,3 @@ "main": "index.js", | ||
"chai": "^4.2.0", | ||
"express": "^4.16.3", | ||
"express": "^4.16.4", | ||
"fastify": "^1.12.1", | ||
@@ -48,3 +48,5 @@ "hapi": "^17.6.0", | ||
"morgan": "^1.9.1", | ||
"pem": "^1.13.1", | ||
"polka": "^0.4.0", | ||
"response-time": "^2.3.2", | ||
"restify": "^7.2.1", | ||
@@ -51,0 +53,0 @@ "standard": "^11.0.1", |
# restana | ||
Blazing fast and minimalist *connect-like* web framework for building REST micro-services. | ||
[![Build Status](https://travis-ci.org/jkyberneees/ana.svg?branch=master)](https://travis-ci.org/jkyberneees/ana) | ||
[![NPM version](https://img.shields.io/npm/v/restana.svg?style=flat)](https://www.npmjs.com/package/restana) [![Greenkeeper badge](https://badges.greenkeeper.io/jkyberneees/ana.svg)](https://greenkeeper.io/) | ||
Blazing fast, tiny and minimalist *connect-like* web framework for building REST micro-services. | ||
> Uses 'find-my-way' blazing fast router: https://www.npmjs.com/package/find-my-way | ||
@@ -44,4 +46,4 @@ | ||
```js | ||
const bodyParser = require('body-parser') | ||
service.use(bodyParser.json()) | ||
const bodyParser = require('body-parser'); | ||
service.use(bodyParser.json()); | ||
@@ -75,3 +77,3 @@ const PetsModel = { | ||
version: '1.0.0' | ||
} | ||
}; | ||
res.send(); // 200 is the default response code | ||
@@ -82,3 +84,3 @@ }); | ||
```js | ||
const methods = ['get', 'delete', 'put', 'patch', 'post', 'put', 'head', 'options']; | ||
const methods = ['get', 'delete', 'put', 'patch', 'post', 'head', 'options']; | ||
``` | ||
@@ -100,6 +102,6 @@ | ||
service.post('/star/:username', async (req, res) => { | ||
await starService.star(req.params.username) | ||
const stars = await starService.count(req.params.username) | ||
await starService.star(req.params.username); | ||
const stars = await starService.count(req.params.username); | ||
return stars | ||
return stars; | ||
}); | ||
@@ -154,8 +156,8 @@ ``` | ||
if (e.data && e.data.errClass) { | ||
console.log(e.data.errClass + ': ' + e.data.message) | ||
console.log(e.data.errClass + ': ' + e.data.message); | ||
} else { | ||
console.log('error response, but not triggered by an Error instance') | ||
console.log('error response, but not triggered by an Error instance'); | ||
} | ||
} | ||
}) | ||
}); | ||
@@ -166,4 +168,2 @@ return next(); | ||
Third party middlewares support: | ||
@@ -177,2 +177,35 @@ > Almost all middlewares using the *function (req, res, next)* signature format should work, considering that no custom framework feature is used. | ||
## AWS Serverless Integration | ||
`restana` is compatible with the [serverless-http](https://github.com/dougmoscrop/serverless-http) library, so restana based services can also run as AWS lambdas 🚀 | ||
```js | ||
// required dependencies | ||
const serverless = require('serverless-http'); | ||
const restana = require('restana'); | ||
// creating service | ||
const service = restana(); | ||
service.get('/hello', (req, res) => { | ||
res.send('Hello World!'); | ||
}); | ||
// lambda integration | ||
const handler = serverless(app); | ||
module.exports.handler = async (event, context) => { | ||
return await handler(event, context); | ||
}; | ||
``` | ||
## Third party integrations | ||
```js | ||
// ... | ||
const service = restana() | ||
service.get('/hello', (req, res) => { | ||
res.send('Hello World!'); | ||
}); | ||
// using "the callback integrator" middleware | ||
const server = http.createServer(service.callback()); | ||
//... | ||
``` | ||
## turbo-http integration | ||
@@ -186,6 +219,6 @@ What is turbo-http? Checkout: https://www.npmjs.com/package/turbo-http | ||
// ATTENTION: The performance of the service below can blow your mind ;) | ||
const server = require('restana/libs/turbo-http') | ||
const server = require('restana/libs/turbo-http'); | ||
const service = require('restana')({ | ||
server | ||
}) | ||
}); | ||
@@ -195,6 +228,6 @@ service.get('/hi', (req, res) => { | ||
msg: 'Hello World!' | ||
}) | ||
}) | ||
}); | ||
}); | ||
service.start() | ||
service.start(); | ||
``` | ||
@@ -205,3 +238,3 @@ > NOTE: When using `turbo-http`, the node.js `cluster` module can't be used! | ||
[Performance comparison](performance/) for a basic *Hello World!* response (single thread process). | ||
Node version: v10.6.0 | ||
Node version: v10.11.0 | ||
Laptop: MacBook Pro 2016, 2,7 GHz Intel Core i7, 16 GB 2133 MHz LPDDR3 | ||
@@ -214,2 +247,3 @@ ```bash | ||
* **restana**: Requests/sec 43575.36 | ||
* **restana-cluster**: Requests/sec 71626.33 | ||
* fastify: Requests/sec 36894.86 | ||
@@ -230,2 +264,2 @@ * koa: Requests/sec 23486.64 | ||
> [Polka](https://github.com/lukeed/polka) micro-framework is not considered because it misses JSON response auto-detection. | ||
> [Polka](https://github.com/lukeed/polka) micro-framework is not considered because it misses JSON response auto-detection. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14387
177
254
16