README.md 1.69 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 5 6 7

## Installation

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

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
15 16 17
npm install
```

18 19 20 21 22 23 24 25 26 27 28 29 30
### 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
31 32
psql assemblee
CREATE EXTENSION IF NOT EXISTS pg_trgm;
33 34
exit
logout
35 36 37 38 39 40 41 42
```

### Configuration

```bash
npm run configure
```

Emmanuel Raviart's avatar
Emmanuel Raviart committed
43 44
## Usage

45 46 47 48 49 50 51 52 53 54 55 56
### 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
57 58

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

### Launch development web server

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