Skip to content

Linesmerrill/police-cad-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Police CAD API

Actions Status codecov

This is as a simple backend API to serve all routes associated with the official Lines Police CAD.

Routes

To view the routes, check our swagger here

Requirements

  1. Go 1.17+ installed. See download and install Go to get started.
  2. Generate jwt token to communicate with front-end web server. See How to Generate a JWT for more details.
  3. Attach the jwt header as an Authorization: Bearer token. See How to attach an Auth Bearer Token for more details.

Run

  1. Duplicate .env.example and rename the new file to .env. Edit to your configurations.
make run

Generate Mocks before committing code

make mocks

Rest Request Examples:

Import our Postman collection here: Postman Collection

Docs

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.

How to Generate a JWT

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:

  1. Password Length: 256
  2. Include Numbers: ✅
  3. Include Lowercase Characters: ✅
  4. Include Uppercase Characters: ✅
  5. Generate On Your Device: ✅
  6. 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.

How to attach an Auth Bearer Token

Attach a header with this JWT created with the 256-bit-secret to your api requests

Example:

Authorization:Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

About

This is as a simple backend API to serve all routes associated with the official Lines Police CAD.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published