Yet Another Event Promised Server

Evheniy Bystrov
HackerNoon.com
3 min readAug 25, 2017

--

Many of us use node.js with express in our job or own projects. But now we can use such interesting features like async/await. We can use koa or make error handler wrapper for express. But it’s not cool.

Express and koa use middleware in kernel as the main pattern. It’s copied from Ruby framework sinatra and it’s not asynchronous. You can compare it with loop — not declarative and non asynchronous.

If you look how node.js server works you can see single process with “request” events.

And with promises:

So if you use loop or middleware or any non asynchronous code all other request will be waiting. The main idea of node.js and javascript is to use non blocking actions. That’s why we have callbacks, promises and async/await.

So after researching I decided to create a new framework. Let’s meet YEPS.

app.js

bin/www

package.json

First of all it’s 100% promise based framework — no blocking actions in kernel.

Promise like middleware

You can check it by yourself just look benchmark results. I tested YEPS with koa and express.

YEPS gives possibility to execute modules in parallel mode using Promise.all().

Or

It’s useful if you need to make connection to DB and make some other stuff like registration logging system, error handler…

The same idea we can use for routing. You don’t need to think which router is the most popular and put it higher like for express. We can start checking all routers at the same time and reject checking if we found it.

And last but not least if you already have some express middlewares you can use express wrapper and it’s easy to migrate just look into YEPS modules.

And some more examples:

Let’s get fun with node.js.

--

--

Evheniy Bystrov
HackerNoon.com

I can help with IT infrastructure (AWS), apps (Node.js + React) and teams.