From cb4a499eed6bace9883cd8df6ba9cdaef6075ebe Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 9 Feb 2022 22:54:05 +0800 Subject: [PATCH] + api demo --- cmd/init.go | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/cmd/init.go b/cmd/init.go index a56f19b8..72c379c3 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -29,7 +29,7 @@ var initCmd = &cobra.Command{ } func makeDirs() { - dirs := []string{"db", "models", "flows", "scripts", "tables", "libs", "ui"} + dirs := []string{"db", "data", "apis", "models", "flows", "scripts", "tables", "libs", "ui"} for _, name := range dirs { dirname := filepath.Join(config.Conf.Root, name) if _, err := os.Stat(dirname); errors.Is(err, os.ErrNotExist) { @@ -183,6 +183,27 @@ function NextDay(day) { } `) + makeFile(filepath.Join("apis", "demo.http.json"), `{ + "name": "Hi", + "version": "1.0.0", + "description": "API demo", + "guard": "bearer-jwt", + "group": "demo", + "paths": [ + { + "path": "/next", + "method": "GET", + "guard": "-", + "process": "scripts.day.NextDay", + "in": ["$query.day"], + "out": { + "status": 200, + "type": "application/json" + } + } + ] +}`) + makeFile(filepath.Join("ui", "index.html"), `It works! https://yaoapps.com`) makeFile(filepath.Join("libs", "f.json"), `{ @@ -236,7 +257,7 @@ func makeAppJSON() { } func checkDir() { - dirs := []string{"db", "models", "flows", "scripts", "tables", "libs", "ui", ".env", "app.json"} + dirs := []string{"db", "data", "models", "flows", "apis", "scripts", "tables", "libs", "ui", ".env", "app.json"} for _, name := range dirs { dirname := filepath.Join(config.Conf.Root, name) if _, err := os.Stat(dirname); !errors.Is(err, os.ErrNotExist) {