Skip to content

MrRainbowCoding/api-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express API Example

This is a simple Express.js API project demonstrating basic route handling using Node.js and Express.

📁 Project Structure


express-api/
├── index.js             # Main application entry point
├── package.json       # Project configuration and dependencies
└── api/               # API route handlers
└──   index.js       # Defines the API endpoints

🚀 Getting Started

1. Clone the Repository

git clone https://github.com/yourusername/express-api.git
cd express-api

2. Install Dependencies

npm install

3. Run the Server

npm start

The server will start at http://localhost:3000

📡 API Endpoints

GET /

Returns a welcome message.


GET /api/hello

Returns a JSON message:

{ "message": "Hello, world!" }

POST /api/echo

Echoes back the JSON you send:

Request:

{ "test": "value" }

Response:

{ "received": { "test": "value" } }

GET /api/user/:id

Returns dummy user data for a given ID:

{ "userId": "123", "name": "User #123" }

🛠 Requirements

📦 License

This project is open-source and available under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published