64 lines
2.0 KiB
JavaScript
64 lines
2.0 KiB
JavaScript
const cors = require('cors');
|
|
const express = require('express');
|
|
const path = require('path');
|
|
const paypal = require('paypal-rest-sdk');
|
|
<<<<<<< HEAD
|
|
const productController = require('./controller/product/product.controller');
|
|
const paymengtController = require('./controller/payment/payment.controller');
|
|
const provincesController = require('./controller/provinces/provinces.controller');
|
|
=======
|
|
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');
|
|
>>>>>>> master
|
|
|
|
paypal.configure({
|
|
'mode': 'sandbox',
|
|
'client_id': process.env.CLIENT_ID,
|
|
'client_secret': process.env.SECRET_KEY
|
|
});
|
|
|
|
const app = express();
|
|
const port = 9999;
|
|
|
|
const allowedOrigins = ['http://localhost:9100', 'https://floranet.onecommerce.dev','http://49.13.85.117','http://floranet.onecommerce.dev'];
|
|
const corsOptions = {
|
|
origin: allowedOrigins,
|
|
optionsSuccessStatus: 200,
|
|
};
|
|
|
|
app.use(cors(corsOptions));
|
|
|
|
app.use(express.json());
|
|
app.use(
|
|
express.urlencoded({
|
|
extended: true,
|
|
}),
|
|
);
|
|
|
|
app.get('/', (req, res) => {
|
|
const indexPath = path.join(__dirname, './', 'index.html');
|
|
res.sendFile(indexPath);
|
|
});
|
|
|
|
//Products
|
|
app.get('/api/products', productController.findAll);
|
|
app.get('/api/products/:id', productController.findById);
|
|
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)
|
|
<<<<<<< HEAD
|
|
=======
|
|
app.get('/api/delivery/dates', deliveryController.findByPostalCode)
|
|
app.post('/api/contact/save', contactController.Create)
|
|
|
|
|
|
>>>>>>> master
|
|
|
|
app.listen(port, () => {
|
|
console.log(`Server listening at http://localhost:${port}`);
|
|
});
|