Socket
Socket
Sign inDemoInstall

@bayerjs/core

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bayerjs/core

Bayer.JS core server library


Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

@bayerjs/core

Core server abstract library. Start the server with Bayer.listen or get a callback function with Bayer.callback.

Usage

Initialize a server object

HTTP Server
import Bayer from "@bayerjs/core";

const app = new Bayer();

app.listen(); // Will listen on port 80 and 404 every request made to it

Add middleware

import { tap } from "rxjs/operators";

app.use(tap(({ res }) => {
  res.status(200, "OK").send("Hello world!");
}));

To pass data to middlewares further down, write into the extra object:

import { map } from "rxjs/operators";
// The number as second parameter is the priority. See the reference doc.
server.use(tap(({ req, extra }) => {
  // Push custom headers into the extra object
  Object.keys(req.headers).filter(v => v.startsWith("x-")).forEach(v => {
    extra[v] = req.headers[v];
  });
}), 1);

Keywords

FAQs

Package last updated on 15 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc