fix signup route and add create users table migration

This commit is contained in:
2026-06-29 00:59:10 +07:00
parent bb2cb3a540
commit 0f9bf8dfc1
5 changed files with 45 additions and 32 deletions
+9 -9
View File
@@ -184,7 +184,7 @@ func (x *EchoRsp) GetText() string {
type SignupReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@@ -220,9 +220,9 @@ func (*SignupReq) Descriptor() ([]byte, []int) {
return file_main_proto_rawDescGZIP(), []int{4}
}
func (x *SignupReq) GetName() string {
func (x *SignupReq) GetUsername() string {
if x != nil {
return x.Name
return x.Username
}
return ""
}
@@ -289,16 +289,16 @@ const file_main_proto_rawDesc = "" +
"\aEchoReq\x12\x12\n" +
"\x04text\x18\x01 \x01(\tR\x04text\"\x1d\n" +
"\aEchoRsp\x12\x12\n" +
"\x04text\x18\x01 \x01(\tR\x04text\"5\n" +
"\tSignupReq\x12\x12\n" +
"\x04name\x18\x01 \x01(\tR\x04name\x12\x14\n" +
"\x04text\x18\x01 \x01(\tR\x04text\"=\n" +
"\tSignupReq\x12\x1a\n" +
"\busername\x18\x01 \x01(\tR\busername\x12\x14\n" +
"\x05email\x18\x02 \x01(\tR\x05email\"!\n" +
"\tSignupRsp\x12\x14\n" +
"\x05error\x18\x01 \x01(\tR\x05error2\xe7\x02\n" +
"\x05error\x18\x01 \x01(\tR\x05error2\xea\x02\n" +
"\x16EveningDetectiveServer\x12k\n" +
"\x04Ping\x12'.crabs.evening_detective_server.PingReq\x1a'.crabs.evening_detective_server.PingRsp\"\x11\x82\xd3\xe4\x93\x02\v\x12\t/api/ping\x12k\n" +
"\x04Echo\x12'.crabs.evening_detective_server.EchoReq\x1a'.crabs.evening_detective_server.EchoRsp\"\x11\x82\xd3\xe4\x93\x02\v\"\t/api/echo\x12s\n" +
"\x06Signup\x12).crabs.evening_detective_server.SignupReq\x1a).crabs.evening_detective_server.SignupRsp\"\x13\x82\xd3\xe4\x93\x02\r\"\v/api/signupB\vZ\tpkg/protob\x06proto3"
"\x04Echo\x12'.crabs.evening_detective_server.EchoReq\x1a'.crabs.evening_detective_server.EchoRsp\"\x11\x82\xd3\xe4\x93\x02\v\"\t/api/echo\x12v\n" +
"\x06Signup\x12).crabs.evening_detective_server.SignupReq\x1a).crabs.evening_detective_server.SignupRsp\"\x16\x82\xd3\xe4\x93\x02\x10:\x01*\"\v/api/signupB\vZ\tpkg/protob\x06proto3"
var (
file_main_proto_rawDescOnce sync.Once
+4 -12
View File
@@ -91,22 +91,17 @@ func local_request_EveningDetectiveServer_Echo_0(ctx context.Context, marshaler
return msg, metadata, err
}
var filter_EveningDetectiveServer_Signup_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
func request_EveningDetectiveServer_Signup_0(ctx context.Context, marshaler runtime.Marshaler, client EveningDetectiveServerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq SignupReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EveningDetectiveServer_Signup_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.Signup(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
@@ -116,10 +111,7 @@ func local_request_EveningDetectiveServer_Signup_0(ctx context.Context, marshale
protoReq SignupReq
metadata runtime.ServerMetadata
)
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EveningDetectiveServer_Signup_0); err != nil {
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Signup(ctx, &protoReq)