purest

module
v0.0.0-...-0ea6ada Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2020 License: MIT

README

puREST

Golang REST API boilerplate with authentication using PASETO tokens, RBAC authorization, PostgreSQL and Swagger for API docs

This project is WiP!

Go

1. (Re)Generate Swagger docs

See Swaggo example for net/http

Then run the following command after any API changes: swag init --dir . -g cmd/server/main.go


2. Specify the app env at runtime
  • Bash: PUREST_ENV=test go run main.go

  • Fish: env PUREST_ENV=test go run main.go

For all supported values for PUREST_ENV see the suffix of .env.<env> files: development (default), test and production.

3. Run

Create PostgreSQL database and user:

CREATE USER purest_user WITH ENCRYPTED PASSWORD 'purest_pass';
CREATE DATABASE purest_db;
GRANT ALL PRIVILEGES ON DATABASE purest_db TO purest_user;

Run it:

go run cmd/server/main.go

or build it and then run it:

go build -o puREST ./cmd/server/main.go
./puREST

The built-in Swagger UI can be accessed at: http://localhost:8000/swagger/

Directories

Path Synopsis
cmd
internal
env

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL