cerebrum

module
v0.0.0-...-2a11bd6 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2021 License: MIT

README

Cerebrum

CircleCI codecov Go Report Card Maintainability

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.

Updates from GORSK:
  • use gorm as the ORM
    • gorm doesn't have the limitations indicated by the author of gorsk
    • gorm 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

Dependencies

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

Project Structure

Development

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\"}"
    

Swagger

Visit http://localhost:8080/swaggerui/ (with trailing slash) in your browser to test out some endpoints!

Endpoints

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 password admin in JSON body.

  • When sending the Authorization header use this format: Authorization: Bearer TOKEN_HASH

License

Currently licensed under MIT, check the LICENSE file for details.

Author

David John Coleman II Initial Commit by GORSK

Directories

Path Synopsis
cmd
api
Package main is the entry point to start the cerebrum server
Package main is the entry point to start the cerebrum server
pkg
api
Package api contains all methodology for interacting with the persistence layer API Docs for CEREBRUM v1 Consumes: - application/json Produces: - application/json Security: - ApiKeyAuth: [] SecurityDefinitions: ApiKeyAuth: type: apiKey name: Authorization in: header
Package api contains all methodology for interacting with the persistence layer API Docs for CEREBRUM v1 Consumes: - application/json Produces: - application/json Security: - ApiKeyAuth: [] SecurityDefinitions: ApiKeyAuth: type: apiKey name: Authorization in: header
api/auth
Package auth is a service for authenticating http requets
Package auth is a service for authenticating http requets
api/auth/transport
Package transport contians HTTP service for authentication
Package transport contians HTTP service for authentication
api/password
Package password contains the service that handles passwords
Package password contains the service that handles passwords
api/store
Package store contains the components necessary for api services to interact with the database
Package store contains the components necessary for api services to interact with the database
api/user
Package user contains the service for user interactions
Package user contains the service for user interactions
api/user/transport
Package transport contains the HTTP service for user interactions
Package transport contains the HTTP service for user interactions
utl/config
Package config is used for loading the environmental configurations
Package config is used for loading the environmental configurations
utl/datastore
Package datastore creates an ORM connection to the databse and persistence layer
Package datastore creates an ORM connection to the databse and persistence layer
utl/middleware/jsonwebtoken
Package jsonwebtoken contains logic for using JSON web tokens
Package jsonwebtoken contains logic for using JSON web tokens
utl/middleware/secure
Package secure contains some of the security features of the application
Package secure contains some of the security features of the application
utl/mock
Package mock contains logic to mock various components of the application
Package mock contains logic to mock various components of the application
utl/mock/mockstore
Package mockstore is used for testing purposes to mock the store package and mock a mysql db through a docker container of mysql
Package mockstore is used for testing purposes to mock the store package and mock a mysql db through a docker container of mysql
utl/models
Package models contains all the models for the application
Package models contains all the models for the application
utl/query
Package query contains support functions for making db queries
Package query contains support functions for making db queries
utl/rbac
Package rbac Role Based Access Control
Package rbac Role Based Access Control
utl/secure
Package secure contains support for application security
Package secure contains support for application security
utl/server
Package server contains support for the HTTP server used for the API
Package server contains support for the HTTP server used for the API
utl/structs
Package structs is for working with structs
Package structs is for working with structs
utl/support
Package support contains functions useful in various components of the application
Package support contains functions useful in various components of the application
utl/zlog
Package zlog contains support for zlog
Package zlog contains support for zlog
scripts
bootstrap
Package main is used to bootstrap a DB for work in a development environment
Package main is used to bootstrap a DB for work in a development environment
testing
Package main is used to bootstrap a DB for work in a development environment
Package main is used to bootstrap a DB for work in a development environment

Jump to

Keyboard shortcuts

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