当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Application.get方法代码示例

本文整理汇总了TypeScript中express.Application.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Application.get方法的具体用法?TypeScript Application.get怎么用?TypeScript Application.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在express.Application的用法示例。


在下文中一共展示了Application.get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

export var setupPhraseRoutes = function (baseUrl: string, expressApp: Application) {
  const categoryHandler = new CategoryHandler();
  const phraseHandler = new PhraseHandler(categoryHandler);

  const phraseController = new PhraseController(phraseHandler);

  expressApp.get(baseUrl + "phrase/get", async (req, res) => {
    phraseController.getAll(req, res);
  });

  expressApp.get(baseUrl + "phrase/get/:id", async (req, res) => {
    phraseController.getOne(req, res);
  });

  expressApp.post(baseUrl + "phrase/create", isAuthenticatedApiMiddleware, async (req, res) => {
    phraseController.createPhrase(req, res);
  });

  expressApp.post(baseUrl + "phrase/update", isAuthenticatedApiMiddleware, async (req, res) => {
    phraseController.updatePhrase(req, res);
  });

  expressApp.post(baseUrl + "phrase/remove", isAuthenticatedApiMiddleware, async (req, res) => {
    phraseController.removePhrase(req, res);
  });

  expressApp.get(baseUrl + "phrase/category/:id", async (req, res) => {
    phraseController.getPhrasesForCategory(req, res);
  });
};
开发者ID:haestflod,项目名称:glossarytraining,代码行数:30,代码来源:PhraseController.ts

示例2: function

export var setupVerbRoutes = function (baseUrl: string, expressApp: Application) {
  var verbHandler: VerbHandler = new VerbHandler();

  var verbController: VerbController = new VerbController(verbHandler);

  expressApp.get(baseUrl + "verb/get", async (req, res) => {
    verbController.getAll(req, res);
  });

  expressApp.get(baseUrl + "verb/get/:id", async (req, res) => {
    verbController.getOne(req, res);
  });

  expressApp.post(baseUrl + "verb/create", isAuthenticatedApiMiddleware, async (req, res) => {
    verbController.create(req, res);
  });

  expressApp.post(baseUrl + "verb/update", isAuthenticatedApiMiddleware, async (req, res) => {
    verbController.update(req, res);
  });

  expressApp.post(baseUrl + "verb/remove", isAuthenticatedApiMiddleware, async (req, res) => {
    verbController.remove(req, res);
  });
}
开发者ID:haestflod,项目名称:glossarytraining,代码行数:25,代码来源:VerbController.ts

示例3: model

 config.collections.forEach((schema: ISchema) => {
   const modelSchema = model(schema);
   app.get(`/${schema.name}`, async (_req: IRequest, res: Response) =>
     res.status(200).json(await modelSchema.find()),
   );
   app.get(`/${schema.name}/:id`, async (req: IRequest, res: Response) => {
     try {
       res.status(200).json(await modelSchema.findOne({_id: req.params.id}));
     } catch (err) {
       res.status(404).json({error: "Not Found"});
     }
   });
   app.post(`/${schema.name}`, async (req: IRequest, res: Response) => {
     try {
       const newModel = new modelSchema(req.body);
       await newModel.save();
       res.status(201).json(newModel);
     } catch (err) {
       res.status(400).json({error: err.message});
     }
   });
   /*
   app.put(`/${schema.name}/:id`, async (req: IRequest, res: Response) => {
     //
   });
   app.patch(`/${schema.name}/:id`, async (req: IRequest, res: Response) => {
     //
   });
   app.delete(`/${schema.name}/:id`, (req: IRequest, res: Response) => {
     //
   });
   */
 });
开发者ID:dandart,项目名称:arsebeatfish,代码行数:33,代码来源:index.ts

示例4: function

export var setupCategoryRoutes = function (baseUrl: string, expressApp: Application) {
  const categoryHandler = new CategoryHandler();

  const categoryController = new CategoryController(categoryHandler);

  expressApp.get(baseUrl + "category/get", async (req, res) => {
    categoryController.getAll(req, res);
  });

  expressApp.get(baseUrl + "category/get/:id", async (req, res) => {
    categoryController.getOne(req, res);
  });

  expressApp.post(baseUrl + "category/create", isAuthenticatedApiMiddleware, async (req, res) => {
    categoryController.create(req, res);
  });

  expressApp.post(baseUrl + "category/update", isAuthenticatedApiMiddleware, async (req, res) => {
    categoryController.update(req, res);
  });

  expressApp.post(baseUrl + "category/remove", isAuthenticatedApiMiddleware, async (req, res) => {
    categoryController.remove(req, res);
  });

  expressApp.get(baseUrl + "category/hasphrases", async (req, res) => {
    categoryController.allHasPhrases(req, res);
  });
};
开发者ID:haestflod,项目名称:glossarytraining,代码行数:29,代码来源:CategoryController.ts

示例5: function

export default function(app: Application, apiRoot: string) {
  var id = "/:id(\\d+)";
  app.get(apiRoot, send(req => Product.findAll()));
  app.get(apiRoot + id, send(req => Product.find(+req.params.id)));
  app.post(apiRoot, send(req => {
    var data = req.body;
    delete data.id;
    return Product.create(data);
  }));
  app.put(apiRoot + id, send(req => Product.update(req.body, { where: { id: +req.params.id } }), 200));
  app.delete(apiRoot + id, send(req => Product.destroy({ where: { id: +req.params.id } }), 204));
}
开发者ID:jussik,项目名称:ssgl,代码行数:12,代码来源:product-ctrl.ts

