Skip to content

Commit

Permalink
Banjofox/add api directory structure (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
BanjoFox authored Oct 16, 2024
1 parent b1ad83f commit 1596227
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 1 deletion.
4 changes: 4 additions & 0 deletions aardwolf-api/README.md
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)
9 changes: 9 additions & 0 deletions aardwolf-api/backend-api/README.md
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.
```
15 changes: 15 additions & 0 deletions aardwolf-api/database-api/README.md
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.
```
15 changes: 15 additions & 0 deletions aardwolf-api/frontend-api/README.md
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.
```
23 changes: 23 additions & 0 deletions aardwolf-api/frontend-api/get_posts.rs
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
}
1 change: 0 additions & 1 deletion aardwolf-templates/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ pub trait Renderable {
pub fn disabled_translations() -> Translations {
Translations::default()
}

0 comments on commit 1596227

Please sign in to comment.