How to use serverless-http - 10 common examples

To help you get started, we’ve selected a few serverless-http 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 infrastructure-components / infrastructure-components / src / assets / server.tsx View on Github external
`
}


// we're exporting the handler-function as default, must match the sls-config!
//export default (assetsDir, resolvedAssetsPath) => serverless(createServer(assetsDir, resolvedAssetsPath));

/*
const serverIndexPath = path.join(serverPath, "index.js");
fs.writeFileSync(serverIndexPath, `const lib = require ('./server');
const server = lib.default('${ssrConfig.assetsPath}', '${resolveAssetsPath(ssrConfig)}');
exports.default = server;*/

// these variables are replaced during compilation
export default serverless(createServer(__ASSETS_PATH__, __RESOLVED_ASSETS_PATH__, __ISOMORPHIC_ID__, __ISOFFLINE__));
github infrastructure-components / infrastructure-components / src / assets / soa-server.tsx View on Github external
} else if (service.method.toUpperCase() == "DELETE") {
            app.delete(service.path, ...unpackMiddlewares(service.middlewares));

        }

        return service;
    });

    return app;
};



// these variables are replaced during compilation
export default serverless(createServer(__SERVICEORIENTED_ID__, __ISOFFLINE__));
github shavo007 / serverless-nodejs-starter / src / index.js View on Github external
// index.js

import serverless from 'serverless-http'
import express from 'express'
import wiki from './wiki'

const app = express()

app.use(express.json())
app.use(express.urlencoded({ extended: true }))

app.use('/wiki', wiki)

module.exports.handler = serverless(app)
github zhenyulin / serverless-hot-boilerplate / src / handlers / get.js View on Github external
import serverless from 'serverless-http';
import express from 'express';

import Todo from 'models/todo';

export const handler = async (req, res) => {
	const result = await Todo.get({
		id: req.params.id,
	});
	res.json(result);
};

export const app = express().use('/todos/:id', handler);

export default serverless(app);
github netlify-labs / netlify-functions-express / functions / api.js View on Github external
import serverless from 'serverless-http'
import express from 'express'

const app = express()

app.get('/yo', (req, res) => {
  res.send('Hello World!')
})

exports.handler = serverless(app)
github zhenyulin / serverless-hot-boilerplate / src / handlers / update.js View on Github external
import Todo from 'models/todo';

export const handler = async (req, res) => {
	const result = await Todo.update(
		{
			id: req.params.id,
		},
		req.body,
	);
	res.json(result);
};

export const app = express().use('/todos/:id', [bodyParser.json(), handler]);

export default serverless(app);
github pharindoko / json-serverless / src / server / handler.ts View on Github external
import { APIGatewayProxyHandler } from 'aws-lambda';
import express from 'express';
import serverlessHttp from 'serverless-http';
import { AppConfig } from './app/app.config';
import fs from 'fs';
import { CloudApp } from './app';
import { Swagger } from './specifications/swagger/swagger';
import { SwaggerConfig } from './specifications/swagger/swagger.config';
import { S3StorageAdapter } from './storage/s3.storage';
import { CloudEnvironment } from './environment/cloud.environment';

const server = express();
const sls = serverlessHttp(server);
const defaultConfig = new AppConfig();
const config = JSON.parse(fs.readFileSync('./config/appconfig.json', 'UTF-8'));
const appConfig = AppConfig.merge(defaultConfig, config);
const environment = new CloudEnvironment();
const swagger = new Swagger(
  server,
  new SwaggerConfig(appConfig.readOnly, appConfig.enableApiKeyAuth),
  environment.basePath
);
const core = new CloudApp(
  appConfig,
  server,
  new S3StorageAdapter(environment.s3Bucket, environment.s3File),
  swagger
);
(async () => {
github webiny / webiny-js / examples / graphql / src / lambda.js View on Github external
import serverless from "serverless-http";
import app from "./graphql";

export const handler = serverless(app());
github kiwicom / margarita / apps / graphql / src / server.js View on Github external
},
  },
  introspection: true,
});

const app = express();
app.use(compression({ threshold: 0 }));
app.use(cors());

if (isDevelopment) {
  app.use(morgan('dev'));
}

server.applyMiddleware({ app });

const handler = serverless(app);
export { handler };
github zhenyulin / serverless-hot-boilerplate / src / handlers / create.js View on Github external
import Todo from 'models/todo';

const handler = async (req, res) => {
	const { text } = req.body;
	const result = await Todo.create({
		id: uuid.v1(),
		text,
		checked: false,
	});
	res.json(result);
};

export const app = express().use([bodyParser.json(), handler]);

export default serverless(app);

serverless-http

Use existing web application frameworks in serverless environments

MIT
Latest version published 2 years ago

Package Health Score

64 / 100
Full package analysis

Popular serverless-http functions