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 <MuhammedElruby@gmail.com>
This commit is contained in:
John Sprunger 2023-05-22 06:09:30 -04:00 committed by GitHub
parent fb45552535
commit 3d35745103
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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}...`);
});