How to use the inversify-express-utils.Get 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 stelltec / public-tech-demos / nodejs-madrid-meetup / demo3 / src / ui / rest_api / controllers / secure_controller.ts View on Github external
import { injectable } from "inversify";
import { Controller, Get } from "inversify-express-utils";
import { authMiddleware } from "../middleware/auth_middleware";

// This is an example of a controller protected by the auth middleware

@injectable()
@Controller("/api/secure", authMiddleware({ role: "admin" }))
export class SecureController {

    @Get("/")
    public async get() {
        return Promise.resolve(["This", "data", "is", "secure!"]);
    }

}
github tierratelematics / prettygoat / scripts / controllers / ProjectionsManager.ts View on Github external
import * as express from 'express';
import {injectable, inject} from 'inversify';
import Dictionary from "../Dictionary";
import IProjectionRunner from "../projections/IProjectionRunner";
import IProjectionsManager from "./IProjectionsManager";
import { Controller, Get } from 'inversify-express-utils';

@Controller('/projections')
@injectable()
class ProjectionsManager implements Controller,IProjectionsManager{

    constructor(@inject("IProjectionRunnerHolder") private projectionsRunnerCollection:Dictionary>){

    }

    @Get('/stop/:name')
    stop(req: express.Request, res: express.Response): void {
        console.log(this.projectionsRunnerCollection);
        let projection:IProjectionRunner = this.getProjectionRunner(null);

        if(projection)
            projection.stop();

        this.writeResponse(res,projection,req.params.name,"Stop");
    }

    @Get('/pause/:name')
    pause(req: express.Request, res: express.Response): void {
        let projection:IProjectionRunner = this.getProjectionRunner(req.params.name);

        if(projection)
            projection.pause();
github tierratelematics / prettygoat / scripts / controllers / ProjectionsManager.ts View on Github external
projection.stop();

        this.writeResponse(res,projection,req.params.name,"Stop");
    }

    @Get('/pause/:name')
    pause(req: express.Request, res: express.Response): void {
        let projection:IProjectionRunner = this.getProjectionRunner(req.params.name);

        if(projection)
            projection.pause();

        this.writeResponse(res,projection,req.params.name,"Pause");
    }

    @Get('/resume/:name')
    resume(req: express.Request, res: express.Response): void {

        let projection:IProjectionRunner = this.getProjectionRunner(req.params.name);

        if(projection)
            projection.resume();

        this.writeResponse(res,projection,req.params.name,"Resume");
    }

    private getProjectionRunner(name : string){
        return (this.projectionsRunnerCollection[name]) ? this.projectionsRunnerCollection[name] : null;
    }

    private writeResponse(res:express.Response,projectionRunner:IProjectionRunner,name:string,operation:string){
        if(projectionRunner)
github stelltec / public-tech-demos / nodejs-madrid-meetup / demo3 / src / ui / rest_api / controllers / director_controller.ts View on Github external
import { Controller, Get, RequestParam } from "inversify-express-utils";
import { directorRepository } from "../../../domain/constants/decorators";
import { DirectorRepository } from "../../../domain/interfaces/repositories";

@injectable()
@Controller("/api/directors")
export class DirectorController {

    @directorRepository public _directorRepository: DirectorRepository;

    @Get("/")
    public async get() {
        return await this._directorRepository.findAll();
    }

    @Get("/:id")
    public async getById(
        @RequestParam("id") id: string,
    ) {
        return await this._directorRepository.findById(id);
    }

}
github stelltec / public-tech-demos / nodejs-madrid-meetup / demo3 / src / ui / rest_api / controllers / search_controller.ts View on Github external
import { injectable } from "inversify";
import { Controller, Get, RequestParam } from "inversify-express-utils";
import { SearchService } from "../../../domain/interfaces/services";
import { searchService } from "../../../domain/constants/decorators";

@injectable()
@Controller("/api/search")
export class SearchController {

    @searchService private _searchService: SearchService;

    @Get("/:query")
    public async get(
        @RequestParam("query") query: string,
    ) {
        return this._searchService.search(query);
    }

}
github stelltec / public-tech-demos / nodejs-madrid-meetup / demo3 / src / ui / rest_api / controllers / director_controller.ts View on Github external
import { injectable } from "inversify";
import { Controller, Get, RequestParam } from "inversify-express-utils";
import { directorRepository } from "../../../domain/constants/decorators";
import { DirectorRepository } from "../../../domain/interfaces/repositories";

@injectable()
@Controller("/api/directors")
export class DirectorController {

    @directorRepository public _directorRepository: DirectorRepository;

    @Get("/")
    public async get() {
        return await this._directorRepository.findAll();
    }

    @Get("/:id")
    public async getById(
        @RequestParam("id") id: string,
    ) {
        return await this._directorRepository.findById(id);
    }

}
github stelltec / public-tech-demos / nodejs-madrid-meetup / demo3 / src / ui / rest_api / controllers / actor_controller.ts View on Github external
import { injectable } from "inversify";
import { Controller, Get, RequestParam } from "inversify-express-utils";
import { actorRepository } from "../../../domain/constants/decorators";
import { ActorRepository } from "../../../domain/interfaces/repositories";

@injectable()
@Controller("/api/actors")
export class ActorController {

    @actorRepository public _actorRepository: ActorRepository;

    @Get("/")
    public async get() {
        return await this._actorRepository.findAll();
    }

    @Get("/:id")
    public async getById(
        @RequestParam("id") id: string,
    ) {
        return await this._actorRepository.findById(id);
    }

}
github w3tecch / express-typescript-boilerplate / src / api / controllers / ApiController.ts View on Github external
*/
@injectable()
@Controller('')
export class ApiController {

    @Get('/info')
    public getInfo( @Response() res: express.Response): any {
        const pkg = require('../../../package.json');
        return res.json({
            name: pkg.name,
            version: pkg.version,
            description: pkg.description
        });
    }

    @Get('/status')
    public getStatus( @Request() req: express.Request, @Response() res: express.Response): any {
        return monitor().pageRoute(req, res);
    }

}
github stelltec / public-tech-demos / nodejs-madrid-meetup / demo3 / src / ui / rest_api / controllers / movie_controller.ts View on Github external
import { injectable } from "inversify";
import { Controller, Get, RequestParam } from "inversify-express-utils";
import { movieRepository } from "../../../domain/constants/decorators";
import { MovieRepository } from "../../../domain/interfaces/repositories";

@injectable()
@Controller("/api/movies")
export class MovieController {

    @movieRepository public _movieRepository: MovieRepository;

    @Get("/")
    public async get() {
        return await this._movieRepository.findAll();
    }

    @Get("/:id")
    public async getById(
        @RequestParam("id") id: string,
    ) {
        return await this._movieRepository.findById(id);
    }

}
github stelltec / public-tech-demos / nodejs-madrid-meetup / demo3 / src / ui / rest_api / controllers / movie_controller.ts View on Github external
import { Controller, Get, RequestParam } from "inversify-express-utils";
import { movieRepository } from "../../../domain/constants/decorators";
import { MovieRepository } from "../../../domain/interfaces/repositories";

@injectable()
@Controller("/api/movies")
export class MovieController {

    @movieRepository public _movieRepository: MovieRepository;

    @Get("/")
    public async get() {
        return await this._movieRepository.findAll();
    }

    @Get("/:id")
    public async getById(
        @RequestParam("id") id: string,
    ) {
        return await this._movieRepository.findById(id);
    }

}