glew
is a (in development / unstable) rapid prototyping and development tool, used to create starter web boiler-plate projects with CRUD+ functionality. The goal is to be able to create a set of convention following models, feed it to glew, and have developer friendly flexible starter code ready produced. Its basically a glorified project template that makes some assumptions and 3rd party library choices to provide more functionality. It's designed to be a best practices basic starting point REST api generator.
The basic functionality out of the box:
drone.yml
initial build template.docker-compose.yml
starter for local dev.nobody:nouser
, CA and TZ info, Dockerfile
starter for local dev..gitignore
and basic Makefile
for easy testing.For each model set provided a "feature" will be created. Each Feature has the following functionality:
go/ast
, go/parser
, go/token
glew relies heavily on 3rd party libraries for abstracting code and is mostly glue code between the libraries. Most of the applications data specific functionality is driven by the struct via tags.
These are the primary dependencies and what they are responsible for:
Library | Handles |
---|---|
gin | base web framework |
validator | input validation |
sqlx | sql interface |
pgx | postgres driver |
rql | dynamic web queries |
swag | swagger generator |
migrate | db migration |
viper | configuration |
cobra | cli |
ladon | authorization |
authboss | authentication |
vue.js | base ui framework |
vue-router | ui router |
vee-validate | ui inline validation |
vuex | ui state store |
bulma | base css framework |
buefy | buefy + bulma components |
./cmd
- the cmd package contains the wire up code for the cli../pkg/static
- base copy paste static templates. This is the dumb starter project static contents../pkg/templates
- this is the base templates for various code features. This is the core bootstrapper code thats being replaced../pkg
- this is where glews core library is.The product of this application is a cli project folder with the following layout:
./
- all the dev tool (drone, go modules, configs and main.go./cmd
- the cli commands../cmd/cli/tools
- tools cli area../cmd/cli/apis
- for apis../db/migrations
- database migration scripts to be used with go migrate
or {{.CLINAME}} all
or {{.CLINAME}} tools migrate
.
/core
- schema for your models and related operations./core_seed
- database seed insert script for quick testing../internal
- internal libraries and extension utilities for 3rd party libraries../pkg
- the applications relevant to the platform
/apis
- all of the apis (core)You can run glew in two ways, in code or as a cli.
touch models.go
git clone https://github.com/kartso/glew.git
go install
glew
type TestModel struct {
StringField string `db:"string_field" json:"stringField"`
NumField int `db:"num_field" json:"numField"`
ID int `db:"id" json:"id"`
Code string `db:"code" json:"code"`
TimeField time.Time `db:"time_field" json:"timeField"`
}
type CreateTestModel struct {
StringField string `db:"string_field" json:"stringField"`
NumField int `db:"num_field" json:"numField"`
ID int `db:"id" json:"id"`
Code string `db:"code" json:"code"`
TimeField time.Time `db:"time_field" json:"timeField"`
}
type UpdateTestModel struct {
StringField string `db:"string_field" json:"stringField"`
NumField int `db:"num_field" json:"numField"`
ID int `db:"id" json:"id"`
Code string `db:"code" json:"code"`
TimeField time.Time `db:"time_field" json:"timeField"`
}
func main() {
/*
CONFIG
destDir - the output directory from this run
appName - the name of the application and docker runtime
importPath - application go import directory, aka the directory of the app to reference itself
*/
app := pkg.NewApp(pkg.Frontend{}, pkg.Backend{}, pkg.DB{})
destDir := "out"
appName := "testApp"
importPath := "github.com/karsto/glew/out"
verticals := []pkg.VerticalMeta{}
vertical, _ := app.GenerateVerticalMeta(TestModel{}, "TestVertical", CreateTestModel{}, UpdateTestModel{})
verticals = append(verticals, vertical)
ctx := pkg.BaseAPPCTX{
ImportPath: importPath,
}
features := pkg.NewConfig()
files, _ := app.GenerateApp(features, destDir, appName, verticals, ctx)
err = pkg.WriteFiles(files, destDir)
if err != nil {
panic(err)
}
TODO: