Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abdallahghorap1212/simple-blog-api
https://github.com/abdallahghorap1212/simple-blog-api
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/abdallahghorap1212/simple-blog-api
- Owner: abdallahGhorap1212
- Created: 2024-07-11T10:55:55.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-07-11T11:06:17.000Z (6 months ago)
- Last Synced: 2024-07-11T12:35:44.375Z (6 months ago)
- Language: PHP
- Size: 69.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Task: Develop a Simple Blog API
Requirements:
1. Project Setup:
Create a new Laravel project.
Set up the necessary environment variables.
2. Database:
Use MySQL as the database.
Create two tables: users and posts.
3. Authentication:
Implement basic authentication using Laravel Sanctum.
4. User Model:
The users table should have the following fields:
id (primary key)
name
password
created_at
updated_at
5. Post Model:
he posts table should have the following fields:
id (primary key)
user_id (foreign key referencing users)
title
body
created_at
updated_at
6. API Endpoints:
Authentication:
POST /api/register: Register a new user.
POST /api/login: Log in a user and return an authentication token.
Posts:
GET /api/posts: Get a list of all posts.
GET /api/posts/{id}: Get a single post by ID.
POST /api/posts: Create a new post (authenticated users only).
PUT /api/posts/{id}: Update a post by ID (authenticated users only).
DELETE /api/posts/{id}: Delete a post by ID (authenticated users only).
7. Validation:
Validate all input data for creating and updating posts.
Ensure proper error handling and return appropriate HTTP status codes.
8. Eloquent Relationships:
Define the relationship between User and Post models.