TrailBuddies / api

The Trail Buddies api. Built with Ruby on Rails
https://trailbuddies.club
GNU General Public License v3.0
0 stars 0 forks source link
api postgresql rails ruby ruby-on-rails trailbuddies
trailbuddies logo ## TrailBuddies (api) https://trailbuddies.club Find friends to hike with! ⚠️ This project is under development. If you want to help please read [this](https://trailbuddies.club/join) ⚠️

![Maintenance](https://img.shields.io/maintenance/yes/2022) ![Website](https://img.shields.io/website?url=https%3A%2F%2Ftrailbuddies.club) ![GitHub commit activity](https://img.shields.io/github/commit-activity/w/TrailBuddies/api) ![GitHub last commit](https://img.shields.io/github/last-commit/TrailBuddies/api) ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/TrailBuddies/api/ci.yml?label=CI&branch=master) ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/TrailBuddies/api/docs.yml?label=Docs&branch=master) ![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/TrailBuddies/api) ![Code Climate coverage](https://img.shields.io/codeclimate/coverage/TrailBuddies/api?label=test%20coverage) ![Code Climate technical debt](https://img.shields.io/codeclimate/tech-debt/TrailBuddies/api) ![GitHub](https://img.shields.io/github/license/TrailBuddies/api) ![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/TrailBuddies/api) ![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/TrailBuddies/api)

Setup

Primary Dependencies

Tool Version Help
Ruby on Rails Rails 7.0.1 Installation guide
RBEnv rbenv 1.2.0 Installation guide
Ruby ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) Install via RBEnv
PostgreSQL postgres (PostgreSQL) 14.5 Installation guide
ImageMagick ImageMagick 7.1.0-45 Q16-HDRI x86_64 20319 Installation guide
TomTom API 1 n/a
Cloudinary API n/a n/a

Secondary (Ruby) Dependencies

❗ These are all defined in Gemfile Package Version Help Reason
net-smtp '~> 0.3.1' Github repo 🤷
rails '~> 7.0.1', '>= 7.0.0' Rails Guides pretty obvious, right?
pg '~> 1.1' Docs Allows PostgreSQL Active Record intergration
puma '~> 5.0' Docs 🤷
bcrypt '~> 3.1.7' Github repo Hash and compare password digests for users
bootsnap '>= 1.4.4' Github repo 🤷
byebug '~> 11.1.3' Rubydoc 🤷
listen '~> 3.3' Rubydoc 🤷
spring '~> 4.0.0' Rubydoc 🤷
rails-erd '~> 1.6.0' RubyDoc Generates /docs/ERD.png. (Entity Relationship Diagram)
simplecov '~> 0.21.2' GitHub repo Generates coverage reports (/coverage/**/*)
simplecov_json_formatter '~> 0.1.2' GitHub repo JSON formatter for simplecov
tzinfo-data '~> 1.2021.5' Rubydoc 🤷
jwt '~> 2.3' Docs (github) Create, sign, and validate Json Web Tokens
rack-cors '~> 1.1.1' Rubydoc Something to do with CORS I think
rmagick '~> 4.2.4' Rubydoc To edit images before storing them with Cloudinary
cloudinary '~> 1.22' Docs Use Cloudinary for Active Record attachments
httparty '~> 0.20' Rubydoc Send HTTP requests to the TomTom API

Environment Variables

Name Description Required Default
DEV_API_DB_USER Development PostgreSQL user that can access all necessary databases nil
DEV_API_DB_PASSWORD The development password for the above user nil
DEV_API_DB_HOST The development PostgreSQL daemon host address localhost
DEV_API_DB_PORT Production PostgreSQL connection port 5432
PROD_API_DB_USER Production PostgreSQL user that can access all necessary databases nil
PROD_API_DB_PASSWORD The production password for the above user nil
PROD_API_DB_HOST The production PostgreSQL daemon host address localhost
PROD_API_DB_PORT Production PostgreSQL connection port 5432
EMAIL An email address for the seed user (created with rails db:seed) nil
PASSWORD An unhashed (plain text) password for the seed user (above) nil
CLOUDINARY_SECRET A Cloudinary API secret. Will be used to store images nil
TOMTOM_API_KEY A TomTom maps API key. Will be used te generate map images nil
SMTP_USERNAME A valid Sendinblue SMTP login nil
SMTP_PASSWORD A valid Sendinblue SMTP key nil

Git Ignored Files

File Description
config/master.key The Rails credentials master key
config/rsa/*.pem The RSA keypair generated with bin/keygen
coverage/ Test coverage reports

RSA Keypair

You will need to generate a private/public keypair. On linux the commands would be: (in the project root)

$ rm -rf config/rsa/*.pem
$ mkdir -p config/rsa
$ ssh-keygen -o -f config/rsa/key -N $PASSPHRASE -t rsa -b 2048 -m pem
$ mv config/rsa/key config/rsa/private.pem
$ ssh-keygen -f config/rsa/key.pub -e -m pem > config/rsa/public.pem
$ rm config/rsa/key.pub

❗ These commands are saved in the bin/keygen file

Useful Information

Location image resolution

https://github.com/TrailBuddies/api/blob/4b3b7d61ea59234f6688843b1b9618153614007b/app/models/hike_event.rb#L21-L22

No Fixtures for Token Model?

That's right. There are no fixtures for the Token model. No sample data is given because each token is generated with a unique passphrase. If I put a token generated with passphrase foo in the fixtures file, it will not be able to be decoded in another instance of the project running with a passphrase of bar.

You cannot decode a JWT if you do not have the right passphrase