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


TypeScript app-root-path.resolve函數代碼示例

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


在下文中一共展示了resolve函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: loadPlugin

function loadPlugin(name: string): void {
    try {
        const meta: Object = require(resolve(`./node_modules/${name}/package.json`));
        const plugin: api.Plugin = require(name);

        plugins.push(new Plugin(meta, plugin));
    } catch (err) {
        debugPlugin(`Skipping invalid plugin ${name}`);
    }
}
開發者ID:jbuerkel,項目名稱:twitchr,代碼行數:10,代碼來源:pluginManager.ts

示例2: express

import * as passport    from 'passport';
import * as session     from 'express-session';
import { Strategy }     from 'passport-twitch';
import { resolve }      from 'app-root-path';

import api  from './routes/api';
import auth from './routes/auth';
import core from './routes/core';
import irc  from './routes/irc';

const app: express.Express = express();
const MongoStore: mongo.MongoStoreFactory = mongo(session);

app.use(compression());
app.use(helmet());
app.use(favicon(resolve('./dist/client/assets/favicon.ico')));
if (app.get('env') !== 'production') {
    app.use(morgan('dev'));
}
app.use(express.static(resolve('./dist/client'), { index: false }));
app.use(session({
    cookie: { secure: process.env.USE_TLS === 'true' },
    resave: false,
    saveUninitialized: false,
    secret: process.env.SESSION_SECRET,
    store: new MongoStore({
        touchAfter: 24 * 3600,
        url: process.env.MONGODB_URL,
    }),
}));
app.use(passport.initialize());
開發者ID:jbuerkel,項目名稱:twitchr,代碼行數:31,代碼來源:app.ts

示例3:

/// <reference path="app-root-path.d.ts" />
import * as root from 'app-root-path';

let resolvedPath: string;
resolvedPath = root.resolve('../dir');
resolvedPath = root.path;
resolvedPath = root.toString();
let resolvedModule: any = root.require('app-root-path');
root.setPath('C:\\app-root');

開發者ID:Agamnentzar,項目名稱:DefinitelyTyped,代碼行數:9,代碼來源:app-root-path-tests.ts

示例4: debug

const debugPlugin: debug.IDebugger = debug('twitchr:plugin');

export class Plugin {
    constructor(private meta: Object, private plugin: api.Plugin) { }

    getMeta(): Object {
        return this.meta;
    }

    getPlugin(): api.Plugin {
        return this.plugin;
    }
}

const pkg: any = require(resolve('./package.json'));
const plugins: Array<Plugin> = [];

Object.keys(pkg.dependencies)
    .filter((k: string) => k.indexOf('twitchr-') === 0 && k !== 'twitchr-plugin-api')
    .forEach(loadPlugin);

if (plugins.length < 1) {
    console.warn('No plugins were found');
}

export function getPlugins(): Array<Plugin> {
    return plugins;
}

function loadPlugin(name: string): void {
開發者ID:jbuerkel,項目名稱:twitchr,代碼行數:30,代碼來源:pluginManager.ts

示例5:

router.get('/*', requireAuthenticated, (req: express.Request, res: express.Response) => {
    res.sendFile(resolve('./dist/client/index.html'));
});
開發者ID:jbuerkel,項目名稱:twitchr,代碼行數:3,代碼來源:core.ts

示例6: debug

import * as http        from 'http';
import * as https       from 'https';
import { readFileSync } from 'fs';
import { resolve }      from 'app-root-path';

import app from '../app';

const debugServer: debug.IDebugger = debug('twitchr:server');
const port: number = 3000;
app.set('port', port);

let server: http.Server | https.Server;

if (process.env.USE_TLS === 'true') {
    const options: https.ServerOptions = {
        cert: readFileSync(resolve('./cert/cert.pem')),
        key: readFileSync(resolve('./cert/key.pem')),
    };

    server = https.createServer(options, app);
} else {
    server = http.createServer(app);
}

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

function onError(error: any): void {
    const protocol: string = process.env.USE_TLS === 'true' ? 'HTTPS' : 'HTTP';
開發者ID:jbuerkel,項目名稱:twitchr,代碼行數:30,代碼來源:www.ts


注:本文中的app-root-path.resolve函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。