• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript app-root-path.resolve函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript app-root-path.toString函数代码示例发布时间:2022-05-25
下一篇:
TypeScript app-root-path.require函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap