issue-metadata
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Issue Metadata

npm version Tests Linters CodeQL codecov

How to use

Creating the Metadata controller instance

import MetadataController from "issue-metadata";

const controller = new MetadataController('my_metadata_ID', {
  owner: 'my_name',
  repo: 'my_repo',
  headers: {
    authorization: `Bearer my_GITHUB_API_TOKEN`,
  },
});

Store metadata on issue

await controller.setMetadata(1, 'foo', 'bar');
// In body of issue #1:
// <!-- my_metadata_ID = {"foo":"bar"} -->

await controller.setMetadata(1, { foo: 'bar' });
// In body of issue #1:
// <!-- my_metadata_ID = {"foo":"bar"} -->

await controller.setMetadata(1, 'complex', [{ bar: 'baz' }]);
// In body of issue #1:
// <!-- my_metadata_ID = {"foo":[{"bar":"baz"}]} -->

Get metadata stored on issue

let metadata = await controller.getMetadata(1, 'foo');
// metadata === "bar"

metadata = await controller.getMetadata(1);
// metadata === {foo: "bar"}

metadata = await controller.getMetadata(1, 'complex');
// metadata === [{ bar: 'baz' }]

Readme

Keywords

Package Sidebar

Install

npm i issue-metadata

Weekly Downloads

14

Version

0.2.0

License

GPLv3

Unpacked Size

53.2 kB

Total Files

16

Last publish

Collaborators

  • jamacku