Install docker on your machine, in my case I could not install the latest docker version which had support for windows 10 pro. Docker provides support for older versions of windows also, so lookup on dockers website on how to get the docker legacy support. During installation docker legacy version will install various tools on your machine. Look-up to the website on further installation steps.
open up powershell on windows and run command as bash ./run.sh in the folder where your app is ensure the mongo server and node docker are running copy the ip from the initial msg like tcp://192.168.59.100:port or run $Env:DOCKER_HOST in another powershell instance.
go to browser and enter url --http://192.168.59.100:3001/user: to test
note the ip may differ in your machine and my node app is mapped to port:3001
go
This repository contains a simple demo API built with NodeJS. The API is used to manage users in a MongoDB database.
This application was developed using ExpressJS. MongoDB was used for persisting data with Mongoose as ORM.
- Start up your terminal (or Command Prompt on Windows OS).
- Ensure that you've
nodeinstalled on your PC. - Clone the repository by entering the command
git clone https://github.com/andela-bolajide/UserManagerin the terminal. - Navigate to the project folder using
cd UserManageron your terminal (or command prompt) - After cloning, install the application's dependencies with the command
npm install. - Create a
.envfile in your root directory as described in.env.samplefile. Variables such as DB_URL (which must be a mongoDB URL) and PORT are defined in the .env file and it is essential you create this file before running the application.
PORT=3000
DB_URL='mongodb://john:doe@localhost:27017/databaseName'
- After this, you can then start the server with the command:
npm start.
To ensure that your installation is successful you'll need to run tests.
The command: npm test makes this possible. It isn't functional right now, but once it's done you'll be notified via the README.
The API only has one endpoint which is the /users endpoint for saving users to the database. The endpoint works with the HTTP verbs: POST, GET, PUT, DELETE.
POST/users- INPUT:
name: John Doe
email: [email protected]
password: johndoe
- HTTP Status:
201: created - JSON data
{
"_id": "59071791b0lkscm2325794",
"name": "John Doe",
"email": "[email protected]",
"password": "johndoe",
"__v": 0
}GET/users
[
{
"_id": "59071791b0lkscm2325794",
"name": "John Doe",
"email": "[email protected]",
"password": "johndoe",
"__v": 0
}
]GET/users/:id
{
"_id": "59071791b0lkscm2325794",
"name": "John Doe",
"email": "[email protected]",
"password": "johndoe",
"__v": 0
}DELETE/users/:id
User John Doe was deletedPUT/users/:id- INPUT:
name: Jane Doe
email: [email protected]
password: janedoe
- HTTP Status:
200: OK - JSON data
{
"_id": "59071791b0lkscm2325794",
"name": "Jane Doe",
"email": "[email protected]",
"password": "janedoe",
"__v": 0
}Olajide Bolaji 'Nuel - Software Developer at Andela