API integration stuff
This commit is contained in:
29
api/index.js
29
api/index.js
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user