# legi

> API NodeJS pour requêter les textes de loi issus d'une base legi.py

Latest version **2.0.0** (published 2019-01-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install legi
pnpm add legi
yarn add legi
bun add legi
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-01-17 |
| First published | 2018-03-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 42 |
| Unpacked size | 21.8 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Julien Bouquillon |
| Maintainers | revolunet |

## Links

- npm: https://www.npmjs.com/package/legi
- Repository: https://github.com/revolunet/legi.js
- Homepage: https://revolunet.github.io/legi.js/
- Issues: https://github.com/revolunet/legi.js/issues
- npm.io page: https://npm.io/package/legi

## Dependencies (42)

- [pg](https://npm.io/package/pg.md) ^7.4.1
- [ora](https://npm.io/package/ora.md) ^2.0.0
- [knex](https://npm.io/package/knex.md) ^0.16.3
- [leven](https://npm.io/package/leven.md) ^2.1.0
- [eslint](https://npm.io/package/eslint.md) ^4.18.2
- [remark](https://npm.io/package/remark.md) ^9.0.0
- [unified](https://npm.io/package/unified.md) ^6.1.6
- [flow-bin](https://npm.io/package/flow-bin.md) ^0.66.0
- [prettier](https://npm.io/package/prettier.md) 1.11.1
- [lexis-count](https://npm.io/package/lexis-count.md) ^1.0.3
- [ora-promise](https://npm.io/package/ora-promise.md) ^1.0.0
- [fast-memoize](https://npm.io/package/fast-memoize.md) ^2.3.0
- [html-to-text](https://npm.io/package/html-to-text.md) ^4.0.0
- [lodash.words](https://npm.io/package/lodash.words.md) ^4.2.0
- [rehype-parse](https://npm.io/package/rehype-parse.md) ^4.1.0
- [remark-parse](https://npm.io/package/remark-parse.md) ^5.0.0
- [rehype-remark](https://npm.io/package/rehype-remark.md) ^3.0.0
- [remark-rehype](https://npm.io/package/remark-rehype.md) ^3.0.0
- [remove-accents](https://npm.io/package/remove-accents.md) ^0.4.2
- [unist-util-map](https://npm.io/package/unist-util-map.md) ^1.0.3
- [rehype-document](https://npm.io/package/rehype-document.md) ^2.0.1
- [unist-util-find](https://npm.io/package/unist-util-find.md) ^1.0.1
- [rehype-stringify](https://npm.io/package/rehype-stringify.md) ^3.0.0
- [remark-stringify](https://npm.io/package/remark-stringify.md) ^5.0.0
- [hast-util-to-html](https://npm.io/package/hast-util-to-html.md) ^3.1.0
- [humanize-duration](https://npm.io/package/humanize-duration.md) ^3.12.1
- [remark-strip-html](https://npm.io/package/remark-strip-html.md) ^1.0.0
- [string-similarity](https://npm.io/package/string-similarity.md) ^1.2.0
- [unist-util-filter](https://npm.io/package/unist-util-filter.md) ^0.2.1
- [unist-util-remove](https://npm.io/package/unist-util-remove.md) ^1.0.1
- [unist-util-select](https://npm.io/package/unist-util-select.md) ^2.0.0
- [unist-util-flatmap](https://npm.io/package/unist-util-flatmap.md) ^1.0.0
- [unist-util-parents](https://npm.io/package/unist-util-parents.md) ^1.0.1
- [condense-whitespace](https://npm.io/package/condense-whitespace.md) ^1.0.0
- [prettier-eslint-cli](https://npm.io/package/prettier-eslint-cli.md) ^4.7.1
- [promise-serial-exec](https://npm.io/package/promise-serial-exec.md) ^1.0.0
- [eslint-config-google](https://npm.io/package/eslint-config-google.md) ^0.9.1
- [eslint-config-prettier](https://npm.io/package/eslint-config-prettier.md) ^2.9.0
- [eslint-plugin-prettier](https://npm.io/package/eslint-plugin-prettier.md) ^2.6.0
- [rehype-minify-whitespace](https://npm.io/package/rehype-minify-whitespace.md) ^2.0.3
- [unist-util-visit-parents](https://npm.io/package/unist-util-visit-parents.md) ^2.0.1
- [unist-util-modify-children](https://npm.io/package/unist-util-modify-children.md) ^1.1.1

## Recent versions

- 2.0.0 (latest) — 2019-01-17
- 1.3.0 — 2019-01-06
- 1.2.0 — 2018-06-26
- 1.1.3 — 2018-03-15
- 1.1.2 — 2018-03-15
- 1.1.1 — 2018-03-15
- 1.1.0 — 2018-03-14
- 1.0.0 — 2018-03-10

## README

# legi.js [![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)

[![npm](https://img.shields.io/npm/v/legi.svg)](https://www.npmjs.com/package/legi)
![license](https://img.shields.io/npm/l/legi.svg)
[![github-issues](https://img.shields.io/github/issues/revolunet/legi.js.svg)](https://github.com/revolunet/legi.js/issues)

![nodei.co](https://nodei.co/npm/legi.png?downloads=true&downloadRank=true&stars=true)

Une API NodeJS pour requêter les textes de loi bruts issus d'une base [legi.py](https://github.com/Legilibre/legi.py)

Utilise [knex](https://github.com/tgriesser/knex/) pour exploiter les données d'une base PostgreSQL avec [legi-postgres](https://github.com/Legilibre/legi-postgres) et le standard [unist](https://github.com/syntax-tree/unist) pour représenter les textes sous forme d'arbre, de HTML, ou de markdown.

Par défaut l'API utilisateur utilise un serveur de dev public pour fournir les textes.

Vous pouvez utiliser votre propre base de données en montnt votre serveur PostgreSQL avec [legi-postgres](https://github.com/legilibre/legi-postgres)

## Install

```sh
npm install legi
```

## Usage

Promise-based API

```js
const Legi = require("legi");

const legi = new Legi();

// liste des codes disponibles
legi.getCodesList().then(console.log);

// code du travail (~1min)
legi.getCode({ cid: "LEGITEXT000006072050", date: "2012-03-05" }).then(console.log);

// section d'un texte
legi.getSection({ id: "LEGISCTA000006132321", date: "2018-05-03" }).then(console.log);

// conversion en markdown
const markdown = require("legi/src/markdown");
legi
  .getCode({ cid: "LEGITEXT000006069414", date: "2012-03-05" })
  .then(markdown)
  .then(console.log);

// conversion en html
const html = require("legi/src/html");
legi
  .getCode({ cid: "LEGITEXT000006069414", date: "2012-03-05" })
  .then(html)
  .then(console.log);
```

Pour utiliser votre propres serveur PostgreSQL :

```
const legi = new Legi({
  client: "pg",
  connection: {
    host: "127.0.0.1",
    port: 5432,
    user: "user",
    password: "pass",
    database: "legi"
  },
  pool: { min: 0, max: 50 }
});
```

Plus d'exemples dans [./examples](./examples)

### A propos

- [legi.py](https://github.com/Legilibre/legi.py) est un module python qui génère une base sqlite à partir de la base LEGI, normalise et consolide les données.

- [legi-postgres](https://github.com/Legilibre/legi-postgres) convertit cette base dans une base PostgreSQL.

- [legi.js](https://github.com/revolunet/legi.js) permet d'interroger cette base avec une API JavaScript.

## Todo

- versions et liens dans getArticle

### Related

- https://github.com/Legilibre/legi.py
- https://github.com/Legilibre/Archeo-Lex
- https://github.com/Legilibre/legi-php
- https://github.com/Legilibre/legi-postgres

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