2017-02-18 20:14:10 +01:00
|
|
|
'use strict';
|
|
|
|
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
const express = require('express');
|
|
|
|
const bodyParser = require('body-parser');
|
|
|
|
const expect = require('chai').expect;
|
|
|
|
const cors = require('cors');
|
|
|
|
require('dotenv').config();
|
2017-02-18 20:14:10 +01:00
|
|
|
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
const apiRoutes = require('./routes/api.js');
|
|
|
|
const fccTestingRoutes = require('./routes/fcctesting.js');
|
|
|
|
const runner = require('./test-runner');
|
2017-02-18 20:14:10 +01:00
|
|
|
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let app = express();
|
2017-02-18 20:14:10 +01:00
|
|
|
|
|
|
|
app.use('/public', express.static(process.cwd() + '/public'));
|
|
|
|
|
|
|
|
app.use(cors({origin: '*'})); //For FCC testing purposes only
|
|
|
|
|
|
|
|
app.use(bodyParser.json());
|
|
|
|
app.use(bodyParser.urlencoded({ extended: true }));
|
|
|
|
|
|
|
|
//Index page (static HTML)
|
|
|
|
app.route('/')
|
|
|
|
.get(function (req, res) {
|
|
|
|
res.sendFile(process.cwd() + '/views/index.html');
|
|
|
|
});
|
|
|
|
|
|
|
|
//For FCC testing purposes
|
|
|
|
fccTestingRoutes(app);
|
|
|
|
|
|
|
|
//Routing for API
|
|
|
|
apiRoutes(app);
|
|
|
|
|
|
|
|
//404 Not Found Middleware
|
|
|
|
app.use(function(req, res, next) {
|
|
|
|
res.status(404)
|
|
|
|
.type('text')
|
|
|
|
.send('Not Found');
|
|
|
|
});
|
|
|
|
|
2021-06-27 18:01:37 +02:00
|
|
|
const port = process.env.PORT || 3000;
|
|
|
|
|
2017-02-18 20:14:10 +01:00
|
|
|
//Start our server and tests!
|
2021-06-27 18:01:37 +02:00
|
|
|
app.listen(port, function () {
|
|
|
|
console.log("Listening on port " + port);
|
2017-02-18 20:14:10 +01:00
|
|
|
if(process.env.NODE_ENV==='test') {
|
|
|
|
console.log('Running Tests...');
|
|
|
|
setTimeout(function () {
|
|
|
|
try {
|
|
|
|
runner.run();
|
|
|
|
} catch(e) {
|
|
|
|
console.log('Tests are not valid:');
|
2021-08-24 18:19:56 +02:00
|
|
|
console.error(e);
|
2017-02-18 20:14:10 +01:00
|
|
|
}
|
|
|
|
}, 1500);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = app; //for testing
|