-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move existing schemas into frontend/backend folders * create home page and profile page schemas * scaffold the API routes * implement ProfilePageService * implement HomePageServiceImpl * show header buttons only when logged in * Add tweet component * almost done replacing profile page with frontend model * make the profile page look good * sort by time * homepage with new profiles column * colors * add a tweet box * nit * delete unused code
- Loading branch information
Showing
50 changed files
with
723 additions
and
268 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,14 @@ | ||
use schemas::profile::Profile; | ||
use schemas::tweet::Tweet; | ||
|
||
pub fn tweet_details(tweet: Tweet, profile: &Profile) -> schemas::frontend::Tweet { | ||
schemas::frontend::Tweet { | ||
tweet_id: tweet.tweet_id, | ||
user_id: tweet.user_id, | ||
first_name: profile.first_name.clone(), | ||
last_name: profile.last_name.clone(), | ||
message: tweet.message, | ||
created_at: tweet.created_at, | ||
parent_tweet_id: tweet.parent_tweet_id, | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
use tokio::task::JoinHandle; | ||
|
||
pub mod db; | ||
pub mod helpers; | ||
mod service; | ||
|
||
pub use service::Service; | ||
|
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
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
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
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 |
---|---|---|
|
@@ -14,3 +14,4 @@ tonic.workspace = true | |
|
||
[build-dependencies] | ||
tonic-build = "0.10.0" | ||
glob.workspace = true |
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,13 @@ | ||
# Schemas | ||
|
||
This directory contains the data models for the frontend and backend. | ||
|
||
The schemas are written using [protobuf](https://protobuf.dev/) definitions. | ||
|
||
## Backend | ||
|
||
The backend schemas reside in the [backend](./protos/backend) folder. The Rust code for each schema is generated by running `cargo build`; it invokes a build script in [build.rs](./build.rs) to compile the proto files into rust. | ||
|
||
## Frontend | ||
|
||
The frontend schemas reside in the [frontend](./protos/frontend) folder. The JavaScript code for each schema is generated by running `protoc`, which we can run using [proto.sh](../scripts/proto.sh). |
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
File renamed without changes.
File renamed without changes.
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
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,22 @@ | ||
syntax = "proto3"; | ||
|
||
import "google/protobuf/empty.proto"; | ||
import "backend/profile.proto"; | ||
import "frontend/tweet.proto"; | ||
|
||
package frontend; | ||
|
||
// The homepage service is responsible for loading the homepage. | ||
service HomePageService { | ||
// Load the homepage. | ||
rpc GetHomePage(google.protobuf.Empty) returns (HomePage); | ||
} | ||
|
||
// The homepage message contains the tweets and profiles to display on the homepage. | ||
message HomePage { | ||
// The tweets to display on the homepage. | ||
repeated Tweet tweets = 1; | ||
|
||
// The profiles to display on the homepage. | ||
repeated profile.Profile profiles = 2; | ||
} |
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,26 @@ | ||
syntax = "proto3"; | ||
|
||
import "frontend/tweet.proto"; | ||
import "backend/profile.proto"; | ||
|
||
package frontend; | ||
|
||
service ProfilePageService { | ||
// Gets a user's profile page. | ||
rpc GetProfilePage(GetProfilePageRequest) returns (ProfilePage); | ||
} | ||
|
||
// The user's profile page. | ||
message ProfilePage { | ||
// The user's profile information. | ||
profile.Profile profile = 1; | ||
|
||
// The user's Tweets. | ||
repeated Tweet tweets = 2; | ||
} | ||
|
||
// Request for getting a user's profile page. | ||
message GetProfilePageRequest { | ||
// The user ID. | ||
string user_id = 1; | ||
} |
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,28 @@ | ||
syntax = "proto3"; | ||
|
||
import "google/protobuf/timestamp.proto"; | ||
|
||
package frontend; | ||
|
||
message Tweet { | ||
// The ID of the tweet. | ||
string tweet_id = 1; | ||
|
||
// The ID of the user who posted the tweet. | ||
string user_id = 2; | ||
|
||
// The ID of the user who posted the tweet. | ||
string first_name = 3; | ||
|
||
// The ID of the user who posted the tweet. | ||
string last_name = 4; | ||
|
||
// The message of the tweet. | ||
string message = 5; | ||
|
||
// The time the tweet was created. | ||
google.protobuf.Timestamp created_at = 6; | ||
|
||
// The ID of the tweet who this tweet is replying to. | ||
string parent_tweet_id = 7; | ||
} |
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Generate the javascript code from the proto files | ||
# Run this script from the root of the project | ||
protoc --proto_path=schemas/protos/ --js_out=import_style=commonjs,binary:twote-web/src/proto --grpc-web_out=import_style=commonjs,mode=grpcwebtext:twote-web/src/proto schemas/protos/*.proto | ||
protoc --proto_path=schemas/protos/ --js_out=import_style=commonjs,binary:twote-web/src/proto --grpc-web_out=import_style=commonjs,mode=grpcwebtext:twote-web/src/proto schemas/protos/**/*.proto |
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
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
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
Oops, something went wrong.