PostgREST 8.0.0 + PostgreSQL -13.4-1 + Windows10でテスト(2)

PostgREST 8.0.0 + PostgreSQL -13.4-1 + Windows10でテストをするための、PostgREST 8.0.0のインストールと設定と実行
1. PostgRESTのサイト https://postgrest.org/en/v8.0/releases/v8.0.0.html  から左の v8.0.0 を選択 
001.png
2. PostgREST v8.0.0 release page をクリック github に移動
002.png
3. 下に移動
003.png
4. postgrest-v8.0.0-windows-x64.zip をダウンロードします。
004.png
5. 解凍します
005.png
6. postgrest.exe (t がついています) を 
C:\Program Files\PostgreSQL\13\bin に コピーします。
006.png
7. 貼り付け
007.png
8. 対象のフォルダーへのアクセスは拒否されました
このフォルダーへコピーするには管理者の権限が必要です
と 警告されますが、 
続行
を押します。
008.png
9. postgres に t がつくだけなので、見間違えそうになりますが、別のexe です。
postgres.exe
postgrest.exe 
009.png
cd C:\Program Files\PostgreSQL\13\bin
postgrest 
で動作確認できます、
Usage: postgrest [-e|--example] [--dump-config | --dump-schema] FILENAME
  PostgREST 8.0.0 (0bc7c03) / create a REST API to an existing Postgres database
などが表示されていれば、オッケーです。
010.png
11. Tutorial 0 - Get it Running を選択して、サンプルの todos の動作を実行していきます。
011.png
12. PostgREST 8.0.0 + PostgreSQL -13.4-1 + Windows10でテスト(1)と 10.までの作業で、Tutorial 0 - Get it Runningの
Step 1. Relax, we’ll help  (ステップ1.リラックスしてください)
Step 2. Install PostgreSQL (ステップ2.PostgreSQLをインストールします)
Step 3. Install PostgREST  (ステップ3.PostgRESTをインストールします)
まで、終了しています。
012.png
13. Step 4. Create Database for API(ステップ4.API用のデータベースを作成する)から、今回用にデータベースのパスワードのみを変更して、psqlで実行します。
----------------------
create schema api;
----------------------
create table api.todos (
  id serial primary key,
  done boolean not null default false,
  task text not null,
  due timestamptz
);
----------------------
insert into api.todos (task) values
  ('finish tutorial 0'), ('pat self on back');
----------------------
create role web_anon nologin;
----------------------
grant usage on schema api to web_anon;
----------------------
grant select on api.todos to web_anon;
----------------------
***この行を変更***create role authenticator noinherit login password 'mysecretpassword';
----------------------
create role authenticator noinherit login password 'pg13dbPasswd';
----------------------
grant web_anon to authenticator;
----------------------
\q
----------------------
各行の意味は、https://postgrest.org/en/v8.0/tutorials/tut0.html を参照してください。
013.png
14. psql を実行します
Server [localhost]: Enterですすむ
Database [postgres]: Enterですすむ
Port [5432]: Enterですすむ
Username [postgres]: Enterですすむ
Client Encoding [SJIS]: Enterですすむ
ユーザ postgres のパスワード: pg13dbPasswd (画面には表示されません) を入力して、Enterですすむ
psql (13.4)
"help"でヘルプを表示します。
postgres=# が表示されれば、オッケー
014.png
15. 続行するには何かキーを押してください . . .
で Enterを押すと、画面がクローズされます。
015.png
16. Step 5. Run PostgREST (ステップ5.PostgRESTを実行します)
***この行を変更***db-uri = "postgres://authenticator:mysecretpassword@localhost:5433/postgres"
db-uri = "postgres://authenticator:pg13dbPasswd@localhost:5432/postgres"
db-schema = "api"
db-anon-role = "web_anon"
で、tutorial.conf を作成します
016.png
17. メモ帳を管理者として実行します。
017.png
18. 
018.png
19. C:\Program Files\PostgreSQL\13\bin
tutorial.conf
として、保存します。
019.png
20. × で閉じます。
020.png
21. サイトの ./postgrest tutorial.conf は 実行するのがWindowsなので
cd C:\Program Files\PostgreSQL\13\bin
postgrest tutorial.conf
となります。
このアプリの機能のいくつかがwindows defenderファイアウォールでブロックされています
の警告がでるので、
アクセスを許可する
を押します。
021.png
22. 下記のように表示で、起動しています。
C:\Program Files\PostgreSQL\13\bin>postgrest tutorial.conf
25/Aug/2021:18:32:00 +0900: Attempting to connect to the database...
25/Aug/2021:18:32:00 +0900: Connection successful
25/Aug/2021:18:32:00 +0900: Listening on port 3000
25/Aug/2021:18:32:00 +0900: Config re-loaded
25/Aug/2021:18:32:00 +0900: Listening for notifications on the pgrst channel
25/Aug/2021:18:32:00 +0900: Schema cache loaded
022.png
23. サイトの curl http://localhost:3000/todos
は、ブラウザで
http://localhost:3000/todos と入力して、確認します。
正しく、jsonが返されています。
[{"id":1,"done":false,"task":"finish tutorial 0","due":null}, 
 {"id":2,"done":false,"task":"pat self on back","due":null}]
023.png

実行時のエラー
portが違うと
err_001_R8_023_pg13_Step5_5433err.png
tutorial.conf の文字コードが違うと
err_002.png
のような、エラーとなりました。

サイトのインストール方法のscoopなとで、