npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dozerjs/node

v0.0.1

Published

<div align="center"> <a target="_blank" href="https://getdozer.io/"> <br><img src="https://dozer-assets.s3.ap-southeast-1.amazonaws.com/logo-blue.svg" width=40%><br> </a> </div>

Downloads

2

Readme

Overview

This repository is a typescript wrapper over gRPC APIs that are automatically generated when you run Dozer.

Installation

yarn add @dozerjs/node

AuthClient

getAuthToken(filter: string): Promise<string>

Generate a user token with custom access more detail

import { AuthClient } from '@dozerjs/node';

const client = new AuthClient({
  authToken: MASTER_TOKEN
});
const token = await client.authToken(JSON.stringify({
  Custom: {
    stock: {
      $filter: {},
    },
  }
}));

CommonClient

getEndpoints(): Promise<string[]>

Get a name list of all endpoints

import { CommonClient } from '@dozerjs/node';
const client = new CommonClient();
const endpoints = await client.getEndpoint();

getFields(endpoint: string): Promise<FieldDefinition.AsObject[]>

Get fields defination for the endpoint

import { CommonClient } from '@dozerjs/node';
const client = new CommonClient();
const fields = await client.getFields('stock')

count(endpoint: string, query?: DozerQUery): Promise<FieldDefinition.AsObject[]>

Count query returns number of records in particular source.

import { CommonClient } from '@dozerjs/node';
const client = new CommonClient();
const count = await client.getCount('stock');

query<T>(endpoint: string, query?: DozerQUery): Promise<[FieldDefinition.AsObject[], DozerRecord<T>[]]>

Query method is used to fetch records from cache more detail

import { CommonClient } from '@dozerjs/node';
const client = new CommonClient();
const [fields, records] = await client.query('stock');

onEvent(options: DozerOnEventOption[]>

Create a gRPC stream to monitor real-time store modifications for multiple endpoints.

import { CommonClient, RecordMapper } from '@dozerjs/node';
import { EventType, Operation } from '@dozerjs/node/gen/types_pb';
const client = new CommonClient();

const options = [
  endpoint: 'stock',
  eventType: EventType.ALL
];

const fieldsMap = options.reduce((map, option) => {
  map[option.endpoint] = client.getFields(option.endpoint).then((fields) => new RecordMapper(fields));
  return map;
}, {});

const stream = client.onEvent(options);

stream.on('data', (operation: Operation) => {
  fieldsMap[operation.getEndpointName()].then((mapper) => {
    const data = {};
    data['endpoint'] = operation.getEndpointName();
    data['typ'] = operation.getTyp();
    if (operation.getOld()) {
      data['old'] = mapper.mapRecord(operation.getOld());
    }
    if (operation.getNew()) {
      data['new'] = mapper.mapRecord(operation.getNew());
    }
    console.log(JSON.stringify(data));
  });
});

HealthClient

healthCheck(): Promise<HealthCheckResponse.ServingStatus>

import { HealthClient } from '@dozerjs/node';

const client = new HealthClient();
const status = await client.healthCheck();

healthWatch(): grpc.ClientReadableStream<HealthCheckResponse.ServingStatus>

import { HealthClient } from '@dozerjs/node';

const client = new HealthClient();
const stream = client.healthWatch();

stream.on('data', (status: HealthCheckResponse.ServingStatus) => {
  console.log('health', status);
})

IngestClient

ingest(): Promise<IngestResponse>

Ingest dat on Dozer pushing data to a gRPC endpoint in a streaming fashion more detail

import { IngestClient } from '@dozerjs/node';
import { OperationType } from '@dozerjs/node/gen/types_pb';
import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb';

const client = new IngestClient();
const request = new IngestRequest();

request.setSchemaName('produce');
request.setTyp(OperationType.INSERT);
request.addNew(new Value().setStringValue('hats'));
request.addNew(new Value().setIntValue(Math.ceil(Math.random() * 10)));
request.addNew(new Value().setTimestampValue(Timestamp.fromDate(new Date())));
client.ingest(request);

ingest_stream(): Promise<IngestResponse>

Ingest dat on Dozer pushing data to a gRPC endpoint in a streaming fashion more detail

import { IngestClient } from '@dozerjs/node';
import { OperationType } from '@dozerjs/node/gen/types_pb';
import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb';

const client = new IngestClient();
const stream = client.ingest_stream();

const request = new IngestRequest();

request.setSchemaName('produce');
request.setTyp(OperationType.INSERT);
request.addNew(new Value().setStringValue('hats'));
request.addNew(new Value().setIntValue(Math.ceil(Math.random() * 10)));
request.addNew(new Value().setTimestampValue(Timestamp.fromDate(new Date())));
stream.write(request);

stream.end();