本文整理汇总了TypeScript中@config.get函数的典型用法代码示例。如果您正苦于以下问题:TypeScript get函数的具体用法?TypeScript get怎么用?TypeScript get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1:
decode: (kind: string, token: string): any => {
return jsonwebtoken.verify(
token,
config.get(`security.secrets.${kind.toUpperCase()}`),
{
algorithms: config.get(`security.TOKEN_GENERATOR_ALGORITHM`)
}
);
}
开发者ID:ZulusK,项目名称:Budgetarium,代码行数:9,代码来源:tokenGenerator.ts
示例2: connectToDB
private connectToDB(): void {
logs.debug(`Try to connect to ${config.get("DB_URL")}`);
mongoose.Promise = bluebird;
return mongoose.connect(config.get("DB_URL"))
.then(() => {
logs.info("Connected to MongoDB");
}).catch((err: any) => {
logs.error("MongoDB connection error. Please make sure MongoDB is running. " + err);
});
}
开发者ID:ZulusK,项目名称:Budgetarium,代码行数:10,代码来源:App.ts
示例3: function
UserSchema.methods.regenerateJWTSalts = async function (): Promise<any> {
const salts: Array<string> = await Promise.all([
bcrypt.genSalt(config.get("security.SALT_LENGTH")),
bcrypt.genSalt(config.get("security.SALT_LENGTH"))
]);
this.jwtSecrets = {
access: salts[0],
refresh: salts[1]
};
return this.save();
};
开发者ID:ZulusK,项目名称:Budgetarium,代码行数:11,代码来源:User.ts
示例4: AuthMiddleware
access: AuthMiddleware(["refresh"], async (_: any, __: any, context: IContext): Promise<any> => {
const currTime = new Date().getTime();
return {
token: context.user.generateAccessToken(),
expiredIn: currTime + Number(config.get("security.tokenLife.ACCESS")) * 1000
};
}),
开发者ID:ZulusK,项目名称:Budgetarium,代码行数:7,代码来源:userResolver.ts
示例5: onError
function onError(err: any, req: Request, res: Response): void {
logs.error("Internal error(%d): %s", res.statusCode, err.message);
res.locals.message = err.message;
res.locals.error = config.get("isDev") ? err : {};
res.status(err.status || 500);
res.json({
message: err.message || "Server error",
});
}
开发者ID:ZulusK,项目名称:Budgetarium,代码行数:9,代码来源:index.ts
示例6: resolve
const next = (user: IUser, info = {}) => {
/**
* GraphQL configuration goes here
*/
resolve({
schema,
graphiql: config.get("isDev"), // <- only enable GraphiQL in production
pretty: config.get("isDev"),
context: {
user: user || null,
},
formatError: (error: any): any => ({
message: error.message,
state: error.originalError && error.originalError.state,
path: error.path,
status:error.status||500
})
});
};
开发者ID:ZulusK,项目名称:Budgetarium,代码行数:19,代码来源:index.ts
示例7: usePlugins
private usePlugins(): void {
this.app.use(morgan(":method :url :status - :response-time ms"));
if (config.get("isDev")) {
this.app.use(errorhandler());
}
this.app.use(cors());
this.app.use(bodyParser.urlencoded({extended: true}));
this.app.use(bodyParser.json());
this.app.use(expressValidator());
this.app.use(compression());
if(config.get("isDev")) {
this.app.use(express.static(path.join(__dirname, "public")));
}else{
this.app.use(express.static(path.join(__dirname, "public"), {maxAge: "10h"}));
}
this.app.use(auth());
this.app.use(favicon(path.join(__dirname, "/public/favicon.ico")));
logs.info("App configured");
}
开发者ID:ZulusK,项目名称:Budgetarium,代码行数:19,代码来源:App.ts
注:本文中的@config.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论