stouter
v0.3.2
Published
Really simple server with routing to static files. Designed for the development phase of Javascript apps that use pushstate.
Downloads
12
Readme
stouter
Really simple node server with routing to static files.
Overview
I write lots of "one page" front end applications that use "pushState".
This means that urls in my applications often end up looking like the following
http://test.com/user/123
When the user hits refresh I want them to simply be served the file sitting at
http://test.com/index.html
but obviously I don't want their actualy URL to change. My front end app will know (using a javascript router) that I should display the content for "user/123"
In reality my apps aren't actually "one page" they have several "about us" kind of text heavy pages and then they have the main app.
So, I wanted to write a very simple server that serves up static pages when they exist. And falls back to a set of rules that I can configure when the static pages don't exist.
Here is an example of the configuration
{
"port":"3006",
"base":"public",
"indexFile":"index.html",
"routes":{
"/": "/index.html",
"/app/*": "/app/index.html",
"/how_it_works/*": "/how_it_works/index.html",
"/sign_up/*": "/sign_up/index.html",
"/about_us/*": "/about_us/index.html",
"/style_guide/*": "/style_guide/index.html"
},
"mimeTypes":{
"html" : "text/html",
"css" : "text/css",
"js" : "application/javascript",
"woff" : "application/font-woff",
"ttf" : "application/x-font-ttf"
}
}