Skip to content

Commit

Permalink
fix(app-service): fix require in cloud function fatal error
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Nov 9, 2021
1 parent b4bc9d2 commit 1c12af5
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions packages/app-service/src/lib/function.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@


import * as engine from "cloud-function-engine"
import { ObjectId } from "mongodb"


export enum FunctionStatus {
DISABLED = 0,
ENABLED = 1
Expand All @@ -28,22 +28,21 @@ export interface CloudFunctionStruct extends engine.CloudFunctionStruct {
created_by: any
}

/**
* Custom require function in cloud function
* @see CloudFunction.require_func
* @param module the module id. ex. `path`, `lodash`
* @returns
*/
engine.CloudFunction.require_func = (module: string): any => {
if (module === '@/cloud-sdk') {
return require('../cloud-sdk')
}

export class CloudFunction extends engine.CloudFunction {
/**
* Custom require function in cloud function
* @see CloudFunction.require_func
* @param module the module id. ex. `path`, `lodash`
* @returns
*/

static require_func = (module: string): any => {
if (module === '@/cloud-sdk') {
return require('../../cloud-sdk')
}
return require(module) as any
}

return require(module) as any
}
export class CloudFunction extends engine.CloudFunction {

/**
* Function data
Expand Down

0 comments on commit 1c12af5

Please sign in to comment.