getById(req: Request, res: Response) { const userId = parseInt(req.params.id); User .getById(userId) .then(_.partial(Handlers.onSuccess, res)) .catch(_.partial(Handlers.onError, res, 'Erro ao buscar usuário')); }
createUser(req: Request, res: Response) { User .create(req.body) .then(_.partial(Handlers.onSuccess, res)) .catch(_.partial(Handlers.dbErrorHandler, res)) .catch(_.partial(Handlers.onError, res, `Erro ao inserir novo usuário`)); }
updateUser(req: Request, res: Response) { const userId = parseInt(req.params.id); User .update(userId, req.body) .then(_.partial(Handlers.onSuccess, res)) .catch(_.partial(Handlers.onError, res, 'Erro ao atualizar usuário')); }
function getTransactionsInternal(connection: Connection, address: string, options: TransactionsOptions ): Promise<GetTransactionsResponse> { const getter = _.partial(getAccountTx, connection, address, options) const format = _.partial(formatResponse, connection, options) return utils.getRecursive(getter, options.limit).then(format) }
export function getCourseDetail(req: Request, res: Response) { const courseId = parseInt(req.params.id); findCourseDetail(courseId) .then(_.partial(onSuccess, res)) .catch(_.partial(onError, res, "Find all courses failed")); }
export function postLesson(req: Request, res: Response) { return createLesson(req.body) .then(_.partial(onSuccess, res)) .catch(_.partial(onDbError, res, "Error on lesson creation")) .catch(_.partial(onError, res, "Find all courses failed")); }
deleteUser(req: Request, res: Response) { const userId = parseInt(req.params.id); User .delete(userId) .then(_.partial(Handlers.onSuccess, res)) .catch(_.partial(Handlers.onError, res, 'Erro ao excluir usuário')); }
export function deleteLesson(req: Request, res: Response) { const lessonId = req.params.id; return deleteLessonById(lessonId) .then(_.partial(onSuccess, res)) .catch(_.partial(onDbError, res, "Error on lesson delete")) .catch(_.partial(onError, res, "Find all courses failed")); }
export function patchLesson(req: Request, res: Response) { const lessonId = req.params.id; const props = _.omit(req.body, ["id"]); return updateLesson(lessonId, props) .then(_.partial(onSuccess, res)) .catch(_.partial(onDbError, res, "Error on lesson update")) .catch(_.partial(onError, res, "Find all courses failed")); }
function formatPartialResponse(address: string, options: TransactionsOptions, data ) { return { marker: data.marker, results: data.transactions .filter(tx => tx.validated) .map(parseAccountTxTransaction) .filter(_.partial(transactionFilter, address, options)) .filter(_.partial(orderFilter, options)) } }