refactoring formatting
This commit is contained in:
@@ -11,46 +11,56 @@ const runner = require('./test-runner');
|
||||
const app = express();
|
||||
|
||||
app.use('/public', express.static(process.cwd() + '/public'));
|
||||
app.use(cors({ origin: '*' })); //For FCC testing purposes only
|
||||
app.use(cors({ origin: '*' }));
|
||||
|
||||
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');
|
||||
});
|
||||
app.route('/').get((req, res) => {
|
||||
|
||||
//For FCC testing purposes
|
||||
res.sendFile(process.cwd() + '/views/index.html');
|
||||
|
||||
});
|
||||
|
||||
apiRoutes(app);
|
||||
fccTestingRoutes(app);
|
||||
|
||||
// User routes
|
||||
apiRoutes(app);
|
||||
|
||||
//404 Not Found Middleware
|
||||
app.use(function (req, res, next) {
|
||||
app.use((req, res, next) => {
|
||||
|
||||
res.status(404)
|
||||
.type('text')
|
||||
.send('Not Found');
|
||||
|
||||
});
|
||||
|
||||
//Start our server and tests!
|
||||
|
||||
const PORT = process.env.PORT || 3000
|
||||
app.listen(PORT, function () {
|
||||
|
||||
app.listen(PORT, () => {
|
||||
|
||||
console.log("Listening on port " + PORT);
|
||||
// process.env.NODE_ENV='test'
|
||||
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
|
||||
console.log('Running Tests...');
|
||||
setTimeout(function () {
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
try {
|
||||
|
||||
runner.run();
|
||||
|
||||
} catch (error) {
|
||||
|
||||
console.log('Tests are not valid:');
|
||||
console.error(error);
|
||||
|
||||
}
|
||||
|
||||
}, 3500);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = app; // for testing
|
||||
Reference in New Issue
Block a user