Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rks-031/rest-api-model


https://github.com/rks-031/rest-api-model

Last synced: 5 days ago
JSON representation

Awesome Lists containing this project

README

        

This repo demonstrates how to build a `REST-API`.

REST-API stands for: `Representational State Transfer Application Programming Interface`

The tech stack used here are: Node.js and Express.js

Source: `Web Dev Simplified`

# Stages of building:
1. Install dependencies
2. Create the server
3. Create the router
4. Create the route
5. Create the model
6. Test your API

# Connection:

**In .env file:** DATABASE_URL = mongodb://localhost/shoes


**In server.js file:**

const mongoose = require("mongoose");

require("dotenv").config();

mongoose.connect(process.env.DATABASE_URL);

# To check if database is connected:
const db = mongoose.connection;

db.on("error", (error) => {
console.log("error");
});

db.once("open", () => {
console.log("Connected to database");
});

# Extension used for testing the API
REST Client

To use this create a file with a .rest extension and all the urls for different operations.


![image](https://github.com/rks-031/rest-api-model/assets/103258259/a2a6fb50-149e-4d72-a075-17453b1cd3ee)

--------------------------------------------------------------------------------------------------------------

![image](https://github.com/rks-031/rest-api-model/assets/103258259/cca8f0ae-cc05-41ef-a612-d55951c3610f)