Commit 14c695bb authored by Knut Behrends's avatar Knut Behrends
Browse files

fix formatting in USAGE.md

parent d9fc6419
......@@ -5,42 +5,45 @@ See also [README.md](README.md).
## Setup
### Configfile
Take a look at file `src./config.js`.
### baseURL
#### baseURL
Update the value for `baseURL` by setting it to the URL of your mDIS that you want to fill with fake-data.
### Credentials
#### Credentials
Login via the web interface once.
After successfull login, use the Browser's developer tools (F11 or CTRL+Shift+I) to find the value of the `Authorization` header for your login.
This will look like this:
This will look like this:
`Authorization: "Bearer eQv809NUzP4447eD3Ws4dBwCOFvf0E8I`
Copy the value after `Bearer`.
Here you need `eQv809NUzP4447eD3Ws4dBwCOFvf0E8I`.
Here you would need `eQv809NUzP4447eD3Ws4dBwCOFvf0E8I`.
Enter this into line 1 of config.js, or export it as a shell environment variable `token`:
Enter this into line 1 of `src/config.js`, or export it as a shell environment variable `token`:
`export token=eQv809NUzP4447eD3Ws4dBwCOFvf0E8I`.
## USAGE
Written in Javascript for the Node Platform v14+
You must use node v14 because the JS code internaly uses the `?.` 'optional chaining' operator as a shortcut for definedness of nested object properties.
Written in Javascript for the Node Platform v14+. You *must* use node v14+, because the JS code internally uses the `?.` 'optional chaining' operator as a shortcut for definedness of nested object properties.
First, look at the `bin/` subdirectory to execute Shell scripts, or enter the `src/`subdirectory to execute Node scripts.
First, look at the `bin/` subdirectory to execute Shell scripts, or enter the `src/` subdirectory to execute Node scripts.
For regular usage, call the scripts from the parent directory.
### Debugging
To enable debugging with the Chrome Developer Tools, open any shellscript `bin/api_caller*.sh`, comment out the line
To enable debugging with the Chrome Developer Tools in the shell scripts: Open any shellscript `bin/api_caller*.sh`, comment out the line
`node src/expedition-inserter.js 1;`
and uncomment line
`#node --inspect-brk --inspect ../src/expedition-inserter.js 1;`
To debug with `.js` files directly, call the node binary on the command line.
### Inserting fake data
#### Inserting a Fake Program
......@@ -68,13 +71,13 @@ The script does not take arguments.
Do not change the line
`num_sites=1` if you want to add more than 1 site.
Instead, you must change file `src/site-inserter.js`.
Instead, you must change file `src/site-inserter.js`.
Change the lines
`let num_sites_to_insert = 1` and
`let expedition_id = 6`
accordingly, if you want to add any sites to that expedition.
You can get the expedition id from the expedition form or from an SQL query.
You can get the expedition id from the expedition form or from an SQL query.
#### Inserting a Fake Hole
......@@ -199,7 +202,7 @@ Expected outputs:
Core was _not_ split before:
```
```json
#############################################################
Core 226: Created A- and W- splits for 4 sections
#############################################################
......@@ -242,7 +245,7 @@ Then add the new science team to the table of scientists:
Part of the response:
```
```json
{
'11': '{"expedition_id":12,"first_name":"Elissa","last_name":"Johnston","title":"Product Paradigm Agent","institute":"TU-Potsdam","department":"Sports","street":"Hal Summit Straße 8","city":"Potsdam","zip":"14496","state":"-","country":"Germany","email":"Johnston@tu-potsdam.de","phone":"1-780-138-4107 x28919","full_name":"Elissa Johnston"}'
}
......@@ -260,13 +263,13 @@ Created fake scientists from undefined entries in file scientists-hole-20-enty.j
Fake Samples for a hole can only be added, if splits, scientists, requests for that hole exist.
```
```sh
node src/sample-inserter.js -h 12
```
When not all preconditions are met:
```
```sh
/api/v1/form?name=expedition&filter[id]=12
/api/v1/form?name=split&per-page=-1&page=1&sort=id&filter[type]=[^A]&filter[expedition_id]=12
/api/v1/form?name=scientists&per-page=-1&page=1&sort=city&filter[expedition_id]=12
......@@ -342,11 +345,11 @@ Example.
Response for a user that has an expired token, and not enough privileges to add new data.
```
```sh
node src/split-inserter.js -c 118
```
```
```sh
/api/v1/form?name=split&per-page=-1&page=1&sort=section&filter[core_id]=118
Unauthorized
Your request was made with invalid credentials.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment