Deployment | |
Code Quality | |
Availability | |
Code frequency | |
Documentation |
This API was delevopped with Ruby on Rails on a period on three months for a school project. We used it to insert data coming from an IoT module we developped and to then fetch this data from a Progressive Web App
Here's a non-exhaustive list of the technologies and dependencies used
- Ruby on Rails 5
- MySQL
- JWT (with the Knock gem)
- Unicorn (for production server)
- Nginx (Reverse Proxy)
- Capistrano (Deployment)
- Travis-CI (Continuous deployment)
- RSpec (Unit & integration tests)
You'll need Ruby 2.5.1 or higher and Ruby on Rails 5.2.1 or higher installed on your device. You also need some sort of SGBD installed, for example MySQL, Postgres, MariaDB, SQlite, ...
First clone the repository to your device :
$ git clone https://github.com/EPHEC-Enovatech/sensorygarden-api.git
Then inside the cloned repository, you need to change some configuration parameters.
In /config/database.yml
change in the development settings the username and password :
development:
<<: *default
database: sensorygarden_api_development
username: {{YOUR USERNAME}}
password: {{YOUR PASSWORD}}
Following the SGBD you choosed to install you'll need to change the database adapter.
In /config/database.yml
change in the default section :
default: &default
adapter: {{eg: pg, mysql2, sqlite3, ...}}
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
host: localhost
Full list of available database adapters here.
Then you need to setup the database with the command :
$ bundle exec rake db:setup
You can now start a development server with the command :
$ rails s
The API is now accessible at localhost:3000
Once you have the developement server running you can test the API by openning an HTTP client (eg. Postman).
You can now perform a GET request on localhost:3000/ping
, you should get a response looking like this :
{
"status": "SUCCESS",
"message": "Pong !"
}
If you want to try out other endpoints you have a complete API documentation here
You can run the tests on the API yourself.
First you may want to change the database user and password in the /config/database.yaml
file first :
test:
<<: *default
database: sensorygarden_api_test
username: {{YOUR USERNAME}}
password: {{YOUR PASSWORD}}
Then run the following command :
$ bundle exec rake spec
You can find the code for the tests in /spec/requests