Skip to content

andretorresdg/API-part1

Repository files navigation

API-part1

API-part1 is a free REST API which is written in JavaScript, using Node.js and Express.js, to connect to MongoDB and implement all CRUD (Create, Read, Update and Delete) operations to manage user accounts.

Feel free to see the source code here .


Table of Contents


Initiating

  1. On GitHub, navigate to the main page of the repository.
  1. Click ‘Clone or Download’ button, under the repository name.
  1. Clone URL buttonIn the Clone with HTTPs section, click to copy the clone URL for the repository ( this web URL ).
  1. Open Git Bash and change the current working directory to the location where you want the cloned directory to be made.
  1. Type git clone, and then paste the URL you copied in Step 3.

Prerequisites

To run this API effectively, you will need the following programs:

And these packages:

Tips

  • Install the Nodemon to program more easily
  • Use the Postman to test
  • always use the last stable version of these programs and packages

Installing

First, make sure you have already downloaded my API (if you do not, click here and follow those steps before continuing the installing procedure)

Then, open your command prompt and write "cd" + the path of the downloaded folder

For example:

$ cd D:\Users\Admin\Desktop\API-part1

Now, install all the packages with the followig command:

$ npm install 

If you want to install the nodemon, you should use this command:

$ npm install -g nodemon

Finally, you can test the API!


Testing

Running the main.js

To run the program, type this in the command prompt:

$ node app-jest.js

PS.: Make sure that the path to the "app-jest.js" is correct.

Commands

These are the steps my API performs. If you wish, feel free to execute each.

PS.: I highly recommend Postman to test the API.

GET​ /users
  • This command returns an array of JSON with all the users in the database.
POST ​/users
  • You should use the "POST", if you want to create a new user.
GET ​/users/:id
  • The program will return a specific user to you.
PUT ​/users/:id
  • It updates some info of a specific user.
DELETE ​/users/:id
  • "DELETE" is useful to remove a specific user.

Running the randomUser.js

The API starts without any type of user. So, if you want that your database initiate with some random users, run the "randomUser.js" once (it will generate 85 random users).

  1. Run the "app-jest.js"
$ node main.js
  1. Open another window of the command prompt, and run this command:
$ node ./server/models/randomUser.js

PS.: Make sure that the "app-jest.js" is running.


Author

| André Devay Torres Gomes |


Support

If you need some help, contact me!

E-mail: [email protected]


License

License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published