Skip to content

immontilla/mgo-n-goji

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mgo-n-goji

Pre-requisites

⚫ go ⚫ mongoDB ⚫ node

Installing

Clone it and then run

cd $GOPATH/src && git clone https://github.com/immontilla/mgo-n-goji.git
cd $GOPATH && go install mgo-n-goji/cmd/app/

Testing

To test, I am going to use Postman and its client Newman. To show the results, I'll use express and newman-reporter-html.

cd $GOPATH/src/mgo-n-goji/tests/postman/ && npm install && npm run test-n-report

Running

$GOPATH/bin/app
  • Add bob as a contact. His mobile is 600000001.
curl -iX POST "http://localhost:9889/contacts" -H "Content-Type: application/json" -d "{\"nick\":\"bob\",\"mobile\":[\"600000001\"]}" && echo ""
  • Get bob's contact data
curl -iX GET "http://localhost:9889/contacts/bob" && echo ""
  • Get all contacts so far
curl -iX GET "http://localhost:9889/contacts" && echo ""
  • Update bob's contact data
curl -iX PUT "http://localhost:9889/contacts/bob" -H "Content-Type: application/json" -d "{\"nick\":\"bob\",\"mobile\":[\"600000001\"],\"email\":[\"[email protected]\"]}" && echo ""
  • Add mobile 600000002 to a bob
curl -iX PATCH "http://localhost:9889/contacts/bob/addMobile/600000002"  && echo ""
  • Remove mobile 600000001 from bob
curl -iX PATCH "http://localhost:9889/contacts/bob/delMobile/600000001"  && echo ""
curl -iX PATCH "http://localhost:9889/contacts/bob/addEmail/[email protected]"  && echo ""
curl -iX PATCH "http://localhost:9889/contacts/bob/delEmail/[email protected]"  && echo ""
  • Change bob nick to bobby
curl -iX PATCH "http://localhost:9889/contacts/bob/newNick/bobby"  && echo ""
  • Delete bobby
curl -iX DELETE "http://localhost:9889/contacts/bobby"  && echo ""