Version: 0.1.2
Last Updated: Unknown
1const AWS = require('aws-sdk');2const S3 = new AWS.S3();3const EXAMPLE_ENV_VAR = process.env.EXAMPLE_ENV_VAR || '';45exports.handler = async function (event, context) {6 try {7 // We got something besides a GET, POST, or DELETE8 return {9 statusCode: 200,10 headers: {},11 body: 'Success',12 };13 } catch (error) {14 var body = error.stack || JSON.stringify(error, null, 2);15 return {16 statusCode: 400,17 headers: {},18 body: body,19 };20 }21};
1#!/usr/bin/env node2const path = require('path');3const fs = require('fs');4const dir = __dirname;5const cwd = process.cwd();6const map = JSON.parse(7 fs.readFileSync(path.resolve(dir, './map.json'), 'utf-8'),8);910let filesErr = [];1112const build = ({ dependencies, data, file, output, basedir }) => {13 dependencies.ejs.renderFile(file, data, {}, function (err, str) {14 // str => Rendered HTML string15 if (err) {16 filesErr.push(output);17 throw err;18 }1920 const outputFilePath = `${basedir}/${output}`;21 dependencies.fs.outputFileSync(outputFilePath, str);22 });23};2425module.exports = async function (options) {26 console.log('Bridging Node Lambda Function');27 try {28 const files = await options.dependencies.recursiveReaddir(dir, ['!*.ejs']);29 const basedir = options.data.basedir30 ? path.resolve(cwd, options.data.basedir)31 : cwd;3233 for (const file of files) {34 let filepath = file.replace(dir + '/', '');35 console.log(`\t - Scaffolding: ${filepath}`);36 build({ ...options, file, output: map[filepath], basedir });37 }3839 return options;40 } catch (err) {41 console.error(err);42 }43};
1{2 "entry.ejs": "index.js",3 "readme.ejs": "README.md"4}
1# <%= name %> Lambda Function