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


TypeScript @config.get函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。