0.6.1 • Published 3 years ago

@matsumana/centraldogma-nodejs v0.6.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

Central Dogma client for Node.js

npm version npm bundle size Dependencies npm downloads

CircleCI Known Vulnerabilities

This is an "unofficial" client library for Central Dogma.

What is Central Dogma?

Central Dogma is an open-source, highly-available and version-controlled service configuration repository

Please visit the official web site for more information.

In Central Dogma, there are various use cases.

e.g.

  • Service discovery
  • Managing Rate limit configuration
  • Managing A/B testing configuration
  • etc

If you refer to a Central Dogma server via client library, an app can get a change immediately.

It means that no need to restart your app for applying that changes.

Configure something that you want to apply changes without restarting your server application.

How to use this client library

How to install

$ npm i @matsumana/centraldogma-nodejs

How to watch a file managed by Central Dogma

You can get changes via EventEmitter continuously.

Please refer to the examples for more details.

import { CentralDogma } from '@matsumana/centraldogma-nodejs';

const centralDogma = new CentralDogma({
    baseURL: 'http://localhost:36462',
});

const emitter = centralDogma.watch.watchFile({
    project: 'project1',
    repo: 'repo1',
    filePath: '/example_config.json',
});

If you want to develop admin application to change configurations managed by Central Dogma

get a file

import { CentralDogma } from '@matsumana/centraldogma-nodejs';

const centralDogma = new CentralDogma({
    baseURL: 'http://localhost:36462',
});

const entry = await centralDogma.content.getFile({
    project: 'project1',
    repo: 'repo1',
    query: {
        path: '/example_config.json',
        type: QueryTypes.Identity,
    },
});

register or change files

import { CentralDogma } from '@matsumana/centraldogma-nodejs';

const centralDogma = new CentralDogma({
    baseURL: 'http://localhost:36462',
});

const result = await centralDogma.content.push({
    project: 'project1',
    repo: 'repo1',
    baseRevision: 'HEAD',
    commitMessage: {
        summary: 'Add /config1.json and /config2.json',
        detail: 'You can write a detail for changes',
    },
    changes: [
        {
            path: '/config1.json',
            type: ChangeTypes.UpsertJson,
            content: { field1: 'foo' },
        },
        {
            path: '/config2.json',
            type: ChangeTypes.UpsertJson,
            content: { field1: 'bar' },
        },
    ],
});

Other APIs

There are some more APIs.

Please refer to the sources and tests for more details.

0.6.1

3 years ago

0.6.0

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago