JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q38647F
  • License Apache-2.0

Simple web server package for Node.js.

Package Exports

  • @jnode/server
  • @jnode/server/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@jnode/server) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JustServer

Simple web server package for Node.js.

Installation

npm install @jnode/server

Usage

Import JustServer

const { Server } = require('@jnode/server');

Start a simple server

const server = new Server({
  '*': {
    '/awa': {
      '/uwu': {
        'TEXT': 'uwu'
      },
      'TEXT': 'awa'
    }
  },
  '#': {
    '!404': {
      '+STATUS': 404,
      'TEXT': '404 Page not found!'
    },
    '!500': {
      '+STATUS': 500,
      'TEXT': '500 Internal server error!'
    }
  }
});
server.listen(8080);
server.on('error', console.error);
server.on('request', (req, res) => {
  res.on('finish', () => {
    console.log(`${res.statusCode} ${req.headers.host}${req.url}`);
  });
});