Skip to content

daxsorbito/friendManagement

Repository files navigation

Technology used

  1. restify - web service framework optimized for building rest api. Optimized for introspection and performance.
  2. docker/docker-compose - for easier creation, deployment and running applications.
  3. mongoose - MongoDB object modeling tool designed to work in an asynchronous environment.
  4. mongodb - non-sql, schema-less document oriented storage.
  5. jest
  6. supertest

Running the app

  1. open a new terminal and run the code below
$ docker-compose up
  1. once done, open the app at http://localhost:4000
  • Note: if you have some port conflict, change the docker-compose.yaml port to a new a port

Running the test

  1. running mongodb; make sure you have a running mongodb in your local and is accessible using this URI
process.env.MONGODB_URI = 'mongodb://127.0.0.1:27017/test';
  • if you don't have, you could run this instead
$ docker-compose up mongo
  1. then, run the test (on a separate terminal)
$ yarn test

or

$ npm run test
  • Note: if you have a different mongodb uri to connect to, change the URI in the ./script/jestTestSetup.js file before running the test

Using the app

Postman could be used to try the application

Below are the exposed routes of the api

  1. POST /friends
  • input example
{
  "friends": ["test1@test.com", "test2@test.com"]
}
  • output
{
  "success": true
}
  1. GET /friends/:email
  • url example
http://localhost:4000/friends/test1@test.com
  • output
{
  "success": true,
  "friends": [
      "test2@ttest.com"
  ],
  "count": 1
}
  1. POST /friends/common
 {
   "friends": ["test1@test.com", "test2@test.com"]
 }
  • output
{
  "count": 1,
  "friends": [
    "test3@test.com",
  ],
  "success": true
}
  1. POST /friends/subscribe
  {
    "requestor": "test1@test.com", 
    "target": "test2@test.com"
  }
  • output
{
  "success": true
}
  1. POST /friends/block
  {
    "requestor": "test1@test.com", 
    "target": "test2@test.com"
  }
  • output
{
  "success": true
}
  1. POST /friends/post
  {
    "sender": "test1@test.com", 
    "text": "Hello World! test2@test.com"
  }
  • output
{
  "recipients": [
    "test2@test.com",
    "test3@test.com"
  ],
  "success": true
}

About

Sample application that uses docker, docker-compose, restify, mongodb and jest using async.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published