-
Install Rails 7
-
Install Ruby version 3.X
-
Instal Postgresql
-
Instal Redis
gem 'jwt'
gem 'bcrypt', '~> 3.1.7'
gem 'faye-websocket' gem 'eventmachine'
- We are adding eventmachine for dependecy gem for websocket
gem 'fast_jsonapi'
gem 'sidekiq' gem 'redis'
- We need to add dependecy for queing process redis gem
git clone [email protected]:mohanrajkpm/Price_app.git
cd price_app
bundle install
rails s
Open new tab with project folder in terminal
redis-server
Open new tab with project folder in terminal
bundle exec sidekiq
Open new tab with project folder in terminal
rails runner app/services/binance_price_services.rb
We can create a user then along with user we can create alert
POST
Accept: application/json Content-Type: application/json
{ "username": "xxxx", "email": "[email protected]", "password": "12345678", "password_confirmation": "12345678" }
{ "data": { "id": "1", "type": "user", "attributes": { "username": "xxxx", "email": "[email protected]" } } }
We can login user with the credentials
http://localhost:3000/auth/login
POST
Accept: application/json Content-Type: application/json
email: [email protected] password: 12345678
{ "token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0LCJleHAiOjE2ODE2MjU2NjR9.30hVGsIDWx3U7HW5IXZV_gIvi9KXNe6_z-zHeyqiGlM", "exp": "04-16-2023 11:44", "email": "[email protected]" }
We can create an alert based on user
POST
Bearer token xxtttkjdkfjk
Accept: application/json Content-Type: application/json
{ "price": "-511.21"
}
{ "data": { "id": "23", "type": "alert", "attributes": { "price": "-511.21", "status": "created", "user_id": 1 } } }
http://localhost:3000/alerts?page%5Bsize%5D=1
GET
Bearer token xxtttkjdkfjk
page%5Bsize%5D: 1
filter%5Bstatus%5D: created/triggered
Filter-status: triggered
{ "data": [ { "id": "1", "type": "alert", "attributes": { "price": "-511.21", "status": "triggered", "user_id": 2 } } ], "meta": { "total": 1, "pages": 1 }, "links": { "self": "http://localhost:3000/alerts?filter[status]=triggered&page[size]=3" } }
Filter-status: created
{ "data": [ { "id": "2", "type": "alert", "attributes": { "price": "-515.21", "status": "created", "user_id": 2 } }, { "id": "3", "type": "alert", "attributes": { "price": "-545.21", "status": "created", "user_id": 2 } }, { "id": "4", "type": "alert", "attributes": { "price": "-645.21", "status": "created", "user_id": 2 } } ], "meta": { "total": 3, "pages": 1 }, "links": { "self": "http://localhost:3000/alerts?filter[status]=created&page[size]=3" } }
{ "errors": "Please try to login again!" }