import { Response } from 'express';

export interface Settings {
    orderBy: string,
    orderDirection: number,
    filterCompleted: boolean,
    dark: boolean,
}

export const sessionUserSettings = (req: any, res: Response, next: (err?: any) => void) => {
    const userSettings = req.session?.userSettings || {
        orderBy: 'title',
        orderDirection: -1,
        filterCompleted: false,
        dark: true
    };

    req.settings = req.session.userSettings = userSettings;
    next();
}


