https://github.com/anders617/mdining-proto
https://github.com/anders617/mdining-proto
api api-client bazel dining-app food menu michigan-dining-api proto umich university-of-michigan uofm
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/anders617/mdining-proto
- Owner: anders617
- Created: 2019-11-03T00:28:16.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-14T01:43:16.000Z (almost 5 years ago)
- Last Synced: 2025-07-25T11:53:06.072Z (3 months ago)
- Topics: api, api-client, bazel, dining-app, food, menu, michigan-dining-api, proto, umich, university-of-michigan, uofm
- Language: Starlark
- Size: 87.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mdining-proto
[](https://travis-ci.org/anders617/mdining-proto)
Proto definitions for use with the [michigan-dining-api](https://github.com/anders617/michigan-dining-api) service
The file [mdining.proto](https://github.com/anders617/mdining-proto/blob/master/proto/mdining.proto) defines the grpc service for michigan-dining-api and is the most important file for clients to use.
The remaining files define the proto messages used by the service
## Language Support
**[Bazel](#Bazel)** \
**[Go](#Go)** \
**[Javascript/Node.js](#Javascript/Node.js)**
### Bazel
Add the following to your WORKSPACE file:
```python
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")go_repository(
name = "com_github_anders617_mdining_proto",
importpath = "github.com/anders617/mdining-proto",
sum = "h1:EqFtsULZ1MWoAAJKotZvMwR351syYg9eiDdBm1pBf78=",
version = "v0.2.2",
)load("@com_github_anders617_mdining_proto//rules:rule_deps.bzl", "rule_dependencies")
rule_dependencies()
load("@com_github_anders617_mdining_proto//rules:proto_deps.bzl", "proto_dependencies")
proto_dependencies()
load("@com_github_anders617_mdining_proto//rules:go_deps.bzl", "go_dependencies")
go_dependencies()
```
### Go
Go is supported through Bazel.
You can reference the `//proto:mdining_go_proto` target like so:
```python
go_library(
name = "my_library",
srcs = [
"my_source.go"
],
importpath = "github.com/my/import/path",
deps = [
"@com_github_anders617_mdining_proto//proto:mdining_go_proto",
],
)
```In your Go code:
```go
package mainimport (
"context"
"fmt"pb "github.com/anders617/mdining-proto/proto/mdining"
"google.golang.org/grpc"
)func main() {
address := "michigan-dining-api.herokuapp.com:80"
fmt.Printf("Connecting to %s...", address)
conn, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock())
if err != nil {
fmt.Printf("Could not dial %s: %s", address, err)
return
}
defer conn.Close()
fmt.Printf("Connected")// Create the MDiningClient
client := pb.NewMDiningClient(conn)// Send a GetDiningHalls request
diningHallsReply, err := client.GetDiningHalls(context.Background(), &pb.DiningHallsRequest{})if err != nil {
fmt.Printf("Could not call GetDiningHalls: %s", err)
return
}
fmt.Printf("DiningHallsReply: %v\n", diningHallsReply)
}
```
### Javascript/Node.js
Download the [npm package](https://www.npmjs.com/package/mdining-proto) using [npm](https://www.npmjs.com/get-npm):
```shell
npm install mdining-proto
```
or [yarn](https://yarnpkg.com/en/docs/install#mac-stable):
```shell
yarn add mdining-proto
```
Then in your code you can import the proto types and client like so:
```javascript
import { MDiningPromiseClient, DiningHallsRequest } from 'mdining-proto';const client = new MDiningPromiseClient('https://michigan-dining-api.herokuapp.com');
client.getDiningHalls(new DiningHallsRequest())
.then((diningHalls) => console.log(diningHalls))
.catch((err) => console.log(err));
```# Development
Run the following command to build and publish the npm package
```shell
bazel run //:mdining_ts_proto_package.publish
```