flitz
v0.18.0
Published
A lightweight and extremly fast HTTP server with all basics.
Downloads
21
Maintainers
Readme
flitz
flitz [ˈflɪt͡s] is a lightweight and extremly fast HTTP server with all basics for Node 10+, written in TypeScript.
Install
Run
npm install --save flitz
from the folder, where your package.json
is stored.
Usage
const flitz = require('flitz');
const run = async () => {
const app = flitz();
app.get('/', async (req, res) => {
res.write('Hello world!');
res.end();
});
await app.listen(3000);
};
run();
Or the TypeScript way:
import flitz from 'flitz';
const run = async () => {
const app = flitz();
app.get('/', async (req, res) => {
res.write('Hello world!');
res.end();
});
await app.listen(3000);
};
run();
Middlewares
import flitz from 'flitz';
// s. https://github.com/flitz-js/body
import { body } from '@flitz/body';
const run = async () => {
const app = flitz();
// 👇👇👇
app.post('/', [ body() ], async (req, res) => {
const body = req.body as Buffer;
res.write('Your body as string: ' + body.toString('utf8'));
res.end();
});
await app.listen(3000);
};
run();
Static files
import flitz from 'flitz';
const run = async () => {
const app = flitz();
app.static('/', '/path/to/my/local/files/to/serve');
await app.listen(3000);
};
run();
TypeScript
TypeScript is optionally supported. The module contains its own definition files.
License
MIT © Marcel Kloubert