Skip to content

Commit 6513f05

Browse files
committed
docs(README): update readme file
1 parent 446f5b3 commit 6513f05

File tree

3 files changed

+69
-92
lines changed

3 files changed

+69
-92
lines changed

README.md

Lines changed: 45 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,45 @@
1-
<div align="center"><img src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1564392111/adonis-banner_o9lunk.png" width="600px"></div>
2-
3-
# AdonisJS Http Server
4-
> Decently fast HTTP server used by AdonisJS
5-
6-
[![appveyor-image]][appveyor-url] [![circleci-image]][circleci-url] [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]
7-
8-
This module is extracted from the AdonisJS framework to work as a standalone HTTP server. The performance of the server is on par with Fastify (not as fast as fastify though).
9-
10-
11-
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
12-
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
13-
## Table of contents
14-
15-
- [Benchmarks](#benchmarks)
16-
- [Features](#features)
17-
- [Usage](#usage)
18-
19-
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
20-
21-
## Benchmarks
22-
The benchmarking scheme is taken from the Fastify github repo.
23-
24-
**Machine**: Quad-Core Intel Core i7, 2.2GHz, 16GB RAM
25-
**Method**: autocannon -c 100 -d 40 -p 10 localhost:3000 * 2, taking the second average
26-
27-
| Framework | Version | Router? | Requests/sec |
28-
| :----------------- | :------------------------- | :----------: | ------------: |
29-
| **Fastify** | **2.0.0** | **&#10003;** | **58,740** |
30-
| **AdonisJS** | **1.8.1** | **&#10003;** | **54,832** |
31-
32-
You can run the same benchmarks by cloning the repo and then running the following command.
33-
34-
```sh
35-
npm run benchmark
36-
```
37-
38-
Since the program correctness and reliability is more important over micro optimizations. We pay penality on following fronts in comparison to Fastify.
39-
40-
- **The AdonisJS query string parser can parse arrays inside query string** `(/api?foo[]=bar&foo[]=fuzz&foo[]=buzz
41-
)`, wherease fastify doesn't parse it by default for performance reasons. However, you can also define your own query string parser with fastify, but again, you will end up paying the same performance penality.
42-
- **Subdomain based routing** is another front, where AdonisJS has to perform little bit extra work to find the correct route and it's handler.
43-
44-
## Features
45-
46-
- The most advanced router with support for **route resources**, **route groups**, **subdomains routing**.
47-
- Support for **global** and **route specific** middleware.
48-
- Reliable and stable query string parser.
49-
- Global exception handler to catch all exceptions handled during an HTTP request.
50-
- Sends data to AdonisJS inbuilt profiler
51-
52-
## Usage
53-
You must be using the server inside a fully fledged AdonisJS application. Still, here's how you can start the standlone server.
54-
55-
```sh
56-
npm i @adonisjs/http-server
57-
```
58-
59-
```ts
60-
import proxyaddr from 'proxy-addr'
61-
import { createServer } from 'http'
62-
import { Ioc } from '@adonisjs/fold'
63-
import { Logger } from '@adonisjs/logger/build/standalone'
64-
import { Profiler } from '@adonisjs/profiler/build/standalone'
65-
import { Encryption } from '@adonisjs/encryption/build/standalone'
66-
67-
import { Server } from '@adonisjs/http-server'
68-
69-
const logger = new Logger({ enabled: true, level: 'trace', name: 'adonis' })
70-
const profiler = new Profiler({ enabled: true })
71-
const encryption = new Encryption({
72-
secret: 'averylongrandom32charslongsecret',
73-
})
74-
75-
const server = new Server(new Ioc(), logger, profiler, encryption, {
76-
etag: false,
77-
jsonpCallbackName: 'callback',
78-
cookie: {},
79-
subdomainOffset: 2,
80-
generateRequestId: false,
81-
trustProxy: proxyaddr.compile('loopback'),
82-
allowMethodSpoofing: false,
83-
})
84-
85-
server.router.get('/', async () => {
86-
return { hello: 'world' }
87-
})
88-
server.optimize()
89-
90-
createServer(server.handle.bind(server)).listen(4000)
91-
```
1+
<div align="center">
2+
<img src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1558612869/adonis-readme_zscycu.jpg" width="600px">
3+
</div>
4+
5+
<br />
6+
7+
<div align="center">
8+
<h3>AdonisJS HTTP Server</h3>
9+
<p>A fully feature HTTP server with first class support for <strong>Route groups</strong>, <strong>Sub-domain routing</strong>, <strong>Middleware</strong> and <strong>Cookies</strong>.</p>
10+
</div>
11+
12+
<br />
13+
14+
<div align="center">
15+
16+
[![circleci-image]][circleci-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url] [![audit-report-image]][audit-report-url]
17+
18+
</div>
19+
20+
<div align="center">
21+
<h3>
22+
<a href="https://preview.adonisjs.com">
23+
Website
24+
</a>
25+
<span> | </span>
26+
<a href="https://preview.adonisjs.com/guides/http/introduction">
27+
Guides
28+
</a>
29+
<span> | </span>
30+
<a href="CONTRIBUTING.md">
31+
Contributing
32+
</a>
33+
<span> | </span>
34+
<a href="benchmarks.md">
35+
Benchmarks
36+
</a>
37+
</h3>
38+
</div>
39+
40+
<div align="center">
41+
<sub>Built with ❤︎ by <a href="https://twitter.com/AmanVirk1">Harminder Virk</a>
42+
</div>
9243

9344
[appveyor-image]: https://img.shields.io/appveyor/ci/thetutlage/http-server/master.svg?style=for-the-badge&logo=appveyor
9445
[appveyor-url]: https://ci.appveyor.com/project/thetutlage/http-server "appveyor"
@@ -104,3 +55,6 @@ createServer(server.handle.bind(server)).listen(4000)
10455

10556
[license-image]: https://img.shields.io/npm/l/@adonisjs/http-server?color=blueviolet&style=for-the-badge
10657
[license-url]: LICENSE.md "license"
58+
59+
[audit-report-image]: https://img.shields.io/badge/-Audit%20Report-blueviolet?style=for-the-badge
60+
[audit-report-url]: https://htmlpreview.github.io/?https://github.com/adonisjs/http-server/blob/develop/npm-audit.html "audit-report"

benchmarks.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Benchmarks
2+
The benchmark scheme is taken from the Fastify Github repo.
3+
4+
**Machine**: MacBook Pro (Quad-Core Intel Core i7, 2.2GHz) 16GB RAM
5+
**Method**: autocannon -c 100 -d 40 -p 10 localhost:3000 * 2, taking the second average
6+
7+
| Framework | Version | Router? | Requests/sec |
8+
| :----------------- | :------------------------- | :----------: | -------------: |
9+
| **Fastify** | **^3.1.1** | **&#10003;** | **53277.6** |
10+
| **AdonisJS** | **3.0.0** | **&#10003;** | **50313.6** |
11+
12+
You can run the same benchmarks by cloning the repo and then running the following command.
13+
14+
```sh
15+
npm run benchmark
16+
```
17+
18+
Since the program correctness and reliability is more important over micro optimizations. We pay penalty on following fronts in comparison to Fastify.
19+
20+
- **The AdonisJS query string parser can parse arrays inside the query string** `(/api?foo[]=bar&foo[]=fuzz&foo[]=buzz
21+
)`, wherease fastify doesn't parse it by default for performance reasons. However, you can also define your own query string parser with fastify, but again, you will end up paying the same performance penalty.
22+
- **Subdomain based routing** is another front, where AdonisJS has to perform little bit extra work to find the correct route and it's handler by matching the domains first.
23+
- **Middleware support** is inbuilt in AdonisJS. Whereas, with [fastify you will have to install](https://www.fastify.io/docs/latest/Middleware/) additional packages for middleware support.

npm-audit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ <h5 class="card-title">
5555
<div class="card">
5656
<div class="card-body">
5757
<h5 class="card-title">
58-
July 24th 2020, 6:20:27 am
58+
July 24th 2020, 6:30:57 am
5959
</h5>
6060
<p class="card-text">Last updated</p>
6161
</div>

0 commit comments

Comments
 (0)