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


TypeScript errorhandler.default方法代碼示例

本文整理匯總了TypeScript中errorhandler.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript errorhandler.default方法的具體用法?TypeScript errorhandler.default怎麽用?TypeScript errorhandler.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在errorhandler的用法示例。


在下文中一共展示了errorhandler.default方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

export default function(app) {
  let env = app.get('env');

  app.set('views', config.root + '/server/views');
  app.set('view engine', 'jade');
  app.use(compression());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());
  app.use(methodOverride());
  app.use(cookieParser());
  app.use(passport.initialize());

  app.set('appPath', path.join(config.root, 'client'));

  if ('production' === env) {
    app.use(favicon(path.join(config.root, 'client', 'favicon.ico')));
    app.use(express.static(app.get('appPath')));
    app.use(morgan('dev'));
  }

  if ('development' === env) {
    app.use(require('connect-livereload')());
  }

  if ('development' === env || 'test' === env) {
    app.use(express.static(path.join(config.root, '.tmp')));
    app.use(express.static(app.get('appPath')));
    app.use(morgan('dev'));
    app.use(errorHandler()); // Error handler - has to be last
  }
}
開發者ID:Jeremy-Doucet,項目名稱:Blog-Example-Typescript,代碼行數:31,代碼來源:express.ts

示例2: error

export default function error(): any {
    if (process.env.NODE_ENV !== "development") {
        return defaultRoutes.error500;
    } else {
        return errorhandler();
    }
}
開發者ID:nicholas-robson,項目名稱:dkydev_webapp,代碼行數:7,代碼來源:error.ts

示例3: function

export default function(app) {

  let rootPath = path.normalize(`${__dirname}/../..`);
  let clientPath: string = path.join(rootPath, 'client');

  app.use(express.static(clientPath));
  app.set('clientPath', clientPath);

  app.use(bodyParser.urlencoded({ extended: true }));
  app.use(bodyParser.json());
  app.use(methodOverride());

  // let env = app.get('env');
  let env = process.env.NODE_ENV  || 'development';
  if (env === 'development') {
    app.use(errorHandler());
  }

}
開發者ID:AlanJui,項目名稱:jspm-md,代碼行數:19,代碼來源:express.ts

示例4: newInstance

    newInstance(config: IConfig, env: string): express.Express {
        var app = express();

        app.set("views", config.root + "/server/views");
        app.set("view engine", "html");
        app.use(compression());
        app.use(bodyParser.urlencoded({ extended: false }));
        app.use(bodyParser.json());
        app.use(methodOverride());
        app.use(cookieParser());

        // Persist sessions with mongoStore / sequelizeStore
        // We need to enable sessions for passport-twitter because it"s an
        // oauth 1.0 strategy, and Lusca depends on sessions
        /*app.use(session({
            secret: config.secrets.session,
            saveUninitialized: true,
            resave: false,
            store: new mongoStore({
                mongooseConnection: mongoose.connection,
                db: "opcrates-bot-server"
            })
        }));*/

        app.set("appPath", path.join(config.root, "client"));
        app.use(morgan("dev"));
        app.use(express.static(app.get("appPath")));

        if ("development" === env || "test" === env) {
            app.use(express.static(path.join(config.root, ".tmp")));
            app.use(errorHandler()); // Error handler - has to be last
        }

        return app;
    }
開發者ID:Tmeister,項目名稱:generator-typescript-express,代碼行數:35,代碼來源:applicationFactory.ts

示例5: config

  private config() {

    const app = this.app;
    const port = this.normalizePort(process.env.PORT || this.port);

    // set server port
    app.set('port', port);
    // view engine setup
    app.set('views', path.join(__dirname, '/views'));
    app.set('view engine', 'jade');
    // uncomment after placing your favicon in /public
    //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
    app.use(logger(this.logLevel));
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded({
      extended: false
    }));
    app.use(cookieParser());
    app.use(cors());
    app.use(express.static(path.resolve(__dirname + '/client/statics')));
    if (process.env.NODE_ENV === 'development') {
      // only use in development
      app.use(errorhandler({
        log: (err, str, req) => this.errorNotification(err, str, req)
      }));
    }
  }
開發者ID:thehachez,項目名稱:maduk,代碼行數:27,代碼來源:app.ts

示例6: config

  /**
   * Configure application
   *
   * @class Server
   * @method config
   */
  public config() {
    //add static paths
    this.app.use(express.static(path.join(__dirname, "public")));

    //configure pug
    this.app.set("views", path.join(__dirname, "views"));
    this.app.set("view engine", "pug");

    //mount logger
    this.app.use(logger("dev"));

    //mount json form parser
    this.app.use(bodyParser.json());

    //mount query string parser
    this.app.use(bodyParser.urlencoded({
      extended: true
    }));

    //mount cookie parser middleware
    this.app.use(cookieParser("SECRET_GOES_HERE"));

    // catch 404 and forward to error handler
    this.app.use(function(err: any, req: express.Request, res: express.Response, next: express.NextFunction) {
        err.status = 404;
        next(err);
    });

    //error handling
    this.app.use(errorHandler());
  }
開發者ID:HaoranYi,項目名稱:gitProj,代碼行數:37,代碼來源:server.ts

示例7: errorHandler

app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => {
  if (app.get('env') === 'development') {
    let errHandler = errorHandler();
    errHandler(err, req, res, next);
  } else {
    res.send(500);
  }
});
開發者ID:tarurar,項目名稱:github-maturity,代碼行數:8,代碼來源:index.ts

示例8: Error

export let init=()=>{
   if(SERVER_CONFIG.env==DEV){
       app.use(errorHandler({log:errorNotification}));
   }
    init=()=>{
        throw  new Error('timeout-parser.ts: Timeout parser has been initialized.');
    }
};
開發者ID:guoyu07,項目名稱:react-node-cms,代碼行數:8,代碼來源:error-parser.ts

示例9: config

    config(router: Express.Router) {
        var app = Express();

        app.use((req, res, next) => {
            console.log("middleware function called");
            next();
        })

        app.use(BodyParser.urlencoded({ extended: false }));
        app.use(BodyParser.json());
        app.use(CookieParser());
        app.use(router);

        app.use(morgan("combined", { "stream": { write: (message) => { Logger.info(message) } } }));

        if (process.env.NODE_ENV === 'dev') {
            app.use(errorhandler());
        }

        return app;
    }
開發者ID:frontians-web,項目名稱:base-middlewares,代碼行數:21,代碼來源:Middlewares.ts

示例10: express

      sampler.pushSome(task);
    } else {
      nextTask = task;
    }
  }

  return {
    task: sampler ? sampler[0] : nextTask,
    numCompleted: _.size(completedTasks),
    numTotal,
  }
}

const app = express();
app.use(bodyParser.urlencoded({extended: false}));
app.use(errorhandler());
app.use(express.static(path.resolve(staticDir)));

app.get('/', utils.wrapPromise(async (req, res) => {
  const nextTask = await getNextTask();
  if (nextTask.task) {
    console.log(nextTask.task);
    const html = await renderTemplate(nextTask);
    res.send(html);
  } else {
    res.send('DONE');
    process.exit(0);
  }
}));

app.post('/submit', utils.wrapPromise(async (req, res) => {
開發者ID:danvk,項目名稱:localturk,代碼行數:31,代碼來源:localturk.ts


注:本文中的errorhandler.default方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。