Skip to content

kreteshq/szelmostwo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Szelmostwo (very-alpha)

This is Huncwot's core engine. It is built on top of uWebSockets.js.

Key features:

  • it provides automatic request payload parsing: JSON/forms submissions, file uploads, query params, dynamic routes
  • it supports middleware-like functionality, but on per-route basis using a regular function composition
  • it comes with static file support
  • it adds security headers out-of-the-box

It is created for convenience when interfacing with uWebSockets.js. You should probably use Huncwot directly.

Był Witalis maści rudej, Niezbyt gruby, niezbyt chudy, Miał na prawym oku bielmo I był szelmą. Strasznym szelmą!

Getting Started

Save it to a file e.g. server.js, run it with node server.js and visit the application https://localhost:5544.

const Szelmostwo = require('szelmostwo');

const app = new Szelmostwo();

// implicit `return` with a `text/plain` response
app.get('/', _ => 'Hello Szelmostwo')

// explicit `return` with a 200 response of `application/json` type
app.get('/json', _ => {
  return ({ status: '200 OK', body: { a: 1, b: 2 } });
})

// set your own headers
app.get('/headers', _ => {
  return { body: 'Niezbyt gruby, Niezbyt chudy', status: '201 Created', headers: { 'Authorization': 'PASS' } }
})

// request body is parsed in `params` by default
app.post('/greet', request => {
  return `Hello POST! ${request.params.name}`;
})

app.listen(5544);

About

Huncwot's Core Engine built on top of uWebSockets.js for Speed & Scale

Resources

Stars

Watchers

Forks

Packages

No packages published