Beispiel #1
0
 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'));
 }
Beispiel #2
0
 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`));
 }
Beispiel #3
0
 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'));
 }
Beispiel #4
0
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)
}
Beispiel #5
0
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"));
}
Beispiel #6
0
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"));
}
Beispiel #7
0
    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'));

    }
Beispiel #8
0
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"));
}
Beispiel #9
0
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"));
}
Beispiel #10
0
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))
  }
}