|
@@ -1,7 +1,7 @@
|
|
|
const Sequelize = require('sequelize');
|
|
|
const express = require("express");
|
|
|
const bodyParser = require("body-parser");
|
|
|
-const cors = require('cors')
|
|
|
+// const cors = require('cors')
|
|
|
require('dotenv').config({ path: '.env.local' });
|
|
|
|
|
|
const database = new Sequelize({
|
|
@@ -15,18 +15,18 @@ const Attendee = database.define('attendee', {
|
|
|
cat: Sequelize.STRING
|
|
|
});
|
|
|
|
|
|
-const whitelist = ['http://localhost:3001', 'http://localhost', 'http://127.0.0.1', 'http://christmas.logicp.ca']
|
|
|
+// const whitelist = ['http://localhost:3001', 'http://localhost', 'http://127.0.0.1', 'http://christmas.logicp.ca']
|
|
|
|
|
|
-const corsOptions = {
|
|
|
- origin: function (origin, callback) {
|
|
|
- console.log('request attempted from ', origin)
|
|
|
- if (whitelist.indexOf(origin) !== -1) {
|
|
|
- callback(null, true)
|
|
|
- } else {
|
|
|
- callback(new Error('Not allowed by CORS'))
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+// const corsOptions = {
|
|
|
+// origin: function (origin, callback) {
|
|
|
+// console.log('request attempted from ', origin)
|
|
|
+// if (whitelist.indexOf(origin) !== -1) {
|
|
|
+// callback(null, true)
|
|
|
+// } else {
|
|
|
+// callback(new Error('Not allowed by CORS'))
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
class App {
|
|
|
//Run configuration methods on the Express instance.
|
|
@@ -47,18 +47,18 @@ class App {
|
|
|
/* This is just to get up and running, and to make sure what we've got is
|
|
|
* working so far. This function will change when we start to add more
|
|
|
* API endpoints */
|
|
|
- this.express.get('/test', cors(corsOptions), (req, res) => {
|
|
|
+ this.express.get('/test', (req, res) => {
|
|
|
console.log(req)
|
|
|
res.json({response: 'yo mamma'})
|
|
|
})
|
|
|
|
|
|
- this.express.get('/list', cors(corsOptions), (req, res) => {
|
|
|
+ this.express.get('/list', (req, res) => {
|
|
|
Attendee.findAll().then(attendees => {
|
|
|
res.json({attendees: attendees})
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- this.express.post('/attendee', cors(corsOptions), (req, res) => {
|
|
|
+ this.express.post('/attendee', (req, res) => {
|
|
|
console.log(req.body)
|
|
|
if ('name' in req.body) {
|
|
|
Attendee.findOrCreate({
|