Giter Site home page Giter Site logo

chat-rails-api-server's Introduction

Rails app

This project provide the backend functionality for the chat. It will get requests from client-side and will generate data in response. Consists in three main parts: Users, Chat Room and Message.

Installation

bundle install

Run App

rails s

Run Migration

rake db:migration

Load Initial Data

rake db:seed

Run Tests

rspec spec

Notice before run the app or tests you must have redis server running first (redis-server).

Endpoints

Users

Get Users

curl http://localhost:3000/users

Get Users sing Ids

curl http://localhost:3000/users?ids=1,3,5

Show User

curl http://localhost:3000/users/1

Search Users

This is use for asyncronous search of users. In case it doesn't find any user will return empty array []. curl http://localhost:3000/users/search?name=admin&[email protected]

Fetch User

This is use to search an user that is suppose to exists. If it doesn't find any will throw an exception. http://localhost:3000/users/fetch?name=admin&[email protected]

Create User

curl -i -X POST -H "Content-Type:application/json" http://localhost:3000/users -d '{"name": "test", "email": "[email protected]"}'

Update User

curl -i -X PUT -H "Content-Type:application/json" http://localhost:3000/users/1 -d '{"name": "test2", "email": "[email protected]"}'

Delete User

curl -i -X DELETE http://localhost:3000/users/1

Chat Rooms

Get Chat Rooms

curl http://localhost:3000/chat_rooms

Show Chat Room

curl http://localhost:3000/chat_rooms/1

Search Chat Rooms

This is use for asyncronous search of users. In case it doesn't find any user will return empty array []. curl http://localhost:3000/chat_rooms/search?title=Sport

Create Chat Room

curl -i -X POST -H "Content-Type:application/json" http://localhost:3000/chat_rooms -d '{"title": "games", "created_id": 1, "sender_id": 1, "recipient_id": 1}'

Update Chat Room

curl -i -X PUT -H "Content-Type:application/json" http://localhost:3000/chat_rooms/1 -d '{"title": "games", "created_id": 1, "sender_id": 1, "recipient_id": 1}'

Delete Chat Room

curl -i -X DELETE http://localhost:3000/chat_rooms/1

Messages

Get Messages

http://localhost:3000/chat_rooms/1/messages

Show Message

http://localhost:3000/chat_rooms/1/messages/2

Create Message

curl -i -X POST -H "Content-Type:application/json" http://localhost:3000/chat_rooms/1/messages -d '{"body": "very long text", "user_id": 1}'

Update Message

curl -i -X PUT -H "Content-Type:application/json" http://localhost:3000/chat_rooms/1/messages/1 -d '{"body": "very long text", "user_id": 1}'

Delete Message

curl -i -X DELETE http://localhost:3000/chat_rooms/1/messages/1

Live Example

https://gmunumel-chat-rails-api-server.herokuapp.com

License

Licensed under MIT

Based on the following tutorials:

Redis:

Postgres:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.