From 3d3574510382a29cdf0fadb154a9093acbf5fd24 Mon Sep 17 00:00:00 2001 From: John Sprunger Date: Mon, 22 May 2023 06:09:30 -0400 Subject: [PATCH] Update server.js with E6 syntax (#101) server.js updates tested and validated here: https://boilerplate-express.johnsprunger.repl.co Co-authored-by: Muhammed Mustafa --- server.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server.js b/server.js index f4c4ee78e..575f3f3ab 100644 --- a/server.js +++ b/server.js @@ -3,15 +3,15 @@ * the verification process may break * ***************************************************/ -var bGround = require('fcc-express-bground'); -var myApp = require('./myApp'); -var express = require('express'); -var app = express(); +const bGround = require('fcc-express-bground'); +const myApp = require('./myApp'); +const express = require('express'); +const app = express(); if (!process.env.DISABLE_XORIGIN) { - app.use(function(req, res, next) { - var allowedOrigins = ['https://narrow-plane.gomix.me', 'https://www.freecodecamp.com']; - var origin = req.headers.origin || '*'; + app.use((req, res, next) => { + const allowedOrigins = ['https://narrow-plane.gomix.me', 'https://www.freecodecamp.com']; + const origin = req.headers.origin || '*'; if(!process.env.XORIG_RESTRICT || allowedOrigins.indexOf(origin) > -1){ console.log(origin); res.setHeader('Access-Control-Allow-Origin', origin); @@ -21,8 +21,8 @@ if (!process.env.DISABLE_XORIGIN) { }); } -var port = process.env.PORT || 3000; -bGround.setupBackgroundApp(app, myApp, __dirname).listen(port, function(){ +const port = process.env.PORT || 3000; +bGround.setupBackgroundApp(app, myApp, __dirname).listen(port, () => { bGround.log(`Node is listening on port ${port}...`); });