• This repository has been archived on 19/Jun/2023
  • Stars
    star
    54
  • Rank 526,647 (Top 11 %)
  • Language
    Crystal
  • License
    MIT License
  • Created over 7 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Crystal library to create REST API with Kemal

kemal-rest-api - PROJECT UNMAINTAINED

This project is not maintained anymore

If you like it or continue to use it fork it please.



A Crystal library to create REST API with Kemal.

See examples folder for mysql, sqlite3 and mongo samples.

NOTE: this is a beta version, a lot of features and security improvements need to be implemented actually

Installation

Add this to your application's shard.yml:

dependencies:
  kemal-rest-api:
    github: blocknotes/kemal-rest-api

Usage

require "db"       # dependency required to use CrystalDbModel
require "sqlite3"  # dependency required to use CrystalDbModel - alternatives: crystal-mysql, crystal-pg
require "kemal"
require "kemal-rest-api"

class MyModel < KemalRestApi::Adapters::CrystalDbModel
  def initialize
    super "sqlite3:./db.sqlite3", "my_table"
  end
end

module WebApp
  res = KemalRestApi::Resource.new MyModel.new, KemalRestApi::ALL_ACTIONS, prefix: "api", singular: "item"
  res.generate_routes!
  Kemal.run
end

Generated routes:

GET    /api/items
GET    /api/items/:id
POST   /api/items
PUT    /api/items/:id
DELETE /api/items/:id

KemalRestApi::Resource options

  • json (Bool): form payload as JSON instead of formdata, default = true
  • plural (String): plural name of the model, used for routes, default = singular pluralized
  • prefix (String): prefix for all API routes, default = ""
  • singular (String): singular name of the model, default = class model name lowercase

More examples

See examples folder.

Notes

crystal-db shard is required only if KemalRestApi::Adapters::CrystalDbModel is used.

The proposed adapters are basic implementations, you can create easily a model adapter that responds better to your needs. prepare_params is used to adjust the create/update parameters.

Contributors

More Repositories

1

activeadmin_quill_editor

Quill Rich Text Editor for ActiveAdmin
JavaScript
142
star
2

activeadmin_dynamic_fields

ActiveAdmin plugin to add dynamic behaviors to fields
Ruby
113
star
3

magickwand-crystal

Crystal C bindings for MagickWand library
Crystal
66
star
4

prawn-html

HTML to PDF renderer using Prawn PDF
Ruby
55
star
5

activeadmin_blaze_theme

A theme for Active Admin based on Blaze CSS 3.x
SCSS
44
star
6

activeadmin_froala_editor

Froala WYSIWYG editor for ActiveAdmin
CSS
41
star
7

rails_admin_material

Material Design theme for RailsAdmin
Ruby
37
star
8

active_storage_db

An ActiveStorage service plugin to store files in a PostgreSQL / MySQL / MSSQL database (for Rails 6/7)
Ruby
30
star
9

activeadmin_trumbowyg

Trumbowyg Editor for ActiveAdmin
JavaScript
29
star
10

administrate_ransack

A plugin for Administrate to use Ransack for filtering resources
Ruby
29
star
11

activeadmin_active_resource

Active Admin + Active Resource: to use a REST API in place of a local database as data source
Ruby
28
star
12

activeadmin_medium_editor

Medium Editor for ActiveAdmin
JavaScript
28
star
13

sinatra-rest-api

Sinatra REST API generator
Ruby
26
star
14

activeadmin_select_many

ActiveAdmin plugin for one-to-many / many-to-many / many-to-one associations
Ruby
25
star
15

activeadmin_selectize

Selectize.js for ActiveAdmin
Ruby
24
star
16

administrate-bootstrap-theme

A Bootstrap 5 theme for Administrate
SCSS
22
star
17

wkhtmltopdf-crystal

Crystal C bindings and wrapper for libwkhtmltox library
Crystal
22
star
18

administrate-materialize-theme

A Material Design theme for Administrate based on Materialize framework
JavaScript
15
star
19

curl-crystal

Crystal C bindings for libcurl
Crystal
14
star
20

activeadmin_materialize_theme

A theme for Active Admin based on Materialize framework
JavaScript
13
star
21

prawn-styled-text

Prawn PDF component which adds basic HTML support
Ruby
13
star
22

activeadmin_jfu_upload

An ActiveAdmin plugin to use jQuery-File-Upload for file uploads in forms
Ruby
12
star
23

rails-vue-example

Starter project for Vue.js in Rails 4.x
Ruby
9
star
24

tiny_admin

A compact and composable dashboard component for Ruby
Ruby
9
star
25

eventish

A simple and composable event library
Ruby
8
star
26

activeadmin_simple_form

An ActiveAdmin 1.x plugin to use Simple Form in place of Formtastic in edit views
Ruby
8
star
27

just-pico

Simple Pico CMS theme made with PureCSS
CSS
6
star
28

rails_admin_mydash

RailsAdmin alternative dashboard
HTML
4
star
29

ruby_experiments

Some Ruby experiments
Ruby
3
star
30

http-mock-server

A Ruby HTTP Mock Server based on Sinatra
Ruby
3
star
31

contents_core

Simple structure to manage contents in a flexible way
Ruby
3
star
32

gumbo-crystal

Crystal C bindings for Gumbo library
Crystal
3
star
33

pico_debug

Debugging tool for Pico CMS
PHP
2
star
34

pinfo-rails

Command line utility to collect informations from a Ruby on Rails project
Ruby
2
star
35

active_job_store

Store jobs' state and custom data on DB
Ruby
2
star
36

rubocop-rbs

RucoCop extension that check RBS signatures
Ruby
2
star
37

editable_components

UI components editable from the front-end for Rails
JavaScript
2
star
38

phantomjs-sitemap-generator

nodejs module to generate sitemaps using PhantomJS
JavaScript
2
star
39

auto-seeding

Auto generate seeding data with ActiveRecord
Ruby
1
star
40

rails_full_page_cache

Sample project to use full page caching on Rails
Ruby
1
star
41

grape_by_examples

Some Grape experiments
Ruby
1
star
42

wordpress_category_featured_images

Wordpress plugin that allows to set featured images for categories
PHP
1
star
43

grape-starter-kit

A grape starter project
Ruby
1
star
44

rails_admin_extended_fields

RailsAdmin plugin to add more options to fields
Ruby
1
star