Files
forgetmenot-nextjs/web/pages/api/v1/hello.js
2022-06-27 09:08:26 -05:00

29 lines
685 B
JavaScript

import db from "../../../lib/db";
import { withErrorHandling } from "../../../lib/apiHelpers";
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 get = async (req, res) => {
const params = {
TableName: process.env.FMN_DYNAMODB_TABLENAME,
KeyConditionExpression: "hk = :hk",
ExpressionAttributeValues: { ":hk": "benramey@fastmail.com" },
};
let user = await db.query(params).promise();
res.status(200).json(user);
};
export default handler;