feat: pass isAuthenticated to function call
Signed-off-by: Innei <i@innei.in>
This commit is contained in:
@@ -70,7 +70,7 @@ export class DebugController {
|
||||
const result =
|
||||
await this.serverlessService.injectContextIntoServerlessFunctionAndCall(
|
||||
model,
|
||||
{ req, res: createMockedContextResponse(res) },
|
||||
{ req, res: createMockedContextResponse(res), isAuthenticated: true },
|
||||
)
|
||||
|
||||
if (!res.sent) {
|
||||
|
||||
@@ -119,7 +119,7 @@ export class ServerlessController {
|
||||
const result =
|
||||
await this.serverlessService.injectContextIntoServerlessFunctionAndCall(
|
||||
snippet,
|
||||
{ req, res: createMockedContextResponse(reply) },
|
||||
{ req, res: createMockedContextResponse(reply), isAuthenticated },
|
||||
)
|
||||
|
||||
if (!reply.sent) {
|
||||
|
||||
@@ -51,6 +51,11 @@ import { allBuiltInSnippetPack as builtInSnippets } from './pack'
|
||||
import { ServerlessStorageCollectionName } from './serverless.model'
|
||||
import { complieTypeScriptBabelOptions, hashStable } from './serverless.util'
|
||||
|
||||
type ScopeContext = {
|
||||
req: FunctionContextRequest
|
||||
res: FunctionContextResponse
|
||||
isAuthenticated: boolean
|
||||
}
|
||||
class CleanableScope {
|
||||
public scopeContextLRU = new LRUCache<string, any>({
|
||||
max: 100,
|
||||
@@ -279,7 +284,7 @@ export class ServerlessService implements OnModuleInit {
|
||||
|
||||
async injectContextIntoServerlessFunctionAndCall(
|
||||
model: SnippetModel,
|
||||
context: { req: FunctionContextRequest; res: FunctionContextResponse },
|
||||
context: ScopeContext,
|
||||
) {
|
||||
const { raw: functionString } = model
|
||||
const scope = `${model.reference}/${model.name}`
|
||||
@@ -457,10 +462,7 @@ export class ServerlessService implements OnModuleInit {
|
||||
|
||||
private async createScopeContext(
|
||||
scope: string,
|
||||
context: {
|
||||
req: FunctionContextRequest
|
||||
res: FunctionContextResponse
|
||||
},
|
||||
context: ScopeContext,
|
||||
model: SnippetModel,
|
||||
logger: Logger,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user