How to use the inversify-express-utils.httpPost function in inversify-express-utils

To help you get started, we’ve selected a few inversify-express-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github julianosam / ts-express-ddd-seed / src / presentation / rest / movie / movie.controller.ts View on Github external
import { RentMovieCommand } from '../../../application/movie/commands/rent-movie-command';

@injectable()
@controller('/api')
export class MovieController {

    constructor(
        @inject('MovieStoreApplicationService') private _movieStoreAppSvc: MovieStoreApplicationService
    ) { }

    // @httpGet('/movies/query')
    // searchMovies(request: any, response: Response) {

    // }

    @httpPost('/movies/commands/register')
    registerMovie(request: any, response: Response) {

        const movieRegCmd = new RegisterMovieCommand();
        movieRegCmd.requestDate = new Date();
        movieRegCmd.storeAdminId = request.headers['customer-id'];
        movieRegCmd.sectionName = request.body.sectionName;
        movieRegCmd.movie = request.body.movie;

        return this._movieStoreAppSvc.registerMovie(movieRegCmd).then((movie) => {
            response.send(movie);
        }).catch((err: Error) => {
            logger.error(err.message);
            logger.error(err.stack);

            response.status(HTTP_CODES.INTERNAL_SERVER_ERROR).send(err.message);
        });
github ERS-HCL / nxplorerjs-microservice-starter / server / api / controllers / examples / controller.ts View on Github external
.setSource(req.url)
          .build();
        res.status(HttpStatus.NOT_FOUND).json(resp);
        this.loggerService.logAPITrace(req, res, HttpStatus.NOT_FOUND);
        this.metricsService.logAPIMetrics(req, res, HttpStatus.NOT_FOUND);
      }
    );
  }

  /**
   * Create request sample
   * Add a new element to the in memory Sample object
   * @param req request
   * @param res response
   */
  @httpPost('/')
  public async create(@request() req: Request, @response() res: Response) {
    return this.exampleService.create(req.body.name);
  }
}
export default ExampleController;
github secret-tech / backend-ico-dashboard / src / controllers / user.controller.ts View on Github external
'ChangePasswordValidation'
  )
  async initiateChangePassword(req: AuthorizedRequest, res: Response): Promise {
    res.json(await this.userService.initiateChangePassword(req.user, req.body));
  }

  @httpPost(
    '/me/changePassword/verify',
    'AuthMiddleware',
    'ChangePasswordValidation'
  )
  async verifyChangePassword(req: AuthorizedRequest, res: Response): Promise {
    res.json(await this.userService.verifyChangePassword(req.user, req.body));
  }

  @httpPost(
    '/resetPassword/initiate',
    'ResetPasswordInitiateValidation'
  )
  async initiateResetPassword(req: Request, res: Response): Promise {
    res.json(await this.userService.initiateResetPassword(req.body));
  }

  @httpPost(
    '/resetPassword/verify',
    'ResetPasswordVerifyValidation'
  )
  async verifyResetPassword(req: Request, res: Response): Promise {
    res.json(await this.userService.verifyResetPassword(req.body));
  }

  @httpPost(
github secret-tech / backend-ico-dashboard / src / controllers / user.controller.ts View on Github external
'AuthMiddleware',
    'VerificationRequiredValidation'
  )
  async enable2faVerify(req: AuthorizedRequest, res: Response): Promise {
    res.json(await this.userService.verifyEnable2fa(req.user, req.body));
  }

  @httpGet(
    '/disable2fa/initiate',
    'AuthMiddleware'
  )
  async disable2faInitiate(req: AuthorizedRequest, res: Response): Promise {
    res.json(await this.userService.initiateDisable2fa(req.user));
  }

  @httpPost(
    '/disable2fa/verify',
    'AuthMiddleware',
    'VerificationRequiredValidation'
  )
  async disable2faVerify(req: AuthorizedRequest, res: Response): Promise {
    res.json(await this.userService.verifyDisable2fa(req.user, req.body));
  }

  @httpPost(
    '/resendVerification',
    'ResendVerificationValidation'
  )
  async resendVerification(req: Request, res: Response): Promise {
    res.json(await this.userService.resendVerification(req.body));
  }
}
github secret-tech / backend-ico-dashboard / src / controllers / user.controller.ts View on Github external
*/
  @httpPost(
    '/activate',
    'ActivateUserValidation'
  )
  async activate(req: Request, res: Response): Promise {
    res.json(await this.userService.activate(req.body));
  }

  /**
   * Initiate user login
   *
   * @param  req  express req object
   * @param  res  express res object
   */
  @httpPost(
    '/login/initiate',
    'InitiateLoginValidation'
  )
  async initiateLogin(req: Request, res: Response): Promise {
    let ip = req.header(config.app.clientIpHeader as string) || req.ip;

    if (ip.substr(0, 7) === '::ffff:') {
      ip = ip.substr(7);
    }

    res.json(await this.userService.initiateLogin(req.body, ip));
  }

  /**
   * Verify user login
   *
github secret-tech / backend-ico-dashboard / src / controllers / user.controller.ts View on Github external
'AuthMiddleware',
    'InviteUserValidation'
  )
  async invite(req: AuthorizedRequest, res: Response): Promise {
    res.json(await this.userService.invite(req.user, req.body));
  }

  @httpGet(
    '/enable2fa/initiate',
    'AuthMiddleware'
  )
  async enable2faInitiate(req: AuthorizedRequest, res: Response): Promise {
    res.json(await this.userService.initiateEnable2fa(req.user));
  }

  @httpPost(
    '/enable2fa/verify',
    'AuthMiddleware',
    'VerificationRequiredValidation'
  )
  async enable2faVerify(req: AuthorizedRequest, res: Response): Promise {
    res.json(await this.userService.verifyEnable2fa(req.user, req.body));
  }

  @httpGet(
    '/disable2fa/initiate',
    'AuthMiddleware'
  )
  async disable2faInitiate(req: AuthorizedRequest, res: Response): Promise {
    res.json(await this.userService.initiateDisable2fa(req.user));
  }
github secret-tech / backend-ico-dashboard / src / controllers / user.controller.ts View on Github external
@controller(
  '/user',
  'OnlyAcceptApplicationJson'
)
export class UserController {
  constructor(
    @inject(UserServiceType) private userService: UserServiceInterface
  ) {}

  /**
   * Create user
   *
   * @param  req  express req object
   * @param  res  express res object
   */
  @httpPost(
    '/',
    'CreateUserValidation'
  )
  async create(req: Request, res: Response): Promise {
    res.json(await this.userService.create(req.body));
  }

  /**
   * Activate user
   *
   * @param  req  express req object
   * @param  res  express res object
   */
  @httpPost(
    '/activate',
    'ActivateUserValidation'
github olivierlsc / swagger-express-ts / src / cars / cars.controller.ts View on Github external
summary: 'Post new car',
        parameters: {
            body: {
                description: 'New car',
                required: true,
                model: 'Car',
            },
        },
        responses: {
            200: {
                model: 'Car',
            },
            400: { description: 'Parameters fail' },
        },
    })
    @httpPost('/')
    public postCar(
        request: express.Request,
        response: express.Response,
        next: express.NextFunction
    ): void {
        if (!request.body) {
            return response.status(400).end();
        }
        const newCar = new CarModel();
        newCar.id = request.body.id;
        newCar.name = request.body.name;
        newCar.description = request.body.description;
        newCar.author = request.body.author;
        this.carsService.addCar(request.body);
        response.json(request.body);
    }
github secret-tech / backend-ico-dashboard / src / controllers / user.controller.ts View on Github external
'AuthMiddleware'
  )
  async getMe(req: AuthorizedRequest, res: Response): Promise {
    res.json(await this.userService.getUserInfo(req.user));
  }

  @httpPost(
    '/me/changePassword/initiate',
    'AuthMiddleware',
    'ChangePasswordValidation'
  )
  async initiateChangePassword(req: AuthorizedRequest, res: Response): Promise {
    res.json(await this.userService.initiateChangePassword(req.user, req.body));
  }

  @httpPost(
    '/me/changePassword/verify',
    'AuthMiddleware',
    'ChangePasswordValidation'
  )
  async verifyChangePassword(req: AuthorizedRequest, res: Response): Promise {
    res.json(await this.userService.verifyChangePassword(req.user, req.body));
  }

  @httpPost(
    '/resetPassword/initiate',
    'ResetPasswordInitiateValidation'
  )
  async initiateResetPassword(req: Request, res: Response): Promise {
    res.json(await this.userService.initiateResetPassword(req.body));
  }