Skip to content

FoxMoss/wisp-server-cpp

Repository files navigation

wisp-server-cpp

wisp-server-cpp is the poorly named NodeJS binding of WispServerCpp it is still written largely in C++ and contains the same pompous attitude of the original with little evidence to back up its claims. If you so choose you can also call this project Wisp C++ Node to distinguish it from the original.

All actual info about the project implementation is stored on WispServerCpp.

Usage

Important

You may want to use --force-node-api-uncaught-exceptions-policy=trueto when running node.

Include and install wisp-server-cpp

import { init, routeRequest, routeUpgrade, shouldRoute } from "wisp-server-cpp"

Call init to setup the internal callbacks before using routeUpgrade anywhere.

init();

Optionally choose the prefix for shouldRoute, default is /wisp/

init("/non-suspicious-path/");

Add express and HTTP server boilerplate.

import http from 'node:http'
import express from "express"

const app = express();
const server = http.createServer();

Hook in express app routes and Wisp Server routing.

server.on('request', (request, response) => {
  if (shouldRoute(request)) {
    response.setHeader
    routeRequest(request, response);
    return;
  }
  app(request, response);
});
server.on('upgrade', (request, socket, head) => {
  if (shouldRoute(request)) {
    routeUpgrade(request, socket, head);
    return;
  }
  socket.end();
});

Then run it;

server.listen(6001)

Credit

  • bare-server-node for userspace arch

About

Node bindings for WispServerCpp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published