Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
faraday
Advanced tools
Readme
A lightweight MVC framework.
To begin, run the following the in the root of your app:
coffee node_modules/faraday/new.coffee
Now you can access faraday throught the folders models
, views
, and controllers
.
To run the server, run
./develop
If you get this:
-bash: ./develop: Permission denied
Run this:
chmod +x develop
This gives develop executable permission. To get develop to work, you may need to install the ruby gem called sass.
I have abandoned the old models
folder in favor of the modooses
model. You can still use models
, but they are deprecated and will be removed in subsequent versions.
A modoose is a humorous malamoneau of "model" and "mongoose". (I can hear you laughing). Each modoose corresponds to a mongoose model in a coffee file in the modooses folder. To create a modoose called Foo, save the file ./modooses/Foo.cofffee
:
fooSchema = # a mongoose schema for Foo...
module.exports = require('mongoose').model('Foo', fooSchema)
Faraday will create this model in the database and you can access it asynchronously as:
require('faraday').modoose(({Foo}) ->
foo = Foo.find({bar: 'baz'})
# Do things with the Foo modoose.
)
In your views
folder, put files the form filename.html.underscorecoffee
. These will be compiled as underscore.js (HTML) templates. You can invoke them as require('faraday').views.filename(scope)
. The scope
object will become the scope in the underscore.js template. That way you can pass variables and data for the template to render.
In your controller
folder, put coffeescript files. If you create a file ./controllers/foo.coffee
with the following:
myRequestHandler = (req, res) ->
#handle the request
module.exports = myRequestHandler
Then navigate to localhost:3000/foo
, myRequestHandler will be invoked with two arguments: the node.js request object and response object. I commonly require views in a controller and invoke some corresponding view.
Faraday will map directories in the controllers folder to path components in the url. For example, if you save the aforementioned coffescript as ./controllers/several/nested/directories/foo.coffee
myRequestHandler will be invoked when you navigate to localhost:3000/several/nested/directories/foo
. You can also create path components by nesting the routing object:
myRequestHandler = (req, res) ->
#handle the request
module.exports =
several:
nested:
directories:
foo: myRequestHandler
You can inspect how this works by reading node_modules/faraday/route.coffee
.
FAQs
A lightweight MVC framework
We found that faraday demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).