How to use the @faasjs/server.Server function in @faasjs/server

To help you get started, we’ve selected a few @faasjs/server 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 / nuxt / src / index.ts View on Github external
}) {
  this.addPlugin({
    src: __dirname + '/plugins/browser.js',
    options,
    mode: 'client'
  });

  this.addPlugin({
    src: __dirname + '/plugins/server.js',
    options,
    mode: 'server'
  });

  if (this.options.dev) {
    const Server = require('@faasjs/server').Server;
    const server = new Server(options.root);

    if (!process.env.FaasEnv && process.env.NODE_ENV === 'development') {
      process.env.FaasEnv = 'development';
    }

    process.env.FaasMode = 'local';
    process.env.FaasLocal = `http${this.options.server.https ? 's' : ''}://${this.options.server.host}:${this.options.server.port}/_faas`;

    console.log(`[faas] Mode: ${process.env.FaasMode} Env: ${process.env.FaasEnv} Local: ${process.env.FaasLocal}`);

    this.addServerMiddleware({
      path: '/_faas',
      async handler(req: any, res: any) {
        await server.processRequest(req, res);
      }
    });
github faasjs / faasjs / packages / cli / src / commands / server.ts View on Github external
export async function action (opts: {
  port: number;
  cache: boolean;
}) {
  defaultsEnv();
  const server = new Server(process.env.FaasRoot!, {
    cache: opts.cache
  });

  const port = opts.port || 3000;
  server.listen(port);

  return true;
}

@faasjs/server

## Functions

MIT
Latest version published 9 hours ago

Package Health Score

81 / 100
Full package analysis

Popular @faasjs/server functions

Similar packages