Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.
/ fortune Public archive
forked from fortunejs/fortune

High-level I/O library for web applications.

License

Notifications You must be signed in to change notification settings

replicon/fortune

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fortune.js

Build Status npm Version License

Fortune is a high-level I/O library for web applications. It provides an implementation of entity-relationship modelling, is agnostic about data storage, and can be used to power real-time (WebSocket) and hypermedia applications (RMM Level 3).

View the website for documentation. Get it from npm:

$ npm install fortune --save

Example

Let's build an API that models Twitter's basic functionality:

import fortune from 'fortune'
import http from 'http'

const store = fortune.create()

// The `net.http` function returns a listener function which does content
// negotiation, parses headers, and maps the response to an HTTP response.
const server = http.createServer(fortune.net.http(store))

store.defineType('user', {
  name: { type: String },

  // Following and followers are inversely related (many-to-many).
  following: { link: 'user', inverse: 'followers', isArray: true },
  followers: { link: 'user', inverse: 'following', isArray: true },

  // Many-to-one relationship of user posts to post author.
  posts: { link: 'post', inverse: 'author', isArray: true }
})

store.defineType('post', {
  message: { type: String },

  // One-to-many relationship of post author to user posts.
  author: { link: 'user', inverse: 'posts' }
})

store.connect().then(() => server.listen(1337))

This yields an ad hoc HTTP API. There are serializers for Micro API (hypermedia) and JSON API.

By default, the data is persisted in memory. There are adapters for databases such as MongoDB, Postgres, and NeDB.

See the plugins page for more details.

License

This software is licensed under the MIT license.

About

High-level I/O library for web applications.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 93.8%
  • CSS 4.2%
  • HTML 1.8%
  • Shell 0.2%