4.0.7 • Published 14 days ago

@peter-schweitzer/ezserver v4.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
14 days ago

EZServer

EZServer versions prior to 3.0.3 are no longer available! (version 3.4.3 or newer is recommended)

simple, ultra light weight node.js module with (basically) 0 dependencies for simple backend/REST-API development all implemented in around a thousand lines or less

EZServer is developed on the current node version (v21) but should run on all active LTS versions

Resolving requests

The most basic way of resolving a request is using the 'add' function of the app. Eg. to resolve a request to /myRequest and respond with Hello World! do the following:

import { App, buildRes, MIME } from '@peter-schweitzer/ezserver';

const app = new App();

app.add('/hello-world', function (_req, res, _params) => {
  buildRes(res, 'Hello, World!', { mime: MIME.TEXT });
});

app.listen(8080);

on localhost:8080/hello-world you should see the text "Hello, World!"

The req-Object is passed from the node:http server, but is slightly modified. EZServer adds the property uri, which is very similar to req.url, but URI-decoded and without a query string. To provide correct type annotations for the req-Object the EZIncomingMessage type is used.

for further documentation refer to the example

4.0.7

14 days ago

4.0.6

14 days ago

4.0.4

1 month ago

4.0.3

1 month ago

4.0.1

2 months ago

4.0.2

2 months ago

4.0.0

2 months ago

3.5.1

2 months ago

3.5.0

3 months ago

3.4.0

6 months ago

3.2.2

7 months ago

3.0.4

11 months ago

3.2.1

7 months ago

3.0.3

11 months ago

3.2.0

7 months ago

3.0.2

12 months ago

3.0.1

12 months ago

3.4.3

5 months ago

3.4.2

5 months ago

3.0.6

11 months ago

3.4.1

5 months ago

3.0.5

11 months ago

3.0.0

12 months ago

3.3.0

7 months ago

3.1.0

10 months ago

2.7.0

1 year ago

2.6.1

1 year ago

2.6.0

1 year ago

2.6.3

1 year ago

2.6.2

1 year ago

2.6.5

1 year ago

2.6.4

1 year ago

2.6.6

1 year ago

2.5.0

1 year ago

2.5.2

1 year ago

2.5.1

1 year ago

2.4.2

1 year ago

2.3.0

1 year ago

2.4.1

1 year ago

2.3.2

1 year ago

2.4.0

1 year ago

2.2.1

1 year ago

2.1.2

2 years ago

2.2.0

1 year ago

2.1.1

2 years ago

2.1.4

2 years ago

2.2.2

1 year ago

2.1.3

2 years ago

2.1.0

2 years ago

1.3.7

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.3.5-rev2

2 years ago

1.3.9

2 years ago

1.3.8

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago