How to use the @faasjs/load.loadNpmVersion function in @faasjs/load

To help you get started, we’ve selected a few @faasjs/load examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github faasjs / faasjs / packages / cloud_function / src / index.ts View on Github external
public async onDeploy (data: DeployData, next: Next) {
    data.logger!.debug('[CloudFunction] 组装云函数配置');
    data.logger!.debug('%o', data);

    const config = deepMerge(data.config!.plugins![this.name || this.type], { config: this.config });

    data.logger!.debug('[CloudFunction] 组装完成 %o', config);

    // 引用服务商部署插件
    // eslint-disable-next-line security/detect-non-literal-require, @typescript-eslint/no-var-requires
    const Provider = require(config.provider.type);
    const provider = new Provider(config.provider.config);

    data.dependencies![config.provider.type as string] = loadNpmVersion(config.provider.type);

    // 部署云函数
    await provider.deploy(this.type, data, config);

    await next();
  }
github faasjs / faasjs / packages / sql / src / index.ts View on Github external
public async onDeploy (data: DeployData, next: Next) {
    switch (this.adapterType || data.config!.plugins[this.name || this.type].adapter) {
      case 'sqlite':
        data.dependencies!['sqlite3'] = loadNpmVersion('sqlite3')!;
        break;
      case 'postgresql':
        data.dependencies!['pg'] = loadNpmVersion('pg')!;
        break;
      case 'mysql':
        data.dependencies!['mysql'] = loadNpmVersion('mysql')!;
        break;
      default:
        throw Error(`[Sql] Unsupport type: ${this.adapterType || data.config!.plugins[this.name || this.type].type}`);
    }
    await next();
  }
github faasjs / faasjs / packages / sql / src / index.ts View on Github external
public async onDeploy (data: DeployData, next: Next) {
    switch (this.adapterType || data.config!.plugins[this.name || this.type].adapter) {
      case 'sqlite':
        data.dependencies!['sqlite3'] = loadNpmVersion('sqlite3')!;
        break;
      case 'postgresql':
        data.dependencies!['pg'] = loadNpmVersion('pg')!;
        break;
      case 'mysql':
        data.dependencies!['mysql'] = loadNpmVersion('mysql')!;
        break;
      default:
        throw Error(`[Sql] Unsupport type: ${this.adapterType || data.config!.plugins[this.name || this.type].type}`);
    }
    await next();
  }
github faasjs / faasjs / packages / sql / src / index.ts View on Github external
public async onDeploy (data: DeployData, next: Next) {
    switch (this.adapterType || data.config!.plugins[this.name || this.type].adapter) {
      case 'sqlite':
        data.dependencies!['sqlite3'] = loadNpmVersion('sqlite3')!;
        break;
      case 'postgresql':
        data.dependencies!['pg'] = loadNpmVersion('pg')!;
        break;
      case 'mysql':
        data.dependencies!['mysql'] = loadNpmVersion('mysql')!;
        break;
      default:
        throw Error(`[Sql] Unsupport type: ${this.adapterType || data.config!.plugins[this.name || this.type].type}`);
    }
    await next();
  }

@faasjs/load

FaasJS's load module.

MIT
Latest version published 15 hours ago

Package Health Score

81 / 100
Full package analysis

Similar packages