Skip to content

Commit

Permalink
Merge pull request #12 from saitamau-maximum/feat/buf-format
Browse files Browse the repository at this point in the history
  • Loading branch information
sor4chi authored Dec 12, 2024
2 parents bde8ae6 + 7fade17 commit b533f7c
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 150 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Check

on: pull_request

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: "8.12.0"
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "20.10"
cache: "pnpm"
cache-dependency-path: "./pnpm-lock.yaml"
- name: Install dependencies
run: pnpm install
- name: Setup protoc-gen-openapiv2
run: |
curl -sSL https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v2.23.0/protoc-gen-openapiv2-v2.23.0-linux-x86_64 -o protoc-gen-openapiv2
chmod +x protoc-gen-openapiv2
mv protoc-gen-openapiv2 /usr/local/bin
- name: Setup protoc-gen-go
run: |
curl -sSL https://github.com/protocolbuffers/protobuf-go/releases/download/v1.35.2/protoc-gen-go.v1.35.2.linux.amd64.tar.gz -o protoc-gen-go.tar.gz
tar -xvf protoc-gen-go.tar.gz
chmod +x protoc-gen-go
mv protoc-gen-go /usr/local/bin
- name: Check
run: pnpm check
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"build:proto": "buf generate",
"build:swagger": "swagger-cli bundle -o docs/swagger.json gen/openapi/proto/api.swagger.json",
"build": "npm run build:proto && npm run build:swagger",
"fix": "buf format -w",
"check": "buf format --exit-code",
"serve": "serve -s docs"
},
"devDependencies": {
Expand Down
166 changes: 77 additions & 89 deletions proto/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,110 +2,98 @@ syntax = "proto3";

package meline;

option go_package = "proto";

import "google/api/annotations.proto";
import "schema/request/channel_request.proto";
import "schema/response/channel_response.proto";
import "schema/request/message_request.proto";
import "schema/response/message_response.proto";
import "schema/request/user_request.proto";
import "schema/response/user_response.proto";
import "schema/request/notify_request.proto";
import "schema/request/user_request.proto";
import "schema/response/channel_response.proto";
import "schema/response/message_response.proto";
import "schema/response/notify_response.proto";
import "schema/response/user_response.proto";

option go_package = "proto";

service ChannelService {
rpc GetAllChannels (schema.request.GetAllChannelsRequest) returns (schema.response.GetAllChannelsResponse) {
option (google.api.http) = {
get : "/channels"
};
}
rpc GetChannelByID (schema.request.GetChannelByIDRequest) returns (schema.response.GetChannelByIDResponse) {
option (google.api.http) = {
get : "/channels/{id}"
};
}
rpc JoinChannel (schema.request.JoinChannelRequest) returns (schema.response.JoinChannelResponse) {
option (google.api.http) = {
post : "/channels/{id}/join"
body : "*"
};
}
rpc CreateChannel (schema.request.CreateChannelRequest) returns (schema.response.CreateChannelResponse) {
option (google.api.http) = {
post : "/channels"
body : "*"
};
}
rpc CreateChildChannel (schema.request.CreateChildChannelRequest) returns (schema.response.CreateChildChannelResponse) {
option (google.api.http) = {
post : "/channels/{id}/create"
body : "*"
};
}
rpc UpdateChannel (schema.request.UpdateChannelRequest) returns (schema.response.UpdateChannelResponse) {
option (google.api.http) = {
put : "/channels/{id}"
body : "*"
};
}
rpc DeleteChannel (schema.request.DeleteChannelRequest) returns (schema.response.DeleteChannelResponse) {
option (google.api.http) = {
delete : "/channels/{id}"
};
}
rpc LeaveChannel (schema.request.LeaveChannelRequest) returns (schema.response.LeaveChannelResponse) {
option (google.api.http) = {
post : "/channels/{id}/leave"
body : "*"
};
}
rpc GetAllChannels(schema.request.GetAllChannelsRequest) returns (schema.response.GetAllChannelsResponse) {
option (google.api.http) = {get: "/channels"};
}
rpc GetChannelByID(schema.request.GetChannelByIDRequest) returns (schema.response.GetChannelByIDResponse) {
option (google.api.http) = {get: "/channels/{id}"};
}
rpc JoinChannel(schema.request.JoinChannelRequest) returns (schema.response.JoinChannelResponse) {
option (google.api.http) = {
post: "/channels/{id}/join"
body: "*"
};
}
rpc CreateChannel(schema.request.CreateChannelRequest) returns (schema.response.CreateChannelResponse) {
option (google.api.http) = {
post: "/channels"
body: "*"
};
}
rpc CreateChildChannel(schema.request.CreateChildChannelRequest) returns (schema.response.CreateChildChannelResponse) {
option (google.api.http) = {
post: "/channels/{id}/create"
body: "*"
};
}
rpc UpdateChannel(schema.request.UpdateChannelRequest) returns (schema.response.UpdateChannelResponse) {
option (google.api.http) = {
put: "/channels/{id}"
body: "*"
};
}
rpc DeleteChannel(schema.request.DeleteChannelRequest) returns (schema.response.DeleteChannelResponse) {
option (google.api.http) = {delete: "/channels/{id}"};
}
rpc LeaveChannel(schema.request.LeaveChannelRequest) returns (schema.response.LeaveChannelResponse) {
option (google.api.http) = {
post: "/channels/{id}/leave"
body: "*"
};
}
}

service MessageService {
rpc GetByChannelID(schema.request.GetByChannelIDRequest) returns (schema.response.GetByChannelIDResponse) {
option (google.api.http) = {
get : "/{channel_id}/messages"
};
}
rpc Create(schema.request.CreateMessageRequest) returns (schema.response.CreateMessageResponse) {
option (google.api.http) = {
post : "/{channel_id}/messages"
body : "*"
};
}
rpc CreateReply(schema.request.CreateReplyMessageRequest) returns (schema.response.CreateReplyMessageResponse) {
option (google.api.http) = {
post : "/{channel_id}/messages/{id}/reply"
body : "*"
};
}
rpc Update(schema.request.UpdateMessageRequest) returns (schema.response.UpdateMessageResponse) {
option (google.api.http) = {
put : "/{channel_id}/messages/{id}"
body : "*"
};
}
rpc Delete(schema.request.DeleteMessageRequest) returns (schema.response.DeleteMessageResponse) {
option (google.api.http) = {
delete : "/{channel_id}/messages/{id}"
};
}
rpc GetByChannelID(schema.request.GetByChannelIDRequest) returns (schema.response.GetByChannelIDResponse) {
option (google.api.http) = {get: "/{channel_id}/messages"};
}
rpc Create(schema.request.CreateMessageRequest) returns (schema.response.CreateMessageResponse) {
option (google.api.http) = {
post: "/{channel_id}/messages"
body: "*"
};
}
rpc CreateReply(schema.request.CreateReplyMessageRequest) returns (schema.response.CreateReplyMessageResponse) {
option (google.api.http) = {
post: "/{channel_id}/messages/{id}/reply"
body: "*"
};
}
rpc Update(schema.request.UpdateMessageRequest) returns (schema.response.UpdateMessageResponse) {
option (google.api.http) = {
put: "/{channel_id}/messages/{id}"
body: "*"
};
}
rpc Delete(schema.request.DeleteMessageRequest) returns (schema.response.DeleteMessageResponse) {
option (google.api.http) = {delete: "/{channel_id}/messages/{id}"};
}
}

service UserService {
rpc Me(schema.request.UserMeRequest) returns (schema.response.UserMeResponse) {
option (google.api.http) = {
get : "/users/me"
};
}
rpc Me(schema.request.UserMeRequest) returns (schema.response.UserMeResponse) {
option (google.api.http) = {get: "/users/me"};
}
}

service NotifyService {
rpc Notify(schema.request.NotifyRequest) returns (schema.response.NotifyResponse) {
option (google.api.http) = {
post : "/ws/notify"
body : "*"
};
rpc Notify(schema.request.NotifyRequest) returns (schema.response.NotifyResponse) {
option (google.api.http) = {
post: "/ws/notify"
body: "*"
};
}
}
16 changes: 8 additions & 8 deletions proto/base/channel_base.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ syntax = "proto3";

package base;

option go_package = "base";

import "base/user_base.proto";

option go_package = "base";

message Channel {
string id = 1;
string name = 2;
string id = 1;
string name = 2;
}

message ChannelDetail {
string id = 1;
string name = 2;
repeated User users = 3;
repeated Channel channels = 4;
string id = 1;
string name = 2;
repeated User users = 3;
repeated Channel channels = 4;
}
22 changes: 11 additions & 11 deletions proto/base/message_base.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ syntax = "proto3";

package base;

option go_package = "base";

import "base/user_base.proto";

option go_package = "base";

message Message {
string id = 1;
User user = 2;
string content = 3;
ReplyToMessage reply_to_message = 4;
string created_at = 5;
string updated_at = 6;
string id = 1;
User user = 2;
string content = 3;
ReplyToMessage reply_to_message = 4;
string created_at = 5;
string updated_at = 6;
}

message ReplyToMessage {
string id = 1;
User user = 2;
string content = 3;
string id = 1;
User user = 2;
string content = 3;
}
10 changes: 5 additions & 5 deletions proto/base/notify_base.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ syntax = "proto3";

package base;

option go_package = "base";

import "base/message_base.proto";

option go_package = "base";

message NotifyMeta {
int64 type_id = 1;
int64 type_id = 1;
}

message Payload {
Message message = 1;
string channel_id = 2;
Message message = 1;
string channel_id = 2;
}
6 changes: 3 additions & 3 deletions proto/base/user_base.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package base;
option go_package = "base";

message User {
string id = 1;
string name = 2;
string image_url = 3;
string id = 1;
string name = 2;
string image_url = 3;
}
18 changes: 9 additions & 9 deletions proto/schema/request/channel_request.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ option go_package = "schema/request";
message GetAllChannelsRequest {}

message GetChannelByIDRequest {
string id = 1;
string id = 1;
}

message JoinChannelRequest {
string id = 1;
string id = 1;
}

message CreateChannelRequest {
string name = 1;
string name = 1;
}

message CreateChildChannelRequest {
string id = 1;
string name = 2;
string id = 1;
string name = 2;
}

message UpdateChannelRequest {
string id = 1;
string name = 2;
string id = 1;
string name = 2;
}

message DeleteChannelRequest {
string id = 1;
string id = 1;
}

message LeaveChannelRequest {
string id = 1;
string id = 1;
}
Loading

0 comments on commit b533f7c

Please sign in to comment.