Nodejs, Express, Passport, mongose, bcrypt api server
Download and install node.jsDownload and install mongodb (Create db folder or when mongo start throw an error)
-
Open a terminal and go to the project folder.
Download all the dependencies with: npm install -
Open other terminal for start mongodb, go to mongodb folder and open mongod.exe
In the terminal with the node project folder run : node app.js
and the server will start on http://localhost:3000/
If all go fine in the terminal appear the next message 'Node server running on http://localhost:3000 Connected to Database'
3.1) To debug
Download node-inspector: npm install -g node-inspector
Open a terminal and write: node-inspector &
Open other terminal in the project folder and write: node --debug app.js
Open in chrome the url that the terminal say and debug.
3.3) To develop fast use nodemon for dont restart the server all the time.
Open a terminal in the project folder and write: npm start.
When change the code and save u can see how nodemon restart the server.
-- House --
{
"_id": "57697694bd33bee81c000001", // Autogenerated, dont include in post method
"name": "Stark",
"watchword": "Winter is comming",
"imageurl": "http://st-listas.20minutos.es/images/2012-07/338740/3645213_249px.jpg?1343563047"
}
-- Character --
{
"_id": "57697992bd33bee81c000008", // Autogenerated, dont include in post method
"name": "Daenerys Targaryen",
"imageurl": "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRWnZAMq3RfivCTchW6O0hMRa-nBP7B6j2r4It7xL3xhneMx29NhWQ",
"house_id": "576976cebd33bee81c000002"
}
-- House --
method: get req: /houses (findAllHouses)
method: get req: /house/:id (findById)
method: post req: /house (addHouse) In the body request send the object with type json
method: put req: /house/:id (updateHouse) In the body request send the object with type json
method: delete req: /house/:id (deleteHouse)
-- Character --
method: get req: /characters (findAllCharacters)
method: get req: /character/:id (findById)
method: post req: /character (addCharacter) In the body request send the object with type json
method: put req: /character/:id (updateCharacter) In the body request send the object with type json
method: delete req: /character/:id (deleteCharacter)
-- User --
method: get req: /users (findAllUsers) Only login in
method: get req: /user/:id (findById) Only login in
method: put req: /user/:id (updateUser) Only login in
method: delete req: /user/:id (deleteUser) Only login in
method: post req: /signin (adduser) In the body request send the object with type json
method: post req: /login (CheckUser) In the body request send the object with type json
method: get req: /logout