# gitlab-issue-status

> get icons for gitlab issue status

Latest version **0.2.2** (published 2018-08-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install gitlab-issue-status
pnpm add gitlab-issue-status
yarn add gitlab-issue-status
bun add gitlab-issue-status
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2018-08-22 |
| First published | 2018-05-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 30.7 KB |
| Known vulnerabilities | 0 (+24 in 1 direct dependencies) |
| Install scripts | no |
| Author | Andreas Offenhaeuser |
| Maintainers | anoff |
| Keywords | gitlab, issue, icon, status |

## Links

- npm: https://www.npmjs.com/package/gitlab-issue-status
- npm.io page: https://npm.io/package/gitlab-issue-status

## Dependencies (3)

- [axios](https://npm.io/package/axios.md) ^0.18.0
- [canvas](https://npm.io/package/canvas.md) ^2.0.0-alpha.12
- [dotenv](https://npm.io/package/dotenv.md) ^5.0.1

## Alternatives

- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) — 2.2M weekly downloads
- [roboto-fontface](https://npm.io/package/roboto-fontface.md) — 196.0K weekly downloads
- [@react-native-vector-icons/common](https://npm.io/package/@react-native-vector-icons/common.md) — 150.4K weekly downloads
- [@procore/core-icons](https://npm.io/package/@procore/core-icons.md) — 4.6K weekly downloads
- [@react-md/material-icons](https://npm.io/package/@react-md/material-icons.md) — 1.6K weekly downloads

## Recent versions

- 0.2.2 (latest) — 2018-08-22
- 0.2.1 — 2018-08-22
- 0.2.0 — 2018-06-07
- 0.1.1 — 2018-05-12

## README

# gitlab-issue-status

> get embeddable status badges for gitlab issues 🦊 🏷

<!-- TOC depthFrom:2 depthTo:4 -->

- [Example](#example)
- [Usage](#usage)
  - [API](#api)
    - [canvas.loadIcons(iconArray)](#canvasloadiconsiconarray)
    - [canvas.createImage(issue, icons)](#canvascreateimageissue-icons)
    - [gitlab.tagToUrl(issueTag, baseUrl)](#gitlabtagtourlissuetag-baseurl)
    - [gitlab.UrlToTag(issueUrl)](#gitlaburltotagissueurl)
    - [gitlab.getIssueStatus(issueUrl, apiToken)](#gitlabgetissuestatusissueurl-apitoken)
  - [Server](#server)
  - [Include in markdown](#include-in-markdown)
  - [Cache policy](#cache-policy)
- [License](#license)

<!-- /TOC -->

## Example

Issue in state _opened_:

`![](http://localhost:8080\?issue\=/group-milestones/something/issues/1)`
![](example2.png)

Issue in state _closed_:

`![](http://localhost:8080\?issue\=group-milestones/something/issues/2)`
![](example1.png)

With added hyperlink:

`[![](http://localhost:8080\?issue\=group-milestones/something/issues/2)](https://gitlab.com/group-milestones/something/issues/2)`
[![](example1.png)](https://gitlab.com/group-milestones/something/issues/2)

Issue with title and larger font size:
`![](http://localhost:8080/?issue=/group-milestones/issues/issues/1)`
![](example3.png)

## Usage

The small server coming with the package can be configured via ENV variables. Otherwise the exposed API can be used to create custom workflows.

> Since `node-canvas` and underlying modules currently have [issues](https://github.com/Automattic/node-canvas/issues/760) with emojis they are loaded as png images into the canvas image.

### API

#### canvas.loadIcons(iconArray)

Load an array of icons for later use in the image creation. Will return a `Promise` resolving to `Object` for use in `canvas.createImage`.

##### iconArray

Type: `Array`

An array of `{key: 'string', path: './icon.png'}` objects specifying an icon name/key and its path to load.

#### canvas.createImage(issue, icons)

##### issue

Type: `Object`

Representation of a GitLab issue including the keys `id`, `title`, `tag`, `labels`, `state`. Best to use `gitlab.getIssue()`

##### icons

Type: `Object`

An object listing different `canvas.image` elements using a specific key. Best to be created using the `canvas.loadIcons()` method.

#### gitlab.tagToUrl(issueTag, baseUrl)

Create a full URL given a GitLab issue tag `project#12` and a baseUrl (e.g. `gitlab.com/api/v4`)

##### issueTag

Type: `string`

A short link for an issue e.g. `group/project#12`

##### baseUrl

Type: `string`

Full API baseUrl of the GitLab server e.g. `https://gitlab.com/api/v4`

#### gitlab.UrlToTag(issueUrl)

Convert a full issue URL to a short tag like `project#12`

##### issueUrl

Type: `string`

Full issue URl e.g. `https://gitlab.com/api/v4/projects/myproject/issues/12`

#### gitlab.getIssueStatus(issueUrl, apiToken)

Fetch isue status from GitLab server.

##### issueUrl

Type: `string`

Full issue URL e.g. `https://gitlab.com/api/v4/projects/myproject/issues/12`

##### apiToken

Type: `string`

Valid API Token for the GitLab instance referred to in `issueUrl`

### Server

The package comes with a default node server bundled that can be started using

```javascript
const gitlabIssues = require('gitlab-issue-status')
gitlabIssues.app(options) // start the server
```

Where options is an `Object` containing any of the following settings:

```javascript
{
  iconArray: [{key: 'opened', path: 'full/path/to/png/resource/with/16by16.png'}], // an array containing icon resources and the key = issue state
  baseUrl: 'https://gitlab.com/api/v4', // base URL of the gitlab server API
  token: 'myPersonalAccessToken', // gitlab token with API rights for above server
  port: 8080, // the port to start the server on
  fontsize: 14, // font size of the first element (title if active, otherwise tag)
  showTitle: true // show title of the issue as well as issue tag
}
```

The following environment variables take precedence over the above options object:

```text
GITLAB_API_URL: overwrites options.baseUrl
GITLAB_ACCESS_KEY: overwrites options.token
PORT
```

### Include in markdown

Having the server deployed with a `GITLAB_ACCESS_KEY` and `GITLAB_API_URL` defined issue badges can be used in markdown with

```md
[![asdf](http://localhost:8080\?issue\=/group/project/issues/5)](http://gitlab-url.com/group/project/issues/5)
```


### Cache policy

By default the images have a cache age of `30 seconds` which should keep load off the server but still offer near _realtime_ updates of issue states.

## License

Licensed under [MIT](LICENSE) by [Andreas Offenhaeuser](https://anoff.io)

---
_Source: https://npm.io/package/gitlab-issue-status · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
