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.examplefile to.env:cp .env.example .env
-
Generate an application key:
php artisan key:generate
-
Configure your database in the
.envfile. -
Run migrations:
php artisan migrate
-
Start the development server:
php artisan serve
- Register a new user using the
/registerendpoint. - Log in to get a JWT token using the
/loginendpoint. - Use the token to access protected endpoints.
- Manage blog posts using
/blogsendpoints.
-
POST /register
- Register a new user.
- Requires
name,email,password, andconfirm_password.
-
POST /login
- Log in and obtain a JWT token.
- Requires
emailandpassword.
-
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
titleandcontent. - Requires a valid token in the Authorization header.
-
PUT /blogs/{blog_id}
- Update an existing blog post.
- Requires
titleandcontent. - 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.