@tremho/mist-lift 1.1.2 → 1.1.3-pre-release.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +65 -65
  3. package/build/lift.js +0 -0
  4. package/package.json +79 -75
  5. package/src/commands/actions/initQuestions.ts +133 -133
  6. package/src/commands/actions/setupPackageJson.ts +32 -32
  7. package/src/commands/build.ts +170 -170
  8. package/src/commands/builtin/ApiDocMaker.ts +102 -102
  9. package/src/commands/builtin/BuiltInHandler.ts +47 -47
  10. package/src/commands/builtin/DeployBuiltInZip.ts +25 -25
  11. package/src/commands/builtin/StageWebrootZip.ts +36 -36
  12. package/src/commands/create.ts +52 -52
  13. package/src/commands/deploy.ts +161 -161
  14. package/src/commands/doctor.ts +106 -106
  15. package/src/commands/help.ts +178 -178
  16. package/src/commands/info.ts +42 -42
  17. package/src/commands/init.ts +61 -61
  18. package/src/commands/package.ts +234 -234
  19. package/src/commands/publish.ts +330 -330
  20. package/src/commands/settings.ts +73 -73
  21. package/src/commands/start.ts +43 -43
  22. package/src/commands/test.ts +37 -37
  23. package/src/commands/user.ts +20 -20
  24. package/src/expressRoutes/all.ts +99 -99
  25. package/src/expressRoutes/api.ts +22 -22
  26. package/src/expressRoutes/functionBinder.ts +155 -155
  27. package/src/integration-tests/quickstart-scenario.test.ts +74 -74
  28. package/src/lib/CaseUtils.ts +63 -63
  29. package/src/lib/DirectoryUtils.ts +34 -34
  30. package/src/lib/LiftConfig.ts +74 -74
  31. package/src/lib/LiftVersion.ts +87 -87
  32. package/src/lib/Tests/fileCompare.test.ts +35 -35
  33. package/src/lib/askQuestion.ts +17 -17
  34. package/src/lib/executeCommand.ts +45 -45
  35. package/src/lib/fileCompare.ts +55 -55
  36. package/src/lib/openAPI/ApiBuildCollector.ts +47 -47
  37. package/src/lib/openAPI/WebrootFileSupport.ts +19 -19
  38. package/src/lib/openAPI/openApiConstruction.ts +196 -196
  39. package/src/lib/pathResolve.ts +26 -26
  40. package/src/lib/utils.ts +43 -43
  41. package/src/lift.ts +87 -87
  42. package/templateData/function-definition-template +20 -20
  43. package/templateData/function-local-ts +16 -16
  44. package/templateData/function-main-ts +16 -16
  45. package/templateData/function-runmain-mjs +6 -6
  46. package/templateData/function-test-template +11 -11
  47. package/templateData/swagger-ui-bundle.js +2 -2
  48. package/templateData/swagger-ui-standalone-preset.js +2 -2
  49. package/templateData/swagger-ui.css +2 -2
  50. package/tsconfig.json +28 -28
  51. /package/build/commands/builtin/{prebuilt-zips → prebult-zips}/API.zip +0 -0
  52. /package/build/commands/builtin/{prebuilt-zips → prebult-zips}/FileServe.zip +0 -0
  53. /package/build/commands/builtin/{prebuilt-zips → prebult-zips}/Webroot.zip +0 -0
