New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bedrock-server

Package Overview
Dependencies
Maintainers
4
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bedrock-server

Bedrock core server module

2.4.1
Source
npm
Version published
Weekly downloads
41
173.33%
Maintainers
4
Weekly downloads
 
Created
Source

bedrock-server

Build Status

A bedrock module that provides a basic HTTP and HTTPS server. Other modules, such as bedrock-express, typically provide a routing framework and other features for writing Web applications, but depend on this module for core low-level functionality like listening for incoming connections, redirecting HTTP traffic to the HTTPS port, and configuring SSL/TLS.

Requirements

  • npm v3+

Quick Examples

npm install bedrock-server

An example of attaching a custom request handler to the server once Bedrock is ready.

var bedrock = require('bedrock');
var server = require('bedrock-server');

// once bedrock is ready, attach request handler
bedrock.events.on('bedrock.ready', function() {
  // attach to TLS server
  server.servers.https.on('request', function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
  });
});

bedrock.start();

By default, bedrock-server will redirect any HTTP requests to HTTPS. To replace this default behavior, do the following:

var server = require('bedrock-server');

// once bedrock is ready, attach request handler
bedrock.events.on('bedrock.ready', function() {
  // attach to HTTP server
  server.servers.http.on('request', function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
  });
});

bedrock.start();

Configuration

For documentation on server configuration, see config.js.

Setup

  • [optional] Tweak configuration
  • Map the bedrock.localhost hostname (or whatever you've configured) to your machine:
    • Edit the /etc/hosts file as the administrator/root.
    • Add an entry mapping the IP address to bedrock.localhost. For example: 127.0.0.1 localhost bedrock.localhost. (If accessing the server externally, you may need to use the IP address of your primary network device).

To access the server once bedrock is running:

How It Works

TODO

Keywords

bedrock

FAQs

Package last updated on 10 Dec 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