Giter Site home page Giter Site logo

portfolio_project_specialization's Introduction

ALX Blog Portfolio Project for specialization

Documentation for the API endpoints for server\routes\admin.js

POST /admin

Description: Authenticates a user and generates a JWT token. Request Body: username: User's username. password: User's password. Response: 200 OK: Successful authentication. 401 Unauthorized: Invalid username or password. Response Body: JSON object with a message indicating success or failure. Headers: Content-Type: application/json Cookies: token: JWT token for authentication.

GET /logout

Description: Logs out the authenticated user by clearing the JWT token. Response: 302 Found: Redirect to the home page. Cookies: Clears the token cookie.

User Management:

POST /register

Description: Registers a new user. Request Body: username: New user's username. password: New user's password. Response: 201 Created: User successfully created. 400 Bad Request: Username already in use. 500 Internal Server Error: Server-side error occurred. Response Body: JSON object with a message indicating success or failure. Headers: Content-Type: application/json

Post Management:

GET /dashboard

Description: Retrieves all posts for the admin dashboard. Authentication: Requires a valid JWT token. Response: 200 OK: Successful operation. Response Body: HTML rendered view containing the admin dashboard. Headers: Content-Type: text/html

GET /add-post

Description: Renders the form to add a new post. Authentication: Requires a valid JWT token. Response: 200 OK: Successful operation. Response Body: HTML rendered view containing the add post form. Headers: Content-Type: text/html

POST /add-post

Description: Creates a new post. Authentication: Requires a valid JWT token. Request Body: title: Title of the new post. body: Content/body of the new post. Response: 302 Found: Redirect to the dashboard upon successful post creation. Headers: Content-Type: application/x-www-form-urlencoded

GET /edit-post/:id

Description: Renders the form to edit a specific post. Authentication: Requires a valid JWT token. Path Parameters: id: ID of the post to edit. Response: 200 OK: Successful operation. Response Body: HTML rendered view containing the edit post form. Headers: Content-Type: text/html

PUT /edit-post/:id

Description: Updates a specific post. Authentication: Requires a valid JWT token. Path Parameters: id: ID of the post to update. Request Body: title: New title of the post. body: New content/body of the post. Response: 302 Found: Redirect to the edit post page upon successful update. Headers: Content-Type: application/x-www-form-urlencoded

DELETE /delete-post/:id

Description: Deletes a specific post. Authentication: Requires a valid JWT token. Path Parameters: id: ID of the post to delete. Response: 302 Found: Redirect to the dashboard upon successful deletion.

Documentation for the API endpoints for \app.js

Authentication:

POST /admin

Description: Authenticates a user and generates a JWT token for authorization. Request Body: username: User's username. password: User's password. Response: 200 OK: Successful authentication. Redirects to the dashboard. 401 Unauthorized: Invalid username or password.

POST /register

Description: Registers a new user. Request Body: username: User's desired username. password: User's desired password. Response: 201 Created: User created successfully. 400 Bad Request: Username already in use. 500 Internal Server Error: Server error. GET /logout Description: Logs out the currently authenticated user. Response: 200 OK: Logout successful. Redirects to the home page.

Dashboard:

GET /dashboard

Description: Fetches all posts for the authenticated user. Authorization: Requires a valid JWT token. Response: 200 OK: Returns dashboard page with post data.

GET /add-post

Description: Renders the page to add a new post. Authorization: Requires a valid JWT token. Response: 200 OK: Renders the add post page.

POST /add-post

Description: Creates a new post. Authorization: Requires a valid JWT token. Request Body: title: Title of the post. body: Body content of the post. Response: 200 OK: Post created successfully. Redirects to the dashboard.

GET /edit-post/:id

Description: Renders the page to edit a post. Authorization: Requires a valid JWT token. Response: 200 OK: Renders the edit post page with post data.

PUT /edit-post/:id

Description: Updates an existing post. Authorization: Requires a valid JWT token. Request Body: title: Updated title of the post. body: Updated body content of the post. Response: 200 OK: Post updated successfully. Redirects to the edit post page.

DELETE /delete-post/:id

Description: Deletes a post. Authorization: Requires a valid JWT token. Response: 200 OK: Post deleted successfully. Redirects to the dashboard.

AUTHORS

DIMKPA Ikenna [email protected] NWEKE Joseph [email protected] STANHOPE Chinonso [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.