From 45230dc112f7c8cab7e284df6ca8710d9e9efcc4 Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Sat, 2 May 2020 15:45:43 -0500 Subject: [PATCH] fix for exception raised when public directory does not exist --- index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index eb267a7..daf75e8 100644 --- a/index.js +++ b/index.js @@ -438,12 +438,14 @@ app.get('/api/:type(game|meta)/:gameId/poll/:afterTime', catchExceptionsJson(get app.get('/api/:type(game|meta)/:gameId', catchExceptionsJson(getGameHandler)); app.post('/api/:type(game|meta)/:gameId', express.json(), catchExceptionsJson(postGameHandler)); -if (fs.statSync('public').isDirectory()) { - app.use(express.static('public', { - fallthrough: false, - maxAge: 0, - })); -} +try { + if (fs.statSync('public').isDirectory()) { + app.use(express.static('public', { + fallthrough: false, + maxAge: 0, + })); + } +} catch (err) {} var config = { port: process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 8765 };