const config = require('../config.js');

let appearanceController = {};

appearanceController.toggleDarkMode = async (req, res, next) => {
    let cur = req.cookies.appearance || 'light';
    if(cur == 'light')
        cur = 'dark';
    else if(cur == 'dark')
        cur = 'light';
    res.cookie('appearance', cur, {
        'domain': config.domain,
        'expires': new Date(253402300000000) 
    });
    return res.json({ currentStyle: cur });
};

module.exports = appearanceController;