16 lines
588 B
JavaScript
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,
|
|
});
|
|
}); |