crystal-rest-api-template
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
.env
file 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
Repository
crystal-rest-api-template
Owner
Statistic
- 0
- 0
- 0
- 0
- 5
- over 1 year ago
- July 9, 2023
License
MIT License
Links
Synced at
Sun, 17 Nov 2024 06:34:45 GMT
Languages