gen

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const NullPackage = "\"gopkg.in/guregu/null.v3\""

NullPackage is the package name used for handling nulls

Variables

This section is empty.

Functions

func FormatCode added in v1.5.0

func FormatCode(code string) ([]byte, error)

FormatCode formats the code

func GenInterface added in v1.5.0

func GenInterface(comment, pkgName, ifaceName, ifaceComment string, methods []string, imports []string) ([]byte, error)

GenInterface takes makes the interface into a byte array

func GenInterfaces added in v1.5.0

func GenInterfaces(files []string, structType, comment, pkgName, ifaceName, ifaceComment string, copyDocuments, copyTypeDoc bool) (result []byte, e error)

GenInterfaces runs GenInterface on all the target files

func InspectFile added in v1.5.0

func InspectFile(filePath string) (s *lib.GoStruct, e error)

InspectFile inspects a file

Types

type Controller added in v1.5.0

type Controller struct {
	Name              string            `json:"Name"`
	Description       string            `json:"Description"`
	Path              string            `json:"-"`
	Routes            []ControllerRoute `json:"Routes"`
	HasDTOsImport     bool              `json:"-"`
	HasResponseImport bool              `json:"-"`
}

Controller represents a REST controller

type ControllerRoute added in v1.5.0

type ControllerRoute struct {
	Name           string                 `json:"Name"`
	Description    string                 `json:"Description"`
	Raw            string                 `json:"Path"`
	Path           string                 `json:"-"`
	Method         string                 `json:"Method"`
	Params         []ControllerRouteParam `json:"Params"`
	Queries        []ControllerRouteQuery `json:"Queries"`
	IsAuth         bool                   `json:"IsAuth"`
	BodyType       string                 `json:"BodyType"`
	BodyFormat     string                 `json:"BodyFormat"`
	HasBody        bool                   `json:"HasBody"`
	ResponseType   string                 `json:"ResponseType"`
	ResponseFormat string                 `json:"ResponseFormat"`
	ResponseCode   int                    `json:"ResponseCode"`
	Permission     string                 `json:"Permission"`
}

ControllerRoute represents a route inside a REST controller

type ControllerRouteParam added in v1.5.0

type ControllerRouteParam struct {
	Name    string
	Pattern string
	Type    string
}

ControllerRouteParam represents a param inside a controller route

type ControllerRouteQuery added in v1.5.0

type ControllerRouteQuery struct {
	Name         string
	Pattern      string
	Type         string
	VariableName string
	ValueRaw     string
}

ControllerRouteQuery represents a query inside a controller route

type DocRoute added in v1.5.0

type DocRoute struct {
	Name           string
	Description    string
	Method         string
	Path           string
	HasBody        bool
	BodyType       string
	BodyFormat     string
	ResponseType   string
	ResponseFormat string
	ResponseCode   int
}

DocRoute is a route in the documentation

type DocRouteParam added in v1.5.0

type DocRouteParam struct {
	Name    string
	Pattern string
	Type    string
}

DocRouteParam represents a parameter inside a route for documentation

type DocRouteQuery added in v1.5.0

type DocRouteQuery struct {
	Name    string
	Pattern string
	Type    string
}

DocRouteQuery represents a query inside a route for documentation

type Gen

type Gen struct {
	Options lib.Options
	Config  *lib.Config
}

Gen conntains all of the generator functionality

func (*Gen) BuildControllerObjFromControllerFile added in v1.5.0

func (g *Gen) BuildControllerObjFromControllerFile(filePath string, src []byte) (controller *Controller, usesPerms bool, e error)

BuildControllerObjFromControllerFile parses a file and extracts all of its @route comments

func (*Gen) BuildRoutesCodeFromController added in v1.5.0

func (g *Gen) BuildRoutesCodeFromController(controller *Controller) (out string, perms []string)

BuildRoutesCodeFromController builds controller code based on a route

func (*Gen) BuildTypescriptPermissions added in v1.5.0

func (g *Gen) BuildTypescriptPermissions() string

BuildTypescriptPermissions returns a formatted typescript file of permission constants

func (*Gen) CleanGoDALs added in v1.4.0

func (g *Gen) CleanGoDALs(dir string, database *lib.Database) (e error)

CleanGoDALs removes any repo files that aren't in the database.Tables map

func (*Gen) CleanGoModels added in v1.4.0

func (g *Gen) CleanGoModels(dir string, database *lib.Database) (e error)

CleanGoModels removes model files that are not found in the database.Tables map

func (*Gen) CleanGoRepos added in v1.4.0

func (g *Gen) CleanGoRepos(dir string, database *lib.Database) (e error)

CleanGoServices removes service files not found in the database.Tables map

func (*Gen) GenMeta added in v1.5.0

func (g *Gen) GenMeta(dir string, database *lib.Database) (e error)

GenMeta returns a string for a model in golang

func (*Gen) GenRoutes added in v1.5.0

func (g *Gen) GenRoutes() (e error)

GenRoutes generates a list of routes from a directory of controller files

func (*Gen) GenServiceTest added in v1.5.0

func (g *Gen) GenServiceTest(serviceName, filePath string) (e error)

GenServiceTest generates a test for a service file

func (*Gen) GenerateAPIRoutes added in v1.4.0

func (g *Gen) GenerateAPIRoutes(apiDir string)

func (*Gen) GenerateCacheBootstrapFile

func (g *Gen) GenerateCacheBootstrapFile(dir string, database *lib.Database) (e error)

GenerateCacheBootstrapFile generates a repos bootstrap file in golang

func (*Gen) GenerateCacheBootstrapGoCodeFromDatabase

