项目作者: daxsorbito

项目描述 :
Sample application that uses docker, docker-compose, restify, mongodb and jest using async.
高级语言: JavaScript
项目地址: git://github.com/daxsorbito/friendManagement.git
创建时间: 2018-02-25T18:21:02Z
项目社区:https://github.com/daxsorbito/friendManagement

开源协议:

下载


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
    1. $ docker-compose up
  2. 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
    1. process.env.MONGODB_URI = 'mongodb://127.0.0.1:27017/test';
  • if you don’t have, you could run this instead
    1. $ docker-compose up mongo
  1. then, run the test (on a separate terminal)
    1. $ yarn test
    or
    1. $ 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
  2. GET /friends/:email

  3. POST /friends/common

    1. {
    2. "friends": ["test1@test.com", "test2@test.com"]
    3. }
  4. POST /friends/subscribe

    1. {
    2. "requestor": "test1@test.com",
    3. "target": "test2@test.com"
    4. }
    • output
      1. {
      2. "success": true
      3. }
  5. POST /friends/block

    1. {
    2. "requestor": "test1@test.com",
    3. "target": "test2@test.com"
    4. }
    • output
      1. {
      2. "success": true
      3. }
  6. POST /friends/post
    1. {
    2. "sender": "test1@test.com",
    3. "text": "Hello World! test2@test.com"
    4. }