Git Product home page Git Product logo

bedrock-server's Introduction

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

  1. [optional] Tweak configuration
  2. Map the bedrock.dev hostname (or whatever you've configured) to your machine:
    1. Edit the /etc/hosts file as the administrator/root.
    2. Add an entry mapping the IP address to bedrock.dev. For example: 192.168.0.15 bedrock.dev (where 192.168.0.15 is the IP address of your primary network device).

To access the server once bedrock is running:

  1. Go to: https://bedrock.dev:18443/
  2. The certificate warning is normal for development mode. Accept it and continue.

How It Works

TODO

bedrock-server's People

Contributors

davidlehn avatar dlongley avatar mattcollier avatar msporny avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.