Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/roitinnovation/roit-queues
Queue manager for Typescript, as well as Nestjs.
https://github.com/roitinnovation/roit-queues
cloudtasks nestjs nodejs pubsub queue typescript
Last synced: about 1 month ago
JSON representation
Queue manager for Typescript, as well as Nestjs.
- Host: GitHub
- URL: https://github.com/roitinnovation/roit-queues
- Owner: roitinnovation
- License: mit
- Created: 2021-01-05T21:34:56.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-23T19:01:40.000Z (almost 2 years ago)
- Last Synced: 2024-10-30T06:59:46.523Z (about 2 months ago)
- Topics: cloudtasks, nestjs, nodejs, pubsub, queue, typescript
- Language: TypeScript
- Homepage:
- Size: 46.9 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ROIT Queues
### Usage for Pub/Sub
In the `env.yaml` file add the `pubSubCredential{}` and `projectId` attributes, with the number of folders inside the {}:
```yaml
dev:
pubSubCredential{5}: my-credential.json
firestore:
projectId: my-project-id
```Note: if you use `glcloud auth application-default login`, you don't need to set `pubSubCredential` at env file!
Inject in your desired class:
```typescript
import { PubSubHandler } from '@roit/roit-queues'constructor(
private readonly pubSubHandler: PubSubHandler
) {}
```Use the `publish` method:
```typescript
const myObject = {
// properties
}const attributes = {
// properties
}const messageId = await this.pubSubHandler.publish(myObject, 'myTopic', attributes)
console.log(messageId) // outputs 234786275
```### Usage for Cloud Tasks
In the `env.yaml` file add the `cloudTaskCredencial{}` and `projectId` attributes, with the number of folders inside the {}:
```yaml
dev:
cloudTaskCredential{5}: my-credential.json
firestore:
projectId: my-project-id
```Inject in your desired class:
```typescript
import { CloudTaskProvider } from '@roit/roit-queues'constructor(
private readonly cloudTaskProvider: CloudTaskProvider
) {}
```Schedule Time params:
```typescript
scheduleTime: {
seconds?: number
nanos?: number
dateExecute?: string // Use moment formats: https://www.npmjs.com/package/moment
executeAt?: string // Use ms formats: https://www.npmjs.com/package/ms
}
```Use the `createTask` method:
```typescript
import { TaskConfiguration } from '@roit/roit-queues'const myTask: TaskConfiguration = {
url: 'https://endpoint.com',
httpMethod: 'POST',
region: 'us-central1',
queue: 'my-queue',
scheduleTime: {
seconds: 3600
},
headers: MyHeadersObject,
body: MyPayloadObject
}const taskResponse = await this.cloudTaskProvider.createTask(myTask)
console.log(taskResponse)
```