Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tostasqb/hl-backend

API that supports the website
https://github.com/tostasqb/hl-backend

Last synced: 30 days ago
JSON representation

API that supports the website

Awesome Lists containing this project

README

        

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c8bee56cfd8d46ed8c351e31aba14c45)](https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=tostasqb/hl-backend&utm_campaign=Badge_Grade)

# Getting started

- Rename the .env and provide the infomation requested there.
- rails db:migrate
- rails db:seed
- `rails s`
- Follow the "How to call" section below

That's it!

## All with free resources (due to low traffic)

- Heroku for app
- AWS S3 for file repository
- Rails Admin for backoffice
- Cloudflare for https/caching/security
- Uptimerobot for uptime alert (and prevents heroku sleep mode)
- Sentry for error alerts

# How this started

On June 2, 2018 following [this tutorial](https://www.pluralsight.com/guides/token-based-authentication-with-ruby-on-rails-5-api).

# How to call

# create a user
User.create!(email: '[email protected]' , password: '123123123' , password_confirmation: '123123123')

# Authenticate the user returning a token
curl -H "Content-Type: application/json" -X POST -d '{ "email":"[email protected]","password":"123123123" }' http://localhost:3000/authenticate
> {"auth_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE0NjA2NTgxODZ9.xsSwcPC22IR71OBv6bU_OGCSyfE89DvEzWfDU0iybMA"}

# Call without authorization
curl http://localhost:3000/products
> {"error":"Not Authorized"}

# Call with authorization
curl -H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE0NjA2NTgxODZ9.xsSwcPC22IR71OBv6bU_OGCSyfE89DvEzWfDU0iybMA" http://localhost:3000/products
> []

# Test the deploy

# running
curl http://api.highline.com.pt/ping

# user authenticated
curl http://api.highline.com.pt/ping_auth

# database connected
curl http://api.highline.com.pt/ping_db