https://github.com/amacariola/rails6-marketapi
A pseudo Market Place API written in Rails
https://github.com/amacariola/rails6-marketapi
rails-api rest-api
Last synced: 10 months ago
JSON representation
A pseudo Market Place API written in Rails
- Host: GitHub
- URL: https://github.com/amacariola/rails6-marketapi
- Owner: amacariola
- Created: 2021-03-08T17:16:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-06T05:11:21.000Z (about 5 years ago)
- Last Synced: 2025-08-07T14:50:00.344Z (11 months ago)
- Topics: rails-api, rest-api
- Language: Ruby
- Homepage: https://market-api-rails6.herokuapp.com/api/v1
- Size: 36.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Market Place API
A Rails API made with json-serializer and jwt gem, primarily intended for demo of basic CRUD concepts and pagination
~~~~~~~
Routes
Prefix Verb URI Pattern
api_v1_users POST /api/v1/users(.:format)
api_v1_user GET /api/v1/users/:id(.:format)
PATCH /api/v1/users/:id(.:format)
PUT /api/v1/users/:id(.:format)
DELETE /api/v1/users/:id(.:format)
api_v1_orders GET /api/v1/orders(.:format)
POST /api/v1/orders(.:format)
api_v1_order GET /api/v1/orders/:id(.:format)
api_v1_tokens POST /api/v1/tokens(.:format)
~~~~~~~~~
## Setup
~~~bash
$ bundle install
$ rake db:create && rake db:migrate
~~~
## Run the test with pride
~~~bash
$ rails test --pride
~~~
## Repopulate the database
~~~bash
$rake db:seed
~~~~
## Perform tests
# Create a new user
~~bash
$ curl -X POST --data "user[email]=new@email.com" --data "user[password]=test1234" http://localhost:3000/api/v1/users
Response:
{"data":{"id":"10","type":"user","attributes":{"email":"new@email.com"},"relationships":{"products":{"data":[]}}}}
# Get Auth token
$ curl -X POST --data "user[email]=new@email.com" --data "user[password]=test1234" http://localhost:3000/api/v1/tokens
# Fetch all products
$ curl --header "Authorization = token here" http://localhost:3000/api/v1/products
## Requirements
- Ruby 2.7+(Rails 6.1.x)
- Sqlite3