0.2.33 • Published 1 year ago

wudu-server v0.2.33

Weekly downloads
102
License
MIT
Repository
-
Last release
1 year ago

Welcome to wudu-server

This is a lightweight backend framework for NodeJS.

Pros

  • ES6
  • Modular
  • Convenient approach to backend logic and flow
  • Impact on performance: close to none!
  • Plug-n-play: no dependencies required
  • No compilers, transpilers or processors - WYSIWYG

Cons

  • Requires basic understanding of backend programming

Benchmark

  • Machine: Windows 10 Pro 10.0.18363 Build 18363, Intel(R) Core(TM) i9-7900X CPU @ 3.30GHz, 3301 Mhz, 10 Core(s), 20 Logical Processor(s), 64GB RAM
  • Method: autocannon -c 100 -d 40 -p 10 http://localhost:3000/ (best avg score in 3 runs)
  • Node: 15.3.0
  • Run: Sun Jan 24 2021 14:12:10

Benchmark setup

Comparing to leading frameworks with routing on the market (by corresponding setups):

FrameworkVersionRequests/sLatencyThroughput/MB
wudu-server0.2.948101.620.498.27
fastify3.10.143312.222.68.1
express4.17.112856.277.242.4

Prerequisites

  • NodeJS >= 15.3.0
  • NPM

Installation

npm i wudu-server

Create Simple Server

Suggested project structure

Project directory
 ├ client
 |  ┖ index.html
 ├ server
 |  ┖ endpoints
 |     ┖ IndexEndpoint.js
 ┕ index.js

Code

index.js

import { App, Router, Server } from 'wudu-server';
import IndexEndpoint from "./src/server/endpoints/IndexEndpoint.js";

// create new application
let app = new App();

// assign router to your app
app.router = Router.handler;

// add endpoint to your router
Router.addEndpoints(IndexEndpoint);

// run your app as a server
app.runServer({
    protocol: Server.HTTP,
    port: 80
});

server/endpoints/IndexEndpoint.js

export default class IndexEndpoint {
    static ['GET /'] (req, res) {
        res.file('./client/index.html', {ifModifiedSince: req.headers['if-modified-since']});
    }
}

client/index.html

<!DOCTYPE html>
<html>
<head></head>
<body>Hello, world!</body>
</html>

HTTPS

You can start an HTTPS server by replacing the corresponding code in index.js by the following:

// run your app as a server
app.runServer({
    protocol: Server.HTTPS,
    port: 443,
    options: { // corresponds to native NodeJS https config
        key: fs.readFileSync('PATH_TO_KEY'),
        cert: fs.readFileSync('PATH_TO_CERT'),
        ...
    }
});

Run

node index.js

CHANGELOG

DOCUMENTATION

Bugs and Issues

Feel free to open bugs, issues or suggest improvements here.

0.2.30

1 year ago

0.2.33

1 year ago

0.2.32

1 year ago

0.2.31

1 year ago

0.2.29

1 year ago

0.2.28

1 year ago

0.2.27

2 years ago

0.2.26

3 years ago

0.2.25

3 years ago

0.2.24

3 years ago

0.2.23

3 years ago

0.2.22

3 years ago

0.2.21

4 years ago

0.2.20

4 years ago

0.2.19

4 years ago

0.2.18

4 years ago

0.2.17

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.14

4 years ago

0.2.13

4 years ago

0.2.12

4 years ago

0.2.11

4 years ago

0.2.10

4 years ago

0.2.9

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.8

4 years ago

0.2.5

5 years ago

0.2.3

5 years ago

0.2.4

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.10

5 years ago

0.1.11

5 years ago

0.1.12

5 years ago

0.1.13

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.2

5 years ago

0.1.3

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago