0.0.6 • Published 7 years ago

http-for-serverless v0.0.6

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

HTTP tools for Serverless

Express-like helper for Lambda http events.

A WORK IN PROGRESS

Inspired by Express and https://github.com/dougmoscrop/serverless-http.

Examples

JSON

var http = require('http-for-serverless');

module.exports.endpoint = http((req, req) => {
  res.json({
    message: `Hello, the current time is ${new Date().toTimeString()}.`,
  });
});

HTML

var http = require('http-for-serverless');

module.exports.endpoint = http((req, req) => {
  res.send(`
    <!DOCTYPE html>
    <html>
      <head>
        <title>http-for-serverless</title>
      </head>
      <body>
        <p>Hello, the current time is ${new Date().toTimeString()}.</p>
      </body>
    </html>`);
});

React

react & react-dom are required

var http = require('http-for-serverless');
var View = require('./views/View');

module.exports.endpoint = http((req, req) => {
  // <DOCTYPE html> is automatically prepended to the rendered component
  // if the output begins with "<html"
  res.render(View, {
    time: new Date().toTimeString()
  });
});
0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago