Files
nuitdelinfo2023/api/routes/themes.js
2023-12-07 23:26:41 +01:00

16 lines
588 B
JavaScript

import express from 'express';
import { verifyToken } from '../modules/token.js';
import { respondWithStatus, respondWithStatusJSON } from '../modules/requestHandler.js';
import { pool } from '../modules/database.js';
const router = express.Router();
// send list of themes
router.post('/', verifyToken, async (req, res) => {
const [rows] = await pool.execute('SELECT * FROM themes');
if (!rows.length) return await respondWithStatus(res, 404, 'There are no themes');
return await respondWithStatusJSON(res, 200, {
message: 'Successfully retrieved themes',
themes: rows,
});
});