- restify - web service framework optimized for building rest api. Optimized for introspection and performance.
- docker/docker-compose - for easier creation, deployment and running applications.
- mongoose - MongoDB object modeling tool designed to work in an asynchronous environment.
- mongodb - non-sql, schema-less document oriented storage.
- jest
- supertest
- open a new terminal and run the code below
$ docker-compose up
- 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 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
- 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
Postman could be used to try the application
Below are the exposed routes of the api
- POST /friends
- input example
{
"friends": ["test1@test.com", "test2@test.com"]
}
- output
{
"success": true
}
- GET /friends/:email
- url example
http://localhost:4000/friends/test1@test.com
- output
{
"success": true,
"friends": [
"test2@ttest.com"
],
"count": 1
}
- POST /friends/common
{
"friends": ["test1@test.com", "test2@test.com"]
}
- output
{
"count": 1,
"friends": [
"test3@test.com",
],
"success": true
}
- POST /friends/subscribe
{
"requestor": "test1@test.com",
"target": "test2@test.com"
}
- output
{
"success": true
}
- POST /friends/block
{
"requestor": "test1@test.com",
"target": "test2@test.com"
}
- output
{
"success": true
}
- POST /friends/post
{
"sender": "test1@test.com",
"text": "Hello World! test2@test.com"
}
- output
{
"recipients": [
"test2@test.com",
"test3@test.com"
],
"success": true
}