floranet/api/index.js

64 lines
2.0 KiB
JavaScript
Raw Normal View History

const cors = require('cors');
const express = require('express');
const path = require('path');
const paypal = require('paypal-rest-sdk');
2024-03-06 17:17:02 +00:00
<<<<<<< HEAD
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
paypal.configure({
'mode': 'sandbox',
'client_id': process.env.CLIENT_ID,
'client_secret': process.env.SECRET_KEY
});
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'];
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);
2024-01-24 18:52:24 +00:00
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)
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
app.listen(port, () => {
console.log(`Server listening at http://localhost:${port}`);
2024-03-06 17:16:03 +00:00
});