Supported packages, build your own http server less than 5 minutes:
# Clone or download this project
git clone https://github.com/NeaByteLab/Restful-API.git
cd Restful-APIdeno task startServer runs on: http://localhost:8000
# 1. Get API info
curl http://localhost:8000/
# 2. List all users
curl http://localhost:8000/users
# 3. Create a new user
curl -X POST http://localhost:8000/users \
-H "Content-Type: application/json" \
-d '{"name":"Alice","email":"alice@example.com","age":30}'
# 4. Get user by ID (replace {id} with actual user ID from step 3)
curl http://localhost:8000/users/{id}
# 5. Update user (replace {id} with actual user ID)
curl -X PUT http://localhost:8000/users/{id} \
-H "Content-Type: application/json" \
-d '{"name":"Alice Updated","email":"alice.updated@example.com"}'
# 6. Delete user (replace {id} with actual user ID)
curl -X DELETE http://localhost:8000/users/{id}
# 7. Test error handling - Non-existent user (404)
curl http://localhost:8000/users/non-existent-id
# 8. Test validation - Missing required fields (400)
curl -X POST http://localhost:8000/users \
-H "Content-Type: application/json" \
-d '{"name":"Test"}'http://localhost:8000
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
API information |
| GET | /users |
List all users |
| POST | /users |
Create a user |
| GET | /users/:id |
Get user by ID |
| PUT | /users/:id |
Update user |
| DELETE | /users/:id |
Delete user |
Returns API information and available endpoints.
Response:
{
"name": "RESTful API",
"version": "1.0.0",
"endpoints": {
"users": {
"list": "GET /users",
"create": "POST /users",
"get": "GET /users/:id",
"update": "PUT /users/:id",
"delete": "DELETE /users/:id"
}
}
}Response:
{
"total": 2,
"users": [
{
"name": "Alice",
"email": "alice@example.com",
"age": 30,
"id": "uuid-here",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}
]
}Request:
{
"name": "Bob",
"email": "bob@example.com",
"age": 25
}Required fields: name, email
Response (201):
{
"message": "User created successfully",
"user": {
"name": "Bob",
"email": "bob@example.com",
"age": 25,
"id": "uuid-here",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}
}Response:
{
"user": {
"name": "Alice",
"email": "alice@example.com",
"age": 30,
"id": "uuid-here",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}
}Request:
{
"name": "Alice Updated",
"email": "alice.new@example.com"
}Response:
{
"message": "User updated successfully",
"user": {
"name": "Alice Updated",
"email": "alice.new@example.com",
"age": 30,
"id": "uuid-here",
"updatedAt": "2024-01-01T01:00:00.000Z"
}
}Response (200):
{
"message": "User deleted successfully",
"deleted": 1,
"id": "uuid-here"
}Restful-API/
├── core/
│ ├── index.ts # Server setup
│ ├── db.ts # Database instance
│ └── mware/
│ └── logger.ts # Request logging
├── routes/
│ ├── index.ts # GET /
│ ├── users.ts # GET, POST /users
│ └── users/
│ └── [id].ts # GET, PUT, DELETE /users/:id
├── db.json # Data storage (auto-generated)
├── deno.json # Deno configuration
└── README.md # This file
This project is licensed under the MIT license. See the LICENSE file for more info.