π️ Day 3 at ENATS
Hello everyone and welcome! π
Here’s a detailed and organized update on my third day at ENATS, building out API endpoints with token-based authentication π
Date: Wednesday, June 18, 2025
Morning Sessions
-
Arrived at 9:30 AM and carried forward the API work from yesterday.
-
Focused on authentication routes located in
routes/api.php
. -
Thoroughly tested routes both with and without a token, ensuring correct responses.
-
All authentication logic resides in my
AuthController
.
π CRUD API Routes Implemented
Following successful authentication testing, I created several essential endpoints:
Endpoint | Method | Functionality |
---|---|---|
/post |
GET | Fetch all blog posts of an authenticated user |
/post |
POST | Create a new post (authentication required) |
/post/{id} |
GET | Retrieve a specific post |
/post/update/{id} |
PUT | Update a specific post |
/post/{id} |
DELETE | Delete a specific post |
Afternoon: Testing & Fixes
-
Rigorous testing on each route using Postman.
-
Encountered several issues during method implementation.
-
Debugged and resolved routing bugs and controller logic mishaps.
-
Made updates to internal controller files and API Resource handling.
π Evening Wrap-Up
-
Successfully built and tested the full authentication system.
-
All CRUD operations for
Post
are functional and secured. -
Finalized the first version of the API; ready to build more features tomorrow.
π Key Takeaways & Resources
-
Laravel Sanctum provides a lightweight method for token-based API authentication. The typical flow:
-
Install Sanctum, publish config, migrate.
-
Add
HasApiTokens
to theUser
model. -
Use
auth:sanctum
middleware to protect routes.
-
-
Protecting routes:
Route::middleware('auth:sanctum')->group(function() { Route::resource('posts', PostController::class); });
π‘ Ask Me Anything
Curious about how I approached authentication, token validation, or debugging?
Drop your questions below—I’d love to dive deeper into any part of the setup!
Comments
Post a Comment