Update README with Windows setup and db seeding
This commit is contained in:
parent
fc057e86dd
commit
7fa6fe2b04
30
README.md
30
README.md
@ -10,6 +10,15 @@ sudo -u postgres -i psql
|
||||
postgres=# ALTER DATABASE shopkeeper OWNER TO shopkeeper;
|
||||
\password shopkeeper
|
||||
postgres=# CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
|
||||
# Or, on Windows in PowerShell:
|
||||
|
||||
& 'C:\Program Files\PostgreSQL\13\bin\createuser.exe' -U postgres shopkeeper
|
||||
& 'C:\Program Files\PostgreSQL\13\bin\createdb.exe' -U postgres shopkeeper
|
||||
& 'C:\Program Files\PostgreSQL\13\bin\psql.exe' -U postgres
|
||||
postgres=# ALTER DATABASE shopkeeper OWNER TO shopkeeper;
|
||||
\password shopkeeper
|
||||
postgres=# CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
```
|
||||
3. Save password somewhere safe and then and add a `.env` file to the project
|
||||
directory with the contents:
|
||||
@ -33,6 +42,27 @@ db_name = "shopkeeper"
|
||||
6. Run `./devserver.sh` to run the dev server (by default it listens at
|
||||
`127.0.0.1:3030`).
|
||||
|
||||
# Testing Data
|
||||
|
||||
Using [httpie](https://httpie.org/) you can use the json files in
|
||||
`test_data/` to seed the database with data.
|
||||
|
||||
The `POST` endpoints require an API key. You can just [generate a random
|
||||
uuidv4](https://www.uuidgenerator.net/version4), just make sure to use the
|
||||
same one in all future requests.
|
||||
|
||||
```
|
||||
http POST "http://localhost:3030/v1/owners" @test_data\owner.json api-key:"13e2f39c-033f-442f-b42a-7ad640d2e439"
|
||||
http POST "http://localhost:3030/v1/shops" @test_data\shop.json api-key:"13e2f39c-033f-442f-b42a-7ad640d2e439"
|
||||
http POST "http://localhost:3030/v1/interior_ref_lists" @test_data\interior_ref_list.json api-key:"13e2f39c-033f-442f-b42a-7ad640d2e439"
|
||||
http POST "http://localhost:3030/v1/merchandise_lists" @test_data\merchandise_list.json api-key:"13e2f39c-033f-442f-b42a-7ad640d2e439"
|
||||
# Then, you can test the GET endpoints
|
||||
http GET "http://localhost:3030/v1/owners"
|
||||
http GET "http://localhost:3030/v1/shops"
|
||||
http GET "http://localhost:3030/v1/interior_ref_lists"
|
||||
http GET "http://localhost:3030/v1/merchandise_lists"
|
||||
```
|
||||
|
||||
# Todo
|
||||
|
||||
* Add update endpoints.
|
||||
|
1
devserver.bat
Normal file
1
devserver.bat
Normal file
@ -0,0 +1 @@
|
||||
systemfd --no-pid -s 127.0.0.1:3030 -- cargo watch -x run
|
Loading…
Reference in New Issue
Block a user