mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-13 19:45:26 +00:00
Multitenant streams api (#72)
This commit is contained in:
@@ -7,16 +7,16 @@ init:
|
||||
go get github.com/micro/micro/v3/cmd/protoc-gen-micro
|
||||
.PHONY: proto
|
||||
proto:
|
||||
protoc --proto_path=. --micro_out=. --go_out=:. proto/codes.proto
|
||||
|
||||
protoc --openapi_out=. --proto_path=. --micro_out=. --go_out=:. proto/codes.proto
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
go build -o codes *.go
|
||||
|
||||
.PHONY: docs
|
||||
docs:
|
||||
protoc --openapi_out=. --proto_path=. --micro_out=. --go_out=:. proto/codes.proto
|
||||
@redoc-cli bundle api-codes.json
|
||||
protoc --openapi_out=. --proto_path=. --micro_out=. --go_out=:. proto/codes.proto
|
||||
@redoc-cli bundle api-protobuf.json
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package handler_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -11,7 +12,12 @@ import (
|
||||
|
||||
func testHandler(t *testing.T) *handler.Codes {
|
||||
// connect to the database
|
||||
db, err := gorm.Open(postgres.Open("postgresql://postgres@localhost:5432/codes?sslmode=disable"), &gorm.Config{})
|
||||
addr := os.Getenv("POSTGRES_URL")
|
||||
if len(addr) == 0 {
|
||||
addr = "postgresql://postgres@localhost:5432/postgres?sslmode=disable"
|
||||
}
|
||||
|
||||
db, err := gorm.Open(postgres.Open(addr), &gorm.Config{})
|
||||
if err != nil {
|
||||
t.Fatalf("Error connecting to database: %v", err)
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.23.0
|
||||
// protoc v3.13.0
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v3.15.5
|
||||
// source: proto/codes.proto
|
||||
|
||||
package codes
|
||||
|
||||
import (
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
timestamp "github.com/golang/protobuf/ptypes/timestamp"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
@@ -22,17 +21,13 @@ const (
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
||||
// of the legacy proto package is being used.
|
||||
const _ = proto.ProtoPackageIsVersion4
|
||||
|
||||
type CreateRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` // e.g. phone number or email being verified
|
||||
ExpiresAt *timestamp.Timestamp `protobuf:"bytes,2,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"` // expiry time for the code, default 5 minutes
|
||||
Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` // e.g. phone number or email being verified
|
||||
ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"` // expiry time for the code, default 5 minutes
|
||||
}
|
||||
|
||||
func (x *CreateRequest) Reset() {
|
||||
@@ -74,7 +69,7 @@ func (x *CreateRequest) GetIdentity() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CreateRequest) GetExpiresAt() *timestamp.Timestamp {
|
||||
func (x *CreateRequest) GetExpiresAt() *timestamppb.Timestamp {
|
||||
if x != nil {
|
||||
return x.ExpiresAt
|
||||
}
|
||||
@@ -249,8 +244,8 @@ var file_proto_codes_proto_rawDesc = []byte{
|
||||
0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x12, 0x14, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x73, 0x2e, 0x56,
|
||||
0x65, 0x72, 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x63,
|
||||
0x6f, 0x64, 0x65, 0x73, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||
0x6e, 0x73, 0x65, 0x42, 0x0d, 0x5a, 0x0b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x63, 0x6f, 0x64,
|
||||
0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x6e, 0x73, 0x65, 0x42, 0x0f, 0x5a, 0x0d, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x63,
|
||||
0x6f, 0x64, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -267,11 +262,11 @@ func file_proto_codes_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_proto_codes_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_proto_codes_proto_goTypes = []interface{}{
|
||||
(*CreateRequest)(nil), // 0: codes.CreateRequest
|
||||
(*CreateResponse)(nil), // 1: codes.CreateResponse
|
||||
(*VerifyRequest)(nil), // 2: codes.VerifyRequest
|
||||
(*VerifyResponse)(nil), // 3: codes.VerifyResponse
|
||||
(*timestamp.Timestamp)(nil), // 4: google.protobuf.Timestamp
|
||||
(*CreateRequest)(nil), // 0: codes.CreateRequest
|
||||
(*CreateResponse)(nil), // 1: codes.CreateResponse
|
||||
(*VerifyRequest)(nil), // 2: codes.VerifyRequest
|
||||
(*VerifyResponse)(nil), // 3: codes.VerifyResponse
|
||||
(*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp
|
||||
}
|
||||
var file_proto_codes_proto_depIdxs = []int32{
|
||||
4, // 0: codes.CreateRequest.expires_at:type_name -> google.protobuf.Timestamp
|
||||
|
||||
@@ -6,7 +6,7 @@ package codes
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
_ "github.com/golang/protobuf/ptypes/timestamp"
|
||||
_ "google.golang.org/protobuf/types/known/timestamppb"
|
||||
math "math"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package codes;
|
||||
option go_package = "proto;codes";
|
||||
option go_package = "./proto;codes";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
service Codes {
|
||||
@@ -23,4 +23,4 @@ message VerifyRequest {
|
||||
string identity = 2;
|
||||
}
|
||||
|
||||
message VerifyResponse {}
|
||||
message VerifyResponse {}
|
||||
|
||||
Reference in New Issue
Block a user