https://github.com/rishiyaduwanshi/restapi
This repository hosts a basic Node.js application powered by Express.js, designed for managing user data. The application provides both HTML and API endpoints to interact with user information stored on mongodb atlas. It includes functionalities such as listing all users, retrieving specific user details, and offering CRUD operations via API
https://github.com/rishiyaduwanshi/restapi
api js json nodejs
Last synced: 3 months ago
JSON representation
This repository hosts a basic Node.js application powered by Express.js, designed for managing user data. The application provides both HTML and API endpoints to interact with user information stored on mongodb atlas. It includes functionalities such as listing all users, retrieving specific user details, and offering CRUD operations via API
- Host: GitHub
- URL: https://github.com/rishiyaduwanshi/restapi
- Owner: Rishiyaduwanshi
- Created: 2024-06-22T14:47:04.000Z (about 2 years ago)
- Default Branch: mongo
- Last Pushed: 2024-09-14T21:02:00.000Z (almost 2 years ago)
- Last Synced: 2025-11-27T11:19:02.465Z (7 months ago)
- Topics: api, js, json, nodejs
- Language: JavaScript
- Homepage: https://restapi.paramountgrove.in
- Size: 457 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# RESTful API Documentation
Welcome to the documentation for our RESTful API. This API allows you to perform CRUD operations on user data. Below you will find details on available routes, methods, and how to interact with the API using Postman or any other API testing tool.
## Getting Started
To get started with the API, follow these steps:
### Prerequisites
- Node.js installed on your machine
- MongoDB installed locally or accessible via a URI
- Postman or any API testing tool
### Installation
1. Clone the repository:
```
git clone
```
2. Install dependencies:
```
npm install
```
3. Set up environment variables:
Create a `.env` file in the root directory with the following variables:
```
PORT=4500
MONGODB_URI=mongodb://localhost:27017/your-database-name
APP_URI=http://localhost:4500
```
Replace `your-database-name` with your MongoDB database name.
4. Start the server:
```
npm start
```
This will start the server at `http://localhost:4500`.
## API Routes
### Users
- **GET /users**
- Fetch all users.
- **POST /users**
- Create a new user.
- Request body should include:
```json
{
"first_name": "John",
"last_name": "Doe",
"email": "john.doe@example.com",
"age": 30,
"major": "Computer Science",
"gpa": 3.8,
"enrollment_date": "2023-01-01",
"graduation_date": "2027-05-15"
}
```
- **GET /users/:student_id**
- Fetch a user by ID.
- **PATCH /users/:student_id**
- Update a user by ID.
- Send only the fields to be updated in the request body.
```json
{
"email": "new.email@example.com",
"age": 31
}
```
- **DELETE /users/:student_id**
- Delete a user by ID.
### API
All the above routes are also available under `/api`. For example:
- **GET /api/users**
- **POST /api/users**
- **GET /api/users/:student_id**
- **PATCH /api/users/:student_id**
- **DELETE /api/users/:student_id**
## Testing the API
Use Postman or any other API testing tool to test the endpoints described above. Make sure to replace `:student_id` with the actual ID of the user you want to interact with.