Skip to content

Commit 5d90272

Browse files
Update README
1 parent 14458cb commit 5d90272

File tree

1 file changed

+69
-11
lines changed

1 file changed

+69
-11
lines changed

README.md

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Blog Backend API
1+
## Laravel - Inertia - React
22

33
A Laravel-based RESTful API for managing blog posts and categories.
44

@@ -68,16 +68,18 @@ php artisan migrate:fresh --seed
6868
php artisan serve
6969
```
7070

71-
1. Open the application in your web browser at `http://localhost:8000`.
71+
9. Open the application in your web browser at `http://localhost:8000`.
7272

7373
## API Documentation
7474

7575
### Authentication
7676

77+
All authentication endpoints are prefixed with `/api/auth`.
78+
7779
#### Register
7880

7981
```http
80-
POST /api/register
82+
POST /api/auth/register
8183
```
8284

8385
| Parameter | Type | Description |
@@ -89,14 +91,24 @@ POST /api/register
8991
#### Login
9092

9193
```http
92-
POST /api/login
94+
POST /api/auth/login
9395
```
9496

9597
| Parameter | Type | Description |
9698
| :--- | :--- | :--- |
9799
| `email` | `string` | **Required**. User's email |
98100
| `password` | `string` | **Required**. User's password |
99101

102+
Successful login returns a **Bearer** token that should be used for authenticated requests.
103+
104+
#### Logout
105+
106+
```http
107+
POST /api/auth/logout
108+
```
109+
110+
Requires authentication. Invalidates the current access token.
111+
100112
### Posts
101113

102114
#### Get All Posts
@@ -105,10 +117,20 @@ POST /api/login
105117
GET /api/posts
106118
```
107119

120+
Supports filtering by:
121+
122+
```http
123+
GET /api/posts?search=query&status=draft&is_featured=true&filter=trash&page=1&per_page=6
124+
```
125+
- search query [search=query]
126+
- status [status=draft/published]
127+
- featured posts [is_featured=true/false]
128+
- trashed posts [filter=all/trash/with_trashed]
129+
108130
#### Get Single Post
109131

110132
```http
111-
GET /api/posts/{id}
133+
GET /api/posts/{slug}
112134
```
113135

114136
#### Create Post (Admin Only)
@@ -121,23 +143,45 @@ POST /api/posts
121143
| :--- | :--- | :--- |
122144
| `title` | `string` | **Required**. Post title |
123145
| `slug` | `string` | **Required**. Post slug |
146+
| `excerpt` | `string` | **Required**. Post excerpt |
124147
| `content` | `string` | **Required**. Post content |
125148
| `category_id` | `integer` | **Required**. Category ID |
126149
| `status` | `string` | **Required**. Post status (draft/published) |
127-
| `cover image` | `file` | Optional. Post image |
150+
| `is_featured` | `boolean` | Optional. Featured post status |
151+
| `cover_image` | `file` | Optional. Post image |
128152

129153
#### Update Post (Admin Only)
130154

131155
```http
132156
PUT /api/posts/{slug}
133157
```
134158

159+
Accepts the same parameters as the create endpoint.
160+
135161
#### Delete Post (Admin Only)
136162

137163
```http
138164
DELETE /api/posts/{slug}
139165
```
140166

167+
Soft deletes the post. The post can be restored later.
168+
169+
#### Restore Post (Admin Only)
170+
171+
```http
172+
POST /api/posts/{id}/restore
173+
```
174+
175+
Restores a soft-deleted post.
176+
177+
#### Force Delete Post (Admin Only)
178+
179+
```http
180+
DELETE /api/posts/{id}/force-delete
181+
```
182+
183+
Permanently deletes the post.
184+
141185
### Categories
142186

143187
#### Get All Categories
@@ -149,7 +193,7 @@ GET /api/categories
149193
#### Get Single Category
150194

151195
```http
152-
GET /api/categories/{id}
196+
GET /api/categories/{category}
153197
```
154198

155199
#### Create Category (Admin Only)
@@ -166,19 +210,33 @@ POST /api/categories
166210
#### Update Category (Admin Only)
167211

168212
```http
169-
PUT /api/categories/{id}
213+
PUT /api/categories/{category}
170214
```
171215

172216
#### Delete Category (Admin Only)
173217

174218
```http
175-
DELETE /api/categories/{id}
219+
DELETE /api/categories/{category}
176220
```
177221

178222
### Authentication
179223

180-
All admin-only endpoints require authentication using a Bearer token. Include the token in the Authorization header:
224+
All admin-only endpoints require authentication using a **Bearer** token. Include the token in the Authorization header:
181225

182226
```http
183227
Authorization: Bearer <your_token>
184-
```
228+
```
229+
230+
### Error Responses
231+
232+
The API uses standard HTTP status codes to indicate the success or failure of requests:
233+
234+
- `200 OK` - Request succeeded
235+
- `201 Created` - Resource created successfully
236+
- `400 Bad Request` - Invalid request parameters
237+
- `401 Unauthorized` - Missing or invalid authentication token
238+
- `403 Forbidden` - Authenticated but not authorized to access the resource
239+
- `404 Not Found` - Resource not found
240+
- `422 Unprocessable Entity` - Validation errors
241+
242+
Made with ❤️ by [developermithu](https://developermithu.com)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy