https://github.com/happilymarrieddad/learning-go-gRPC
export PATH=$PATH:/usr/local/go/bin export PATH=$PATH:/home/comp/go/bin
sudo apt install mysql-server
{ "Omega Assertion": { "prefix": "omega", "body": "Ω($1)", "description": "Ginkgo Gomega Assertion" }, }
- Intro
- Setup ENV
- setup migrations
- installing
- https://github.com/golang-migrate/migrate/tree/master/cmd/migrate
- migrate create -dir migrations -ext sql create_users_table
- migrate -path ./migrations -database mysql://root:pass@/grpc -verbose up
- Create
User
types - Add validation
- Create global repo
- Create users repo
- Add
Create
func - Add
FindById
func - Add
FindByEmail
func - Add
Update
func - Discuss testing and install gomega && ginkgo
- ginkgo bootstrap
- IF YOU WANT TO USE SQL-MOCK, please take a look at git branch
section3-lesson10
- Add
Create
tests- ginkgo -v -failFast --focus="UsersRepo"
- Add
FindById
tests - Add
FindByEmail
tests - Add
Update
tests - Generate mocks for repos
If you get the wrong version of protobuf use these commands
curl -OL https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip
unzip protoc-3.2.0-linux-x86_64.zip -d protoc3
sudo mv protoc3/bin/* /usr/local/bin/
sudo mv protoc3/include/* /usr/local/include/
sudo chown $USER /usr/local/bin/protoc sudo chown -R $USER /usr/local/include/google
ln -s /protoc3/bin/protoc /usr/bin/protoc
- Intro to protobufs
- Add
types
protobuf - Add
users
protobuf - Add
auth
protobuf - Generate protobuf files
- Create
utils
file - Create globalRepo intercepter
- Create users handler
- Flesh out users
Create
route - Flesh out users
FindById
route - Flesh out users
FindByEmail
route - Flesh out users
Update
route - Build initial users tests file
- Build
Create
tests - Build
FindById
tests - Build
FindByEmail
tests - Build
Update
tests - Run full test suite for users
- Create a main.go file to run the server
- Install grpc_cli
- git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc
- cd grpc
- git submodule update --init
- make grpc_cli
- sudo make install grpc_cli
- IF IT FAILS ON YOU DO THE FOLLOWING!!
- I just found out a workaround. If you add -Wno-unused-variable to the cppflags at line 356 of Makefile at grpc root folder, the complier will ignore the unused variable warning/error.
- grpc/grpc#16739
- cp ./bins/opt/grpc_cli ~/go/bin
- Run grpc_cli ls command to see all available services
- Run grpc_cli call command to create a user
- grpc_cli call localhost:8080 users.V1Users.Create "newUser:{firstName:'Nick',lastName:'Doe2',email:'[email protected]',password:'1234',confirmPassword:'1234'}"
- Create Auth repo
- Add
GetNewClaims
func
- go get -u github.com/pascaldekloe/jwt
- Add
GetSignedToken
func - Add
GetDataFromToken
func - Create tests file
- Build
GetNewClaims
tests - Build
GetSignedToken
tests - Build
GetDataFromToken
tests - Run full test suite for auth
- Flesh out auth
Login
route - Build initial auth tests file
- Build
Login
tests - Run full test suite for auth
- Build api file to integrate routes
- Run grpc_cli call command to login with a user
- grpc_cli call localhost:8080 auth.V1Auth.Login "email:'[email protected]', password: '1234'"
- Intro to gRPC authentication
- Add JWT field to routes
- Add JWT checks to the interceptor
- grpc_cli call localhost:8080 auth.V1Auth.Login "email:'[email protected]', password: '1234'"
- grpc_cli call localhost:8080 users.V1Users.Create "newUser:{firstName:'Nick2',lastName:'Doe2',email:'[email protected]',password:'1234',confirmPassword:'1234'}"
- Test routes
https://github.com/grpc/grpc-web https://github.com/improbable-eng/grpc-web/tree/master/go/grpcwebproxy
install into our project
npm install grpc grpc-web google-protobuf --save