Socket
Socket
Sign inDemoInstall

@bayerjs/core

Package Overview
Dependencies
20
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @bayerjs/core

Bayer.JS core server library


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
5.94 MB
Created
Weekly downloads
 

Readme

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

Last updated on 15 Mar 2019

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc