forked from labring/laf
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(docker): 修改启动命令;优化 dockerfile;增加 docker-compose 启动安全性配置;
- Loading branch information
Showing
15 changed files
with
157 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules | ||
.env | ||
ecosystem.config.js | ||
dist | ||
dist | ||
data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ tmp | |
|
||
.env | ||
|
||
ecosystem.config.js | ||
ecosystem.config.js | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"action": "database.queryDocument", | ||
"collectionName": "permissions", | ||
"limit": 10, | ||
"limit": 20, | ||
"queryType": "WHERE" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"params": { | ||
"test": 1 | ||
} | ||
"username": "less", | ||
"password": "less123" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
# 读数据 | ||
ab -n 10000 -c 100 -p ./db_read.json -T application/json -H "Authorization: Bearer eyJ1aWQiOiI2MDU1YTJhYWYyODhhNzQyNjEyNjA1MmYiLCJ0eXBlIjoiYWRtaW4iLCJleHBpcmUiOjE2MTcxNTY1MjY0MDJ9.a2ef2628165b3071a1694151111ca921" http://localhost:8080/admin/entry | ||
ab -n 10000 -c 100 -p ./db_read.json -T application/json -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI2MDg1MzhkMjhlMWI0MTM2YjEyMzIyZjIiLCJ0eXBlIjoiYWRtaW4iLCJleHAiOjE2Mjc1NTEyNzksImlhdCI6MTYyNjk0NjQ3OX0.BFJPeJYb9-tifpKWKW2C0ipWSwy9pEFvrORqrIbNh9s" http://localhost:8080/admin/entry | ||
|
||
|
||
# 云函数调用 | ||
ab -n 1000 -c 100 -p ./empty.json -T application/json -H "Authorization: Bearer eyJ1aWQiOiI2MDU1YTJhYWYyODhhNzQyNjEyNjA1MmYiLCJ0eXBlIjoiYWRtaW4iLCJleHBpcmUiOjE2MTcxNTY1MjY0MDJ9.a2ef2628165b3071a1694151111ca921" http://localhost:8080/admin//func/invoke/hello | ||
|
||
|
||
ab -n 1000 -c 100 -p ./empty.json -T application/json http://localhost:8000/prod-api/func/invoke/user-passwd-login |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,65 @@ | ||
|
||
const path = require('path') | ||
const assert = require('assert') | ||
const { FunctionEngine } = require('../../dist/lib/faas/index') | ||
const { handler } = require('./func') | ||
const { FunctionEngine } = require('../../dist/lib/faas/engine') | ||
const ts = require('typescript') | ||
|
||
|
||
const source = ` | ||
import * as crypto from 'crypto' | ||
exports.main = async function (ctx: any) { | ||
console.log(ctx) | ||
console.log(crypto) | ||
return 'ok' | ||
} | ||
` | ||
|
||
const source2 = ` | ||
import * as crypto from 'crypto' | ||
export async function main (ctx: any) { | ||
console.log(ctx) | ||
console.log(crypto) | ||
return 'ok' | ||
} | ||
` | ||
|
||
describe("FaaS Engine", () => { | ||
|
||
it("constructor", async () => { | ||
const engine = new FunctionEngine() | ||
assert(engine instanceof FunctionEngine) | ||
}) | ||
|
||
it("run code", async () => { | ||
it("run code 1", async () => { | ||
const engine = new FunctionEngine() | ||
|
||
const result = ts.transpile(source2, { | ||
module: ts.ModuleKind.CommonJS, | ||
target: ts.ScriptTarget.ES2017 | ||
}) | ||
|
||
const code = result | ||
const ret = await engine.run(code, { | ||
context: {} | ||
}) | ||
assert.strictEqual(ret.data, 'ok') | ||
}) | ||
|
||
it("run code 2", async () => { | ||
const engine = new FunctionEngine() | ||
|
||
const code = handler.toString() | ||
const ret = await engine.run(code, {}) | ||
assert.strictEqual(ret, 'ok') | ||
const result = ts.transpile(source2, { | ||
module: ts.ModuleKind.CommonJS, | ||
target: ts.ScriptTarget.ES2017 | ||
}) | ||
|
||
const code = result | ||
const ret = await engine.run(code, { | ||
context: {} | ||
}) | ||
assert.strictEqual(ret.data, 'ok') | ||
}) | ||
|
||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const crypto = require("crypto"); | ||
exports.main = async function (ctx) { | ||
console.log(ctx); | ||
console.log(crypto); | ||
return 'ok'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as crypto from 'crypto' | ||
|
||
exports.main = async function (ctx: any) { | ||
console.log(ctx) | ||
console.log(crypto) | ||
return 'ok' | ||
} | ||
|
||
|
||
// tsc --lib es6 -t ES2017 -m commonjs --pretty index.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
const ts = require('typescript') | ||
|
||
const source = ` | ||
import * as crypto from 'crypto' | ||
exports.main = async function (ctx: any) { | ||
console.log(ctx) | ||
console.log(crypto) | ||
return 'ok' | ||
} | ||
` | ||
|
||
const result = ts.transpile(source, { | ||
module: ts.ModuleKind.CommonJS, | ||
target: ts.ScriptTarget.ES2017 | ||
}) | ||
|
||
console.log(result) |