Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rks-031/rest-api-model
https://github.com/rks-031/rest-api-model
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/rks-031/rest-api-model
- Owner: rks-031
- Created: 2024-01-03T11:25:18.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-01-04T16:01:51.000Z (11 months ago)
- Last Synced: 2024-01-05T14:31:13.819Z (11 months ago)
- Language: JavaScript
- Size: 39.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)