Starting on working bookmarks api

This commit is contained in:
2022-06-27 09:01:36 -05:00
parent 4c37658cd8
commit 6fe79a1892
13 changed files with 652 additions and 58 deletions

View File

@@ -1,23 +1,26 @@
const AWS = require("aws-sdk");
import db from "../../lib/db";
import { withErrorHandling } from "../../lib/apiHelpers";
AWS.config.update({
accessKeyId: process.env.FMN_AWS_ACCESS_KEY_ID, // Do NOT HARD-CODE your secret credentials here
secretAccessKey: process.env.FMN_AWS_SECRET_ACCESS_KEY, // Do NOT HARD-CODE your secret credentials here
region: process.env.FMN_AWS_REGION,
const handler = withErrorHandling(async (req, res) => {
const { method } = req;
switch (method) {
case "GET":
await get(req, res);
default:
res.setHeader("Allow", ["GET"]);
res.status(405).end(`Method ${method} Not Allowed`);
}
});
const dynamodb = new AWS.DynamoDB.DocumentClient({
region: process.env.FMN_AWS_REGION,
});
const handler = async (req, res) => {
const get = async (req, res) => {
const params = {
TableName: process.env.FMN_DYNAMODB_TABLENAME,
KeyConditionExpression: "hk = :hk",
ExpressionAttributeValues: { ":hk": "benramey@fastmail.com" },
};
let user = await dynamodb.query(params).promise();
let user = await db.query(params).promise();
res.status(200).json(user);
};