# facepunch-api

> api from commits.facepunch.com

Latest version **1.2.6** (published 2020-09-26) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install facepunch-api
pnpm add facepunch-api
yarn add facepunch-api
bun add facepunch-api
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.6 |
| Published | 2020-09-26 |
| First published | 2020-09-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Zakhar |
| Maintainers | zakharya |
| Keywords | facepunch, api, commits, node, js |

## Links

- npm: https://www.npmjs.com/package/facepunch-api
- Repository: https://gitlab.com/ZakharYA/facepunch-api
- Homepage: https://gitlab.com/ZakharYA/facepunch-api.git
- Issues: https://gitlab.com/ZakharYA/facepunch-api/-/issues
- npm.io page: https://npm.io/package/facepunch-api

## Dependencies (1)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.2.6 (latest) — 2020-09-26
- 1.2.5 — 2020-09-25
- 1.2.4 — 2020-09-24
- 1.2.3 — 2020-09-24
- 1.2.2 — 2020-09-23
- 1.2.1 — 2020-09-23
- 1.2.0 — 2020-09-23
- 1.1.9 — 2020-09-22
- 1.1.8 — 2020-09-22
- 1.1.7 — 2020-09-21
- 1.1.6 — 2020-09-21
- 1.1.5 — 2020-09-15
- 1.1.4 — 2020-09-12
- 1.1.3 — 2020-09-12
- 1.1.2 — 2020-09-12
- … 12 more at https://npm.io/package/facepunch-api/versions

## README

<div style="text-align: center;"><img src="https://commits.facepunch.com/logo.svg" alt="facepunch logo"></div>
This library allows you to subscribe to commits from [commits](https://commits.facepunch.com)

## Documentation

### NPM
```
npm i facepunch-api
```

## Functions
```js
subscribeToAuthor(author, callback)
```
* **Key:** `author`
	* **Type:** String.
	* **Description:** Name of the author to subscribe to.
* **Key:** `callback`
	* **Type:** Function.
	* **Description:** The function that will be called with the new commit.

```js
subscribeToRepository(repository, callback)
```
* **Key:** `repository`
	* **Type:** String.
	* **Description:** Name of the repository to subscribe to.
* **Key:** `callback`
	* **Type:** Function.
	* **Description:** The function that will be called with the new commit.

```js
subscribeToAuthorRepository(author, repository, callback)
```
* **Key:** `author`
	* **Type:** String.
	* **Description:** Name of the author to subscribe to.
* **Key:** `repository`
	* **Type:** String.
	* **Description:** Name of the repository to subscribe to.
* **Key:** `callback`
	* **Type:** Function.
	* **Description:** The function that will be called with the new commit.

```js
subscribeToAll(callback)
```
* **Key:** `callback`
	* **Type:** Function.
	* **Description:** The function that will be called with the new commit.

```js
throwError(callback)
```
* **Key:** `callback`
	* **Type:** Function.
    * **Description:** Where mistakes will arrive


# Example return in callback function
```json
{
      "id": 372193,
      "repo": "rust_reboot",
      "branch": "main/ai_test_changes/events",
      "changeset": "54530",
      "created": "2020-09-12T10:44:02",
      "message": "wip AI state events & listener.",
      "user": {
        "name": "Adam Woolridge",
        "avatar": "https://files.facepunch.com/s/b8ec968c721a.jpg"
      }
}
```

## Example usage
```js
const _FACEPUNCHAPI = require('facepunch-api');

const facepunchAPI = new _FACEPUNCHAPI(60000); // interval check commits in ms

facepunchAPI.subscribeToAuthor('Garry Newman', (commit) => {
	// Here we subscribe to commits from author Garry Newman
	console.log('Ohh... New commit from Garry!!!', commit);
})

facepunchAPI.subscribeToRepository('sandbox.source', (commit) => {
	// Here we subscribe to the comments on the repository sandbox.source
	console.log('O yes. S&Box released', commit);
})

facepunchAPI.subscribeToAuthorRepository('Garry Newman', 'Fad', (commit) => {
	console.log('fad?? New commit from Garry in rep Fad', commit);
})

facepunchAPI.subscribeToAll((commit) => {
	console.log(`new commit from ${commit.user.name}:`, commit);
})

facepunchAPI.throwError((_err) => {
	console.log('Oh... Site down!');
})
```
<a href="https://www.npmjs.com/package/facepunch-api"><img src="https://img.shields.io/npm/v/facepunch-api.svg?style=flat-square" alt="NPM version"></a>
<a href="https://vk.com/ghost1337gg"><img src="https://brand.vkforms.ru/static/media/logo_color_154.08f6e176.svg" height=20></a>

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