From f980c330732b832befd5bc606325ba5901200631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Bigio?= Date: Thu, 8 Oct 2015 14:15:15 -0700 Subject: [PATCH] Unify oss and internal version of status page middleware Reviewed By: @vjeux Differential Revision: D2519415 fb-gh-sync-id: 2cf27c88b29c18a7a1f3aa1611f0d7f510a8fa24 --- packager/packager.js | 12 +----------- packager/statusPageMiddleware.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 packager/statusPageMiddleware.js diff --git a/packager/packager.js b/packager/packager.js index 9ca6c05ba..0c4a21c2a 100644 --- a/packager/packager.js +++ b/packager/packager.js @@ -23,6 +23,7 @@ const getDevToolsMiddleware = require('./getDevToolsMiddleware'); const openStackFrameInEditorMiddleware = require('./openStackFrameInEditorMiddleware'); const parseCommandLine = require('./parseCommandLine.js'); const ReactPackager = require('./react-packager'); +const statusPageMiddleware = require('./statusPageMiddleware.js'); const webSocketProxy = require('./webSocketProxy.js'); var options = parseCommandLine([{ @@ -167,17 +168,6 @@ function loadRawBody(req, res, next) { }); } -// A status page so the React/project.pbxproj build script -// can verify that packager is running on 8081 and not -// another program / service. -function statusPageMiddleware(req, res, next) { - if (req.url === '/status') { - res.end('packager-status:running'); - } else { - next(); - } -} - function systraceProfileMiddleware(req, res, next) { if (req.url !== '/systrace') { next(); diff --git a/packager/statusPageMiddleware.js b/packager/statusPageMiddleware.js new file mode 100644 index 000000000..fb793468f --- /dev/null +++ b/packager/statusPageMiddleware.js @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + +/** + * Status page so that anyone who needs to can verify that the packager is + * running on 8081 and not another program / service. + */ +module.exports = function(req, res, next) { + if (req.url === '/status') { + res.end('packager-status:running'); + } else { + next(); + } +};