Run npm install to generate package.json
Remove the packages from package.json that you won't use. Here is a list of what each does
backbone: Backbone.js
bluebird: For Promise support in node
body-parser: For dealing with json body
bootstrap: styling for Frontend
css-loader: for including CSS
expore-loader: for exponsive jQuery to jQuery plugins
express: server
file-loader: common dependency
handlebars: Templates
jquery: Jquery :P
json-loader: for loading json files in require
localtunnel: for generating a local tunnel so that external services can hit your local server
mailgun: mailing service
moment: date service
parse: database as a service
socket.io: socket server
socket.io-client: socket client
styler-loader: dependency of css-loader
twilio: text message API
underscore: data manipulation toolkit
url-loader: common dependency
webpack: frontend asset compressor
winston: for logging
Copy config.sample.js to config.js (it's git ignored and should never be in repo, should be manually copied)
Install webpack sudo npm install -g webpack
Install nodemon sudo npm install -g nodemon
Run webpack watcher in on terminal window webpack --watch in project root
Run nodemon watchin in another terminal window nodemon in project root
Enabled/disable the modules in init that you'll be using
All your publically accessible content will stem from public/app/index.js
var Person = Parse . Object . extend ( 'Person' ) ;
( new Parse . Query ( Person ) )
. get ( personId )
. then ( _ . bind ( function ( data ) {
} ) ) . catch ( _ . bind ( function ( err ) {
} , this ) ) ;
new Person ( {
name : 'Harry'
} ) . save ( ) . then ( function ( ) {
//saved
} ) . catch ( function ( err ) {
//error
} ) ;
this . twilioClient . makeCall ( {
to : '+1' + phoneNumber ,
from : this . config . twilio . fromNumber ,
url : this . config . rootUrl + '/api/v1/startCall'
} ) ;
Make A Simple TwiML Response
var resp = new twilio . TwimlResponse ( )
. say ( 'Hello' ) ;
res . set ( 'Content-Type' , 'text/xml' ) ;
res . end ( resp . toString ( ) ) ;
resp . hangup ( ) ; //Hangs up
var messageTpl = Handlebars . compile (
fs . readFileSync ( 'template.hbs' , 'utf8' )
) ;
this . twilioClient . messages . create ( {
body : messageTpl ( {
//fill in template details here
} ) ,
to : '+1' + phoneNumber ,
from : this . config . twilio . fromPhone
} ) ;
this . socket . emit ( 'data' , 'Some Data' ) ;
var socket = require ( 'socket.io-client' ) ;
this . socket = socket . connect ( ) ;
this . socket . on ( 'data' , function ( data ) {
//data
} ) ;
var emailTpl = Handlebars.compile(
fs.readFileSync('template.hbs', 'utf8')
);
this.mailgun.sendText(
config.email.fromEmail,
toEmail,
'Email Subject',
emailTpl({
//Template details here
})
);