Skip to content

Commit

Permalink
SYNC
Browse files Browse the repository at this point in the history
  • Loading branch information
EverettBazzocchi committed Jul 28, 2024
1 parent 190bbc7 commit f877099
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 110 deletions.
41 changes: 5 additions & 36 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,18 @@ const app = express();
const config = require('./config/config.js');

app.use(bodyParser.json());
app.use(cors({ origin: 'https://skullpos.shotty.tech' }));
// also allow localhost for testing
// allow multiple origins
// app.use(cors({ origin: 'http://localhost:3000' }));

app.use(cors({ origin: 'http://localhost:3000' }));

const port = process.env.PORT || 5000;

app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});

/* models
"staff";
"terminals";
"locations";
"transactions";
"transaction_types";
"transaction_status";
"products";
"categories";
"discounts";
"roles";
"customers";
"subscriptions";
"subscription_types";
"events";
"transfers";
"transfer_types";
"transfer_items";
"stock";
"event_counts";
*/

const staff = require('./routes/staff');
const customers = require('./routes/customers.js');
const products = require('./routes/products.js');
Expand All @@ -55,12 +37,8 @@ const transferItems = require('./routes/transferItems.js');
const stock = require('./routes/stock.js');
const eventCounts = require('./routes/eventCounts.js');


const functions = require('./routes/functions.js');




app.use('/api/staff', staff);
app.use('/api/customers', customers);
app.use('/api/products', products);
Expand All @@ -83,12 +61,3 @@ app.use('/api/eventCounts', eventCounts);

app.use('/api/functions', functions);




const session = require('express-session');
const cookieParser = require('cookie-parser');
const passport = require('passport');

app.use(cookieParser());
app.use(session ({secret: config.setup.secret}));
9 changes: 5 additions & 4 deletions routes/functions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const router = require('express').Router();
const { auth } = require('../utils/auth');
const { sendEmail, login } = require('../utils/functions');
const { sendEmail, login } = require('../functions');

router.get('/test/email', auth, async (req, res) => {
const subject = 'Test email';
Expand All @@ -16,11 +16,12 @@ router.get('/test/email', auth, async (req, res) => {
}
);

router.get('/login', (req, res) => {
router.post('/login', (req, res) => {
console.log(req.body);
login(req.body.username, req.body.password).then((token) => {
res.json({ token: token });
login(req.body.username, req.body.password).then((result) => {
res.json(result);
}).catch((error) => {
console.log(error);
res.status(403).json({ error: error.message });
}
);
Expand Down
70 changes: 0 additions & 70 deletions utils/functions.js

This file was deleted.

0 comments on commit f877099

Please sign in to comment.