You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-51Lines changed: 33 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,18 +11,19 @@
11
11
12
12
```
13
13
Everything in the -modern- web is arguable,
14
-
however we are convinced that Rayo is the fastest framework.
15
-
In the world.
14
+
however we believe that Rayo is the fastest framework for Nodejs.
16
15
Period.
17
16
```
18
17
19
18
## In a nutshell
20
19
21
-
- Really fast (yeah, like really fast. Up to 50% faster than Express)
22
-
- API similiar to Express.
23
-
- Compatible with existing Express middlware.
24
-
- Extensible & plugable.
25
-
- Less than 150 lines of code, with routing and all.
20
+
- Really fast (yeah, like really fast. See [how it compares](#how-does-it-compare)),
21
+
- similar API to express¹,
22
+
- compatible with express middleware,
23
+
- extensible & plugable,
24
+
- less than 150 lines of code, with routing and all.
25
+
26
+
> ¹ `Rayo` is not intended to be an express replacement, thus the API is similar, inspired-by, and not identical.
26
27
27
28
28
29
## Install
@@ -75,7 +76,7 @@ rayo({ port: 5050 })
75
76
76
77
`handler` functions accept an [IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage) (a.k.a `req`), a [ServerResponse](https://nodejs.org/dist/latest-v9.x/docs/api/http.html#http_class_http_serverresponse) (a.k.a `res`) and a `step through` (a.k.a `step`) function. `step()` is optional and it may be used to move the program's execution logic to the next handler in the stack.
77
78
78
-
`step()` may also be used to invoke an error at any time. See [error handling](#error-handling).
79
+
`step()` may also be used to return an error at any time. See [error handling](#error-handling).
79
80
80
81
> **Note:** An error will be thrown if `step()` is called on an empty stack.
- It's your responsibility to deal with them accordingly.
123
122
```
124
123
125
-
> ¹ `Rayo` is WIP, so you may encounter actual errors that need to be dealt with. If so, please point them out to us via a `pull request`. 👍
124
+
> ² `Rayo` is WIP, so you may encounter actual errors that need to be dealt with. If so, please point them out to us via a `pull request`. 👍
125
+
126
+
If you have implemented a custom error function (see `onError` under [options](#rayooptions--)) you may invoke it at any time by calling the `step()` function with an argument.
In the above example, the error will be returned on the `/` path, since `step()` is being called with an argument. Run the example, open your browser and go to [http://localhost:5050](http://localhost:5050) and you will see "Here's your error: Thunderstruck!".
142
+
143
+
If you don't have a custom error function, you may still call `step()` (with an argument), in which case the error will be returned using Rayo's standard function.
144
+
145
+
146
+
## API
126
147
127
148
#### rayo(options = {})
128
149
```
@@ -155,26 +176,7 @@ Please keep in mind that:
155
176
// Your custom logic.
156
177
}
157
178
```
158
-
159
-
`Default:` A "Page not found." message with a `404` status code.<br />
160
-
161
-
```js
162
-
constrayo=require('rayo');
163
-
164
-
constoptions= {
165
-
port:5050,
166
-
notFound: (req, res) => {
167
-
res.end('The requested page is magically gone.');
168
-
}
169
-
};
170
-
171
-
/**
172
-
* Visit `/hello` to trigger the `notFound` method.
0 commit comments