示例6: default

/**
 * Sets up route handlers for static HTML pages.
 */
export default (app: Application, config: Config) => {

    app.get('/', (req, res) => {
        res.render('index', {
            loggedIn: (req as AppRequest).isAuthenticated(),
            version: config.version,
            title: config.title || 'Feeds',
            production: process.env.NODE_ENV === 'production'
        });
    });

    app.get('/old', (req, res) => {
        res.render('old');
    });
};
开发者ID:rla,项目名称:feeds,代码行数:18,代码来源:front.ts

示例7:

 setup: (app: Application, server: WebpackDevServer) => {
     // Here you can access the Express app object and add your own custom middleware to it.
     // For example, to define custom handlers for some paths:
     app.get('/some/path', (req, res) => {
         res.json({ custom: 'response' });
     });
 },
开发者ID:csrakowski,项目名称:DefinitelyTyped,代码行数:7,代码来源:webpack-dev-server-tests.ts

示例8: MakeRoutes

    public static MakeRoutes(express: Application): void {
        const keys = Object.keys(routes);
        Server.Log('Registering routes: ', keys);

        for (let key in keys) {
            key = keys[key];
            if (!routes.hasOwnProperty(key)) {
                continue;
            }

            let route = routes[key];
            let split = key.split(' ');

            if (split[0] === 'post') {
                express.post(split[1], route);
            } else {
                express.get(split.length === 1 ? split[0] : split[1], route);
            }
        }

        express.use(function(req: Request, res: Response) {
            res.status(404).render('errors/404.html', { title: '404: File Not Found' });
        });

        express.use(function(error: Error, req: Request, res: Response, next: any) {
            res.status(500).render('errors/500.html', { title: '500: Internal Server Error', error: error });
        });
    }
开发者ID:Garland220,项目名称:tabletop-audio-player,代码行数:28,代码来源:Routes.ts

示例9: config

  config(app: Application, passport: Passport){
    app.get("/", function(req: Request, res: Response){
      res.sendFile("index.html", {"root": "pages/"});
    });

    app.get("/ping", passport.authenticate("bearer", { session: false }), this.serialize, this.generateToken, function(req: Request, res: Response){
      res.status(200).json({hello: "world"});
    });

    app.get("/google", passport.authenticate("google", { session: false }), function(req: Request, res: Response){
      res.status(200).json({google: "success"});
    });

    // app.get("/login", function(req: Request, res: Response){
    //   res.sendFile("login.html", {"root": "pages/"});
    // });

    // app.get("/signup", function(req: Request, res: Response){
    //   res.sendFile("signup.html", {"root": "pages/"});
    // });

    // app.get("/finance", function(req: Request, res: Response){
    //   res.sendFile("finance.html", {"root": "pages/"});
    // });

    // app.post('/login', passport.authenticate('local-login', {
    //   successRedirect : '/finance', // redirect to the secure profile section
    //   failureRedirect : '/login', // redirect back to the signup page if there is an error
    //   failureFlash : true // allow flash messages
    // }));

    // // process the signup form
    // app.post('/signup', passport.authenticate('local-signup', {
    //   successRedirect : '/finance', // redirect to the secure profile section
    //   failureRedirect : '/signup', // redirect back to the signup page if there is an error
    //   failureFlash : true // allow flash messages
    // }));

    // // =====================================
    // // LOGOUT ==============================
    // // =====================================
    // app.get('/logout', function(req, res) {
    //   req.logout();
    //   res.redirect('/');
    // });
  }
开发者ID:kongbb,项目名称:MyFinance,代码行数:46,代码来源:index.route.ts

示例10: setupApiRoutes

function setupApiRoutes(app: Application){
	app.get('/api/boards', function(req:Request, res:Response){
		tokenGuard(req).then(function(token:any){
			return getBoards(token.id)
		}).then(function (boards:IBoard[]){
			res.json({ success:true, message:'', boards: boards });
		})
		.catch( function(error:string){
			env().logger().error(error);
			res.json({ success:false, message:'failed to get boards' });
		})
	});  
	
	/*
	app.get('/api/recent', function(req:Request, res:Response){
		apiGuard(req,res, function(req:Request, res:Response, token:any){
			getRecent(token.id, function(success:boolean, message:string, boards?:IBoard[]) {
				res.json({ success:true, message:'', boards: boards });
			})	
		}
	});*/

	app.get('/api/board/:id', function(req:Request, res:Response){
		//TODO CHECK IF USER HAS ACCESS TO THIS SECTIONS
		tokenGuard(req)
		.then( function(decodedToken:any){
			
			var p1 = getSections(decodedToken.id, req.params.id);
			var p2 = getBoard(decodedToken.id, req.params.id);
			let p : [Promise<ISection[]>,Promise<IBoard>] = [p1,p2];
			
			return Promise.all(p);
			//return getSections(decodedToken.id, req.params.id) 
		})
		.then( function(results:any){
			var sections:ISection[]= results[0]
			var board:IBoard = results[1]
			res.json({ success:true, board:board, sections: sections });
		})
		.catch( function(error:string){
			env().logger().error(error);
			res.json({ success:false, message:'failed to get board' });
		})
	});  

}
开发者ID:ychebotarev,项目名称:InColUn-v0,代码行数:46,代码来源:api.ts


注:本文中的express.Application.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。