-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Banjofox/add api directory structure (#345)
- Loading branch information
Showing
6 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Placeholder for API modules | ||
- Server: Actix, models, localization(?) | ||
- Frontend: Templates, and Yew Framework | ||
- Database: Modular database component (Postgres Default) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Placeholder for server/backend API code | ||
|
||
Some endpoint suggestions: | ||
``` | ||
POST /api/auth/login: Authenticate a user and generate a token for accessing protected routes. | ||
POST /api/users: Create a new user account. | ||
GET /api/users/:userId: Retrieve user details by user ID. | ||
PUT /api/users/:userId: Update user information. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Placeholder for database API code | ||
|
||
Some endpoint suggestions: | ||
``` | ||
GET /api/db/users: Retrieve all users from the database. | ||
POST /api/db/users: Add a new user to the database. | ||
GET /api/db/users/:userId/posts: Retrieve posts by a specific user. | ||
GET /api/db/posts: Retrieve all posts from the database. | ||
POST /api/db/posts: Add a new post to the database. | ||
PUT /api/db/posts/:postId: Update a post in the database. | ||
DELETE /api/db/posts/:postId: Delete a post from the database. | ||
POST /api/db/posts/:postId/like: Add a like to a post. | ||
POST /api/db/posts/:postId/comment: Add a comment to a post. | ||
GET /api/db/posts/:postId/comments: Retrieve comments for a post. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Placeholder for frontend API code | ||
|
||
Some endpoint suggestions: | ||
``` | ||
GET /api/posts: Retrieve a list of posts to display on the feed. | ||
POST /api/posts/create: Create a new post. | ||
PUT /api/posts/update/:postId: Update a post. | ||
DELETE /api/posts/delete/:postId: Delete a post. | ||
POST /api/posts/like/:postId: Like a post. | ||
POST /api/posts/comment/:postId: Add a comment to a post. | ||
GET /api/users/:userId/posts: Retrieve posts by a specific user. | ||
GET /api/users/:userId/followers: Retrieve followers of a user. | ||
POST /api/users/follow/:userId: Follow a user. | ||
POST /api/users/unfollow/:userId: Unfollow a user. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//- | ||
// Feel free to ignore this, as it was code generated by Banjo's favorite AI helper | ||
// | ||
|
||
use actix_web::{web, App, HttpServer, Responder, HttpResponse}; | ||
|
||
async fn get_posts() -> impl Responder { | ||
// Logic to retrieve a list of posts (replace this with actual implementation) | ||
let posts = vec!["Post 1", "Post 2", "Post 3"]; // Sample posts | ||
|
||
HttpResponse::Ok().json(posts) | ||
} | ||
|
||
#[actix_web::main] | ||
async fn main() -> std::io::Result<()> { | ||
HttpServer::new(|| { | ||
App::new() | ||
.route("/api/posts", web::get().to(get_posts)) | ||
}) | ||
.bind("127.0.0.1:8080")? | ||
.run() | ||
.await | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,3 @@ pub trait Renderable { | |
pub fn disabled_translations() -> Translations { | ||
Translations::default() | ||
} | ||
|