Original design from GORSK - GO(lang) Restful Starter Kit
Gorsk is a Golang starter kit for developing RESTful services. It is designed to help you kickstart your project, skipping the 'setting-up part' and jumping straight to writing business logic.
- use
gorm
as the ORMgorm
doesn't have the limitations indicated by the author of gorskgorm
allows for use of various different DB's- in this case we use MySQL
- get rid of go-swagger
- it's too complicated to find Open API docs all throughout the codebase comments
- built a new design to organize and compile all Open API doc in
third_party/swaggerui/spec
- Updated the swagger distribution and spec file that were out of date.
- new naming conventions / refactoring
- Account and Team models created and therefore removed Company and Location
- Other packages and directories have been renamed to help ease the understanding of what they are used for
- other minor refactoring and renaming of directories such as moving the swagger distribution from
/assets
to/third_party/swaggerui/dist
- Use CirclCI instead of Travis
- There's no reason to start 10 new docker containers for every test DB test.
- Just use 1 test container and be sure to refresh the DB for every test.
- Removed unused dependencies
- Added React Redux frontend website
PACKAGE | LICENSE |
---|---|
Golang | |
github.com/labstack/echo | MIT |
github.com/jinzhu/gorm | MIT |
github.com/dgrijalva/jwt-go | MIT |
github.com/rs/zerolog | MIT |
github.com/go-playground/validator | MIT |
github.com/nbutton23/zxcvbn-go | MIT |
github.com/stretchr/testify | MIT |
github.com/go-yaml/yaml | Apache |
node.js | |
npmjs.com/package/multi-file-swagger | MIT |
-
Started with the project structure from gorsk
-
trying to maintain golang-standards for project layout
ensure that you have properly setup dependencies
$ make deps
use make to help with development
-
just run make help to see all the automated support with
make
$ make help
-
run
make setup
then after that,make serve
to use swagger to test endpoints. -
or use
curl
to login with bootstrap data$ curl -X POST "http://localhost:8080/login" \ -H "accept: application/json" \ -H "Content-Type: application/json" \ -d "{ \"password\": \"admin\", \"username\": \"admin\"}"
Visit http://localhost:8080/swaggerui/
(with trailing slash) in your browser to test out some endpoints!
- use
make TYPE=yaml swagger
or multi-file-swagger to generate the swagger.yaml
spec file. - more docs on creating a swagger server: https://goswagger.io/use/spec.html#parsing-rules
- this application uses the latest distribution from github.com/swagger-api/swagger-ui
- this repo uses swagger docs file
full_spec.yaml
as an update from the upstream branch
- this repo uses swagger docs file
The application runs as an HTTP server at port 8080. It provides the following RESTful endpoints:
-
POST /login
: accepts username/passwords and returns jwt token and refresh token -
GET /refresh/:token
: refreshes sessions and returns jwt token -
GET /me
: returns info about currently logged in user -
GET /swaggerui/
(with trailing slash): launches swaggerui in browser -
GET /v1/users
: returns list of users -
GET /v1/users/:id
: returns single user -
POST /v1/users
: creates a new user -
PATCH /v1/password/:id
: changes password for a user -
DELETE /v1/users/:id
: deletes a user -
You can log in as admin to the application by sending a post request to localhost:8080/login with username
admin
and passwordadmin
in JSON body. -
When sending the Authorization header use this format:
Authorization: Bearer TOKEN_HASH
Currently licensed under MIT, check the LICENSE file for details.