https://github.com/remorses/cloud-run-node-sdk
Sdk to deploy cloud run services
https://github.com/remorses/cloud-run-node-sdk
Last synced: 7 months ago
JSON representation
Sdk to deploy cloud run services
- Host: GitHub
- URL: https://github.com/remorses/cloud-run-node-sdk
- Owner: remorses
- Created: 2020-05-30T19:29:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-31T11:43:08.000Z (over 5 years ago)
- Last Synced: 2025-06-07T07:16:19.620Z (7 months ago)
- Language: TypeScript
- Size: 104 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cloud-run-node-sdk
Google Cloud Run client for nodejs (uses `googleapis`, '@google-cloud/monitoring`and`@google-cloud/logging` under the hood)
The package exposes detailed typescript types, use them to explore the shape of returned resources
## Installation
```
npm i cloud-run-node-sdk
```
## Example usage
Deploying a service
```js
import { CloudRunSdk } from 'cloud-run-node-sdk'
const client = new CloudRunSdk({
projectId: 'proj-id',
})
const data = await client.deployService({
name: 'name',
region: 'us-central1',
image: 'gcr.io/cloudrun/hello',
port: 8080,
env: {
CIAO: '1',
},
})
const error = await client.waitServiceReady({
name: 'example,
region: 'us-central1,
})
```
Getting logs and metrics of a service
```js
import { CloudRunSdk } from 'cloud-run-node-sdk'
const client = new CloudRunSdk({
projectId: 'proj-id',
})
const logs = await client.getServicesLogs({
from: new Date(new Date().getTime() - 3600),
to: new Date(),
services: ['example-service'],
})
const requestsCountPoints = await client.getRequestsCountMetrics({
lastHours: 10,
services: ['example-service'],
})
const requestsLatencyPoints = await client.getRequestsLatencyMetrics({
lastHours: 10,
services: ['example-service'],
})
```
Inspecting service details
```ts
import { CloudRunSdk } from 'cloud-run-node-sdk'
const client = new CloudRunSdk({
projectId: 'proj-id',
})
const data = await client.getService({
name: 'example,
region: 'us-central1,
})
console.log('url', data.status.url)
const { ready, error } = await client.getServiceStatus({
name: 'example,
region: 'us-central1,
})
```