Skip to content

martijnkorbee/gobaboon

Repository files navigation

gobaboon

Gobaboon

Baboon aims to kickstart the development of go web and api projects by laying out a project structure and doing the scaffolding for tasks that could be seen as repetitive in various projects.

GOTO


Working on updates

Working on this project to include the things I've learned after building and deploying a REST API made on top of gobaboon.

  • Update project structure
  • After creating a new project there should be no dependency on this repo:
    • Move baboonapp template to this repo (generated project)
    • Update the generated project structure
    • Include baboon logic in the result (merge baboon.go and app.go as result)
    • Expand application struct with pkgs functionality
    • Check/Fix/Test baboonctl make commands
    • Check/Fix/Test baboonctl migrate commands
    • Check/Fix/Test baboonctl rpc commands
    • Document new result of creating a new project
  • Add easy containerization support
  • Check/fix rpc issue #21
  • Revisit config loading and default values
  • Revisit logger pkg (include new slog from 1.21?)

Used libraries

subject library
baboonctl spf13/cobra
logging rs/zerolog
log rotating natefinch/lumberjack
Routing go-chi/chi
CSRF protection justinas/nosurdf
Databases upper/db
Sessions alexedwards/scs

Supported databases

Type Comments
Postgresql
Mysql - MariaDB
SQLite3
SQL Server not support with baboonctl make commands

Supported caching

Type Comments
Redis
BadgerDB

baboonctl

Refer to the full documentation: docs

Getting started

Clone the repo.

git clone https://github.com/martijnkorbee/gobaboon

CD to the repo directory.

cd gobaboon

Build or install baboonctl

Build will compile baboonctl in ./bin.
After compiling you can cp or mv the binary to your preferred bin location.

make baboonctl_build 

Install will build the file to your $GOPATH.

make baboonctl_install

Create a new project

Create a new project in the current directory.

bobo make new --name [application name]

Authentication

If you want you can add the pre-made authentication to your project.
This will create up and down migrations for the auth tables and add user and token models in the models directory.
Should be called from the application's root directory.

Note: after running the command - add the models in the models struct and activate the middleware on your desired routes.

bobo make auth --db-type [value]

Sessions

If you want you can activate the persistent session store to your project.
Creates up and down migrations for the server's persistent sessions.

Note: Set the persistent session store type in the .config.properties file.

bobo make session --db-type [value]

Middleware

Add your middleware to http/middleware.

  • CSRF protection is automatically enforced by the baboon server, exempts all API routes.
  • CORS is automatically enabled by the baboon server on API routes.

Routes and Handlers

Add your routes and handlers to their respective folders in the http directory.