Popularity
8.2
Stable
Activity
0.0
Stable
68
9
6

Programming language: Crystal
License: GNU Lesser General Public License v3.0 only
Tags: Api Builders    

crystal_api alternatives and similar shards

Based on the "API Builders" category.
Alternatively, view crystal_api alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of crystal_api or a related project?

Add another 'API Builders' Shard

README

crystal_api

Dependency Status devDependency Status Build Status

crystal_api is a set of tools to allow create very fast JSON APIs.

Key notes:

  • all models are struct instead of class (like in active_record.cr)
  • custom SQL requests are preferred and encouraged
  • but you can use one macro to create all REST (no customization)
  • there are some Rails-like methods (coming soon)
  • logic need to be customized

Sample payment API is explained here

Here, Alive - real life API example with JS frontend

API of API - list of all methods (coming soon)

Roadmap

  • [x] Fix DB mapping to allow create database - add types of columns to definition list
  • [x] Check and fix JSON mapping
  • [x] Update action
  • [x] Destroy action
  • [x] Clean Postgres adapter
  • [x] Rewrite for easier usage as lib
  • [x] JSON response header
  • [x] DB inline config (no config file needed)
  • [x] devise compatible sign in controller
  • [x] JWT request authentication
  • [x] Initial rights managament
  • [x] Utilize singleton-like approach to get service
  • [x] Remove kemal-pg and use crystal-pg
  • [x] Use DB connection pool
  • [ ] Use typed queries
  • [x] Escape parameters - only quotation characters
  • [x] Add Nil to field type as union by default - shorter model definition
  • [ ] Rename service to something better
  • [x] Add "scope" method to model Mode.scope({where: Hash, limit: Int32, order: String})
  • [x] Add page, per_page, offset
  • [ ] Add random to fetch_one
  • [ ] Add random order to fetch_all
  • [x] One method for fetching
  • [ ] Models should be as much immutable as possible
  • [ ] Websockets

Usage

Please check:

Fast full REST

pg_connect_from_yaml("config/database.yml")

# all fields must be union with Nil
crystal_model(EventModel, id : Int32, name : String)

# magic macro
# crystal_resource_full_rest(<name>, <resource path without '/' >, <DB table name>, <Model struct>)
crystal_resource_full_rest(event, events, events, EventModel)

# create table if not exists
crystal_migrate_event

# set port
Kemal.config.port = 8002
# run, this run migrations before running the HTTP server
CrystalInit.start

Custom API

Please check short sample. This is money transfers API. User has its account and assigned payments: incoming (external transfered money to system), outgoing (user withdraw money), transfer (user's account money transfered to another user's account).

Rails like model methods

At this moment I'm refactoring and adding code for easier DB operations. Readme will be updated after that moment.

Contributing

  1. Fork it ( https://github.com/akwiatkowski/crystal_api/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors