The lightweight, flexible web framework

Usage no npm install needed!

<script type="module">
  import vaxic from '';


vaxic logo

The ultra-light superpower Node web framework

GitHub | NPM


npm install --save vaxic

Basic usage

const Vaxic = require('vaxic')

const app = new Vaxic()

app.add('GET', '/getEndpoint', (req, res) => {

app.listen(80, '')


Extensions are super powerful overlays you can add onto your app to add new functionality!

Two built-in extensions exist. One is called static. It can be used to serve static files.


The other built-in extension is called route. It can be used to route requests.


app.add('POST', async (req, res) => {
    try {
        await res.route({
            'origin': 'http://localhost:5135'
    catch (err) {
        res.end('Failed to route!')


Handles are methods you provide to be used as request handlers for specific requests.

You can target them by request method or by URL (or both or neither!)

Creating handles is as easy as...

app.add('POST', (req, res) => {
    // This handle handles all POST requests.


Regular expressions in handles

Regular expressions can be used as handle URL targets!

app.add('GET', /^\/api/, (req, res) => {
    // This handle handles all GET requests to /api and all subpaths of /api!

The Request and Response classes, extended

Vaxic request and response objects passed to handlers extend the http.ClientRequest and http.ServerResponse objects.

How Vaxic changes ClientRequest

Vaxic adds the body property to requests which contain a body. (Ex. POST requests with bodies.)

Vaxic changes the url property of ClientRequest by URL parsing it into a URL object. (Without its querystring parsed.)

How Vaxic changes ServerResponse

Vaxic adds the endGzip, endDeflate, and endCompressed methods to the http.ServerResponse object.

ServerResponse.endGzip(body, statusCode, ?headers, ?cb)

ServerResponse.endDeflate(body, statusCode, ?headers, ?cb)

ServerResponse.endCompressed(body, ?statusCode:200, ?headers, ?cb)

All of the compression methods add the appropriate content-encoding header. Use endCompressed to autodetect the preferred compression method of the client based on the accept-encoding header.

Using another HTTP server package (such as HTTPS)

If you'd like to use your Vaxic app with another HTTP server such as Node's built-in HTTPS module, you can do so using app.serverHandler.

For example:

const https = require('https')


Creating extensions

Making extensions is easy! Extensions are just methods to which requests are passed before (or instead of) being handed over to handles.

(req, res, next) => {
    res.setHeader('Powered-By': 'Vaxic-Engine')

Calling next() in extension handler methods is important because it allows the request to propagate to the next applicable handler. (An extension or handle.)

Async / Promise handler methods for handles and extensions

Async or Promise-returning functions may be used as handlers in handles and extensions.

If a promise returned by a Promise-based handler is rejected, the rejection will be caught and a promiseHandleRejection (for handles) or a promiseExtensionRejection (for extensions) will be emitted with the error from the Vaxic instance.

Ex. for Async handle handlers:

app.add('GET', '/async', async function (req, res) {
    // Perform await / other logic if desired and handle request.

Ex. for async extension handlers:

app.use(async function (req, res, next) {
    // Perform await / other logic if desired and handle request.