The Blog API is a Laravel-based RESTful API designed to manage blog posts and user authentication.
- User registration and login with JWT authentication.
- Create, read, update, and delete blog posts.
- Secure endpoints to ensure only authorized users can perform actions.
- Token refresh functionality for extended sessions.
-
Clone the repository:
git clone https://github.com/youngyusuff6/blogger.git
-
Change into the project directory:
cd blogger
-
Install dependencies:
composer install
-
Copy the
.env.example
file to.env
:cp .env.example .env
-
Generate an application key:
php artisan key:generate
-
Configure your database in the
.env
file. -
Run migrations:
php artisan migrate
-
Start the development server:
php artisan serve
- Register a new user using the
/register
endpoint. - Log in to get a JWT token using the
/login
endpoint. - Use the token to access protected endpoints.
- Manage blog posts using
/blogs
endpoints.
-
POST /register
- Register a new user.
- Requires
name
,email
,password
, andconfirm_password
.
-
POST /login
- Log in and obtain a JWT token.
- Requires
email
andpassword
.
-
POST /logout
- Log out and invalidate the JWT token.
- Requires a valid token in the Authorization header.
-
POST /refresh
- Refresh a JWT token.
- Requires a valid token in the Authorization header.
-
GET /blogs
- Get a list of all blog posts.
-
GET /my-blogs
- Get a list of the user's blog posts.
- Requires a valid token in the Authorization header.
-
POST /blogs
- Create a new blog post.
- Requires
title
andcontent
. - Requires a valid token in the Authorization header.
-
PUT /blogs/{blog_id}
- Update an existing blog post.
- Requires
title
andcontent
. - Requires a valid token in the Authorization header.
-
DELETE /blogs/{blog_id}
- Delete an existing blog post.
- Requires a valid token in the Authorization header.