How to use the @faasjs/load.loadConfig 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 / server / src / index.ts View on Github external
try {
            const ts = await loadTs(cache.file, { tmp: true });
            func = ts.module;
          } catch (error) {
            this.logger.error(error);
            res.statusCode = 500;
            res.write(error.message);
            res.end();
            return reject(error);
          }
        }
      }
      try {
        if (!cache.handler) {
          // 读取云函数配置并写入缓存
          func.config = loadConfig(this.root, path).development;
          // eslint-disable-next-line require-atomic-updates
          cache.handler = func.export().handler;
        }

        let body = '';
        req.on('readable', function () {
          body += req.read() || '';
        });

        req.on('end', async () => {
          const uri = URL.parse(req.url!);

          let data;
          try {
            data = await cache.handler({
              headers: req.headers,
github faasjs / faasjs / packages / deployer / src / index.ts View on Github external
constructor (data: DeployData) {
    data.name = data.filename.replace(data.root, '').replace('.func.ts', '').replace(/^\/?[^/]+\//, '').replace(/\/$/, '');
    data.version = new Date().toLocaleString('zh-CN', {
      hour12: false,
      timeZone: 'Asia/Shanghai',
    }).replace(/(\/|:|\s)/g, '_');

    data.logger = new Logger('Deployer');

    const Config = loadConfig(data.root, data.filename);

    if (!data.env) {
      data.env = process.env.FaasEnv || Config.defaults.deploy.env;
    }

    data.config = Config[data.env!];

    if (!data.config) {
      throw Error(`Config load failed: ${data.env}`);
    }

    data.tmp = `${data.root}/tmp/${data.env}/${data.name}/${data.version}/`;

    data.tmp.split('/').reduce(function (acc: string, cur: string) {
      acc += '/' + cur;
      if (!existsSync(acc)) {

@faasjs/load

FaasJS's load module.

MIT
Latest version published 15 hours ago

Package Health Score

81 / 100
Full package analysis

Similar packages