I was told that raw http package is much faster than the frameworks. But I don’t really trust such claims.
So I make a test on how performance changes on http raw packages and frameworks.
Here is the test code, so you can get your own result.

You will see, in my test, as the url getting complicated, the performance difference is getting smaller.

The detailed result is as follows:

root url “/”

the averaged results:

visual differences:

none root url access “/url”

the averaged results:

visual differences:

parameterized url “/user/:id”

the averaged results:

visual differences:

Originally published at https://dev.to on March 11, 2021.

--

--

Aex is the only framework currently exists which really helps you forge your projects in the object oriented way.

There is no modules, no services, no new concepts, no more things you need to learn.

Also there is no MVCs, Aex is not a mvc web framework, but a framework reflects the real http requests.

It smooths http requests with simple decorators, makes your code clean, simple, intuitive and well organised.

You can find the project here

Here is an example on how to use aex in the object oriented way:

Originally published at https://dev.to on February 6, 2021.

--

--

When your middlewares are failed.
fallbacks can be added to rescue.

It is quite useful for policies.

1. define your middleware, return `false` when failed.

```
const logined = async function(this:User, req, res, scope) => {
this.name = “Peter”;
if (…) {
return false
}
};
```
2. define your fallback processer,

```
const notLoginHandler = async function fallback(this:User, req, res, scope){
// some fallback processing
res.end(“Fallback”);
}
```

3. inject it to your web request processing

```ts
class User {
private name = “Aex”;
@http(“post”, “/user/login”)
@body()
@inject(login, notLoginHandler)
public async login(req: any, res: any, scope: any) {
// req.session.user.name
// ok

}
}
```

see more details [here](https://github.com/calidion/aex#inject)

--

--

this package is created for project [aex](https://github.com/calidion/aex), but it is general to all node.js http processing.
It is on it’s early stage, any contribution is appriciated.

It provide abstract class Store and Session.
Currently only MemoryStore and CookieSession are available.

You can check the project at [https://github.com/aex-ts-node/session](https://github.com/aex-ts-node/session).

Usage:

import { MemoryStore, Cookie } from “@aex/session”;
import * as http from “http”;
const store = new MemoryStore();
const cookie = new Cookie(store);
const scope: any = {};
const server = http.createServer(function(req: any, res: any) {
cookie.parse(req, res, scope).then(() => {
scope.session.user = “alice”;
res.write(“Hello World!”);
res.end();
});
}).listen(port);

--

--