mirror of
https://github.com/cubixle/tuugen.git
synced 2026-04-24 21:14:41 +01:00
tidy up
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Tuugen
|
||||
|
||||
Tuugen takes a tuugen.yml and a grpc proto definition to generate common boiler plate logic. Some of the common boiler plate it generates is http routes, grpc service, data model structs and a main file with some default plumbing.
|
||||
Tuugen takes a tuugen.yml and a grpc proto definition to generate common boiler plate logic. Some of the common boiler plate it generates is http routes, grpc service, basic data model structs and a main file with some default plumbing.
|
||||
|
||||
Tuugen adds an interactor package which the http and grpc transport layers use for business logic.
|
||||
|
||||
@@ -43,4 +43,9 @@ data_models:
|
||||
type: varchar
|
||||
- name: name
|
||||
type: varchar
|
||||
```
|
||||
```
|
||||
|
||||
## TODO
|
||||
|
||||
- [ ] http routes
|
||||
- [ ] improve data model to struct. add more types.
|
||||
20
service.go
20
service.go
@@ -91,16 +91,20 @@ func parseProto(cfg Config) (serviceDef, error) {
|
||||
return serviceDef{}, fmt.Errorf("failed to parse compiled proto go file: %w", err)
|
||||
}
|
||||
|
||||
importStrs := []string{}
|
||||
servicePath := filepath.Dir(cfg.GRPCFile)
|
||||
for _, i := range f.Imports {
|
||||
importStrs = append(importStrs, strings.Replace(i.Path.Value, `"`, "", -1))
|
||||
}
|
||||
importStrs = append(importStrs, strings.Join([]string{cfg.ImportPath, strings.TrimLeft(servicePath, "/")}, "/"))
|
||||
|
||||
imports := parseImports(cfg, f)
|
||||
funcs := parseFuncs(cfg, f)
|
||||
|
||||
return serviceDef{Funcs: funcs, Imports: importStrs}, nil
|
||||
return serviceDef{Funcs: funcs, Imports: imports}, nil
|
||||
}
|
||||
|
||||
func parseImports(cfg Config, f *ast.File) []string {
|
||||
imports := []string{}
|
||||
servicePath := filepath.Dir(cfg.GRPCFile)
|
||||
for _, i := range f.Imports {
|
||||
imports = append(imports, strings.Replace(i.Path.Value, `"`, "", -1))
|
||||
}
|
||||
imports = append(imports, strings.Join([]string{cfg.ImportPath, strings.TrimLeft(servicePath, "/")}, "/"))
|
||||
return imports
|
||||
}
|
||||
|
||||
func parseFuncs(cfg Config, f *ast.File) []serviceFuncDef {
|
||||
|
||||
Reference in New Issue
Block a user