Skeleton files required to start a nodejs client app
that accesses one of my APIs.
top-level directory
-------------------
js/
modules/
node_modules/
package.json
root/
views/
node_modules/
-------------
the command npm install
will read the package.json file, create this directory, and place the downloaded the packages listed in the json file at this location.
modules/
-----------
date.format.js - i manually downloaded and placed this module in this directory. i found it on github.
js/
---
dispatch.js
errors.js
pageglobals.js
search.js
usercookies.js
root/
-----
css/
- normalize.css
- veery.css
views/
------
error.hbs
searchform.hbs - (simple page to display)
layouts/
- main.hbs
partials/
- header.hbs
- footer.hbs
package.json
{
"name" : "Veery-Client-NodeJS",
"version" : "1.0.0",
"dependencies" : {
"express" : "4.0.0",
"express-handlebars" : "1.1.0",
"body-parser" : "1.9.2",
"html-entities" : "1.1.1",
"querystring" : "0.2.0",
"cookie-parser" : "1.3.3"
}
}
dispatch.js
var express = require('express'),
bodyParser = require('body-parser'),
exphbs = require('express-handlebars'),
path = require('path'),
cookie_parser = require('cookie-parser'),
search = require('./search'),
errors = require('./errors'),
app = express();
app.engine('hbs', exphbs({
extname:'hbs',
layoutsDir: path.join(__dirname, '../views/layouts'),
defaultLayout: path.join(__dirname, '../views/layouts/main.hbs'),
partialsDir: path.join(__dirname, '../views/partials'),
}));
app.set('views', path.join(__dirname, '../views'));
app.set('view engine', 'hbs');
app.use(bodyParser.urlencoded({ extended: true })); // parse application/x-www-form-urlencoded
app.use(cookie_parser());
app.get('/searchform', search.form);
app.use(errors.error404);
app.listen(3001);
From JR's : articles
181 words - 1875 chars
- 1 min read
created on
updated on
- #
source
- versions