Skip to content

mattfelske/service-messaging

Repository files navigation

service-messaging

A simple REST API service that allows the user to perform CRUD operations on a messages database collection.

REQUIREMENTS

In order to test the application locally, you will need to have the following minimum requirements met.

  1. Node.JS (8.9.4)
  2. NPM (5.5.1)
  3. MongoDB (3.4.9)
  4. Redis (3.2.100)

ARCHITECTURE

The stack is based primarily on NodeJS for the backend, and React for the frontend. I also identified that in order to push updates to the client side dynamically, I would need to include Websockets, via socket.io, in order to push down new messages to all connected users. I also wanted to find a way to track unique users, and the initial thought was to not go down the path of username/password, login email, etc. Instead I decided that through the use of sessions we could identifier new users, allows themself to create a "user account" for that particular session. I've done session management through using Redis, so it seemed like the simplest approach.

alt text

In terms of tracking the messages, I decided that we were going to need two collection to start with.

alt text

By tracking the User in the messages collection, we allow ourselves to query messages per user, and identify (in the future) who is allowed to delete which message.

With regards to updating active users with message updates, we can acccomplish this by using the following examples.

alt text

alt text

API ENDPOINTS

GET /v1/message?id

Parameters
+ id: optional. references the mongodb _id of the document.
Returns
200: [{Message}}]
400: {msg: String}
500: {msg: String}

POST /v1/message

BODY
+ text: String A required field
RETURNS
201: {Message}
400: {msg: String}
500: {msg: String}

PUT /v1/message

Parameters
+ id: required. references the mongodb _id of the document.
Body
+ text: String A required field
Returns
200: {Message}
400: {msg: String}
500: {msg: String}

DELETE /v1/message?id

Parameters
+ id: required. references the mongodb _id of the document.
Returns
200: {Message}
400: {msg: String}
500: {msg: String}

HOW TO

If you have any issues building, deploying or accessing the application, please reach out and let me konw. At this time the application will be running in developement mode.

  1. Download the repository

git clone https://github.com/mattfelske/service-messaging.git

  1. Install NPM dependencies

npm install

  1. Build the application

npm run build

  1. Launch the application

npm start

The application can be reached on http://localhost:8001, or online at http://test-jeragroup.ca:8001.

Please note that Chrome is notorious for redirecting to https, but the application still works in Incognito mode.

TO DOs

  • Allows users to submit/post messages
  • Lists received messages (Locally)
  • Retreives a specific message on demand, and dtermines if it is a palindrome
  • Allows users to delete specific messages (Currently allows any user to delete any message
  • Shows the list of messages posted by the users
  • Allows to post new messages
  • Allows to select a given message to see extra details
  • Add user support to messages (need to resolve sessionID cookie generation)
  • Add WebSocket support so that multiple users connected at the same time can updated the DB and the UI simultaneously
  • Fix express session implementation to allow for user creation (requires modal for first time user/session)
  • Mocha/Chair Test case suite for testing endpoints and functions. (Specifically palindrome utility function)
  • Containerize the application using Docker
  • Update configuration management to be dynamic based on environment.
  • Improve loggin implementation
  • Front end implementation of user functionality

About

A simple REST API service that allows the user to perform CRUD operations on a messages database collection.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published