kemal-rest-api
Version, currently 0.1.25 versions
- 0.1.6latestDec 1, 2018
- 0.1.5not indexedJun 19, 2023
- 0.1.4not indexedJun 19, 2023
- 0.1.2not indexedJun 19, 2023
- 0.1.0not indexedJun 19, 2023
github.com/blocknotes/kemal-rest-api
Crystal library to create REST API with Kemal
56 stars
0 dependents
License: MIT
Nothing has been indexed for 0.1.2 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
kemal-rest-api:
github: blocknotes/kemal-rest-api
version: ~> 0.1.2Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.2. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
# kemal-rest-api [](https://travis-ci.org/blocknotes/kemal-rest-api)
A Crystal library to create REST API with Kemal.
See [examples](https://github.com/blocknotes/kemal-rest-api/tree/master/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`:
```yaml
dependencies:
kemal-rest-api:
github: blocknotes/kemal-rest-api
```
## Usage
```ruby
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](https://github.com/blocknotes/kemal-rest-api/tree/master/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
- [Mattia Roccoberton](http://blocknot.es) - creator, maintainer, Crystal fan :)
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.2- Tagged
- Jun 19, 2023
- Commit
24cf04e860c7- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/blocknotes/kemal-rest-api
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 5