Adding annotations to routes.json and correct interpreting code to include information about static assets. Will be used by routes-to-nginx-conf for building nginx regex patterns

This commit is contained in:
Colby Gutierrez-Kraybill 2015-09-14 12:16:58 -04:00
parent 724551b40c
commit 393552bd46
3 changed files with 18 additions and 8 deletions

View file

@ -39,6 +39,7 @@
"react": "0.13.3",
"react-modal": "0.3.0",
"react-slick": "0.7.0",
"routes-to-nginx-conf": "0.0.2",
"sass-loader": "2.0.1",
"slick-carousel": "1.5.8",
"style-loader": "0.12.3",

View file

@ -11,15 +11,15 @@ var app = express();
app.disable('x-powered-by');
app.use(log());
app.use(compression());
app.use(express.static(path.resolve(__dirname, '../build'), {
lastModified: true,
maxAge: '1y'
}));
// Bind routes
for (var item in routes) {
var route = routes[item];
app.get(route.pattern, handler(route));
if ( route.static ) {
app.use( express.static( eval( route.resolve ), route.attributes ) );
} else {
app.get(route.pattern, handler(route));
}
}
// Start listening

View file

@ -1,15 +1,24 @@
[
{
"pattern": "/",
"view": "splash"
"view": "splash",
"static": false
},
{
"pattern": "/about",
"view": "about",
"title": "About"
"title": "About",
"static": false
},
{
"pattern": "/components",
"view": "components"
"view": "components",
"static": false
},
{
"static": true,
"resolve": "path.resolve(__dirname, '../build')",
"attributes": { "lastModified": true, "maxAge": "1y" },
"_todo": " TODO: Define a specification for how each entry is used/expected to look like, given the nginx conf generator's needs and stand-alone run-time needs. An outline of this so far: static requires resolve/attributes but could use pattern too. ..."
}
]