Giter Club home page Giter Club logo

node-server-skeleton's Introduction

Node Server Skeleton

Lightweight, simple, configurable, drop-in and go http server for Node.js.

motivation

I wanted to have a simple, but effective relatively fast framework that could be used with many different web projects merely by dropping in a different config. My desire at the time was to learn node's http functionality by doing rather than just reading through Express (though now I do that anyway). Java Play was a sort of inspiration for the general idea. But it also grew out of necessity.

Example Usage:

~$ node server/start_server.js sample_aps/simplest_page

~$ node server/start_server.js --help

~$ node server/start_server.js ../my_cool_website 80

The 4th argument (optional) is port. Defaults to 8000 for testing.

config.js

The server sets itself up via a config.js file that is found inside the project directory at the top level. The 3rd argument after the start_server.js script is the path to the project-directory. config.js is optional, as the server will serve static files from the project directory absent of any other instruction.

static_dir

a static directory (static_dir) is set in the config.js at startup. This directory and its sub-directories are the only place where files are allowed to be served from. Even so, there are two config vars, both arrays, that can be set to add additional things blocked from serving: block_list for files, and block_dirs for directories. The server will block any path that has any member of block_dirs[] within it.

handlers & router

config.js is where handlers are setup for the router. That is, functions which run some routine and return a response to the server, rather than simply dishing out a file. See the sample projects for examples how to do this.

contact

greg AT naughton DOT org for comments, questions, etc. I would love to hear from you if you are using this in your project.

Peace

node-server-skeleton's People

Contributors

gmn avatar

Watchers

 avatar James Cloos 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.