Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fortune

Package Overview
Dependencies
Maintainers
1
Versions
297
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fortune

Web framework for prototyping rich hypermedia APIs.

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.6K
increased by192.72%
Maintainers
1
Weekly downloads
 
Created
Source

Fortune.js Build Status

Hello nerds. Fortune is a web framework for prototyping rich hypermedia APIs that implement the JSON API specification. It comes with a modular persistence layer, with MongoDB support out of the box, and an adapter for MySQL, Postgres, & SQLite (see guide for how to use).

Get it by installing from npm:

$ npm install fortune

Features

Fortune implements everything you need to get started with JSON API, with a few extra features:

  • Focus on ease of use, especially for those who are not familiar with node.js. Fortune does the heavy lifting for you.
  • Associations and bi-directional relationship mapping. Fortune manages associations between resources so you don't have to.
  • Hooks to transform resources before writing and after reading, for implementing application-specific logic.

It does not come with any authentication or authorization, you should implement your own application-specific logic (see keystore.js for an example).

Guide & Documentation

The full guide and API documentation are located at fortunejs.com.

Basic Usage

Here is a minimal application:

require('fortune')()

.resource('person', {
  name: String,
  age: Number,
  pets: ['pet'] // "has many" relationship to pets

}).resource('pet', {
  name: String,
  age: Number,
  owner: 'person' // "belongs to" relationship to a person

}).listen(1337);

This exposes a few routes for the person and pet resources, as defined by the JSON API specification:

HTTPPersonPetNotes
GET/people/petsGet a collection of resources, accepts query ?ids=1,2,3...
POST/people/petsCreate a resource
GET/people/:id/pets/:idGet a specific resource, or multiple: 1,2,3
PUT/people/:id/pets/:idCreate or update a resource
PATCH/people/:id/pets/:idPatch a resource (see RFC 6902)
DELETE/people/:id/pets/:idDelete a resource
GET/people/:id/pets/pets/:id/ownerGet a related resource (one level deep)

Unit Testing

Tests are written with Mocha, and require MongoDB already set up on your system. To run tests:

$ npm test

Client-side Implementations

Meta

For release history and roadmap, see CHANGELOG.md.

Fortune is licensed under the MIT license, see LICENSE.md.

Development of Fortune is sponsored by AdStack.

Keywords

FAQs

Package last updated on 05 Sep 2013

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc