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


TypeScript express.Router函数代码示例

本文整理汇总了TypeScript中express.Router函数的典型用法代码示例。如果您正苦于以下问题:TypeScript Router函数的具体用法?TypeScript Router怎么用?TypeScript Router使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: pNext

            }catch(pErr){
                console.log('Error while parsing token : ' + pErr);
                pResponse.sendStatus(403);
            }
        }
    }
    // Sanitize all the parameter send with POST request
    if(pRequest.method === 'POST') {
        for(let param in pRequest.body) {
            pRequest.body[param] = vValidator.escape(pRequest.body[param]);
        }
    }
    pNext();
});

var vRouter = vExpress.Router();
vRouter.post('/login',vLoginCtrl.login);
vRouter.post('/login/MPIN', vLoginCtrl.submitMPIN);
vRouter.get('/logout', vLoginCtrl.logout);
vRouter.get('/retailer/alert',vRetailerCtrl.getAllRetailerAlert);
vRouter.post('/getSalesRoute',vRetailerCtrl.getSalesRoute);
vRouter.post('/getRetailerSummary',vRetailerCtrl.getRetailerSummary);
vRouter.get('/getRetailerAlert',vRetailerCtrl.getAllRetailerAlert);
// vRouter.post('/accountsReceivables',vAccCtrl.accountsReceivables);
// vRouter.post('/retailerSelf',vAccCtrl.retailerSelf);
vRouter.get('/testSync',vSchedCtrl.syncTableMaster);

//API BASED ON GUIDELINES
vRouter.get('/task',vRetailerCtrl.task);
vRouter.post('/retailerCallPreparation',vRetailerCtrl.retailerCallPreparation);
vRouter.post('/loadWallet',vRetailerCtrl.loadWallet);
开发者ID:acndavidd,项目名称:iDSP-admin,代码行数:31,代码来源:main.ts

示例2: constructor

 constructor() {
   this.router = express.Router();
   this.router.get('/', this.index);
 }
开发者ID:sestrella,项目名称:express-example,代码行数:4,代码来源:index.ts

示例3: Router

import {Request, Response, Router} from "express";
const router: Router = Router();
import {IRoute} from "express-serve-static-core";
import {entityModel} from "../models/models";
import {checkObjectIDValidity, checkIfDataIsArray} from "../helpers/validation";
import {errorIDValidationMessages, errorApiMessages} from "../helpers/errorMessages";

const api: IRoute = router.route("/api/entity/:id");

api.get(async (req: Request, res: Response) => {
    let id: string = req.params.id;
    if (!checkObjectIDValidity(id)) {
        res.status(400).json(errorIDValidationMessages.getMessage);
    }
    let obj: Object = await entityModel
        .find({_id: id})
        .exec()
        .catch((e: Error) => {
            res.status(400).send({ error: errorApiMessages.postMessage + e });
        });

    res.json(obj);
});

