gen

package
v1.8.15 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: MIT Imports: 26 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 BuildRoutesCodeFromController

func BuildRoutesCodeFromController(permissionMap map[string]string, controller *Controller) (out string, perms []string, e error)

BuildRoutesCodeFromController builds controller code based on a route

func BuildTypescriptPermissions added in v1.8.11

func BuildTypescriptPermissions() string

BuildTypescriptPermissions returns a formatted typescript file of permission constants

func CleanGoDALs

func CleanGoDALs(dir string, database *schema.Schema) (e error)

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

func CleanGoModels

func CleanGoModels(dir string, database *schema.Schema) (e error)

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

func GenDALs

func GenDALs(dalsDir string, config *lib.Config, force, clean bool) error

func GenInterface

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

GenInterface takes makes the interface into a byte array

func GenInterfaces

func GenInterfaces(srcDir, destDir string) error

func GenModels

func GenModels(modelsDir string, force bool, clean bool) error

GenModels generates models

func GenPermissionsGoFile

func GenPermissionsGoFile()

func GenRoutes

func GenRoutes(config *lib.Config) (e error)

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

func GenerateDALsBootstrapFile

func GenerateDALsBootstrapFile(config *lib.Config, dir string, schemaList *schema.SchemaList) (e error)

GenerateDALsBootstrapFile generates a dal bootstrap file in golang

func GenerateGoDAL

func GenerateGoDAL(config *lib.Config, table *schema.Table, dir string) (e error)

GenerateGoDAL returns a string for a repo in golang

func GenerateGoModel

func GenerateGoModel(dir string, schemaName string, table *schema.Table) (e error)

GenerateGoModel returns a string for a model in golang

func InspectFile

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

InspectFile inspects a file

Types

type Controller

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

func BuildControllerObjFromControllerFile

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

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

type ControllerRoute

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

type ControllerRouteParam struct {
	Name    string
	Pattern string
	Type    string
}

ControllerRouteParam represents a param inside a controller route

type ControllerRouteQuery

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

ControllerRouteQuery represents a query inside a controller route

type DocRoute

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

type DocRouteParam struct {
	Name    string
	Pattern string
	Type    string
}

DocRouteParam represents a parameter inside a route for documentation

type DocRouteQuery

type DocRouteQuery struct {
	Name    string
	Pattern string
	Type    string
}

DocRouteQuery represents a query inside a route for documentation

type Gen

type Gen struct {
	Config *lib.Config
}

Gen conntains all of the generator functionality

func (*Gen) GenAPITests

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

GenAPITests generates api tests

func (*Gen) GenMeta

func (g *Gen) GenMeta(dir string, database *schema.Schema) (e error)

GenMeta returns a string for a model in golang

func (*Gen) GenerateAPIRoutes

func (g *Gen) GenerateAPIRoutes(apiDir string) error

func (*Gen) GenerateDALSQL

func (g *Gen) GenerateDALSQL(dir string, database *schema.Schema) (e error)

GenerateDALSQL generates a constants file filled with sql statements

func (*Gen) GenerateGoAPI

func (g *Gen) GenerateGoAPI(dir string) error

func (*Gen) GenerateGoApp

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

GenerateGoApp generates the base app code

func (*Gen) GenerateServiceBootstrapFile

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

@deprecated

func (*Gen) GenerateServiceInterfaces

func (g *Gen) GenerateServiceInterfaces(definitionsDir string, servicesDir string) 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 *schema.Table) (goCode string, e error)

GenerateTypescriptType returns a string for a type in typescript

func (*Gen) GenerateTypescriptTypes

func (g *Gen) GenerateTypescriptTypes(database *schema.Schema) (goCode string, e error)

GenerateTypescriptTypes returns a string for a typscript types file

func (*Gen) GenerateTypescriptTypesFile

func (g *Gen) GenerateTypescriptTypesFile(dir string, database *schema.Schema) (e error)

GenerateTypescriptTypesFile generates a typescript type file

func (*Gen) GetOrphanedDals

func (g *Gen) GetOrphanedDals(dir string, database *schema.Schema) []string

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

type RoutesJSONContainer

type RoutesJSONContainer struct {
	Routes     map[string]*ControllerRoute  `json:"routes"`
	DTOs       map[string]map[string]string `json:"dtos"`
	Models     map[string]map[string]string `json:"models"`
	Aggregates map[string]map[string]string `json:"aggregates"`
	Constants  map[string][]string          `json:"constants"`
}

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