Development¶
Prerequisites¶
You need the following libraries and/or programs:
- Python 3.9 or higher
- Python Virtualenv and Pip
- PostgreSQL 9.5 or above
- Node.js
- npm
Getting started¶
Developers can follow the following steps to set up the project on their local development machine.
Obtain source¶
You can retrieve the source code using the following command:
$ git clone git@github.com:VNG-realisatie/documenten-api.git drc
Note: You can also use the HTTPS syntax:
$ git clone https://github.com/VNG-realisatie/documenten-api.git drc
Setting up virtualenv¶
Go to the project directory:
$ cd drc
Create the virtual environment:
$ virtualenv -p /usr/bin/python3.x ./env
Source the activate script in your virtual environment to enable it:
$ source env/bin/activate
Install all the required libraries:
(env) $ pip install -r requirements/dev.txt
Installing the database¶
The default settings for the database are:
- name:
drc
- user:
drc
- password:
drc
You can customize these by setting (any of) the following environment variables:
DB_NAME
DB_USER
DB_PASSWORD
DB_HOST
DB_PORT
- name:
Launch the migration process
(env) $ python src/manage.py migrate
Note
You can put local, machine specific setting changes in
src/drc/conf/local.py
. These settings are NOT checked into version
control.
Running server¶
Create a superuser to access the management interface:
(env) $ python src/manage.py createsuperuser
You can now run your installation and point your browser to the address given by this command:
(env) $ python src/manage.py runserver
Generate the API schema¶
Install Javascript modules:
$ npm install
Launch the schema generation tool:
generate-schema
The resulting
openapi.yaml
andswagger2.0.json
files can be visualized with Swagger
Update installation¶
When updating an existing installation:
Activate the virtual environment:
$ cd drc $ source env/bin/activate
Update the code and libraries:
(env) $ git pull (env) $ pip install -r requirements/dev.txt (env) $ npm install
Update the database:
(env) $ python src/manage.py migrate