# ng2-hal

> An HAL Navigator for Angular2

Latest version **0.1.2** (published 2016-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install ng2-hal
pnpm add ng2-hal
yarn add ng2-hal
bun add ng2-hal
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2016-08-28 |
| First published | 2016-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 4.2.1 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | David Herges |
| Maintainers | haggis_ |
| Keywords | ng2, angular2, hal, hypermedia, rest, http, json |

## Links

- npm: https://www.npmjs.com/package/ng2-hal
- Repository: https://github.com/dherges/ng2-hal
- Homepage: https://dherges.github.io/ng2-hal
- Issues: https://github.com/dherges/ng2-hal/issues
- npm.io page: https://npm.io/package/ng2-hal

## Dependencies (2)

- [halfred](https://npm.io/package/halfred.md) ^1.0.0
- [uri-templates](https://npm.io/package/uri-templates.md) ^0.2.0

## 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

- 0.1.2 (latest) — 2016-08-28
- 0.1.1 — 2016-08-27
- 0.1.0 — 2016-08-27

## README

ng2-hal
=======

[![Build Status](https://travis-ci.org/dherges/ng2-hal.svg?branch=master)](https://travis-ci.org/dherges/ng2-hal)
[![Dependency Status](https://david-dm.org/dherges/ng2-hal/status.svg)](https://david-dm.org/dherges/ng2-hal)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![npm version](https://img.shields.io/npm/v/ng2-hal.svg)](https://npmjs.org/ng2-hal)
[![npm downloads](https://img.shields.io/npm/dm/ng2-hal.svg)](https://npmjs.org/ng2-hal)


> An HAL Navigator for Angular2


## Usage

```bash
$ npm install ng2-hal
```

Register with Angular's dependency injection:
```ts
import { Navigator, ConversionStrategy, ConversionStrategyJson } from '../../dist';

const MY_PROVIDERS: any[] = [
  new Provider(ConversionStrategy, { useFactory: () => new ConversionStrategyJson() }),
  Navigator
];
```

Please note: you also need Angular's ``Http`` ready for DI. It is required by ``Navigator``.


Navigation example:
```ts
import { Navigator } from 'ng2-hal';

@Injectable()
export class Foo {

  constructor(private navigator: Navigator) {}

  demo() {
    this.navigator
      .get('/my/hal-document.json')
      .subscribe((doc: HalDocument) => console.log(doc));
  }
}
```


## Demo application

[http://spektrakel.de/ng2-hal](http://spektrakel.de/ng2-hal)


## API Design Considerations

``d.ts`` are the API docs.
Please refer to the generated type definitions.


## Reading List

 * HAL - Hypertext Application Language: [specification](http://stateless.co/hal_specification.html)
 * JSON Hypertext Application Language: [draft-kelly-json-hal-08](https://tools.ietf.org/html/draft-kelly-json-hal-08)
 * URI Templates: [RFC 6570](https://tools.ietf.org/html/rfc6570)


## Heads up!

**This is still very much work-in-progress.**

### TODOs

 - [ ] URI templating
 - [ ] ``npm test``: add unit testing
 - [ ] ``Navigator`` API: convenient shortcut for follow-on navigation
   * e.g., ``follow((hal: HalDocument) => Observable<HalDocument>)``
   * currently, ``mergeMap()`` achieves desired behaviour – just an alias?
 - [ ] ``Link`` API: uri templating as instance methods on ``Link``
   * requires: ``Resource`` implementation to map ``Object`` (declares as ts interface ``Link``) to class instances
 - [ ] publish to npm
 - [ ] ``ConversionStrategy``:
   * in later version, it would be nice to chose between ``hal+json`` and ``hal+xml``
   * also: have a multiple strategies registered, then choose the right one dependent on ``Content-Type``
 - [x] ``ConversionStrategy`` API: ``(res: Response) => boolean`` and ``(res: Response) => Resource`` is good
 - [x] ``HalDocument`` API: a tuple of ``(Request, Response, Resource)``?
 - [x] ``npm test``: for now, only build and linting


## Version History

 * ``v0.1.0`` first version on public npm registry


## License

```
Copyright (c) 2016 David Herges

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```


## Credits

 * [basti1302/halfred](https://github.com/basti1302/halfred): resource parsing and normalization for ``application/hal+json``
 * [geraintluff/uri-templates](https://github.com/geraintluff/uri-templates): URI templates according to [RFC6570](https://tools.ietf.org/html/rfc6570)
 * [Daniel Rosenwasser](https://github.com/DanielRosenwasser): for helping out on [TypeScript #10463](https://github.com/Microsoft/TypeScript/issues/10463)
 * [AngularClass/angular2-webpack-starter](https://github.com/AngularClass/angular2-webpack-starter): build tools

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