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


TypeScript Express.use方法代码示例

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


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

示例1: configureRoutes

export function configureRoutes(app: Express): void{

    let rootPath: string = path.join(__dirname, '../public');
    app.use( express.static(rootPath) );

    let servePath: string = path.join(__dirname, '../public/views');
    app.use( express.static(servePath) );

    setDummyRouting(app);
}
开发者ID:peerhenry,项目名称:pulety,代码行数:10,代码来源:routeconfig.ts

示例2: configure

    private static configure(app: Express, server:Server) {
        
        app.use((req:Request, res:Response, next:NextFunction) => {
            res.header('Access-Control-Allow-Origin', '*');
            res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
            next();
        });

        app.use(bodyParser.json());
        app.use(express.static('public'));

        let repository = new ReportsRepository();
        let routes = ReportRoutes(repository);

        app.use('/api/reports', routes);

        app.get('/*', (req:Request, res:Response) => {
            res.sendfile('./public/index.html');
        });

        let tickerService = new TickerService(server, repository);
        tickerService.listen();
    }
开发者ID:JonathanYates,项目名称:report-ticker-angular2,代码行数:23,代码来源:reports.server.ts

示例3: setDummyRouting

function setDummyRouting(app: Express){
    let dummyRouter: Router = Router();

    let dummyServePath: string = path.join(__dirname, '../public/views/dummy');
    dummyRouter.use( express.static(dummyServePath) );

    dummyRouter.get('/test', function(req : Request, res: Response){
        res.send(dummy.getDummyMessage());
    })

    dummyRouter.get('/forajax', function(req : Request, res: Response){
        res.send('This was retrieved through ajax!');
    })

    app.use('/dummy/', dummyRouter);
}
开发者ID:peerhenry,项目名称:pulety,代码行数:16,代码来源:routeconfig.ts

示例4: express

import * as express from "express";
import {Express} from "express-serve-static-core";

import * as cors from "cors";

export let app: Express = express();
app.use(cors());

export default app;
开发者ID:insa-frif,项目名称:omni-chat-server-api,代码行数:9,代码来源:app.ts


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