func (g *Gen) GenerateCacheBootstrapGoCodeFromDatabase(database *lib.Database) (goCode string, e error)

GenerateCacheBootstrapGoCodeFromDatabase generates golang code for a Repo Bootstrap file from a database object

func (*Gen) GenerateDALSQL added in v1.5.0

func (g *Gen) GenerateDALSQL(dir string, database *lib.Database) (e error)

GenerateDALSQL generates a constants file filled with sql statements

func (*Gen) GenerateDALsBootstrapFile added in v1.4.0

func (g *Gen) GenerateDALsBootstrapFile(dir string, database *lib.Database) (e error)

GenerateDALsBootstrapFile generates a dal bootstrap file in golang

func (*Gen) GenerateGoAPI added in v1.4.0

func (g *Gen) GenerateGoAPI(dir string)

func (*Gen) GenerateGoApp added in v1.4.0

func (g *Gen) GenerateGoApp(dir string) (e error)

GenerateGoApp generates the base app code

func (*Gen) GenerateGoCache

func (g *Gen) GenerateGoCache(table *lib.Table, fileFoot string, imports []string) (goCode string, e error)

GenerateGoCache returns a string for a repo in golang

func (*Gen) GenerateGoCacheFile

func (g *Gen) GenerateGoCacheFile(dir string, table *lib.Table) (e error)

GenerateGoCacheFile generates a repo file in golang

func (*Gen) GenerateGoCacheFiles

func (g *Gen) GenerateGoCacheFiles(reposDir string, database *lib.Database) (e error)

GenerateGoCacheFiles generates go repository files based on the database schema

func (*Gen) GenerateGoDAL added in v1.4.0

func (g *Gen) GenerateGoDAL(table *lib.Table, dir string) (e error)

GenerateGoDAL returns a string for a repo in golang

func (*Gen) GenerateGoModel

func (g *Gen) GenerateGoModel(dir string, table *lib.Table) (e error)

GenerateGoModel returns a string for a model in golang

func (*Gen) GenerateGoRepo

func (g *Gen) GenerateGoRepo(table *lib.Table, fileHead string, fileFoot string, imports []string, dir string) (e error)

GenerateGoRepo returns a string for a repo in golang

func (*Gen) GenerateGoRepoFile

func (g *Gen) GenerateGoRepoFile(dir string, table *lib.Table) (e error)

GenerateGoRepoFile generates a repo file in golang

func (*Gen) GenerateGoRepoFiles

func (g *Gen) GenerateGoRepoFiles(dir string, database *lib.Database) (e error)

GenerateGoRepoFiles generates go repository files based on the database schema

func (*Gen) GenerateGoSchema

func (g *Gen) GenerateGoSchema(database *lib.Database) (goCode string, e error)

GenerateGoSchema generates golang code for a schema file

func (*Gen) GenerateGoSchemaFile

func (g *Gen) GenerateGoSchemaFile(dir string, database *lib.Database) (e error)

GenerateGoSchemaFile generates a schema file in golang

func (*Gen) GenerateRepoInterfaces added in v1.4.0

func (g *Gen) GenerateRepoInterfaces(database *lib.Database, dir string) (e error)

GenerateRepoInterfaces generates a go interfaces file for use by the services directory

func (*Gen) GenerateReposBootstrapFile

func (g *Gen) GenerateReposBootstrapFile(dir string, database *lib.Database) (e error)

GenerateReposBootstrapFile generates a repos bootstrap file in golang

func (*Gen) GenerateReposBootstrapGoCodeFromDatabase

func (g *Gen) GenerateReposBootstrapGoCodeFromDatabase(database *lib.Database, dir string) (e error)

GenerateReposBootstrapGoCodeFromDatabase generates golang code for a Repo Bootstrap file from a database object

func (*Gen) GenerateServiceBootstrapFile added in v1.4.0

func (g *Gen) GenerateServiceBootstrapFile(servicesDir string) (e error)

func (*Gen) GenerateServiceInterfaces added in v1.4.0

func (g *Gen) GenerateServiceInterfaces(definitionsDir string, servicesDir string) (e error)

GenerateServiceInterfaces scans the services directory and outputs 2 files

  1. A services bootstrap file in the services directory
  2. A services definition file in the definitions directory

func (*Gen) GenerateTypescriptType

func (g *Gen) GenerateTypescriptType(table *lib.Table) (goCode string, e error)

GenerateTypescriptType returns a string for a type in typescript

func (*Gen) GenerateTypescriptTypes

func (g *Gen) GenerateTypescriptTypes(database *lib.Database) (goCode string, e error)

GenerateTypescriptTypes returns a string for a typscript types file

func (*Gen) GenerateTypescriptTypesFile

func (g *Gen) GenerateTypescriptTypesFile(dir string, database *lib.Database) (e error)

GenerateTypescriptTypesFile generates a typescript type file

func (*Gen) GetOrphanedDals added in v1.4.0

func (g *Gen) GetOrphanedDals(dir string, database *lib.Database) []string

GetOrphanedDals gets repo files that aren't in the database.Tables map

func (*Gen) GetOrphanedRepos added in v1.4.0

func (g *Gen) GetOrphanedRepos(dir string, database *lib.Database) []string

GetOrphanedRepos returns a slice of service files that are not in the database.Tables map

type RoutesJSONContainer added in v1.5.0

type RoutesJSONContainer struct {
	Routes []*Controller                `json:"routes"`
	DTOs   map[string]map[string]string `json:"dtos"`
	Models map[string]map[string]string `json:"models"`
}

RoutesJSONContainer is a container for JSON Routes

Jump to

Keyboard shortcuts

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