Skip to content

Commit

Permalink
feat(src): Add postNotificationHandler functionality and create scrat…
Browse files Browse the repository at this point in the history
…ch.js
  • Loading branch information
wajeht committed Aug 7, 2024
1 parent 3f62b24 commit 33e1feb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export function getHealthzHandler() {

export function postNotificationHandler() {
return async (req: Request, res: Response) => {
res.json({ message: 'postNotificationHandler()' });
console.log(req.body);
res.json({ message: 'ok' });
};
}
27 changes: 27 additions & 0 deletions src/scratch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
async function main() {
try {
const response = await fetch('http://localhost', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': '42069247355',
},
body: JSON.stringify({
id: 69,
message: 'Hello, this is a test message',
details: {
name: 'John Doe',
age: 30,
email: '[email protected]',
},
}),
});

const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error:', error);
}
}

main();

0 comments on commit 33e1feb

Please sign in to comment.