mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
21 lines
558 B
JavaScript
21 lines
558 B
JavaScript
module.exports = {
|
|
slug(text) {
|
|
return text.toLowerCase().replace(/ /g, '_');
|
|
},
|
|
|
|
async_handler(fn) {
|
|
return (req, res, next) => Promise.resolve(fn(req, res, next))
|
|
.catch((err) => {
|
|
console.log(err);
|
|
// handle error
|
|
res.status(err ? err.status_code : 500).send({ error: err ? err.message : 'Unknown Error'});
|
|
});
|
|
},
|
|
|
|
async sleep(seconds) {
|
|
return new Promise(resolve => {
|
|
setTimeout(resolve, seconds * 1000);
|
|
});
|
|
}
|
|
}
|