Skip to content

Instantly share code, notes, and snippets.

View wenheqi's full-sized avatar

Wenhe Qi wenheqi

View GitHub Profile
@wenheqi
wenheqi / index.js
Last active July 24, 2020 21:26
Serve front-end web pages and backend APIs under the same URL
const express = require("express");
const path = require("path");
const PORT = process.env.PORT || 5000;
const app = express();
const router = express.Router();
// this middleware function must come before
// express.static middleware
router.use("/", (req, res, next) => {
@wenheqi
wenheqi / index.js
Created July 23, 2020 06:15
Connect DynamoDB from Lambda function
const AWS = require('aws-sdk');
const ddb = new AWS.DynamoDB.DocumentClient();
exports.handler = (event, context, callback) => {
const params = {
TableName: "TABLE_NAME_HERE",
Key: {
"KEY_NAME_HERE": "KEY_VALUE_HERE"
}
}