API integration stuff

This commit is contained in:
2025-08-25 23:34:49 -04:00
parent 3dadaf3b24
commit 342c6cd706
4 changed files with 100 additions and 23 deletions

View File

@@ -50,7 +50,11 @@ app.get('/application/me', async (req, res) => {
const applicationId = 1;
const rows = await pool.query(
'SELECT * FROM applications WHERE id = ?',
`SELECT app.*,
member.name AS member_name
FROM applications AS app
INNER JOIN members AS member ON member.id = app.member_id
WHERE app.member_id = ?;`,
[applicationId]
);
@@ -65,6 +69,29 @@ app.get('/application/me', async (req, res) => {
}
});
app.get('/application/:id', async (req, res) => {
const appID = req.params.id;
try {
const rows = await pool.query(
`SELECT app.*,
member.name AS member_name
FROM applications AS app
INNER JOIN members AS member ON member.id = app.member_id
WHERE app.id = 1;`,
[appID]
);
if (!Array.isArray(rows) || rows.length === 0) {
return res.send(404).json("Application Not Found");
}
return res.status(200).json(rows[0]);
}
catch (err) {
console.error('Query failed:', err);
return res.status(500).json({ error: 'Failed to load application' });
}
})
app.get('/application/all', async (req, res) => {
try {