This is as a simple backend API to serve all routes associated with the official Lines Police CAD.
To view the routes, check our swagger here
- Go 1.17+ installed. See download and install Go to get started.
- Generate jwt token to communicate with front-end web server. See How to Generate a JWT for more details.
- Attach the jwt header as an
Authorization: Bearer
token. See How to attach an Auth Bearer Token for more details.
- Duplicate
.env.example
and rename the new file to.env
. Edit to your configurations.
make run
make mocks
Import our Postman collection here: Postman Collection
To build the docs run:
make swagger
To run the docs locally:
make serve-swagger
To update the docs navigate to /docs/docs.go
and follow along with the swagger annotations and comments to
document your routes and parameters.
I recommend using https://jwt.io/ to easily generate jwt's for your applications.
Header: (you can leave this the same)
{
"alg": "HS256",
"typ": "JWT"
}
Payload: (you can modify this to be an empty object)
{}
Verify Signature: (generate a 256 random alphanumeric key and paste in here)
We recommend visiting https://passwordsgenerator.net/ and selecting the following:
- Password Length:
256
- Include Numbers: ✅
- Include Lowercase Characters: ✅
- Include Uppercase Characters: ✅
- Generate On Your Device: ✅
- Click Generate and copy the password back into https://jwt.io/
This 256-bit-secret will also be used to decrypt/encrypt the jwt in police-cad-api
environment variables
Encoded: (The encoded JWT you can use to now communicate between the backend and frontend)
Copy and paste this into your environment variables in police-cad
application.
Attach a header with this JWT created with the 256-bit-secret to your api requests
Example:
Authorization:Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c