let verificaAdmin_Role = (req, res, next) => {

    let usuario = req.usuario;

    if (usuario.role === 'ADMIN_ROLE') {
        next();
    } else {
        return res.status(409).json({
            ok: false,
            err: {
                message: 'El usuario no es administrador.'
            }
        })
    }

};

By rootweiller, 2020-06-18 18:30:41
if (cookiesBannerHeight !== 0 && isMobile) {
      style = {
        top: cookiesBannerHeight === 0 ? 0 : cookiesBannerHeight
      }
}
By Kubus, 2018-02-28 11:00:11
const setFormFlag(state){
    state.formFlag ? state.formFlag = false : state.formFlag = true;
}
By Apeiron, 2018-07-27 20:43:23
/**
 * Stringify a JSON object
 * @param {*} value JSON value to stringify
 * @returns {string} stringify JSON
 */
function stringify(value) {
    var result = {};
    try {
        result = JSON.stringify(value);
    } catch (e) {
        Logger.error('Error while trying to stringify ' + e);
        result = JSON.stringify(result);
    }
    return result;
}

Stringify a JSON object

By Ihor Did, 2023-04-12 19:36:08
this.props.HeaderStore.setHeader(true, null, false, false, true, true,'dashboardNavigation');
By Fluttershy, 2018-01-19 08:53:26
// powtierdzenie decyzji
function zapytaj(pytanie){
	if(confirm(pytanie)) return true
	else return false;
}
By first year student, 2018-10-02 21:30:46

class Timer extends React.Component{
    state ={
        time: 10
    };
    setInvt = () =>{
        let t = this.state.time
        if(t<=1){
            clearInterval(this.invertal)
        }
        this.setState({time: t-1})
    }
    componentDidMount(){
        this.invertal = setInterval(this.setInvt, 1000)
    }

    render(){
        return (<label>{this.state.time}</label>)
    }
}

export {Timer}
By Anonymous, 2021-07-30 21:13:46
$(document).on('click', '.edit-item', function(event) {
    let row_id = event.currentTarget.attributes['data-row'].value,
    data = dataIndex[
        dataIndex.findIndex(i => i.id === Number(row_id))
    ];
    $('.modal-body div:nth-child(1) input').attr('value', data.name)
    $('.modal-body div:nth-child(2) input').attr('value', data.category)
    $('.modal-body div:nth-child(3) #basicSelect').val(data.status)
    $('.modal-body div:nth-child(4) input').attr('value', data.price)
    $('.modal-body div:nth-child(5) input').attr('value', data.bju.mass)
    $('.modal-body div:nth-child(6) input').attr('value', data.bju.calories)
    $('.modal-body div:nth-child(7) input').attr('value', data.bju.proteins)
    $('.modal-body div:nth-child(8) input').attr('value', data.bju.fats)
    $('.modal-body div:nth-child(9) input').attr('value', data.bju.carbohydrates)
}
)
By Nik Destrave, 2021-05-30 21:59:31
class FileReader extends EventTarget(...READER_EVENTS) {
    // [...]
    readAsArrayBuffer() {
        throw new Error('FileReader.readAsArrayBuffer is not implemented');
    }
}

React Native's way of saying they don't support FileReader.readAsArrayBuffer()

By Aurovik, 2018-12-12 12:50:22
// What they did:
var serverCommands = {};
for(var each in commandList.general)
    (dmCommands[commandList.general[each].type] ? dmCommands[commandList.general[each].type] +=
    (config.prefix + each + (commandList.general[each].args ? ' ' + commandList.general[each].args : '') +
    ': ' + commandList.general[each].description + '\n') : (dmCommands[commandList.general[each].type] =
    '\u200B'+ config.prefix + each + (commandList.general[each].args ? ' ' + commandList.general[each].args : '') +
    ': ' + commandList.general[each].description + '\n'))

// What they should've done:
let srvrCmds = new Map();
let gldCmds = commandList[message.guild.id];
for (let each in gldCmds) {
    const cur = gldCmds[each];
    const text = `${config.prefix + each + (cur.args ? " " + cur.args : "")}: ${cur.description}\n`;
    const srvrCmdType = srvrCmds.get(cur.type);
    srvrCmds.set(cur.type, (srvrCmdType || "\u200B") + text);
}
By Anonymous, 2018-01-18 05:57:37
<div class="scrollContent">
	{foreach $animations as $index => $a}
		{if $index > 2}
			{if $a.filename == '9_1447691013_3726.png'}
			{else}
				{if $a.filename == '9_1423150010_6441.png'}
				{else}
					{if $a.filename == '9_1423149959_5909.png'}
					{else}
						{if $a.filename == '9_1423149908_5874.png'}
						{else}
							{if $a.filename == '9_1528213223_6374.jpg'}
							{else}
								{if $a.filename == '9_1527670984_3732.jpg'}
								{else}

							<div class="spotlightFrame frame{$index+1} contains1" data-index="{$index}">
								{if $a.link}<a href="{$a.link}">{/if}
								<img src="/upload/{$a.filename}" alt="{$a.title}" />
								{if $a.link}</a>{/if}
							</div>

								{/if}
							{/if}
						{/if}
					{/if}
				{/if}
			{/if}
		{/if}
	{/foreach}
</div>

Handovers are great.

By Anonymous, 2018-07-09 14:50:36
		roots.push(resolver(Config.root, `${pageDir}${path.sep}${page}${path.sep}${page}.html`));
By Anonymous, 2023-04-01 10:39:37
$options.splice($options.indexOf('option7'), 1);
$options.splice($options.indexOf('option5'), 1);
$options.splice($options.indexOf('option4'), 1);
$options.splice($options.indexOf('option3'), 1);
$options.splice($options.indexOf('option2'), 1);
$options.splice($options.indexOf('option1'), 1);
By A "senior" developer, 2018-02-19 16:49:52
isCreatedUser : !this.isEdit ? true : false

Vue.js project, someone wanted to verify if the user was being edited or created...

By rat, 2021-10-21 17:11:54
const convertMenu = menus => {
    const menusAssinged = menus.filter(menu => menu.parentId == null).sort((a, b) => a.order - b.order).map(menu => {
        if (menus.some(element => element.parentId == menu.menuId)) {
            return {
                title: menu.title,
                icon: { icon: menu.icon },
                children: menus.filter(menuChil => menuChil.parentId == menu.menuId).sort((a, b) => a.order - b.order).map(menuChil => {

                    if (menuChil.pathRoute.includes(":")) {
                        const params = menuChil.pathRoute.split(":").pop()

                        return {
                            title: menuChil.title,
                            to: { name: menuChil.nameRoute, params: { [params]: "abc" } },
                        }
                    } else {
                        return {
                            title: menuChil.title,
                            to: menuChil.nameRoute,
                        }
                    }
                }),
            }
        } else {
            return {
                title: menu.title,
                icon: { icon: menu.icon },
                to: menu.nameRoute,
            }
        }
    })

    menusUser.value = menusAssinged
    localStorage.setItem('menus', JSON.stringify(menusAssinged))
}

when they exorcise the callbacks demon but they appear in functional

By Juan David Castro, 2023-03-16 15:34:29