@@ -1,32 +1,32 @@
1
- /** Adds necessary scripts to package.json */
2
-
3
- import * as path from 'path'
4
- import * as fs from 'fs'
5
- import { executeCommand } from '../../lib/executeCommand'
6
-
7
- /**
8
- * Adds necessary scripts to package.json
9
- */
10
- export function addPackageScripts (
11
- projectPath: string
12
- ): void {
13
- const pkgPath = path.join(projectPath, 'package.json')
14
- let pkgJson: any = {}
15
- try { pkgJson = JSON.parse(fs.readFileSync(pkgPath).toString()) } catch {}
16
- const script = pkgJson.script ?? {}
17
- script.test = 'lift test'
18
- pkgJson.script = script
19
- }
20
- export async function installPackage (
21
- projectPath: string,
22
- packageName: string
23
- ): Promise<void> {
24
- await executeCommand('npm', ['i', packageName], projectPath, true)
25
- }
26
-
27
- export async function installDevPackage (
28
- projectPath: string,
29
- packageName: string
30
- ): Promise<void> {
31
- await executeCommand('npm', ['i', '--save-dev', packageName], projectPath, true)
32
- }
1
+ /** Adds necessary scripts to package.json */
2
+
3
+ import * as path from 'path'
4
+ import * as fs from 'fs'
5
+ import { executeCommand } from '../../lib/executeCommand'
6
+
7
+ /**
8
+ * Adds necessary scripts to package.json
9
+ */
10
+ export function addPackageScripts (
11
+ projectPath: string
12
+ ): void {
13
+ const pkgPath = path.join(projectPath, 'package.json')
14
+ let pkgJson: any = {}
15
+ try { pkgJson = JSON.parse(fs.readFileSync(pkgPath).toString()) } catch {}
16
+ const script = pkgJson.script ?? {}
17
+ script.test = 'lift test'
18
+ pkgJson.script = script
19
+ }
20
+ export async function installPackage (
21
+ projectPath: string,
22
+ packageName: string
23
+ ): Promise<void> {
24
+ await executeCommand('npm', ['i', packageName], projectPath, true)
25
+ }
26
+
27
+ export async function installDevPackage (
28
+ projectPath: string,
29
+ packageName: string
30
+ ): Promise<void> {
31
+ await executeCommand('npm', ['i', '--save-dev', packageName], projectPath, true)
32
+ }
@@ -1,170 +1,170 @@
1
- /** handles building in the project directory */
2
-
3
- import * as path from 'path'
4
- import * as fs from 'fs'
5
- import * as ac from 'ansi-colors'
6
- import { resolvePaths } from '../lib/pathResolve'
7
- import { recurseDirectory } from '../lib/DirectoryUtils'
8
- import { isNewer } from '../lib/fileCompare'
9
- import { executeCommand } from '../lib/executeCommand'
10
- import { mkdirSync } from 'fs'
11
-
12
- // Build command
13
- export async function doBuildAsync (
14
- args: string[] // zero or more functions to build. zero means build all
15
- ): Promise<number> {
16
- const projectPaths = resolvePaths()
17
- if (!projectPaths.verified) {
18
- console.log(ac.bold.magenta('current directory is not at project root'))
19
- return -1
20
- }
21
- const funcsToBuild: string[] = []
22
- const options: string[] = []
23
- for (const arg of args) {
24
- if (arg.charAt(0) === '-') {
25
- options.push(arg.toLowerCase())
26
- } else funcsToBuild.push(arg)
27
- }
28
-
29
- if (funcsToBuild.length === 0) {
30
- let firstDepth = 0
31
- recurseDirectory(projectPaths.functionPath, (filepath, stats) => {
32
- const depth = filepath.split(path.sep).length
33
- if (firstDepth === 0) firstDepth = depth
34
- if (stats.isDirectory() && depth === firstDepth) {
35
- funcsToBuild.push(path.basename(filepath))
36
- }
37
- return false
38
- })
39
- }
40
-
41
- let failFast = options.includes('--failfast')
42
- if (options.includes('--deferfail')) failFast = false
43
-
44
- let fails = 0
45
-
46
- for (const func of funcsToBuild) {
47
- const funcDir = path.join(projectPaths.functionPath, func)
48
- if (fs.existsSync(funcDir)) {
49
- fails += await buildSingleFunction(funcDir, options)
50
- if (fails > 0 && failFast) break
51
- } else {
52
- console.log(ac.red.bold(`${func} does not exist as a function`))
53
- fails++
54
- if (failFast) break
55
- }
56
- }
57
- return fails
58
- }
59
-
60
- // build command for a single function
61
- async function buildSingleFunction (
62
- funcDir: string,
63
- options: string[]
64
- ): Promise<number> {
65
- const funcName = funcDir.substring(funcDir.lastIndexOf('/') + 1)
66
- const buildPath = path.normalize(path.join(funcDir, '..', '..', 'build', 'functions', funcName))
67
- if (options.includes('--clean')) {
68
- if (fs.existsSync(buildPath)) {
69
- fs.rmSync(buildPath, { recursive: true })
70
- }
71
- }
72
- // strategy here is to invoke tsc on a per-folder basis rather than letting tsc do the recurse because it is easier to control this way
73
- return await buildFunctionModules(funcName, funcDir, buildPath, options)
74
- }
75
-
76
- // build all the function modules in path
77
- async function buildFunctionModules (
78
- funcName: string,
79
- funcDir: string,
80
- buildPath: string,
81
- options: string[]
82
- ): Promise<number> {
83
- const announce = ac.blue.dim(`building ${funcName}...`)
84
- let announced = false
85
- let fails = 0
86
- // let builds = 0
87
- let failFast = options.includes('--failfast')
88
- if (options.includes('--deferfail')) failFast = false
89
- const all: Array<Promise<void>> = []
90
- recurseDirectory(funcDir, (filepath, stats) => {
91
- if (path.extname(filepath) === '.ts') {
92
- let relPath = filepath.substring(funcDir.length)
93
- relPath = relPath.substring(0, relPath.lastIndexOf('/'))
94
- const outDir = path.join(buildPath, relPath)
95
-
96
- if (!(fails > 0 && failFast)) {
97
- if (isNewer(filepath, outDir)) {
98
- if (!announced) {
99
- announced = true
100
- console.log(announce)
101
- }
102
- // builds++
103
- all.push(executeCommand('tsc', [
104
- '--esModuleInterop', 'true',
105
- '--target', 'ES2015',
106
- '--module', 'commonjs',
107
- '--lib', 'dom,es2015,scripthost,es2015.proxy',
108
- '--strict', 'true',
109
- '--noImplicitAny', 'false',
110
- '--skipLibCheck', 'true',
111
- '--forceConsistentCasingInFileNames', 'true',
112
- '--sourceMap', 'true',
113
- '--outdir', outDir,
114
- filepath
115
- ], '', true).then((result: { retcode: number | undefined, stdOut: string, stdErr: string }) => {
116
- if (result.retcode !== 0) {
117
- fails++
118
- // console.log("error detected", fails)
119
- const now = new Date()
120
- fs.utimesSync(filepath, now, now) // touch file so it is not skipped next build
121
- }
122
- }))
123
- }
124
- }
125
- }
126
- fails += doPostBuildSteps(funcDir, buildPath)
127
- return false
128
- })
129
- return await Promise.all(all).then(async () => {
130
- return fails
131
- })
132
- }
133
-
134
- // do the steps after the build (file copies, etc)
135
- function doPostBuildSteps (
136
- funcDir: string,
137
- buildPath: string
138
- ): number {
139
- // copy the definitions,json file over
140
- const srcdef = path.join(funcDir, 'src', 'definition.json')
141
- const dstdef = path.join(buildPath, 'src', 'definition.json')
142
- if (fs.existsSync(srcdef)) {
143
- const destFolder = path.dirname(dstdef)
144
- if (!fs.existsSync((destFolder))) mkdirSync(destFolder, { recursive: true })
145
- fs.copyFileSync(srcdef, dstdef)
146
- } else {
147
- console.error(ac.red.bold('no definition file found at ' + srcdef))
148
- return 1
149
- }
150
- // copy the resources folder if it exists
151
- const filedirPath = path.join(funcDir, 'resources')
152
- if (fs.existsSync(filedirPath)) {
153
- const bfiles = path.join(buildPath, 'resources')
154
- if (!fs.existsSync(bfiles)) fs.mkdirSync(bfiles, { recursive: true })
155
- recurseDirectory(filedirPath, (filepath, stats) => {
156
- let relPath = filepath.substring(funcDir.length)
157
- relPath = relPath.substring(0, relPath.lastIndexOf('/'))
158
- const outDir = path.join(buildPath, relPath)
159
- const target = path.join(outDir, path.basename(filepath))
160
- if (stats.isDirectory() && !fs.existsSync(target)) {
161
- fs.mkdirSync(target, { recursive: true })
162
- }
163
- if (stats.isFile()) {
164
- fs.copyFileSync(filepath, target)
165
- }
166
- return false
167
- })
168
- }
169
- return 0
170
- }
1
+ /** handles building in the project directory */
2
+
3
+ import * as path from 'path'
4
+ import * as fs from 'fs'
5
+ import * as ac from 'ansi-colors'
6
+ import { resolvePaths } from '../lib/pathResolve'
7
+ import { recurseDirectory } from '../lib/DirectoryUtils'
8
+ import { isNewer } from '../lib/fileCompare'
9
+ import { executeCommand } from '../lib/executeCommand'
10
+ import { mkdirSync } from 'fs'
11
+
12
+ // Build command
13
+ export async function doBuildAsync (
14
+ args: string[] // zero or more functions to build. zero means build all
15
+ ): Promise<number> {
16
+ const projectPaths = resolvePaths()
17
+ if (!projectPaths.verified) {
18
+ console.log(ac.bold.magenta('current directory is not at project root'))
19
+ return -1
20
+ }
21
+ const funcsToBuild: string[] = []
22
+ const options: string[] = []
23
+ for (const arg of args) {
24
+ if (arg.charAt(0) === '-') {
25
+ options.push(arg.toLowerCase())
26
+ } else funcsToBuild.push(arg)
27
+ }
28
+
29
+ if (funcsToBuild.length === 0) {
30
+ let firstDepth = 0
31
+ recurseDirectory(projectPaths.functionPath, (filepath, stats) => {
32
+ const depth = filepath.split(path.sep).length
33
+ if (firstDepth === 0) firstDepth = depth
34
+ if (stats.isDirectory() && depth === firstDepth) {
35
+ funcsToBuild.push(path.basename(filepath))
36
+ }
37
+ return false
38
+ })
39
+ }
40
+
41
+ let failFast = options.includes('--failfast')
42
+ if (options.includes('--deferfail')) failFast = false
43
+
44
+ let fails = 0
45
+
46
+ for (const func of funcsToBuild) {
47
+ const funcDir = path.join(projectPaths.functionPath, func)
48
+ if (fs.existsSync(funcDir)) {
49
+ fails += await buildSingleFunction(funcDir, options)
50
+ if (fails > 0 && failFast) break
51
+ } else {
52
+ console.log(ac.red.bold(`${func} does not exist as a function`))
53
+ fails++
54
+ if (failFast) break
55
+ }
56
+ }
57
+ return fails
58
+ }
59
+
60
+ // build command for a single function
61
+ async function buildSingleFunction (
62
+ funcDir: string,
63
+ options: string[]
64
+ ): Promise<number> {
65
+ const funcName = funcDir.substring(funcDir.lastIndexOf('/') + 1)
66
+ const buildPath = path.normalize(path.join(funcDir, '..', '..', 'build', 'functions', funcName))
67
+ if (options.includes('--clean')) {
68
+ if (fs.existsSync(buildPath)) {
69
+ fs.rmSync(buildPath, { recursive: true })
70
+ }
71
+ }
72
+ // strategy here is to invoke tsc on a per-folder basis rather than letting tsc do the recurse because it is easier to control this way
73
+ return await buildFunctionModules(funcName, funcDir, buildPath, options)
74
+ }
75
+
76
+ // build all the function modules in path
77
+ async function buildFunctionModules (
78
+ funcName: string,
79
+ funcDir: string,
80
+ buildPath: string,
81
+ options: string[]
82
+ ): Promise<number> {
83
+ const announce = ac.blue.dim(`building ${funcName}...`)
84
+ let announced = false
85
+ let fails = 0
86
+ // let builds = 0
87
+ let failFast = options.includes('--failfast')
88
+ if (options.includes('--deferfail')) failFast = false
89
+ const all: Array<Promise<void>> = []
90
+ recurseDirectory(funcDir, (filepath, stats) => {
91
+ if (path.extname(filepath) === '.ts') {
92
+ let relPath = filepath.substring(funcDir.length)
93
+ relPath = relPath.substring(0, relPath.lastIndexOf('/'))
94
+ const outDir = path.join(buildPath, relPath)
95
+
96
+ if (!(fails > 0 && failFast)) {
97
+ if (isNewer(filepath, outDir)) {
98
+ if (!announced) {
99
+ announced = true
100
+ console.log(announce)
101
+ }
102
+ // builds++
103
+ all.push(executeCommand('tsc', [
104
+ '--esModuleInterop', 'true',
105
+ '--target', 'ES2015',
106
+ '--module', 'commonjs',
107
+ '--lib', 'dom,es2015,scripthost,es2015.proxy',
108
+ '--strict', 'true',
109
+ '--noImplicitAny', 'false',
110
+ '--skipLibCheck', 'true',
111
+ '--forceConsistentCasingInFileNames', 'true',
112
+ '--sourceMap', 'true',
113
+ '--outdir', outDir,
114
+ filepath
115
+ ], '', true).then((result: { retcode: number | undefined, stdOut: string, stdErr: string }) => {
116
+ if (result.retcode !== 0) {
117
+ fails++
118
+ // console.log("error detected", fails)
119
+ const now = new Date()
120
+ fs.utimesSync(filepath, now, now) // touch file so it is not skipped next build
121
+ }
122
+ }))
123
+ }
124
+ }
125
+ }
126
+ fails += doPostBuildSteps(funcDir, buildPath)
127
+ return false
128
+ })
129
+ return await Promise.all(all).then(async () => {
130
+ return fails
131
+ })
132
+ }
133
+
134
+ // do the steps after the build (file copies, etc)
135
+ function doPostBuildSteps (
136
+ funcDir: string,
137
+ buildPath: string
138
+ ): number {
139
+ // copy the definitions,json file over
140
+ const srcdef = path.join(funcDir, 'src', 'definition.json')
141
+ const dstdef = path.join(buildPath, 'src', 'definition.json')
142
+ if (fs.existsSync(srcdef)) {
143
+ const destFolder = path.dirname(dstdef)
144
+ if (!fs.existsSync((destFolder))) mkdirSync(destFolder, { recursive: true })
145
+ fs.copyFileSync(srcdef, dstdef)
146
+ } else {
147
+ console.error(ac.red.bold('no definition file found at ' + srcdef))
148
+ return 1
149
+ }
150
+ // copy the resources folder if it exists
151
+ const filedirPath = path.join(funcDir, 'resources')
152
+ if (fs.existsSync(filedirPath)) {
153
+ const bfiles = path.join(buildPath, 'resources')
154
+ if (!fs.existsSync(bfiles)) fs.mkdirSync(bfiles, { recursive: true })
155
+ recurseDirectory(filedirPath, (filepath, stats) => {
156
+ let relPath = filepath.substring(funcDir.length)
157
+ relPath = relPath.substring(0, relPath.lastIndexOf('/'))
158
+ const outDir = path.join(buildPath, relPath)
159
+ const target = path.join(outDir, path.basename(filepath))
160
+ if (stats.isDirectory() && !fs.existsSync(target)) {
161
+ fs.mkdirSync(target, { recursive: true })
162
+ }
163
+ if (stats.isFile()) {
164
+ fs.copyFileSync(filepath, target)
165
+ }
166
+ return false
167
+ })
168
+ }
169
+ return 0
170
+ }
@@ -1,102 +1,102 @@
1
- import { gatherFunctionDefinitions } from '../../lib/openAPI/ApiBuildCollector'
2
- import { buildOpenApi } from '../../lib/openAPI/openApiConstruction'
3
- import { GetWebrootServePaths } from '../../lib/openAPI/WebrootFileSupport'
4
-
5
- export async function MakePublicApiDoc
6
- (
7
- ): Promise<Uint8Array> {
8
- const defs = gatherFunctionDefinitions()
9
- return await buildOpenApi(defs)
10
- }
11
-
12
- export async function MakeBuiltinApiDoc
13
- (
14
- yamlFile: string
15
-
16
- ): Promise<Uint8Array> {
17
- const defs = gatherFunctionDefinitions()
18
- addBuiltInDefinitions(defs)
19
- return await buildOpenApi(defs, false, yamlFile) //, true)
20
- }
21
-
22
- export function addBuiltInDefinitions (defs: any[]): void {
23
- // console.warn("NOT ADDING ANY BUILTIN API INTEGRATIONS")
24
- // console.log("ADDING apiDef");
25
- defs.push(apiDef)
26
- // console.log("ADDING webrootDef");
27
- defs.push(webrootDef)
28
-
29
- // console.warn("Adding webroot literals");
30
- // do just /docs and see how that goes
31
- const fsdef = Object.assign({}, fileServeDef) // copy
32
- fsdef.name = 'fileserve_docs'
33
- fsdef.pathMap = '/docs/{path}'
34
- defs.push(fsdef)
35
- const roots = GetWebrootServePaths()
36
- // console.log("roots", roots)
37
- for (const root of roots) {
38
- if (root !== '') {
39
- let rootName = root
40
- while (rootName.includes('/')) rootName = rootName.replace('/', '').toLowerCase().trim()
41
- const fileserve = Object.assign({}, fileServeDef) // copy
42
- fileserve.name = 'fileserve_' + rootName
43
- fileserve.pathMap = `${root}/{path}`
44
- defs.push(fileserve)
45
- }
46
- }
47
- }
48
-
49
- const apiDef = {
50
- name: 'API',
51
- description: '',
52
- version: '1.0.0',
53
- pathMap: '/api',
54
- allowedMethods: 'GET',
55
- logLevel: 'Debug',
56
- sessionRequired: false,
57
- userRequired: false,
58
- schemas: {},
59
- parameters: [],
60
- returns: {
61
- 200: { type: 'empty', description: 'successful response.' },
62
- 500: {
63
- type: 'string',
64
- description: 'Error details'
65
- }
66
- }
67
- }
68
-
69
- const fileServeDef = {
70
- name: 'FileServe',
71
- description: 'file service',
72
- version:
73
- '1.0.0',
74
- pathMap: '',
75
- allowedMethods: 'GET',
76
- logLevel: 'Debug',
77
- sessionRequired: false,
78
- userRequired: false,
79
- schemas: {},
80
- parameters: [{ name: 'path', in: 'path' }],
81
- returns: {
82
- 200: { type: 'empty', description: 'successful response.' },
83
- 500: { type: 'string', description: 'Error details' }
84
- }
85
- }
86
-
87
- const webrootDef = {
88
- name: 'Webroot',
89
- description: 'Serves files from the webroot /',
90
- version: '1.0.0',
91
- pathMap: '/{path}',
92
- allowedMethods: 'get',
93
- logLevel: 'Debug',
94
- sessionRequired: false,
95
- userRequired: false,
96
- schemas: {},
97
- parameters: [{ name: 'path', in: 'path' }],
98
- returns: {
99
- 200: { type: 'empty', description: 'successful response.' },
100
- 500: { type: 'string', description: 'Error details' }
101
- }
102
- }
1
+ import { gatherFunctionDefinitions } from '../../lib/openAPI/ApiBuildCollector'
2
+ import { buildOpenApi } from '../../lib/openAPI/openApiConstruction'
3
+ import { GetWebrootServePaths } from '../../lib/openAPI/WebrootFileSupport'
4
+
5
+ export async function MakePublicApiDoc
6
+ (
7
+ ): Promise<Uint8Array> {
8
+ const defs = gatherFunctionDefinitions()
9
+ return await buildOpenApi(defs)
10
+ }
11
+
12
+ export async function MakeBuiltinApiDoc
13
+ (
14
+ yamlFile: string
15
+
16
+ ): Promise<Uint8Array> {
17
+ const defs = gatherFunctionDefinitions()
18
+ addBuiltInDefinitions(defs)
19
+ return await buildOpenApi(defs, false, yamlFile) //, true)
20
+ }
21
+
22
+ export function addBuiltInDefinitions (defs: any[]): void {
23
+ // console.warn("NOT ADDING ANY BUILTIN API INTEGRATIONS")
24
+ // console.log("ADDING apiDef");
25
+ defs.push(apiDef)
26
+ // console.log("ADDING webrootDef");
27
+ defs.push(webrootDef)
28
+
29
+ // console.warn("Adding webroot literals");
30
+ // do just /docs and see how that goes
31
+ const fsdef = Object.assign({}, fileServeDef) // copy
32
+ fsdef.name = 'fileserve_docs'
33
+ fsdef.pathMap = '/docs/{path}'
34
+ defs.push(fsdef)
35
+ const roots = GetWebrootServePaths()
36
+ // console.log("roots", roots)
37
+ for (const root of roots) {
38
+ if (root !== '') {
39
+ let rootName = root
40
+ while (rootName.includes('/')) rootName = rootName.replace('/', '').toLowerCase().trim()
41
+ const fileserve = Object.assign({}, fileServeDef) // copy
42
+ fileserve.name = 'fileserve_' + rootName
43
+ fileserve.pathMap = `${root}/{path}`
44
+ defs.push(fileserve)
45
+ }
46
+ }
47
+ }
48
+
49
+ const apiDef = {
50
+ name: 'API',
51
+ description: '',
52
+ version: '1.0.0',
53
+ pathMap: '/api',
54
+ allowedMethods: 'GET',
55
+ logLevel: 'Debug',
56
+ sessionRequired: false,
57
+ userRequired: false,
58
+ schemas: {},
59
+ parameters: [],
60
+ returns: {
61
+ 200: { type: 'empty', description: 'successful response.' },
62
+ 500: {
63
+ type: 'string',
64
+ description: 'Error details'
65
+ }
66
+ }
67
+ }
68
+
69
+ const fileServeDef = {
70
+ name: 'FileServe',
71
+ description: 'file service',
72
+ version:
73
+ '1.0.0',
74
+ pathMap: '',
75
+ allowedMethods: 'GET',
76
+ logLevel: 'Debug',
77
+ sessionRequired: false,
78
+ userRequired: false,
79
+ schemas: {},
80
+ parameters: [{ name: 'path', in: 'path' }],
81
+ returns: {
82
+ 200: { type: 'empty', description: 'successful response.' },
83
+ 500: { type: 'string', description: 'Error details' }
84
+ }
85
+ }
86
+
87
+ const webrootDef = {
88
+ name: 'Webroot',
89
+ description: 'Serves files from the webroot /',
90
+ version: '1.0.0',
91
+ pathMap: '/{path}',
92
+ allowedMethods: 'get',
93
+ logLevel: 'Debug',
94
+ sessionRequired: false,
95
+ userRequired: false,
96
+ schemas: {},
97
+ parameters: [{ name: 'path', in: 'path' }],
98
+ returns: {
99
+ 200: { type: 'empty', description: 'successful response.' },
100
+ 500: { type: 'string', description: 'Error details' }
101
+ }
102
+ }