Gathering detailed insights and metrics for chalice
Gathering detailed insights and metrics for chalice
Gathering detailed insights and metrics for chalice
Gathering detailed insights and metrics for chalice
npm install chalice
Typescript
Module System
NPM Version
CoffeeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
6 Stars
9 Commits
2 Watchers
1 Branches
1 Contributors
Updated on Feb 26, 2015
Latest Version
0.0.1
Package Id
chalice@0.0.1
Size
12.53 kB
NPM Version
1.2.30
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
3
A small framework on top of CoffeeScript Backbone and Node to render apps on the client and server.
If you haven't already done so, install grunt-init and grunt-cli
.
npm install -g grunt-init grunt-cli
Once grunt-init is installed, place this template in your ~/.grunt-init/
directory. It's recommended that you use git to clone this template into that directory, as follows:
git clone git@github.com:shanejonas/grunt-init-chalice.git ~/.grunt-init/chalice
(Windows users, see the documentation for the correct destination directory path)
mkdir myproject
cd myproject
grunt-init chalice
Note that this template will generate files in the current directory, so be sure to change to a new directory first if you don't want to overwrite existing files.
Then you can run
npm install .
grunt
And you it will build/serve/watch for you. You can go to
http://localhost:3000
in your browser to view the page.
I'm sure everyone has a different view but heres mine:
And for development:
commonJS
modules and npm
for package managementlive-reload
out of the boxnode.js
tool chainfor debugging in chrome dev tools.
This documentation site and the libraries (backbone + chalice + handlebars + zepto) are only 29kb gzip/compressed.
Dom creation libraries are getting faster. But the clear winner is still concatenating strings. This also makes it easier to work with views on the server.
By having the markup served on the server and loading javascript asynchronously you take it out of the critical rendering path, this gives you 5x faster perceived loading time. From the twitter blog
There are a variety of options for improving the performance of our JavaScript, but we wanted to do even better. We took the execution of JavaScript completely out of our render path. By rendering our page content on the server and deferring all JavaScript execution until well after that content has been rendered, we've dropped the time to first Tweet to one-fifth of what it was.
I'm pretty opinionated with my CommonJS dependencies here but it just makes sense
if the end goal is to get Backbone running on the server. My approach is
to provide a thin layer on top of Backbone that allows it to run fast
and seamless inside node.js
. The templates are handlebars and the
language is coffeescript. This approach differs from rendr in
that I'm not rewriting the routing layer. Simply overwriting
Backbone.Router::route
to make an express route and call the same
route on the server. Something like:
Backbone.Router::route = (route, name) ->
app.get '/' + route, (req, res) =>
@[name] _.values(req.params)
This leaves the MV*
implementation up to the developer.
The backbone docs say it best:
References between Models and Views can be handled several ways. Some people like to have direct pointers, where views correspond 1:1 with models (model.view and view.model). Others prefer to have intermediate "controller" objects that orchestrate the creation and organization of views into a hierarchy. Others still prefer the evented approach, and always fire events instead of calling methods directly. All of these styles work well.
The View
overrides _ensureElement
to try to first get the element
out of the DOM. Calling super wont create anything if @el
is defined but when
it isn't it will create the element using jQuery. This method does nothing on
the server.
_ensureElement: ->
if Backbone.$?
@el = @getElFromDom()
super
When calling render on the view, on the server it will return a wrapped
string, and on the client side it will return this
as usual.
render: ->
unless @$el?.html @toHTML(no)
return @toHTML(yes)
@afterRender()
this
View = require 'chalice-view'
view = new View
# client side
view.render()
=> view object
# server side
view.render()
=> '<div class=\'view\' data-cid=\'view1\' ></div>'
Grunt is becoming a popular build tool, and for good reason. If you
haven't seen grunt before, check the getting started guide. Running
grunt
out of the box will give you a dev server on localhost:3000
that will selectively rebuild and livereload in the browser when .coffee
or
.styl
files change.
grunt
- Alias for "default" taskgrunt default
- Alias for "clean", "stylus:dev", "browserify2:dev", "express:app", "livereload-start", "regarde" tasks.grunt build
- Alias for "clean", "stylus:build", "browserify2:build".grunt serve
- Alias for "express:app", "express-keepalive" tasks.grunt clean
- Clean files and folders.grunt devtools
- A GUI For grunt in chrome devtoolsYou can use the following grunt tasks to generate new views/models/routers:
grunt generate:view --name=MyView
grunt generate:model --name=MyModel
grunt generate:router --name=MyRouter
grunt delete:view --name=MyView
grunt delete:model --name=MyModel
grunt delete:router --name=MyRouter
Sample output:
$ grunt generate:router --name=MyRouter
Running "generate:router" (generate) task
File written to: ./src/routers/myrouter.coffee
File written to: ./test/routers/myrouter.coffee
Done, without errors.
$ grunt delete:router --name=MyRouter
Running "delete:router" (delete) task
File deleted: ./src/routers/myrouter.coffee
File deleted: ./test/routers/myrouter.coffee
Done, without errors.
You can get a list of all the tasks by running grunt --help
.
(Note that these examples may still be pointing to older npm packages for Chalice libs)
Add unit tests for any new or changed functionality and Follow the CoffeeScript style guide
npm test
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
no SAST tool detected
Details
Reason
Found 0/9 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More