Giter VIP home page Giter VIP logo

fortune's Introduction

Fortune.js Build Status

Hello nerds. Fortune is a web framework for prototyping hypermedia APIs that implement the JSON API specification. It comes with a modular persistence layer, with adapters for NeDB (built-in), MongoDB, MySQL, Postgres, & SQLite.

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. Fortune gives you routing and database interactions for free, so you don't have to do the plumbing.
  • 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 (and magic).

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:

HTTP Person Pet Notes
GET /people /pets Get a collection of resources, accepts query ?ids=1,2,3...
POST /people /pets Create a resource
GET /people/:id /pets/:id Get a specific resource, or multiple: 1,2,3
PUT /people/:id /pets/:id Create or update a resource
PATCH /people/:id /pets/:id Patch a resource (see RFC 6902)
DELETE /people/:id /pets/:id Delete a resource
GET /people/:id/pets /pets/:id/owner Get a related resource (one level deep)

Unit Testing

Tests are written with Mocha, and are run against the built-in NeDB adapter, plus MongoDB & MySQL on Travis. You will also need to have the developer dependencies installed. 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.

fortune's People

Contributors

gr0uch avatar joefiorini avatar thewebguy avatar

Watchers

lemonhall avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.