当前位置: 首页>>代码示例>>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;未经允许,请勿转载。