Web framework built on Node.js.
This node framework is a production-ready Node.js framework that takes advantage of ECMAScript 6 features through the use of 6to5. It is built on top of Express.
View the docs on controllers and views.
The idea here is that you have your app in development on Git. Then you'll clone or deploy to your production server, and run CS in production mode.
> npm install -g cs
> cs init {{appname}}
> npm install
> cs run
See production docs.
> cd {{app dir}}
> cs run
See production docs.
config.json
module.exports = { ... }
env
key is the default. Everything inside the env
key will overwrite those depending on the enviroment you run in. You run different arbitrary enviroments via cs run [myapp] [env]
{
"name": "appname",
"port": "8000",
"session": "redis",
"debug": false,
"db": {
"adapter": "mongodb",
"mongodb" : {
"host": "mongodb://localhost:27017/sixtyvocab"
}
},
"env": {
"production": {
"port": 80
},
"development": {
"debug": true
}
}
}
./controllers
./models
./public
./private
./views
./services
./public
is your web root. All static files, js, css, images, etc. go here../private
is where you put things to be compiled such as stylus, coffeescript, or ES6 files. By default, stylus files will compile and minify files into public/css automatically../services
is the location of all services which are basically CS extended functionality> node index
or > node index development
(development
is the default environment)../app.log
is a log of all database queries.{{log variable}}
to log a hbs variable to the node console{{log variable client=true}}
to log a hbs variable to the browser consolelog()
is a convenient alias to console.log
.CS
is made global.
CS.private
-- all variables available to your view that you passedCS.public
-- variables available to your JS files in CS.publicCS.session
-- the session (which is available in your view)CS.server
-- server vars (which are available in your view)// include and compile a template
var compiledHTML = app.util.include("path/to/file")(data);
Services are a way to share complete parts of CS that are just arbitrary functions.
services/yourservice/index.js
package.json
defining your attributes and dependeciesmodule.exports = ...
Sample service package.json for gmail service
{
"name": "gmail",
"version": "1.0.0",
"description": "Gmail SMTP sending",
"main": "gmail.js",
"keywords": ["gmail","email","smtp"],
"author": "ConnectAi",
"license": "BSD-2-Clause",
"dependencies": {
"emailjs": "~0.3.5"
}
}
Currently the services package.json don't do anything
Read about the cool stuff ES6 can do you for you
Controllers
"/:token1/:token2"
."/:token1/:token2"(req, res, next, param1, param2) {}
"/:id/:username?"(req, res, next, id, username) {}
Views