當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript express-serve-static-core.Express類代碼示例

本文整理匯總了TypeScript中express-serve-static-core.Express的典型用法代碼示例。如果您正苦於以下問題:TypeScript Express類的具體用法?TypeScript Express怎麽用?TypeScript Express使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Express類的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類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。