Compare commits
No commits in common. "ai-dev" and "master" have entirely different histories.
File diff suppressed because one or more lines are too long
@ -71,11 +71,5 @@ config.apiUrl = `${config.host}${config.port ? `:${config.port}` : ``}/api`;
|
|||||||
config.swaggerUrl = `${config.swaggerUI}${config.swaggerPort}`;
|
config.swaggerUrl = `${config.swaggerUI}${config.swaggerPort}`;
|
||||||
config.uiUrl = `${config.hostUI}${config.portUI ? `:${config.portUI}` : ``}/#`;
|
config.uiUrl = `${config.hostUI}${config.portUI ? `:${config.portUI}` : ``}/#`;
|
||||||
config.backUrl = `${config.hostUI}${config.portUI ? `:${config.portUI}` : ``}`;
|
config.backUrl = `${config.hostUI}${config.portUI ? `:${config.portUI}` : ``}`;
|
||||||
// Payment gateway configurations
|
|
||||||
config.stripeSecretKey = process.env.STRIPE_SECRET_KEY || 'sk_test_dummy';
|
|
||||||
config.stripeWebhookSecret = process.env.STRIPE_WEBHOOK_SECRET || 'whsec_dummy';
|
|
||||||
config.paypalClientId = process.env.PAYPAL_CLIENT_ID || 'paypal_client_dummy';
|
|
||||||
config.paypalClientSecret = process.env.PAYPAL_CLIENT_SECRET || 'paypal_secret_dummy';
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = config;
|
module.exports = config;
|
||||||
|
|||||||
@ -25,11 +25,6 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
allowNull: true,
|
allowNull: true,
|
||||||
unique: true,
|
unique: true,
|
||||||
},
|
},
|
||||||
certificate_url: {
|
|
||||||
type: DataTypes.TEXT,
|
|
||||||
allowNull: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
timestamps: true,
|
timestamps: true,
|
||||||
|
|||||||
@ -95,39 +95,6 @@ app.use(
|
|||||||
);
|
);
|
||||||
|
|
||||||
app.use(cors({ origin: true }));
|
app.use(cors({ origin: true }));
|
||||||
|
|
||||||
// Stripe webhook endpoint
|
|
||||||
const stripe = require('stripe')(config.stripeSecretKey);
|
|
||||||
app.post(
|
|
||||||
'/api/webhooks/stripe',
|
|
||||||
express.raw({ type: 'application/json' }),
|
|
||||||
async (req, res) => {
|
|
||||||
const sig = req.headers['stripe-signature'];
|
|
||||||
let event;
|
|
||||||
try {
|
|
||||||
event = stripe.webhooks.constructEvent(
|
|
||||||
req.body,
|
|
||||||
sig,
|
|
||||||
config.stripeWebhookSecret,
|
|
||||||
);
|
|
||||||
} catch (err) {
|
|
||||||
return res.status(400).send(`Webhook Error: ${err.message}`);
|
|
||||||
}
|
|
||||||
if (event.type === 'checkout.session.completed') {
|
|
||||||
const session = event.data.object;
|
|
||||||
const enrollmentId = session.metadata.enrollmentId;
|
|
||||||
await db.enrollments.update(
|
|
||||||
{
|
|
||||||
payment_status: 'completed',
|
|
||||||
certificate_url: `${config.uiUrl}/certificate?enrollmentId=${enrollmentId}`,
|
|
||||||
},
|
|
||||||
{ where: { id: enrollmentId } },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
res.json({ received: true });
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
require('./auth/auth');
|
require('./auth/auth');
|
||||||
|
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
|
|||||||
@ -26,12 +26,6 @@ const nextConfig = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
rewrites: async () => [
|
|
||||||
{
|
|
||||||
source: '/api/:path*',
|
|
||||||
destination: `${process.env.NEXT_PUBLIC_API_URL}/api/:path*`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
const trimSlash = (url: string) => url.replace(/\/$/, '');
|
export const hostApi =
|
||||||
const apiUrlEnv = process.env.NEXT_PUBLIC_API_URL;
|
process.env.NODE_ENV === 'development' && !process.env.NEXT_PUBLIC_BACK_API
|
||||||
const defaultDevApi = 'http://localhost:8080';
|
? 'http://localhost'
|
||||||
const host = apiUrlEnv
|
: '';
|
||||||
? trimSlash(apiUrlEnv)
|
export const portApi =
|
||||||
: process.env.NODE_ENV === 'development'
|
process.env.NODE_ENV === 'development' && !process.env.NEXT_PUBLIC_BACK_API
|
||||||
? defaultDevApi
|
? 8080
|
||||||
: '';
|
: '';
|
||||||
export const baseURLApi = host ? `${host}/api` : '/api';
|
export const baseURLApi = `${hostApi}${portApi ? `:${portApi}` : ``}/api`;
|
||||||
|
|
||||||
export const localStorageDarkModeKey = 'darkMode';
|
export const localStorageDarkModeKey = 'darkMode';
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { baseURLApi } from '../config';
|
|
||||||
|
|
||||||
|
|
||||||
export async function getPexelsImage() {
|
export async function getPexelsImage() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`${baseURLApi}/pexels/image`);
|
const response = await axios.get(`/pexels/image`);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching image:', error);
|
console.error('Error fetching image:', error);
|
||||||
@ -14,7 +12,7 @@ export async function getPexelsImage() {
|
|||||||
|
|
||||||
export async function getPexelsVideo() {
|
export async function getPexelsVideo() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`${baseURLApi}/pexels/video`);
|
const response = await axios.get(`/pexels/video`);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching video:', error);
|
console.error('Error fetching video:', error);
|
||||||
@ -52,7 +50,7 @@ export async function getMultiplePexelsImages(
|
|||||||
const queryString = missingQueries.join(',');
|
const queryString = missingQueries.join(',');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`${baseURLApi}/pexels/multiple-images`, {
|
const response = await axios.get(`/pexels/multiple-images`, {
|
||||||
params: { queries: queryString },
|
params: { queries: queryString },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user