appbase

package module
v0.0.0-...-d5fa0d2 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: MIT Imports: 0 Imported by: 0

README

Default WebApp template

Test project to build simple RESTful service based on OpenApi definitions defined in /api directory.

TODOs

  • Configuration with Viper
  • Add support for flags (cobra?)
  • Version tags / Build info
  • Containerization
  • OpenApi code generation
  • REST server using echo.Echo
  • Middleware for REST endpoints
  • Picking structured logging library
  • Dummy Frontend SPA
  • Single Binary deployment with embedded SPA
  • Persistence storage
  • SearchStore capabilities

Directory layout

Directory Description
./.iac "infrastructure as code"
./api OpenAPI, gRPC contracts
./bin/<arch> Build output directory, grouped by architecture (eg: darwin, linux)
./cmd application main
./config application specific configuration
./internal project private libraries
./pkg project libraries
./scripts Shell scripts used in dev environment (env setup, automation etc)
./ui frontend as Single Page Application

Prerequisites

Minimum

  • Go 1.14+
  • Go Modules

Recommended

  • Git (SCM)
  • Docker (containerization)
  • Unix based system (for scripts execution)
  • Javascript with React (for UI component development)
  • yarn (frontend package manager)
  • developer tools binaries installed on host

Installation

Image build
gomodroot=$(go list -m)
buildTime=$(date -u '+%Y-%m-%d %H:%M:%S %Z') && \
docker build \
  --build-arg VERSION=$(git describe --tags --always --dirty) \
  --build-arg GIT_COMMIT=$(git rev-list -1 HEAD) \
  --build-arg BUILD_TIME=$buildTime \
  --build-arg GO_MOD_ROOT=$gomodroot \
  -t macpla/webapp .
Docker run
docker run -p 8080:8080 --rm macpla/webapp
Local build
  1. build ui component (React App)
./scripts/build-ui.sh
  1. build backend with embedded SPA.
./scripts/build-local.sh

optional steps

  • clean pack2 generated files
./scripts/build-local.sh clean
  • openApi spec generation
./scripts/openapi-gen.sh

Interacting with a Service

http://localhost:8080/ -- React landing Page

http://localhost:8080/api/v1/demoapp/.well-known/alive?full=1 -- backend health-check

Developer tools

deepmap/oapi-codegen - OpenAPI 3 client and server boilerplate generator for GO

mikefarah/yq - cli YAML preprocessor

openapi-generator-cli - all purpose node based OpenAPI generator used to generate frontend client

gobuffalo/packr/v2 - static files to Go embedding processor

Documentation

Overview

Package appbase is a template WebApp scaffolding backed with Go and React

Directories

Path Synopsis
cmd
pkg
demoapp/rest
Package restv1 provides primitives to interact the openapi HTTP API.
Package restv1 provides primitives to interact the openapi HTTP API.
spa
You can use the "packr clean" command to clean up this, and any other packr generated files.
You can use the "packr clean" command to clean up this, and any other packr generated files.
spa/packrd
You can use the "packr2 clean" command to clean up this, and any other packr generated files.
You can use the "packr2 clean" command to clean up this, and any other packr generated files.

Jump to

Keyboard shortcuts

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