This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http = require("http"); | |
url = require("url"); | |
fizzBuzz = function(v) { | |
return (v%15===0) && "FizzBuzz" || (v%3===0) && "Fizz" || (v%5===0) && "Buzz" || v; | |
}; | |
http.createServer(function(req, res) { | |
var i = parseInt(url.parse(req.url).pathname.substring(1)); | |
res.writeHead(200, {"Content-Type": "application/json"}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.handler = function (req, res) { | |
return res.send('Hello World!') | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config() | |
import { MongoClient } from 'mongodb' | |
const connectMongoDB = () => MongoClient.connect(process.env.MONGODB) | |
const getContacts = (req, res) => { | |
return connectMongoDB() | |
.then( | |
db => db.collection('contacts') | |
.find({}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config() | |
import { MongoClient } from 'mongodb' | |
const connectMongoDB = () => MongoClient.connect(process.env.MONGODB) | |
const getContacts = (req, res) => { | |
return connectMongoDB() | |
.then( | |
db => db.collection('contacts') | |
.find({}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config() | |
const { MongoClient } = require('mongodb') | |
const connectMongoDB = () => MongoClient.connect(process.env.MONGODB) | |
const getContacts = (req, res) => { | |
return connectMongoDB() | |
.then( | |
db => db.collection('contacts') | |
.find({}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config() | |
import { MongoClient } from 'mongodb' | |
import { get, post, router } from 'microrouter' | |
const connectMongoDB = () => MongoClient.connect(process.env.MONGODB) | |
const getContacts = async (req, res) => { | |
const db = await connectMongoDB() | |
const contacts = await db.collection('contacts').find({}).toArray() | |
db.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.handler = (event, context, callback) => { | |
const response = { | |
statusCode: 200, | |
body: 'Hello World!', | |
} | |
callback(null, response) | |
// Use this code if you don't use the http event with the LAMBDA-PROXY integration | |
// callback(null, { message: 'Go Serverless v1.0! Your function executed successfully!', event }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const serverless = require('serverless-http') | |
const { handler } = require('./index') | |
const app = express() | |
app.use(handler) | |
module.exports.handler = serverless(app) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service: hello-world | |
provider: | |
name: aws | |
runtime: nodejs6.10 | |
functions: | |
hello: | |
handler: index-aws.handler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.handler = function (req, res) { | |
return res.send('My Serverless App') | |
} |
OlderNewer