Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
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').view.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
The npm package faraday receives a total of 37 weekly downloads. As such, faraday popularity was classified as not popular.
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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.