You've already forked golang-saas-starter-kit
mirror of
https://github.com/raseels-repos/golang-saas-starter-kit.git
synced 2025-06-17 00:17:59 +02:00
fix readme web-api example
This commit is contained in:
22
README.md
22
README.md
@ -302,7 +302,7 @@ For more details on this service, read [web-api readme](https://gitlab.com/geeks
|
|||||||
### Making Requests to Web API
|
### Making Requests to Web API
|
||||||
|
|
||||||
Once the web-api service is running it will be available on port 3000.
|
Once the web-api service is running it will be available on port 3000.
|
||||||
http://127.0.0.1:3000/
|
http://127.0.0.1:3001/
|
||||||
|
|
||||||
The easiest way to make requests to the web-api service is by using CURL via your CLI.
|
The easiest way to make requests to the web-api service is by using CURL via your CLI.
|
||||||
|
|
||||||
@ -318,6 +318,15 @@ web-api service is running, it can be accessed at /docs
|
|||||||
http://127.0.0.1:3001/docs/
|
http://127.0.0.1:3001/docs/
|
||||||
|
|
||||||
|
|
||||||
|
#### Initalize the database.
|
||||||
|
|
||||||
|
The database is created but does not include any schema when first started.
|
||||||
|
```bash
|
||||||
|
cd tools/schema/
|
||||||
|
source sample.env
|
||||||
|
go run main.go
|
||||||
|
```
|
||||||
|
|
||||||
#### Creating Initial User
|
#### Creating Initial User
|
||||||
|
|
||||||
Create an initial user service first using the signup endpoint documented at /docs
|
Create an initial user service first using the signup endpoint documented at /docs
|
||||||
@ -353,7 +362,7 @@ Then click button Execute, which will return the CURL command and execute the ca
|
|||||||
|
|
||||||
Example CURL command:
|
Example CURL command:
|
||||||
```bash
|
```bash
|
||||||
curl -X POST "http://127.0.0.1:3001/v1/signup" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"account\": { \"address1\": \"221 Tatitlek Ave\", \"address2\": \"Box #1832\", \"city\": \"Valdez\", \"country\": \"USA\", \"name\": \"Company 78d335d2-62a3-42a2-beff-148c63a2f5cd\", \"region\": \"AK\", \"timezone\": \"America/Anchorage\", \"zipcode\": \"99686\" }, \"user\": { \"email\": \"51088243-7e60-4cdd-b2c8-395c91b0c738@example.com\", \"name\": \"Gabi May\", \"password\": \"SecretString\", \"password_confirm\": \"SecretString\" }}"
|
curl -X POST "http://127.0.0.1:3001/v1/signup" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"account\": { \"address1\": \"221 Tatitlek Ave\", \"address2\": \"Box #1832\", \"city\": \"Valdez\", \"country\": \"USA\", \"name\": \"Geeks on a Lake\", \"region\": \"AK\", \"timezone\": \"America/Anchorage\", \"zipcode\": \"99686\" }, \"user\": { \"email\": \"twin@example.com\", \"name\": \"Gabi May\", \"password\": \"SecretString\", \"password_confirm\": \"SecretString\" }}"
|
||||||
```
|
```
|
||||||
|
|
||||||
If successful, data should be returned for code 201.
|
If successful, data should be returned for code 201.
|
||||||
@ -367,22 +376,23 @@ Before any authenticated requests can be sent you must acquire an auth token. Ma
|
|||||||
your email and password to get an auth token.
|
your email and password to get an auth token.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ curl --user "admin@example.com:gophers" http://127.0.0.1:3000/v1/users/token
|
curl --user "twin@example.com:SecretString" -X POST http://127.0.0.1:3001/v1/oauth/token
|
||||||
```
|
```
|
||||||
|
|
||||||
It is best to put the resulting token in an environment variable like `$TOKEN`.
|
It is best to put the resulting token in an environment variable like `$TOKEN`.
|
||||||
|
|
||||||
#### Adding Token as Environment Variable
|
#### Adding Token as Environment Variable
|
||||||
|
|
||||||
dfadsf
|
```bash
|
||||||
|
export TOKEN="COPY TOKEN STRING FROM LAST CALL"
|
||||||
|
```
|
||||||
|
|
||||||
#### Authenticated Requests
|
#### Authenticated Requests
|
||||||
|
|
||||||
To make authenticated requests put the token in the `Authorization` header with the `Bearer ` prefix.
|
To make authenticated requests put the token in the `Authorization` header with the `Bearer ` prefix.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ curl -H "Authorization: Bearer ${TOKEN}" http://127.0.0.1:3000/v1/users
|
curl -H "Authorization: Bearer ${TOKEN}" http://127.0.0.1:3001/v1/users
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ one `docker-compose.yaml` file that is shared between all services.
|
|||||||
|
|
||||||
4. Open the Swagger UI.
|
4. Open the Swagger UI.
|
||||||
|
|
||||||
Navigate your browser to [http://localhost:3001/docs](http://localhost:3001/docs).
|
Navigate your browser to [http://127.0.0.1:3001/docs](http://127.0.0.1:3001/docs).
|
||||||
|
|
||||||
5. Signup a new account.
|
5. Signup a new account.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user