Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
/ grape Public archive
forked from cyppan/grape

The opinionated, data-first, graphy Clojure library to build HTTP APIs

License

Notifications You must be signed in to change notification settings

BeOpinion/grape

 
 

Repository files navigation

A Clojure library designed to build data-first APIs.

Release a new version

It includes the version increment, git commit, tag and deploy tasks.

lein release :major, :minor, :patch, :alpha, :beta, or :rc

At the end another commit and deploy is done with a new snapshot version

Features

Everything is built around the concept of resources You can see a resource as a super-powered collection of document with graph capabilities.

A resource corresponds generally to a MongoDB collection, it's a dictionary configuration to expose your collection safely to the external world, providing:

  • One or more Rest endpoint for your resource with a JSON DSL for fetching
  • Authorization
  • Soft Delete
  • Function Hooks
  • Relations (automatic fetching of related resources)
  • Schema validations (using the powerful Prismatic Schema lib)

This library is highly functional and you can easily add features around your resources using hooks on:

  • pre-read: to map the query
  • post-read: to modify the fetched documents
  • pre-create-pre-validate: the payload has been parsed, but occurs before the validation
  • pre-create-post-validate: the payload has been parsed and the document validated and coerced
  • post-create: after being inserted into the database, synchronous (you can map the result)
  • post-create-async: after being inserted into the database, asynchronous (used to feed the oplog for example)
  • pre-update-pre-validate: either for update or partial update
  • pre-update-post-validate
  • post-update
  • post-update-async
  • pre-delete
  • post-delete
  • post-delete-async

Hooks use cases:

  • Synchronize a secondary database (like an Elastic Search)
  • Increment counters (that comment has n like)
  • Denormalize your data (Maintain an array of the 3 last replies for a comment to ensure efficient comments fetching)
  • Map the users fetched to inject a Facebook graph url for their avatar
  • Perform complex validation involving multiple fields / collections
  • ...

Examples:

You'll find in the examples folder Grape showcases for:

  • A comment thread with users, comments and likes
  • The same project implemented with Component (lifecycle management)

About

The opinionated, data-first, graphy Clojure library to build HTTP APIs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Clojure 100.0%