fix naming in prod
This commit is contained in:
@@ -68,7 +68,7 @@ PORT=:9999 JWT_SECRET=change-me RESET_INTERVAL=10m go run ./cmd/api
|
|||||||
## Auth workflow
|
## Auth workflow
|
||||||
|
|
||||||
Use curl or PowerShell.
|
Use curl or PowerShell.
|
||||||
If using the website hosted api, replace localhost:8080 with https://go-api.poc.fló.fo
|
If using the website hosted api, replace localhost:8080 with https://abuse-registration-api.poc.fló.fo
|
||||||
Reader with curl:
|
Reader with curl:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
+9
-9
@@ -5,8 +5,8 @@ vars:
|
|||||||
PKG: main
|
PKG: main
|
||||||
BINARY_DIR: ./bin
|
BINARY_DIR: ./bin
|
||||||
DEV_BINARY_DIR: ./local
|
DEV_BINARY_DIR: ./local
|
||||||
BINARY_API: "{{.BINARY_DIR}}/go-api"
|
BINARY_API: "{{.BINARY_DIR}}/abuse-registration-api"
|
||||||
DEV_BINARY_API: "{{.DEV_BINARY_DIR}}/go-api/"
|
DEV_BINARY_API: "{{.DEV_BINARY_DIR}}/abuse-registration-api/"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
@@ -27,10 +27,10 @@ tasks:
|
|||||||
desc: build api, stage files, and deploy api to remote server
|
desc: build api, stage files, and deploy api to remote server
|
||||||
deps: [build]
|
deps: [build]
|
||||||
cmds:
|
cmds:
|
||||||
- ssh {{.SERVER}} "rm -rf /tmp/go-api-deploy && mkdir -p /tmp/go-api-deploy"
|
- ssh {{.SERVER}} "rm -rf /tmp/abuse-registration-api-deploy && mkdir -p /tmp/abuse-registration-api-deploy"
|
||||||
- rsync -avz --delete {{.BINARY_API}} {{.SERVER}}:/tmp/go-api-deploy/
|
- rsync -avz --delete {{.BINARY_API}} {{.SERVER}}:/tmp/abuse-registration-api-deploy/
|
||||||
- ssh -t {{.SERVER}} "sudo rsync -a --delete --exclude='.env' --exclude='config.json' --exclude='data/' --chown=go-api:go-api /tmp/go-api-deploy/ /opt/go-api/ && sudo systemctl restart go-api"
|
- ssh -t {{.SERVER}} "sudo rsync -a --delete --exclude='.env' --exclude='config.json' --exclude='data/' --chown=abuse-registration-api:abuse-registration-api /tmp/abuse-registration-api-deploy/ /opt/abuse-registration-api/ && sudo systemctl restart abuse-registration-api"
|
||||||
- ssh {{.SERVER}} "rm -rf /tmp/go-api-deploy"
|
- ssh {{.SERVER}} "rm -rf /tmp/abuse-registration-api-deploy"
|
||||||
|
|
||||||
dev-build:
|
dev-build:
|
||||||
desc: runs DEV for vet, fmt, and build DEV api
|
desc: runs DEV for vet, fmt, and build DEV api
|
||||||
@@ -41,7 +41,7 @@ tasks:
|
|||||||
cmds:
|
cmds:
|
||||||
- go tool task dev-clean-api
|
- go tool task dev-clean-api
|
||||||
- mkdir -p {{.DEV_BINARY_API}}
|
- mkdir -p {{.DEV_BINARY_API}}
|
||||||
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o {{.DEV_BINARY_API}}/go-api ./cmd/api
|
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o {{.DEV_BINARY_API}}/abuse-registration-api ./cmd/api
|
||||||
|
|
||||||
dev-start-api:
|
dev-start-api:
|
||||||
desc: build api, create dirs, and start DEV api binary
|
desc: build api, create dirs, and start DEV api binary
|
||||||
@@ -49,7 +49,7 @@ tasks:
|
|||||||
cmds:
|
cmds:
|
||||||
- "rm -rf *"
|
- "rm -rf *"
|
||||||
- go tool task dev-build-api
|
- go tool task dev-build-api
|
||||||
- "./go-api"
|
- "./abuse-registration-api"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
desc: run the POC API locally on :8080 by default
|
desc: run the POC API locally on :8080 by default
|
||||||
@@ -77,4 +77,4 @@ tasks:
|
|||||||
|
|
||||||
dev-clean-api:
|
dev-clean-api:
|
||||||
cmds:
|
cmds:
|
||||||
- rm -f {{.DEV_BINARY_API}}/go-api
|
- rm -f {{.DEV_BINARY_API}}/abuse-registration-api
|
||||||
|
|||||||
@@ -67,44 +67,44 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<div class="workflow-content">
|
<div class="workflow-content">
|
||||||
<h3>Reader user examples</h3>
|
<h3>Reader user examples</h3>
|
||||||
<pre><code>READER_TOKEN=$(curl -s -X POST https://go-api.poc.fló.fo/login \
|
<pre><code>READER_TOKEN=$(curl -s -X POST https://abuse-registration-api.poc.fló.fo/login \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d '{"user_name":"reader","password":"reader-password"}' \
|
-d '{"user_name":"reader","password":"reader-password"}' \
|
||||||
| sed -n 's/.*"token":"\([^"]*\)".*/\1/p')
|
| sed -n 's/.*"token":"\([^"]*\)".*/\1/p')
|
||||||
|
|
||||||
curl -s 'https://go-api.poc.fló.fo/api/v1/registrations?location=Tórshavn&limit=5' \
|
curl -s 'https://abuse-registration-api.poc.fló.fo/api/v1/registrations?location=Tórshavn&limit=5' \
|
||||||
-H "Authorization: $READER_TOKEN" | jq
|
-H "Authorization: $READER_TOKEN" | jq
|
||||||
|
|
||||||
curl -s 'https://go-api.poc.fló.fo/api/v1/registrations?gender=female&abuse_type=psychological&status=open&limit=10' \
|
curl -s 'https://abuse-registration-api.poc.fló.fo/api/v1/registrations?gender=female&abuse_type=psychological&status=open&limit=10' \
|
||||||
-H "Authorization: $READER_TOKEN" | jq
|
-H "Authorization: $READER_TOKEN" | jq
|
||||||
|
|
||||||
curl -s 'https://go-api.poc.fló.fo/api/v1/registrations?from=1989-01-01&to=1990-01-01&offset=20&limit=10' \
|
curl -s 'https://abuse-registration-api.poc.fló.fo/api/v1/registrations?from=1989-01-01&to=1990-01-01&offset=20&limit=10' \
|
||||||
-H "Authorization: $READER_TOKEN" | jq
|
-H "Authorization: $READER_TOKEN" | jq
|
||||||
|
|
||||||
curl -s 'https://go-api.poc.fló.fo/api/v1/locations' \
|
curl -s 'https://abuse-registration-api.poc.fló.fo/api/v1/locations' \
|
||||||
-H "Authorization: $READER_TOKEN" | jq</code></pre>
|
-H "Authorization: $READER_TOKEN" | jq</code></pre>
|
||||||
|
|
||||||
<h3>CRUD user — create, update, and delete examples</h3>
|
<h3>CRUD user — create, update, and delete examples</h3>
|
||||||
<pre><code>ADMIN_TOKEN=$(curl -s -X POST https://go-api.poc.fló.fo/login \
|
<pre><code>ADMIN_TOKEN=$(curl -s -X POST https://abuse-registration-api.poc.fló.fo/login \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d '{"user_name":"admin","password":"admin-password"}' \
|
-d '{"user_name":"admin","password":"admin-password"}' \
|
||||||
| sed -n 's/.*"token":"\([^"]*\)".*/\1/p')
|
| sed -n 's/.*"token":"\([^"]*\)".*/\1/p')
|
||||||
|
|
||||||
CREATED_ID=$(curl -s -X POST https://go-api.poc.fló.fo/api/v1/registrations \
|
CREATED_ID=$(curl -s -X POST https://abuse-registration-api.poc.fló.fo/api/v1/registrations \
|
||||||
-H "Authorization: $ADMIN_TOKEN" \
|
-H "Authorization: $ADMIN_TOKEN" \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d '{"gender":"unknown","location":"Tórshavn","abuse_type":"psychological","status":"new"}' \
|
-d '{"gender":"unknown","location":"Tórshavn","abuse_type":"psychological","status":"new"}' \
|
||||||
| sed -n 's/.*"id":"\([^"]*\)".*/\1/p')
|
| sed -n 's/.*"id":"\([^"]*\)".*/\1/p')
|
||||||
|
|
||||||
curl -s "https://go-api.poc.fló.fo/api/v1/registrations/$CREATED_ID" \
|
curl -s "https://abuse-registration-api.poc.fló.fo/api/v1/registrations/$CREATED_ID" \
|
||||||
-H "Authorization: $ADMIN_TOKEN"
|
-H "Authorization: $ADMIN_TOKEN"
|
||||||
|
|
||||||
curl -s -X PUT "https://go-api.poc.fló.fo/api/v1/registrations/$CREATED_ID" \
|
curl -s -X PUT "https://abuse-registration-api.poc.fló.fo/api/v1/registrations/$CREATED_ID" \
|
||||||
-H "Authorization: $ADMIN_TOKEN" \
|
-H "Authorization: $ADMIN_TOKEN" \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d '{"gender":"female","location":"Skopun","abuse_type":"digital","status":"referred"}'
|
-d '{"gender":"female","location":"Skopun","abuse_type":"digital","status":"referred"}'
|
||||||
|
|
||||||
curl -s -X DELETE "https://go-api.poc.fló.fo/api/v1/registrations/$CREATED_ID" \
|
curl -s -X DELETE "https://abuse-registration-api.poc.fló.fo/api/v1/registrations/$CREATED_ID" \
|
||||||
-H "Authorization: $ADMIN_TOKEN"</code></pre>
|
-H "Authorization: $ADMIN_TOKEN"</code></pre>
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
@@ -117,32 +117,32 @@ curl -s -X DELETE "https://go-api.poc.fló.fo/api/v1/registrations/$CREATED_ID"
|
|||||||
<h3>Reader user examples</h3>
|
<h3>Reader user examples</h3>
|
||||||
<pre><code>$reader = Invoke-RestMethod `
|
<pre><code>$reader = Invoke-RestMethod `
|
||||||
-Method Post `
|
-Method Post `
|
||||||
-Uri "https://go-api.poc.fló.fo/login" `
|
-Uri "https://abuse-registration-api.poc.fló.fo/login" `
|
||||||
-ContentType "application/json" `
|
-ContentType "application/json" `
|
||||||
-Body '{"user_name":"reader","password":"reader-password"}'
|
-Body '{"user_name":"reader","password":"reader-password"}'
|
||||||
|
|
||||||
$READER_TOKEN = $reader.token
|
$READER_TOKEN = $reader.token
|
||||||
|
|
||||||
Invoke-RestMethod `
|
Invoke-RestMethod `
|
||||||
-Uri "https://go-api.poc.fló.fo/api/v1/registrations?location=Tórshavn&limit=5" `
|
-Uri "https://abuse-registration-api.poc.fló.fo/api/v1/registrations?location=Tórshavn&limit=5" `
|
||||||
-Headers @{Authorization=$READER_TOKEN}
|
-Headers @{Authorization=$READER_TOKEN}
|
||||||
|
|
||||||
Invoke-RestMethod `
|
Invoke-RestMethod `
|
||||||
-Uri "https://go-api.poc.fló.fo/api/v1/registrations?gender=female&abuse_type=psychological&status=open&limit=10" `
|
-Uri "https://abuse-registration-api.poc.fló.fo/api/v1/registrations?gender=female&abuse_type=psychological&status=open&limit=10" `
|
||||||
-Headers @{Authorization=$READER_TOKEN}
|
-Headers @{Authorization=$READER_TOKEN}
|
||||||
|
|
||||||
Invoke-RestMethod `
|
Invoke-RestMethod `
|
||||||
-Uri "https://go-api.poc.fló.fo/api/v1/registrations?from=1989-01-01&to=1990-01-01&offset=20&limit=10" `
|
-Uri "https://abuse-registration-api.poc.fló.fo/api/v1/registrations?from=1989-01-01&to=1990-01-01&offset=20&limit=10" `
|
||||||
-Headers @{Authorization=$READER_TOKEN}
|
-Headers @{Authorization=$READER_TOKEN}
|
||||||
|
|
||||||
Invoke-RestMethod `
|
Invoke-RestMethod `
|
||||||
-Uri "https://go-api.poc.fló.fo/api/v1/locations" `
|
-Uri "https://abuse-registration-api.poc.fló.fo/api/v1/locations" `
|
||||||
-Headers @{Authorization=$READER_TOKEN}</code></pre>
|
-Headers @{Authorization=$READER_TOKEN}</code></pre>
|
||||||
|
|
||||||
<h3>CRUD user — create, update, and delete examples</h3>
|
<h3>CRUD user — create, update, and delete examples</h3>
|
||||||
<pre><code>$admin = Invoke-RestMethod `
|
<pre><code>$admin = Invoke-RestMethod `
|
||||||
-Method Post `
|
-Method Post `
|
||||||
-Uri "https://go-api.poc.fló.fo/login" `
|
-Uri "https://abuse-registration-api.poc.fló.fo/login" `
|
||||||
-ContentType "application/json" `
|
-ContentType "application/json" `
|
||||||
-Body '{"user_name":"admin","password":"admin-password"}'
|
-Body '{"user_name":"admin","password":"admin-password"}'
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ $ADMIN_TOKEN = $admin.token
|
|||||||
|
|
||||||
$created = Invoke-RestMethod `
|
$created = Invoke-RestMethod `
|
||||||
-Method Post `
|
-Method Post `
|
||||||
-Uri "https://go-api.poc.fló.fo/api/v1/registrations" `
|
-Uri "https://abuse-registration-api.poc.fló.fo/api/v1/registrations" `
|
||||||
-Headers @{Authorization=$ADMIN_TOKEN} `
|
-Headers @{Authorization=$ADMIN_TOKEN} `
|
||||||
-ContentType "application/json" `
|
-ContentType "application/json" `
|
||||||
-Body '{"gender":"unknown","location":"Tórshavn","abuse_type":"psychological","status":"new"}'
|
-Body '{"gender":"unknown","location":"Tórshavn","abuse_type":"psychological","status":"new"}'
|
||||||
@@ -159,14 +159,14 @@ $CREATED_ID = $created.id
|
|||||||
|
|
||||||
Invoke-RestMethod `
|
Invoke-RestMethod `
|
||||||
-Method Put `
|
-Method Put `
|
||||||
-Uri "https://go-api.poc.fló.fo/api/v1/registrations/$CREATED_ID" `
|
-Uri "https://abuse-registration-api.poc.fló.fo/api/v1/registrations/$CREATED_ID" `
|
||||||
-Headers @{Authorization=$ADMIN_TOKEN} `
|
-Headers @{Authorization=$ADMIN_TOKEN} `
|
||||||
-ContentType "application/json" `
|
-ContentType "application/json" `
|
||||||
-Body '{"gender":"female","location":"Skopun","abuse_type":"digital","status":"referred"}'
|
-Body '{"gender":"female","location":"Skopun","abuse_type":"digital","status":"referred"}'
|
||||||
|
|
||||||
Invoke-RestMethod `
|
Invoke-RestMethod `
|
||||||
-Method Delete `
|
-Method Delete `
|
||||||
-Uri "https://go-api.poc.fló.fo/api/v1/registrations/$CREATED_ID" `
|
-Uri "https://abuse-registration-api.poc.fló.fo/api/v1/registrations/$CREATED_ID" `
|
||||||
-Headers @{Authorization=$ADMIN_TOKEN}</code></pre>
|
-Headers @{Authorization=$ADMIN_TOKEN}</code></pre>
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
|
|||||||
Reference in New Issue
Block a user