This is a sample of a Node API running in a docker container.
Make sure you have nvm
for Mac or nvm-windows
for Windows installed, and have set up the latest v8 of Node.js under one of those node version managers (latest at the time of this documentation is v8.15.1)
Mac: https://github.com/creationix/nvm
Windows: https://github.com/coreybutler/nvm-windows
You'll need the following global dependencies installed as well before attempting to run this project. Run the following command before attempting to run the project:
$ npm install -g gulp typescript
To run the project:
$ git clone [email protected]:minhazfm/docker-node-api.git
$ cd docker-node-api
$ npm install
$ gulp develop
Check out http://blog.teamtreehouse.com/install-node-js-npm-windows for installation details
Note: in cygwin I ran "npm install --global gulp" to install gulp.
- Always include a
Client-Type
that hasclient="yourClientName";
andversion="theAPIVersionYouAreRequesting"
in your Request Headers, for example:
Client-Type: client=snMobile;version=1.0.0
- The registration and login API do not require a token to be used, but for the login request use the following credentials:
username -> testuser
andpassword -> 123123
POST http://0.0.0.0:3000/rest/registration
Version: 1.0.0
Request Body
{
"username": string
}
POST http://0.0.0.0:3000/rest/user/login
Version: 1.0.0
Request Body
{
"username": string,
"password": string
}
POST http://0.0.0.0:3000/rest/user/logout
Version: 1.0.0
GET http://0.0.0.0:3000/rest/user/account
Version: 1.0.0
POST http://0.0.0.0:3000/rest/user/login/account
Version: 1.0.0
GET http://0.0.0.0:3000/rest/events/gatewayId/21
Version: 1.0.0
* You will want to do this in a CURL command as POSTMAN does not support SSE, for example:
curl --header "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI5OWMwOGViNS1kZGZhLTQxMzQtYjIwNC04ZDI1YTFhZGYxMDEiLCJ1dWlkIjoiYTg5ZjZmN2EtYWQzYi0xMWU4LTk4ZDAtNTI5MjY5ZmIxNDU5IiwiaWF0IjoxNTM2MTYzMzY5LCJleHAiOjE1MzY3NjgxNjl9.DxKeoOugUASx8gFmGvqpsMJiYbKFgPmv6E5TlTR-CUU" --header "Content-Type: application/json" --header "Client-Type: client=snMobile;version=1.0.0" \
--request GET \
http://0.0.0.0:3000/rest/events/gatewayId/21
- Minhaz Mohammad [email protected]