@tremho/mist-lift 1.1.7 → 1.2.0-prerelease.4
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.
- package/README.md +12 -0
- package/build/commands/builtin/ApiDocMaker.js +3 -3
- package/build/commands/builtin/ApiDocMaker.js.map +1 -1
- package/build/commands/builtin/StageWebrootZip.js +1 -0
- package/build/commands/builtin/StageWebrootZip.js.map +1 -1
- package/build/commands/create.js +6 -0
- package/build/commands/create.js.map +1 -1
- package/build/commands/init.js +4 -0
- package/build/commands/init.js.map +1 -1
- package/build/commands/publish.js +2 -2
- package/build/commands/publish.js.map +1 -1
- package/build/commands/start.js +144 -11
- package/build/commands/start.js.map +1 -1
- package/build/expressRoutes/all.js +9 -8
- package/build/expressRoutes/all.js.map +1 -1
- package/build/expressRoutes/functionBinder.js +43 -37
- package/build/expressRoutes/functionBinder.js.map +1 -1
- package/build/lib/DirectoryUtils.js +3 -1
- package/build/lib/DirectoryUtils.js.map +1 -1
- package/build/lib/openAPI/openApiConstruction.js +37 -7
- package/build/lib/openAPI/openApiConstruction.js.map +1 -1
- package/package.json +7 -3
- package/src/commands/builtin/ApiDocMaker.ts +3 -3
- package/src/commands/builtin/StageWebrootZip.ts +1 -0
- package/src/commands/create.ts +7 -0
- package/src/commands/init.ts +5 -0
- package/src/commands/publish.ts +2 -2
- package/src/commands/start.ts +163 -11
- package/src/expressRoutes/all.ts +8 -7
- package/src/expressRoutes/functionBinder.ts +39 -32
- package/src/lib/DirectoryUtils.ts +7 -5
- package/src/lib/openAPI/openApiConstruction.ts +14 -7
- package/templateData/function-definition-template +1 -1
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -20,6 +43,7 @@ const oas30_1 = require("openapi3-ts/oas30");
|
|
|
20
43
|
const fs_1 = __importDefault(require("fs"));
|
|
21
44
|
const path_1 = __importDefault(require("path"));
|
|
22
45
|
const pathResolve_1 = require("../pathResolve");
|
|
46
|
+
const ac = __importStar(require("ansi-colors"));
|
|
23
47
|
function buildOpenApi(defs_1) {
|
|
24
48
|
return __awaiter(this, arguments, void 0, function* (defs, includePrivate = false, yamlFile) {
|
|
25
49
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -60,18 +84,24 @@ function buildOpenApi(defs_1) {
|
|
|
60
84
|
if (def.private === true && !includePrivate)
|
|
61
85
|
continue; // skip private
|
|
62
86
|
const parameters = (_f = def.parameters) !== null && _f !== void 0 ? _f : [];
|
|
63
|
-
|
|
87
|
+
let method = def.method;
|
|
88
|
+
if (!def.method) {
|
|
89
|
+
console.log(ac.red('no method defined for ' + def.name));
|
|
90
|
+
if (def.allowedMethods) {
|
|
91
|
+
console.log(ac.bgBlack.yellowBright('DEPRECATED') + ac.blue(' As of v1.1.8, The use of ') + ac.black.italic('allowedMethods') + ac.blue(' is replaced by the single' +
|
|
92
|
+
ac.black.italic(' method ') + ac.blue('property.') + ac.black.bold('Please update your definition file')));
|
|
93
|
+
def.method = def.allowedMethods.split(',')[0];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
64
96
|
const schemas = (_g = def.schemas) !== null && _g !== void 0 ? _g : {};
|
|
65
97
|
for (const schemaName of Object.getOwnPropertyNames(schemas)) {
|
|
66
98
|
const schema = schemas[schemaName];
|
|
67
99
|
addTypeSchema(builder, schemaName, schema);
|
|
68
100
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
addParameter(pathDef, param);
|
|
74
|
-
}
|
|
101
|
+
method = method.trim().toLowerCase();
|
|
102
|
+
addFunctionMethod(pathDef, method, def);
|
|
103
|
+
for (const param of parameters) {
|
|
104
|
+
addParameter(pathDef, param);
|
|
75
105
|
}
|
|
76
106
|
addCORSOptionMethod(pathDef);
|
|
77
107
|
builder.addPath(((_h = def.pathMap) !== null && _h !== void 0 ? _h : '/' + def.name), pathDef);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openApiConstruction.js","sourceRoot":"","sources":["../../../src/lib/openAPI/openApiConstruction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"openApiConstruction.js","sourceRoot":"","sources":["../../../src/lib/openAPI/openApiConstruction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,6CAAkD;AAClD,4CAAmB;AACnB,gDAAuB;AACvB,gDAA6C;A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ACrC,OAAO,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAA;AACpG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tremho/mist-lift",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-prerelease.4",
|
|
4
4
|
"description": "lift command line utility for MistLift development",
|
|
5
5
|
"main": "build/lift.js",
|
|
6
6
|
"bin": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"indev": "run-script-os",
|
|
22
22
|
"indev:nix": "echo nix",
|
|
23
23
|
"indev:windows": "echo windows",
|
|
24
|
-
"postbuild"
|
|
24
|
+
"postbuild": "run-script-os",
|
|
25
25
|
"postbuild:nix": "cp -r src/commands/builtin/prebuilt-zips build/commands/builtin",
|
|
26
26
|
"postbuild:windows": "robocopy src/commands/builtin/prebuilt-zips build/commands/builtin/prebuilt-zips /e > NUL 2>&1"
|
|
27
27
|
},
|
|
@@ -51,12 +51,15 @@
|
|
|
51
51
|
"@aws-sdk/client-api-gateway": "^3.598.0",
|
|
52
52
|
"@aws-sdk/client-lambda": "^3.598.0",
|
|
53
53
|
"@aws-sdk/credential-providers": "^3.598.0",
|
|
54
|
-
"@tremho/inverse-y": "^1.1.
|
|
54
|
+
"@tremho/inverse-y": "^1.1.5-prerelease.6",
|
|
55
55
|
"ansi-colors": "^4.1.3",
|
|
56
56
|
"body-parser": "^1.20.2",
|
|
57
57
|
"clear-module": "^4.1.2",
|
|
58
|
+
"esbuild": "^0.23.0",
|
|
58
59
|
"express": "^4.19.2",
|
|
60
|
+
"express-ws": "^5.0.2",
|
|
59
61
|
"md5": "^2.3.0",
|
|
62
|
+
"node-watch": "^0.7.4",
|
|
60
63
|
"openapi-ui": "^1.0.4",
|
|
61
64
|
"openapi3-ts": "^4.3.3",
|
|
62
65
|
"readline-sync": "^1.4.10",
|
|
@@ -64,6 +67,7 @@
|
|
|
64
67
|
},
|
|
65
68
|
"devDependencies": {
|
|
66
69
|
"@types/express": "^4.17.21",
|
|
70
|
+
"@types/express-ws": "^3.0.4",
|
|
67
71
|
"@types/md5": "^2.3.5",
|
|
68
72
|
"@types/node": "^20.14.2",
|
|
69
73
|
"@types/tap": "^15.0.11",
|
|
@@ -54,7 +54,7 @@ const apiDef = {
|
|
|
54
54
|
description: '',
|
|
55
55
|
version: '1.0.0',
|
|
56
56
|
pathMap: '/api',
|
|
57
|
-
|
|
57
|
+
method: 'GET',
|
|
58
58
|
logLevel: 'Debug',
|
|
59
59
|
sessionRequired: false,
|
|
60
60
|
userRequired: false,
|
|
@@ -75,7 +75,7 @@ const fileServeDef = {
|
|
|
75
75
|
version:
|
|
76
76
|
'1.0.0',
|
|
77
77
|
pathMap: '',
|
|
78
|
-
|
|
78
|
+
method: 'GET',
|
|
79
79
|
logLevel: 'Debug',
|
|
80
80
|
sessionRequired: false,
|
|
81
81
|
userRequired: false,
|
|
@@ -92,7 +92,7 @@ const webrootDef = {
|
|
|
92
92
|
description: 'Serves files from the webroot /',
|
|
93
93
|
version: '1.0.0',
|
|
94
94
|
pathMap: '/{path}',
|
|
95
|
-
|
|
95
|
+
method: 'get',
|
|
96
96
|
logLevel: 'Debug',
|
|
97
97
|
sessionRequired: false,
|
|
98
98
|
userRequired: false,
|
|
@@ -19,6 +19,7 @@ export async function StageWebrootZip
|
|
|
19
19
|
const webroot = path.join(projectPaths.basePath, 'webroot')
|
|
20
20
|
const packageTemp = path.join(projectPaths.basePath, '.package_temp')
|
|
21
21
|
const zipFilesPath = path.join(packageTemp, 'Webroot', '__files__')
|
|
22
|
+
await fs.mkdirSync(zipFilesPath, { recursive: true })
|
|
22
23
|
await recurseDirectory(webroot, (filepath, stats) => {
|
|
23
24
|
const relPath = filepath.substring(webroot.length)
|
|
24
25
|
if (stats.isDirectory()) {
|
package/src/commands/create.ts
CHANGED
|
@@ -29,6 +29,13 @@ export function doCreate (
|
|
|
29
29
|
if (!fs.existsSync(path.join(funcPath, testdirname))) fs.mkdirSync(path.join(funcPath, testdirname))
|
|
30
30
|
if (!fs.existsSync(path.join(funcPath, 'src'))) fs.mkdirSync(path.join(funcPath, 'src'))
|
|
31
31
|
|
|
32
|
+
// create link to common lib
|
|
33
|
+
if(!fs.existsSync(path.join(funcPath, 'src', 'commonLib'))) {
|
|
34
|
+
const funcSrc = path.join(funcPath, 'src')
|
|
35
|
+
const relPath = path.relative(funcSrc, projectPaths.basePath)
|
|
36
|
+
fs.symlinkSync(path.join(relPath, 'commonLib'),path.join(funcSrc, 'lib'), 'dir')
|
|
37
|
+
}
|
|
38
|
+
|
|
32
39
|
let localsrc = fs.readFileSync(path.join(dataDir, 'function-local-ts')).toString()
|
|
33
40
|
while (localsrc.includes('$$FUNCTION_NAME$$')) {
|
|
34
41
|
localsrc = localsrc.replace('$$FUNCTION_NAME$$', funcName)
|
package/src/commands/init.ts
CHANGED
|
@@ -39,6 +39,11 @@ export async function doInit (
|
|
|
39
39
|
fs.mkdirSync(funcDir)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
const libDir = path.join(refPath, 'commonLib')
|
|
43
|
+
if (!fs.existsSync(libDir)) {
|
|
44
|
+
fs.mkdirSync(libDir)
|
|
45
|
+
}
|
|
46
|
+
|
|
42
47
|
// make webroot with docs folder and placeholder yaml
|
|
43
48
|
const webrootDocs = path.join(refPath, 'webroot', 'docs')
|
|
44
49
|
if (!fs.existsSync(webrootDocs)) {
|
package/src/commands/publish.ts
CHANGED
|
@@ -199,7 +199,7 @@ class PrereqInfo {
|
|
|
199
199
|
// console.log("resourceMethods", api.resourceMethods)
|
|
200
200
|
const methodList = Object.getOwnPropertyNames(api.resourceMethods)
|
|
201
201
|
// ClogTrace("methodList", methodList)
|
|
202
|
-
for (const meth of allowedMethods.toUpperCase().split(',')) {
|
|
202
|
+
for (const meth of allowedMethods.toUpperCase().split(',')) { // NOTE: we no longer try to support multiples, but this still works as is.
|
|
203
203
|
// console.log("meth", meth)
|
|
204
204
|
if (methodList.includes(meth)) {
|
|
205
205
|
(api).method = meth
|
|
@@ -226,7 +226,7 @@ class PrereqInfo {
|
|
|
226
226
|
const out: PutIntegrationRequest[] = []
|
|
227
227
|
for (const d of this.defs) {
|
|
228
228
|
const def = (d)
|
|
229
|
-
const api = this.findApi(def.pathMap, def.
|
|
229
|
+
const api = this.findApi(def.pathMap, def.method)
|
|
230
230
|
const arn = this.findARN(def.name) ?? ''
|
|
231
231
|
if (arn === '') {
|
|
232
232
|
console.log(`>>> No ARN for ${(def.name as string)} ${(def.pathMap as string)}, ${(api.id as string)}`)
|
package/src/commands/start.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/** Run Express Server */
|
|
2
2
|
import express from 'express'
|
|
3
3
|
|
|
4
|
+
import * as esbuild from 'esbuild'
|
|
5
|
+
import watch from 'node-watch';
|
|
6
|
+
import expressWS from 'express-ws'
|
|
7
|
+
|
|
4
8
|
import functionRouter, { functionBinder } from '../expressRoutes/functionBinder'
|
|
5
9
|
|
|
6
10
|
import apiRouter from '../expressRoutes/api'
|
|
@@ -10,7 +14,18 @@ import { doBuildAsync } from './build'
|
|
|
10
14
|
|
|
11
15
|
import * as ac from 'ansi-colors'
|
|
12
16
|
|
|
17
|
+
import path from 'path'
|
|
18
|
+
import fs from 'fs'
|
|
19
|
+
|
|
20
|
+
import {Log} from "@tremho/inverse-y"
|
|
21
|
+
|
|
22
|
+
const defaultPort = 8081
|
|
23
|
+
const serverConfig = readServerConfig();
|
|
24
|
+
let server:any = null
|
|
25
|
+
const app = express()
|
|
26
|
+
|
|
13
27
|
export async function startLocalServer (): Promise<void> {
|
|
28
|
+
// console.warn('startLocalServer')
|
|
14
29
|
const projectPaths = resolvePaths()
|
|
15
30
|
if (!projectPaths.verified) {
|
|
16
31
|
console.log(ac.bold.red('Cannot start local server'))
|
|
@@ -18,26 +33,163 @@ export async function startLocalServer (): Promise<void> {
|
|
|
18
33
|
console.log('')
|
|
19
34
|
return
|
|
20
35
|
}
|
|
36
|
+
|
|
37
|
+
// first build will exit on an error regardless of config
|
|
21
38
|
await doBuildAsync([])
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
functionBinder()
|
|
25
|
-
|
|
39
|
+
await allBinder()
|
|
40
|
+
// Log.Trace('calling functionBinder')
|
|
41
|
+
await functionBinder()
|
|
42
|
+
// Log.Trace('done calling functionBinder')
|
|
26
43
|
// for JSON posts
|
|
27
44
|
// app.use(bodyParser.json({limit: '50mb'}))
|
|
28
45
|
app.use(express.json())
|
|
29
46
|
// for form posts
|
|
30
|
-
app.use(express.urlencoded({
|
|
47
|
+
app.use(express.urlencoded({extended: true}))
|
|
31
48
|
|
|
32
49
|
app.use('/', functionRouter)
|
|
33
50
|
app.use('/api', apiRouter)
|
|
34
51
|
app.use('*', allRouter)
|
|
35
52
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
53
|
+
startServers()
|
|
54
|
+
|
|
55
|
+
funcWatcher(path.join(projectPaths.basePath, 'functions'), path.join(projectPaths.basePath, 'webroot'));
|
|
56
|
+
esbuilder();
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
function startServers() {
|
|
60
|
+
startWebSocketConnection(app)
|
|
61
|
+
server = app.listen(serverConfig.port, function () {
|
|
62
|
+
console.log(`http listening on port ${serverConfig.port ?? defaultPort}`)
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function readServerConfig() {
|
|
67
|
+
// console.log('readServerConfig...')
|
|
68
|
+
const projectPaths = resolvePaths()
|
|
69
|
+
const confFile = path.join(projectPaths.basePath, 'localServerConfig.json')
|
|
70
|
+
if(!fs.existsSync(confFile)) return {}
|
|
71
|
+
|
|
72
|
+
const conf:any = JSON.parse(fs.readFileSync(confFile).toString())
|
|
73
|
+
// console.log("server configuration", conf)
|
|
74
|
+
return conf
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function esbuilder() {
|
|
78
|
+
|
|
79
|
+
if(!serverConfig.esbuild) return;
|
|
80
|
+
|
|
81
|
+
const entryPoints = serverConfig.esbuild.entryPoints ?? []
|
|
82
|
+
const outDir = serverConfig.esbuild.outdir ?? 'webroot'
|
|
83
|
+
const watch = serverConfig.esbuild.watch ?? false
|
|
84
|
+
const breakOnError = serverConfig.esbuild.breakOnError ?? false
|
|
85
|
+
const breakOnWarn = serverConfig.esbuild.breakOnWarn ?? false
|
|
86
|
+
|
|
87
|
+
let ctx = await esbuild.context({
|
|
88
|
+
entryPoints,
|
|
89
|
+
bundle: true,
|
|
90
|
+
outdir: outDir
|
|
91
|
+
})
|
|
92
|
+
// console.log('esbuild...')
|
|
93
|
+
|
|
94
|
+
let result = await ctx.rebuild()
|
|
95
|
+
let more = watch
|
|
96
|
+
do {
|
|
97
|
+
await sleep(500)
|
|
98
|
+
result = await ctx.rebuild()
|
|
99
|
+
} while(more)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function sleep(ms:number)
|
|
103
|
+
{
|
|
104
|
+
return new Promise(resolve => {
|
|
105
|
+
setTimeout(resolve, ms)
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function funcWatcher(watchPath:string, webrootPath:string) {
|
|
110
|
+
|
|
111
|
+
if(serverConfig.rebuildFunctionsOnChange !== true) return;
|
|
112
|
+
// console.log('watching for changes in functions')
|
|
113
|
+
watch(watchPath, {recursive:true}, onWatch1)
|
|
114
|
+
|
|
115
|
+
if(serverConfig.refreshBrowserOnWebrootChange) {
|
|
116
|
+
// console.log('watching for webroot changes')
|
|
117
|
+
watch(webrootPath, {recursive: true}, onWatch2)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function onWatch1(evt:string, name:string) {
|
|
121
|
+
// console.log("funcWatch Event seen", {evt, name})
|
|
122
|
+
triggerRebuild()
|
|
123
|
+
}
|
|
124
|
+
function onWatch2(evt:string, name:string) {
|
|
125
|
+
// console.log("Webroot Watch Event seen", {evt, name})
|
|
126
|
+
triggerBrowserRestart()
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let alreadyBuilding = false
|
|
130
|
+
async function triggerRebuild() {
|
|
131
|
+
if(!alreadyBuilding) {
|
|
132
|
+
alreadyBuilding = true;
|
|
133
|
+
const errRet = await doBuildAsync([]);
|
|
134
|
+
if(errRet) {
|
|
135
|
+
process.exit(errRet)
|
|
136
|
+
}
|
|
137
|
+
alreadyBuilding = false;
|
|
138
|
+
if(serverConfig.refreshBrowserOnFunctionChange)
|
|
139
|
+
triggerBrowserRestart()
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function triggerBrowserRestart() {
|
|
144
|
+
// console.log("Trigger Browser Restart")
|
|
145
|
+
if(server) {
|
|
146
|
+
socketClose();
|
|
147
|
+
server.close(() => {
|
|
148
|
+
startServers()
|
|
149
|
+
})
|
|
150
|
+
// console.log("server close initiated")
|
|
151
|
+
} else {
|
|
152
|
+
// console.log("first start of servers")
|
|
153
|
+
startServers()
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
class WSConnection {
|
|
158
|
+
on: any
|
|
159
|
+
sendUTF: any
|
|
160
|
+
remoteAddress:string = ''
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
var socketClose:any = () => {}
|
|
164
|
+
|
|
165
|
+
function startWebSocketConnection(app:any)
|
|
166
|
+
{
|
|
167
|
+
// console.log("Starting WebSocket Connection Listener")
|
|
168
|
+
const ews = expressWS(app)
|
|
169
|
+
const wsapp = ews.app
|
|
170
|
+
|
|
171
|
+
socketClose = (e:any) => {
|
|
172
|
+
// console.log("close wss", e)
|
|
173
|
+
ews.getWss().close()
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
// wsapp.use((err:any, req:any, res:any, next:any) => {
|
|
178
|
+
// console.error(err.stack);
|
|
179
|
+
// res.status(500).send('Something broke!');
|
|
180
|
+
// })
|
|
181
|
+
|
|
182
|
+
wsapp.get('/watch', (req:any, res:any, next:any) => {
|
|
183
|
+
// console.log('get route', req.testing)
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
wsapp.ws('/watch', (ws:any, req:any) => {
|
|
187
|
+
ws.on('message', (msg:string)=> {
|
|
188
|
+
// console.log('Received WS Message: ' + msg)
|
|
189
|
+
ws.send(msg)
|
|
190
|
+
})
|
|
191
|
+
ws.on('close', () => {
|
|
192
|
+
// console.log("Websocket connection closed")
|
|
193
|
+
})
|
|
41
194
|
})
|
|
42
|
-
// ================================================
|
|
43
195
|
}
|
package/src/expressRoutes/all.ts
CHANGED
|
@@ -29,7 +29,6 @@ export function allBinder (): void {
|
|
|
29
29
|
*/
|
|
30
30
|
router.all('*', (req, res, next) => {
|
|
31
31
|
// any PHP requests should be ignored
|
|
32
|
-
// ClogTrace('incoming: '+req.originalUrl)
|
|
33
32
|
if (req.originalUrl.includes('.php')) {
|
|
34
33
|
return res.send('')
|
|
35
34
|
}
|
|
@@ -84,12 +83,14 @@ export function allBinder (): void {
|
|
|
84
83
|
return res.sendStatus(200)
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
if (!filepath.endsWith('.websocket')) {
|
|
87
|
+
filepath = path.resolve(path.join(projectPaths.basePath, 'webroot', filepath)) // .. out of build
|
|
88
|
+
if (fs.existsSync(filepath)) {
|
|
89
|
+
return res.sendFile(filepath)
|
|
90
|
+
} else {
|
|
91
|
+
console.log(ac.red.bold("can't find " + filepath))
|
|
92
|
+
return res.sendStatus(404)
|
|
93
|
+
}
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
// if none of the above, tickle enumerator so we can process other paths
|
|
@@ -18,42 +18,49 @@ export function functionBinder (): void {
|
|
|
18
18
|
const projectPaths = resolvePaths()
|
|
19
19
|
|
|
20
20
|
for (const def of defs) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
let { name, pathMap, method } = def
|
|
22
|
+
try {
|
|
23
|
+
if(!method) {
|
|
24
|
+
console.log(ac.red('no method defined for ' + name));
|
|
25
|
+
if(def.allowedMethods) {
|
|
26
|
+
console.log(ac.bgBlack.yellowBright('DEPRECATED')+ac.blue(' As of v1.1.8, The use of ')+ac.black.italic('allowedMethods')+ac.blue(' is replaced by the single' +
|
|
27
|
+
ac.black.italic(' method ')+ac.blue('property.')+ac.black.bold('Please update your definition file')));
|
|
28
|
+
method = def.allowedMethods.split(',')[0]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
method = method.trim().toLowerCase()
|
|
33
|
+
const rpath = path.join(projectPaths.buildPath, 'functions', name, 'src', 'main.js')
|
|
34
|
+
clearModule(rpath)
|
|
35
|
+
const { start } = require(rpath)
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
handleResponse(res, respOut)
|
|
38
|
-
}).catch<any>((reason: any) => undefined)
|
|
39
|
-
}
|
|
37
|
+
let entryRoot: string = pathMap
|
|
38
|
+
const n = entryRoot.indexOf('/{')
|
|
39
|
+
if (n !== -1) entryRoot = entryRoot.substring(0, n) + '/*'
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
41
|
+
const callHandler = (pathMap: string, req: any, res: any): void => {
|
|
42
|
+
const event = requestToEvent(pathMap, req)
|
|
43
|
+
Promise.resolve(start(event, null, null)).then(respOut => {
|
|
44
|
+
handleResponse(res, respOut)
|
|
45
|
+
}).catch<any>((reason: any) => undefined)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (method === 'get') {
|
|
49
|
+
router.get(entryRoot, (req, res) => callHandler(pathMap, req, res))
|
|
50
|
+
} else if (method === 'post') {
|
|
51
|
+
router.post(entryRoot, (req, res) => callHandler(pathMap, req, res))
|
|
52
|
+
} else if (method === 'put') {
|
|
53
|
+
router.put(entryRoot, (req, res) => callHandler(pathMap, req, res))
|
|
54
|
+
} else if (method === 'patch') {
|
|
55
|
+
router.patch(entryRoot, (req, res) => callHandler(pathMap, req, res))
|
|
56
|
+
} else if (method === 'delete') {
|
|
57
|
+
router.delete(entryRoot, (req, res) => callHandler(pathMap, req, res))
|
|
58
|
+
} else {
|
|
59
|
+
console.log(ac.red.bold('Cannot map method ') + ac.blue.bold(method))
|
|
56
60
|
}
|
|
61
|
+
} catch (e: any) {
|
|
62
|
+
// Log.Error(ac.bold.red(e.message.split('\n')[0]))0
|
|
63
|
+
Log.Exception(e)
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
}).catch<any>((reason: any) => undefined)
|
|
@@ -9,12 +9,14 @@ export type RecurseCB = (filepath: string, stats: Stats) => boolean
|
|
|
9
9
|
export function recurseDirectory (dirpath: string, callback?: RecurseCB): void {
|
|
10
10
|
fs.readdirSync(dirpath).forEach((file: string) => {
|
|
11
11
|
const fpath = path.join(dirpath, file)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
|
|
12
|
+
// if(fpath.indexOf('node_modules') === -1) {
|
|
13
|
+
const stat = fs.statSync(fpath)
|
|
14
|
+
if ((callback != null) && !callback(fpath, stat)) {
|
|
15
|
+
if (stat.isDirectory()) {
|
|
16
|
+
recurseDirectory(fpath, callback)
|
|
17
|
+
}
|
|
16
18
|
}
|
|
17
|
-
}
|
|
19
|
+
// }
|
|
18
20
|
})
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -5,6 +5,7 @@ import { OpenApiBuilder } from 'openapi3-ts/oas30'
|
|
|
5
5
|
import fs from 'fs'
|
|
6
6
|
import path from 'path'
|
|
7
7
|
import { resolvePaths } from '../pathResolve'
|
|
8
|
+
import * as ac from 'ansi-colors'
|
|
8
9
|
|
|
9
10
|
export async function buildOpenApi (
|
|
10
11
|
defs: any[],
|
|
@@ -49,18 +50,24 @@ export async function buildOpenApi (
|
|
|
49
50
|
if (def.private === true && !includePrivate) continue // skip private
|
|
50
51
|
|
|
51
52
|
const parameters = def.parameters ?? []
|
|
52
|
-
|
|
53
|
+
let method = def.method
|
|
54
|
+
if(!def.method) {
|
|
55
|
+
console.log(ac.red('no method defined for ' + def.name));
|
|
56
|
+
if(def.allowedMethods) {
|
|
57
|
+
console.log(ac.bgBlack.yellowBright('DEPRECATED')+ac.blue(' As of v1.1.8, The use of ')+ac.black.italic('allowedMethods')+ac.blue(' is replaced by the single' +
|
|
58
|
+
ac.black.italic(' method ')+ac.blue('property.')+ac.black.bold('Please update your definition file')));
|
|
59
|
+
def.method = def.allowedMethods.split(',')[0]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
53
62
|
const schemas = def.schemas ?? {}
|
|
54
63
|
for (const schemaName of Object.getOwnPropertyNames(schemas)) {
|
|
55
64
|
const schema = schemas[schemaName]
|
|
56
65
|
addTypeSchema(builder, schemaName, schema)
|
|
57
66
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
addParameter(pathDef, param)
|
|
63
|
-
}
|
|
67
|
+
method = method.trim().toLowerCase()
|
|
68
|
+
addFunctionMethod(pathDef, method, def)
|
|
69
|
+
for (const param of parameters) {
|
|
70
|
+
addParameter(pathDef, param)
|
|
64
71
|
}
|
|
65
72
|
addCORSOptionMethod(pathDef)
|
|
66
73
|
builder.addPath((def.pathMap ?? '/' + (def.name as string)), pathDef)
|