README.md 1.78 KB
Newer Older
1
# Tricoteuses-API-Assemblee
Emmanuel Raviart's avatar
Emmanuel Raviart committed
2

3
## _REST API based on open data of French Assemblée nationale_
Emmanuel Raviart's avatar
Emmanuel Raviart committed
4

Emmanuel Raviart's avatar
Emmanuel Raviart committed
5
This project has **migrated** to https://git.en-root.org/tricoteuses/tricoteuses-api-assemblee.
Emmanuel Raviart's avatar
Emmanuel Raviart committed
6

Emmanuel Raviart's avatar
Emmanuel Raviart committed
7 8 9
## Installation

```bash
10 11
git clone https://framagit.org/tricoteuses/tricoteuses-api-assemblee
cd tricoteuses-api-assemblee/
12 13 14 15 16
```

Create a `.env` file to set PostgreSQL database informations and other configuration variables (you can use `example.env` as a template). Then

```bash
Emmanuel Raviart's avatar
Emmanuel Raviart committed
17 18 19
npm install
```

20 21 22 23 24 25 26 27 28 29 30 31 32
### Database Creation

#### When using _Debian GNU/Linux_

As `root` user:
```bash
apt install postgresql postgresql-contrib

su - postgres
createuser -D -P -R -S assemblee
  Enter password for new role: assemblee
  Enter it again: assemblee
createdb -E utf-8 -O assemblee assemblee
33 34
psql assemblee
CREATE EXTENSION IF NOT EXISTS pg_trgm;
35 36
exit
logout
37 38 39 40 41 42 43 44
```

### Configuration

```bash
npm run configure
```

Emmanuel Raviart's avatar
Emmanuel Raviart committed
45 46
## Usage

47 48 49 50 51 52 53 54 55 56 57 58
### Retrieval & cleaning of open data from Assemblée nationale

_See README file of [Tricoteuses Assemblée](https://framagit.org/tricoteuses/tricoteuses-assemblee) for details._

```bash
npx babel-node --extensions ".ts" -- node_modules/tricoteuses-assemblee/src/scripts/retrieve_open_data.ts ../assemblee-data/
npx babel-node --extensions ".ts" -- node_modules/tricoteuses-assemblee/src/scripts/reorganize_data.ts ../assemblee-data/
npx babel-node --extensions ".ts" -- node_modules/tricoteuses-assemblee/src/scripts/clean_reorganized_data.ts ../assemblee-data/
npx babel-node --extensions ".ts" -- node_modules/tricoteuses-assemblee/src/scripts/retrieve_deputes_photos.ts --fetch ../assemblee-data/
```

### Import of open data files to database
Emmanuel Raviart's avatar
Emmanuel Raviart committed
59 60

```bash
61
npx babel-node --extensions ".ts" -- src/scripts/update_db.ts ../assemblee-data/
Emmanuel Raviart's avatar
Emmanuel Raviart committed
62 63 64 65 66 67 68
```

### Launch development web server

```bash
npm run dev ../assemblee-data/
```