api.post(async (req: Request, res: Response) => {

    // check data before saving also could do validation within function
    let obj: Array<Object> = checkIfDataIsArray(req.body);

    let dataRes: Object = await entityModel.insertMany(obj);
    res.status(200).json(dataRes);
开发者ID:vildantursic,项目名称:walter,代码行数:31,代码来源:entity.ts

示例4: require

import * as express from 'express'
import * as _ from 'lodash'
import { data } from '../data-import/data-storage'
import { IGroup } from '../data-import/data-import'
import * as path from 'path';
import * as request from 'request';

var shipNameToImageId = require('../public/ship-name-to-image-id.json');

export let router = express.Router({ mergeParams: true });
var result: Array<IGroup> = JSON.parse(data);

router.get('/', (req: express.Request, res: express.Response) => {
    let race = findRace(result, req);

    let response = _.map(race.ships, (ship) => {
        return {
            name: ship.name,
            group: ship.group,
            race: ship.race
        };
    });

    res.json(response);
});

router.get('/:shipId', (req: express.Request, res: express.Response) => {
    let race = findRace(result, req);

    res.send(_.find(race.ships, { name: req.params.shipId }));
});
开发者ID:dimkinv,项目名称:eve-static-server,代码行数:31,代码来源:ships.ts

示例5: getAuthorizationData

import * as express from 'express';

import {sendError, formatSend, getAuthorizationData} from '../core/web_util';
import {addressBookGroupService} from './address_book_group_service';
import {AddressBookGroup, ModelOptions} from '../../client/core/dto';

const router = express.Router();

router.post('/', (req, res) => {
  const modelOptions: ModelOptions = {
    authorization: getAuthorizationData(req),
    copyAuthorizationData: 'createdBy'
  };
  addressBookGroupService.createOne(req.body, modelOptions)
    .then((group: AddressBookGroup) => formatSend(res, group), (err) => sendError(res, err));
});

router.put('/:id', (req, res) => {
  const modelOptions: ModelOptions = {
    authorization: getAuthorizationData(req)
  };
  req.body._id = req.params.id;
  addressBookGroupService.updateOne(req.body, modelOptions)
    .then((group: AddressBookGroup) => formatSend(res, group), (err) => sendError(res, err));
});

router.delete('/:id', (req, res) => {
  const modelOptions: ModelOptions = {
    authorization: getAuthorizationData(req),
    additionalData: {_id: req.params.id}
  };
开发者ID:jnamla,项目名称:herokuTestCymplar,代码行数:31,代码来源:address_book_group_router.ts

示例6: require

/// <reference path="../typings/tsd.d.ts"/>
import {Request, Response} from "express";
var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req: Request, res: Response, next: Function) {
  res.render('index', { title: 'Express' })
});

module.exports = router;
开发者ID:ShiningRay,项目名称:MoreFun,代码行数:11,代码来源:index.ts

示例7: Router

import {Router} from 'express';
import {addPost,searchPost, searchPostArea, pushElasticSearch, getAll,
     editPost,addView,getPostAllByUser}
from '../controller/postController';
import {addRate} from '../controller/rateController';
import {verifyToken} from '../libs/verifyToken';
const router: any = Router();
import { uploadPost as upload } from '../libs/uploads';

router.route('/post')
    .post(upload, verifyToken, addPost)
    .put(verifyToken, editPost)
    .all((req: any, res: any, next: any) => {
        res.sendStatus(404);
    });


router.route('/elastichpush')
    .get(pushElasticSearch)
    .all((req: any, res: any, next: any) => {
        res.sendStatus(404);
    });

router.route('/search')
    .get(searchPost)
    .all((req: any, res: any, next: any) => {
        res.sendStatus(404);
    });

router.route('/limit/:limit/offset/:offset')
    .get(getAll)
开发者ID:khacthanh244,项目名称:mocha,代码行数:31,代码来源:postRouter.ts

示例8: require

import * as express from 'express';
import * as bodyParser from 'body-parser';

var jwt = require('jsonwebtoken');
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var localStrategyConfig = require('./strategies/local');

import * as User from './../../user/User';
var config = require('./config');

// CONFIG
localStrategyConfig();

const authRoutes: express.Router = express.Router();

// ROUTES

authRoutes.post('/', function(req: express.Request, res: express.Response, next) {
    console.log(req.body)
    if (req.body.type) {
        switch (req.body.type) {
            case 'password':
                localAuthentication(req, res, next);
        }
    } else {
        return res.status(401).send({
            message: 'credentials not provided'
        });
    }
开发者ID:ieltxu13,项目名称:ag2print-server,代码行数:30,代码来源:authRoutes.ts

示例9:

import * as express from 'express'
import * as _ from 'lodash'
import {data} from '../data-import/data-storage'
import * as races from './races'
import {IGroup} from '../data-import/data-import'

export var router = express.Router({mergeParams: true});

router.get('/', (req:express.Request, res:express.Response)=>{
    var result:Array<IGroup> = JSON.parse(data);
    _.each(result, (group:IGroup)=>{
        delete group.races;
    })
    res.json(result);
});

router.get('/:groupId', (req:express.Request, res:express.Response)=>{
    var groups:Array<IGroup> = JSON.parse(data);
    var group = _.find(groups, {name: req.params.groupId});
    delete group.races;
    
    res.send(group);
});

router.use('/:groupId/races', races.router);
开发者ID:dimkinv,项目名称:eve-static-server,代码行数:25,代码来源:groups.ts

示例10: createReqFiles

  videosSortValidator,
  videosUpdateValidator
} from '../../../middlewares'
import { TagModel } from '../../../models/video/tag'
import { VideoModel } from '../../../models/video/video'
import { VideoFileModel } from '../../../models/video/video-file'
import { abuseVideoRouter } from './abuse'
import { blacklistRouter } from './blacklist'
import { videoCommentRouter } from './comment'
import { rateVideoRouter } from './rate'
import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
import { VideoSortField } from '../../../../client/src/app/shared/video/sort-field.type'
import { createReqFiles, isNSFWHidden } from '../../../helpers/express-utils'
import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'

const videosRouter = express.Router()

const reqVideoFileAdd = createReqFiles(
  [ 'videofile', 'thumbnailfile', 'previewfile' ],
  Object.assign({}, VIDEO_MIMETYPE_EXT, IMAGE_MIMETYPE_EXT),
  {
    videofile: CONFIG.STORAGE.VIDEOS_DIR,
    thumbnailfile: CONFIG.STORAGE.THUMBNAILS_DIR,
    previewfile: CONFIG.STORAGE.PREVIEWS_DIR
  }
)
const reqVideoFileUpdate = createReqFiles(
  [ 'thumbnailfile', 'previewfile' ],
  IMAGE_MIMETYPE_EXT,
  {
    thumbnailfile: CONFIG.STORAGE.THUMBNAILS_DIR,
开发者ID:jiang263,项目名称:PeerTube,代码行数:31,代码来源:index.ts


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