Skip to content

Commit

Permalink
chore: use esm export
Browse files Browse the repository at this point in the history
  • Loading branch information
zixiang2018 committed Jan 3, 2024
1 parent c6e903b commit 80d77c3
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 40 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"func-names": ["error", "as-needed"],
"prettier/prettier": "error",
"no-unused-expressions": "off",
"import/no-import-module-exports": "off"
"import/no-import-module-exports": "off",
"import/prefer-default-export": "off"

}
}
14 changes: 6 additions & 8 deletions src/email/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const validateApiKey = (key) => {
throw new Error("Invalid API key");
};

const handleEmail = async (event, _context, callback) => {
const handleEmail = async (event) => {
try {
const { to, data, captcha } = JSON.parse(event.body);

Expand Down Expand Up @@ -50,18 +50,16 @@ const handleEmail = async (event, _context, callback) => {
// Send certificate out
await certificateMailer({ to, certificate: data });

callback(null, {
return {
statusCode: 200,
body: JSON.stringify({ success: true })
});
};
} catch (e) {
callback(null, {
return {
statusCode: 400,
body: JSON.stringify({ error: e.message })
});
};
}
};

const handler = middy().use(cors()).handler(handleEmail);

module.exports = { handler };
export const handler = middy().use(cors()).handler(handleEmail);
6 changes: 1 addition & 5 deletions src/storage/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,4 @@ const handleCreate = async (event) => {
}
};

const handler = middy().use(cors()).handler(handleCreate);

module.exports = {
handler
};
export const handler = middy().use(cors()).handler(handleCreate);
6 changes: 1 addition & 5 deletions src/storage/createAtId.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,4 @@ const handleCreateAtId = async (event) => {
}
};

const handler = middy().use(cors()).handler(handleCreateAtId);

module.exports = {
handler
};
export const handler = middy().use(cors()).handler(handleCreateAtId);
6 changes: 1 addition & 5 deletions src/storage/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,4 @@ const handleGet = async (event) => {
}
};

const handler = middy().use(cors()).handler(handleGet);

module.exports = {
handler
};
export const handler = middy().use(cors()).handler(handleGet);
6 changes: 1 addition & 5 deletions src/storage/queueNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,4 @@ const handleQueueNumber = async () => {
}
};

const handler = middy().use(cors()).handler(handleQueueNumber);

module.exports = {
handler
};
export const handler = middy().use(cors()).handler(handleQueueNumber);
17 changes: 6 additions & 11 deletions src/verify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import cors from "@middy/http-cors";
const { verify, isValid } = require("@govtechsg/opencerts-verify");
const config = require("./config");

// adding a comment to trigger a deploy
const handleVerify = async (event, _context, callback) => {
const handleVerify = async (event) => {
const { document } = JSON.parse(event.body);
try {
const fragments = await verify({ network: config.network })(document);
callback(null, {
return {
statusCode: 200,
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
Expand All @@ -21,17 +20,13 @@ const handleVerify = async (event, _context, callback) => {
},
data: fragments
})
});
};
} catch (e) {
callback(null, {
return {
statusCode: 400,
body: e.message
});
};
}
};

const handler = middy().use(cors()).handler(handleVerify);

module.exports = {
handler
};
export const handler = middy().use(cors()).handler(handleVerify);

0 comments on commit 80d77c3

Please sign in to comment.