crystal-rest-api-template
Version, currently develop branch1 version
- develop branchlatestJul 14, 2023
github.com/RockManJoe64/crystal-rest-api-template
A template implementing best practices to create a REST API in Crystal lang!
Installation
# Add this to your shard.yml
dependencies:
crystal-rest-api-template:
github: RockManJoe64/crystal-rest-api-template
branch: developdevelop is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
1.8.2- License
- MIT
- Author
- Jose Chavez
- Target
crystal-rest-api-templatefrom src/crystal-rest-api-template.cr
Dependencies
Runtime Dependencies
README
crystal-rest-api-template
This repo defines a standard of creating a REST API that interfaces with a relational database.
- It's using the grip-framework to wire up the RESTful endpoints.
- Clear is being used as the ORM. This means PostgreSQL is the target database.
- Micrate handles database migrations against a Postgres DB.
- Your
.envfile will be loaded via dotenv. - Hardwire handles the dependency injection!
Installation
Make sure you have crystal installed on your Linux/MacOS/WSL environment.
Install the shards.
shards install
Create a .env file with the DB connection URL. You can copy the sample.env file for this.
Modify the docker-compose.yaml file with details on your database, or keep it as is.
Usage
Bring up the Postgres DB using docker-compose.
docker-compose up
Run migrations against your DB.
./migrations/micrate up
Run the application.
crystal src/main.cr
Test it via a curl command.
curl "http://0.0.0.0:8080/"
Development
Use this template to quickly create a REST microservice.
It's crystal. Have fun!
Contributing
- Fork it (https://github.com/your-github-user/crystal-rest-api-template/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Jose Chavez - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
develop- Seen
- Jul 14, 2023
- Crystal
1.8.2- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/RockManJoe64/crystal-rest-api-template
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 1