本文整理匯總了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`)
}
);
}
示例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);
});
}
示例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();
};
示例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
};
}),
示例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",
});
}
示例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
})
});
};
示例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");
}