Skip to content

Nano-framework for Node.js powered by uWebSockets.js

License

Notifications You must be signed in to change notification settings

innomaxx/nanoexpress

 
 

Repository files navigation

nanoexpress

Greenkeeper badge Travis Code Climate Scrutinizer Code Quality Coverage Status NPM Downloads NPM Version size gzipsize

Nano-framework for Node.js powered by uWebSockets.js

Documentation available here

Are you want faster and stable performance with extra features, see PRO version

If you want Suport me, please see Support section

See Credits if you want which libraries i've used

Warning

This library does not support HTTP2!

NOTE

This library reached the Stable status and works good, see /examples folder.

This library up to 25% slower than uWebSockets.js on normal and complex application because of method polyfilling layer. Basic usage/examples performance are same as uWebSockets.js, but not in all case gives you same performance.

Requires: Node.js v10 or greater

Benchmarks

Benchmarks Memory Usage

Benchmarked on my macBook Pro 2012 13" (Core i5, 8Gb RAM) performance.

Note: Real-world app memory/rps may differs from these numbers and these numbers are in my macBook

You can install wrk via Homebrew in macOS or Linux

Benchmark command: wrk -t1 -d60 -c100

Motiviation

I've long-time planned somehow create own Express-like alternative Node.js framework, then seen uWebSockets.js. Almost 2 month i've think how do this right and decided to create Node.js framework with almost same as Express API.

This library makes very thin layer between uWebSockets.js and your code. But, gives you very Familiar and Clean API. Async/Await supported out-of-the-box!

Features

  • Async/Await out-of-the-box
  • No async mode supported
  • Easy to use (for Express users especially)
  • Blazing fast performance
  • Ultra lightweight size
  • Resource (CPU / Memory) effecient
  • Familiar API
  • Normalised API
  • Can define routes Declaratively
  • Express-compatible middleware
  • In-built middlewares
  • In-built Stream (Video stream, yay!) support
  • In-built WebSocket support (Express-like API and Events)
  • In-built Schema validator via Ajv
  • Out-of-the-box fast-json-stringify support via {schema} middleware
  • Small working examples
  • TypeScript declaration
  • Tests and CI checked code

Examples

All examples are lives here

Built-in Middlewares

Built-in middlewares implemented at layer-level for performance reason and enables automacilly when needed, not always

  • cookie
  • body-parser
  • express-ws (for comparing, uWS has built-in support at core-level)
  • fast-json-stringify (for serialization)
  • express-ajv (for comparing, for validation, this library does it at layer-level)
  • redoc
  • swagger-ui

In-box Middlewares

I'm excluded in-box modules from initialization for performance reason

How-to import

import { middlewares } from 'nanoexpress/packed';
// or import { passportInitialize } from 'nanoexpress/packed/middlewares';

const app = nanoexpress();
app.use(middlewares.passportInitialize()); // or app.use(passportInitialize());
  • passport

Working Middlewares

  • body-parser (yes, if you don't want built-in)
  • express-fileupload
  • cors (yes, express cors middleware)
  • express-jwt
  • express-session
  • express-graphql
  • passport

Docker Support

If you using alpine or slim version of node images, some errors may happen and you can fix with this minimal guide

Requires

  • git

For git missing error

# FROM ...
RUN apk update && apk add --no-cache git
# your scripts

For Alpine incompatible error

# your scripts
RUN ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2
CMD ["node", "server.js"]

Credits

And to other libraries which used to create this library and without these libraries wouldn't be possible to create this library

License

license

Support

Beerpay GitHub issues

  • Star project
  • Fork project
  • Add Tests to Project
  • Watch project
  • Report bugs
  • Fix issue
  • Make PR

About

Nano-framework for Node.js powered by uWebSockets.js

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%