TinyAPI is a simple storage service that allows users to save and edit payloads through a RESTful API. It's built with Ruby on Rails and uses Redis for rate limiting.
- Create, read, and update payloads
- Automatic payload expiration
- Rate limiting
- Configurable payload size and expiry time
- Ruby 3.3.4
- Rails 7.2.1
- Redis
- Docker
- Kamal
-
Clone the repository:
git clone https://github.com/your-username/tinyapi.git cd tinyapi
-
Install dependencies:
bundle install
-
Set up the database:
rails db:create db:migrate
-
Start the Redis server:
redis-server
-
Start the Rails server:
rails server
Before any deployment, I prefer to run the below commands, to ensure everything is working fine.
rubocop -A # check lint enforcement
bundle exec rspec # check test coverage
bundle exec rails test # check unit test coverage
rails server # to locally start the server
For local run you can use below command
rails server # to start the server
bundle exec sidekiq # to start sidekiq
This project uses Kamal for deployment. Follow these steps to deploy:
-
Ensure you have Kamal installed:
gem install kamal
-
Set up your
.env
file with the necessary environment variables (see.env.example
for required variables). -
Build and push your Docker image:
docker build -t your-docker-hub-username/tinyapi:latest . docker push your-docker-hub-username/tinyapi:latest
-
Deploy your application:
kamal setup kamal deploy
The main deployment configuration is in config/deploy.yml
. This file defines:
- The Docker image to use
- The server(s) to deploy to
- Environment variables
- Accessory services (like Redis)
- Traefik configuration for SSL
Sample Kamal deployment hooks are available in the .kamal/hooks
directory. To use a hook:
- Copy the relevant
.sample
file in the.kamal/hooks
directory. - Remove the
.sample
extension from the copied file. - Modify the hook as needed for your deployment process.
Note: Active hook files (without the .sample
extension) are gitignored to prevent committing sensitive information.
See API_DOCUMENTATION.md for detailed API usage instructions.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE.md file for details.