2024-01-11 10:16:45 +00:00
|
|
|
const cors = require('cors');
|
|
|
|
const express = require('express');
|
|
|
|
const path = require('path');
|
2024-02-08 11:27:20 +00:00
|
|
|
const paypal = require('paypal-rest-sdk');
|
2024-03-06 17:17:02 +00:00
|
|
|
<<<<<<< HEAD
|
2024-02-08 11:27:20 +00:00
|
|
|
const productController = require('./controller/product/product.controller');
|
|
|
|
const paymengtController = require('./controller/payment/payment.controller');
|
|
|
|
const provincesController = require('./controller/provinces/provinces.controller');
|
2024-03-06 17:17:02 +00:00
|
|
|
=======
|
2024-03-06 17:16:03 +00:00
|
|
|
const productController = require('./controller/Product/product.controller');
|
|
|
|
const paymengtController = require('./controller/Payment/payment.controller');
|
|
|
|
const provincesController = require('./controller/Provinces/provinces.controller');
|
|
|
|
const deliveryController = require('./controller/Delivery/delivery.controller');
|
|
|
|
const contactController = require('./controller/Contact/contact.controller');
|
2024-03-06 17:17:02 +00:00
|
|
|
>>>>>>> master
|
2024-02-08 11:27:20 +00:00
|
|
|
|
|
|
|
paypal.configure({
|
|
|
|
'mode': 'sandbox',
|
|
|
|
'client_id': process.env.CLIENT_ID,
|
|
|
|
'client_secret': process.env.SECRET_KEY
|
|
|
|
});
|
2024-01-11 10:16:45 +00:00
|
|
|
|
|
|
|
const app = express();
|
|
|
|
const port = 9999;
|
|
|
|
|
2024-03-06 17:16:03 +00:00
|
|
|
const allowedOrigins = ['http://localhost:9100', 'https://floranet.onecommerce.dev','http://49.13.85.117','http://floranet.onecommerce.dev'];
|
2024-01-11 10:16:45 +00:00
|
|
|
const corsOptions = {
|
|
|
|
origin: allowedOrigins,
|
|
|
|
optionsSuccessStatus: 200,
|
|
|
|
};
|
2024-02-08 11:27:20 +00:00
|
|
|
|
2024-01-11 10:16:45 +00:00
|
|
|
app.use(cors(corsOptions));
|
|
|
|
|
2024-02-08 11:27:20 +00:00
|
|
|
app.use(express.json());
|
|
|
|
app.use(
|
|
|
|
express.urlencoded({
|
|
|
|
extended: true,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
|
2024-01-11 10:16:45 +00:00
|
|
|
app.get('/', (req, res) => {
|
|
|
|
const indexPath = path.join(__dirname, './', 'index.html');
|
|
|
|
res.sendFile(indexPath);
|
|
|
|
});
|
|
|
|
|
|
|
|
//Products
|
|
|
|
app.get('/api/products', productController.findAll);
|
2024-01-24 18:52:24 +00:00
|
|
|
app.get('/api/products/:id', productController.findById);
|
2024-02-08 11:27:20 +00:00
|
|
|
app.post('/api/payment/', paymengtController.Create)
|
|
|
|
app.post('/api/payment/success', paymengtController.Success)
|
|
|
|
app.get('/api/payment/cancel', paymengtController.Cancel)
|
|
|
|
app.get('/api/provinces', provincesController.findAll)
|
2024-03-06 17:17:02 +00:00
|
|
|
<<<<<<< HEAD
|
|
|
|
=======
|
2024-03-06 17:16:03 +00:00
|
|
|
app.get('/api/delivery/dates', deliveryController.findByPostalCode)
|
|
|
|
app.post('/api/contact/save', contactController.Create)
|
|
|
|
|
|
|
|
|
2024-03-06 17:17:02 +00:00
|
|
|
>>>>>>> master
|
2024-01-11 10:16:45 +00:00
|
|
|
|
|
|
|
app.listen(port, () => {
|
|
|
|
console.log(`Server listening at http://localhost:${port}`);
|
2024-03-06 17:16:03 +00:00
|
|
|
});
|