UNPKG

5.75 kBMarkdownView Raw
1[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
2[//]: # "To regenerate it, use `python -m synthtool`."
3<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
4
5# [Google APIs Proto Files: Node.js Client](https://github.com/googleapis/nodejs-proto-files)
6
7[![release level](https://img.shields.io/badge/release%20level-stable-brightgreen.svg?style=flat)](https://cloud.google.com/terms/launch-stages)
8[![npm version](https://img.shields.io/npm/v/google-proto-files.svg)](https://www.npmjs.org/package/google-proto-files)
9
10
11
12
13All of the Google API's protocol buffer files
14
15
16A comprehensive list of changes in each version may be found in
17[the CHANGELOG](https://github.com/googleapis/nodejs-proto-files/blob/main/CHANGELOG.md).
18
19* [Google APIs Proto Files Node.js Client API Reference][client-docs]
20
21* [github.com/googleapis/nodejs-proto-files](https://github.com/googleapis/nodejs-proto-files)
22
23Read more about the client libraries for Cloud APIs, including the older
24Google APIs Client Libraries, in [Client Libraries Explained][explained].
25
26[explained]: https://cloud.google.com/apis/docs/client-libraries-explained
27
28**Table of contents:**
29
30
31* [Quickstart](#quickstart)
32
33 * [Installing the client library](#installing-the-client-library)
34 * [Using the client library](#using-the-client-library)
35* [Samples](#samples)
36* [Versioning](#versioning)
37* [Contributing](#contributing)
38* [License](#license)
39
40## Quickstart
41
42### Installing the client library
43
44```bash
45npm install google-proto-files
46```
47
48
49### Using the client library
50
51```javascript
52const protos = require('google-proto-files');
53
54async function quickstart() {
55 // Get a directory path by executing as a function
56 const files = protos.getProtoPath('logging', 'v2');
57 console.log(files);
58 // node_modules/google-proto-files/google/logging/v2
59
60 // Get a path to the entry proto file for a specific API version
61 console.log(protos.pubsub.v1);
62 // node_modules/google-proto-files/google/pubsub/v1/pubsub.proto
63
64 // Load a proto which depends on google common protos.
65 const root1 = await protos.load('./cloudcats.proto');
66 const service1 = root1.lookup('example.MyService');
67 console.log(service1);
68
69 // Load protos synchronously
70 const root2 = protos.loadSync('./cloudcats.proto');
71 const service2 = root2.lookup('example.MyService');
72 console.log(service2);
73}
74quickstart();
75
76```
77
78
79
80## Samples
81
82Samples are in the [`samples/`](https://github.com/googleapis/nodejs-proto-files/tree/main/samples) directory. Each sample's `README.md` has instructions for running its sample.
83
84| Sample | Source Code | Try it |
85| --------------------------- | --------------------------------- | ------ |
86| Quickstart | [source code](https://github.com/googleapis/nodejs-proto-files/blob/main/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-proto-files&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |
87
88
89
90The [Google APIs Proto Files Node.js Client API Reference][client-docs] documentation
91also contains samples.
92
93## Supported Node.js Versions
94
95Our client libraries follow the [Node.js release schedule](https://github.com/nodejs/release#release-schedule).
96Libraries are compatible with all current _active_ and _maintenance_ versions of
97Node.js.
98If you are using an end-of-life version of Node.js, we recommend that you update
99as soon as possible to an actively supported LTS version.
100
101Google's client libraries support legacy versions of Node.js runtimes on a
102best-efforts basis with the following warnings:
103
104* Legacy versions are not tested in continuous integration.
105* Some security patches and features cannot be backported.
106* Dependencies cannot be kept up-to-date.
107
108Client libraries targeting some end-of-life versions of Node.js are available, and
109can be installed through npm [dist-tags](https://docs.npmjs.com/cli/dist-tag).
110The dist-tags follow the naming convention `legacy-(version)`.
111For example, `npm install google-proto-files@legacy-8` installs client libraries
112for versions compatible with Node.js 8.
113
114## Versioning
115
116This library follows [Semantic Versioning](http://semver.org/).
117
118
119
120This library is considered to be **stable**. The code surface will not change in backwards-incompatible ways
121unless absolutely necessary (e.g. because of critical security issues) or with
122an extensive deprecation period. Issues and requests against **stable** libraries
123are addressed with the highest priority.
124
125
126
127
128
129
130More Information: [Google Cloud Platform Launch Stages][launch_stages]
131
132[launch_stages]: https://cloud.google.com/terms/launch-stages
133
134## Contributing
135
136Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-proto-files/blob/main/CONTRIBUTING.md).
137
138Please note that this `README.md`, the `samples/README.md`,
139and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`)
140are generated from a central template. To edit one of these files, make an edit
141to its templates in
142[directory](https://github.com/googleapis/synthtool).
143
144## License
145
146Apache Version 2.0
147
148See [LICENSE](https://github.com/googleapis/nodejs-proto-files/blob/main/LICENSE)
149
150[client-docs]: https://cloud.google.com/nodejs/docs/reference/google-proto-files/latest
151
152[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
153[projects]: https://console.cloud.google.com/project
154[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
155
156[auth]: https://cloud.google.com/docs/authentication/getting-started