0.0.3 • Published 7 months ago

sawer v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

The easiest way to get start is by using create-sawer-app.

Installation

Installing the core package:

$ npm install sawer

Installing CLI package:

$ npm install sawer-cli -D

Getting started

Create a route:

// server/route.ts
import type { Request, Response } from 'sawer';

export async function GET(req: Request, res: Response) {
    res.end('Hello, world!');
}

Create build:

$ sawer build

Run build:

$ sawer start

Creating custom server

A final build exposes many methods that can be used to create a custom server.\ Including sawer which is the main route handler for incoming requests.

// server.js
import { sawer, config } from '../dist/index.js';
import http from 'node:http';

const server = http.createServer();
const port = config.port || 3000;

server.on('request', async (req, res) => {
    // some custom logic
    if (req.url === '/') {
        res.end('<h1>Hello, world!</h1>');
        return;
    }

    await sawer(req, res);
});

server.listen(port, () => {
    console.log(`Listening on http://localhost:${port}`);
});

In order to run it, create a build and execute the file:

$ sawer build
$ node server.js

Disclaimer

⚠ This is still being developed. It's not ready for production yet.

License

This project is licensed under the MIT License ❤️

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago

0.0.0

7 months ago

0.0.0-security

7 months ago