Compare commits

...

1 Commits

Author SHA1 Message Date
Flatlogic Bot
229cc21dac Sept18_2025 2025-09-19 03:32:55 +00:00
7 changed files with 66 additions and 13 deletions

File diff suppressed because one or more lines are too long

View File

@ -71,5 +71,11 @@ config.apiUrl = `${config.host}${config.port ? `:${config.port}` : ``}/api`;
config.swaggerUrl = `${config.swaggerUI}${config.swaggerPort}`;
config.uiUrl = `${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;

View File

@ -25,6 +25,11 @@ module.exports = function (sequelize, DataTypes) {
allowNull: true,
unique: true,
},
certificate_url: {
type: DataTypes.TEXT,
allowNull: true,
},
},
{
timestamps: true,

View File

@ -95,6 +95,39 @@ app.use(
);
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');
app.use(bodyParser.json());

View File

@ -26,6 +26,12 @@ const nextConfig = {
},
],
},
rewrites: async () => [
{
source: '/api/:path*',
destination: `${process.env.NEXT_PUBLIC_API_URL}/api/:path*`,
},
],
};
export default nextConfig;

View File

@ -1,12 +1,12 @@
export const hostApi =
process.env.NODE_ENV === 'development' && !process.env.NEXT_PUBLIC_BACK_API
? 'http://localhost'
: '';
export const portApi =
process.env.NODE_ENV === 'development' && !process.env.NEXT_PUBLIC_BACK_API
? 8080
: '';
export const baseURLApi = `${hostApi}${portApi ? `:${portApi}` : ``}/api`;
const trimSlash = (url: string) => url.replace(/\/$/, '');
const apiUrlEnv = process.env.NEXT_PUBLIC_API_URL;
const defaultDevApi = 'http://localhost:8080';
const host = apiUrlEnv
? trimSlash(apiUrlEnv)
: process.env.NODE_ENV === 'development'
? defaultDevApi
: '';
export const baseURLApi = host ? `${host}/api` : '/api';
export const localStorageDarkModeKey = 'darkMode';

View File

@ -1,8 +1,10 @@
import axios from 'axios';
import { baseURLApi } from '../config';
export async function getPexelsImage() {
try {
const response = await axios.get(`/pexels/image`);
const response = await axios.get(`${baseURLApi}/pexels/image`);
return response.data;
} catch (error) {
console.error('Error fetching image:', error);
@ -12,7 +14,7 @@ export async function getPexelsImage() {
export async function getPexelsVideo() {
try {
const response = await axios.get(`/pexels/video`);
const response = await axios.get(`${baseURLApi}/pexels/video`);
return response.data;
} catch (error) {
console.error('Error fetching video:', error);
@ -50,7 +52,7 @@ export async function getMultiplePexelsImages(
const queryString = missingQueries.join(',');
try {
const response = await axios.get(`/pexels/multiple-images`, {
const response = await axios.get(`${baseURLApi}/pexels/multiple-images`, {
params: { queries: queryString },
});