Did more stuff than I even wanna write. Notably:
- Auth/account management - Navigation system - Admin views for LOA stuff
This commit is contained in:
46
api/routes/statuses.js
Normal file
46
api/routes/statuses.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const express = require('express');
|
||||
const status = express.Router();
|
||||
const memberStatus = express.Router();
|
||||
|
||||
const pool = require('../db');
|
||||
|
||||
//insert a new latest rank for a user
|
||||
memberStatus.post('/', async (req, res) => {
|
||||
// try {
|
||||
// const App = req.body?.App || {};
|
||||
|
||||
// // TODO: replace with current user ID
|
||||
// const memberId = 1;
|
||||
|
||||
// const sql = `INSERT INTO applications (member_id, app_version, app_data) VALUES (?, ?, ?);`;
|
||||
// const appVersion = 1;
|
||||
|
||||
// const params = [memberId, appVersion, JSON.stringify(App)]
|
||||
|
||||
// console.log(params)
|
||||
|
||||
// await pool.query(sql, params);
|
||||
|
||||
// res.sendStatus(201);
|
||||
// } catch (err) {
|
||||
// console.error('Insert failed:', err);
|
||||
// res.status(500).json({ error: 'Failed to save application' });
|
||||
// }
|
||||
res.status(501).json({ error: 'Not implemented' });
|
||||
});
|
||||
|
||||
//get all statuses
|
||||
status.get('/', async (req, res) => {
|
||||
try {
|
||||
const result = await pool.query('SELECT * FROM statuses;');
|
||||
res.json(result);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
});
|
||||
|
||||
module.exports.status = status;
|
||||
module.exports.memberStatus = memberStatus;
|
||||
|
||||
// TODO, implement get all ranks route with SQL stirng SELECT id, name, short_name, category, sort_id FROM ranks;
|
||||
Reference in New Issue
Block a user