diff --git a/server-script/startappprod.sh b/server-script/startappprod.sh index e6669a8a..e7f711a5 100755 --- a/server-script/startappprod.sh +++ b/server-script/startappprod.sh @@ -2,4 +2,4 @@ cd /var/www/aihomework/prod/ mkdir -p logs -/usr/bin/yarn prod >> logs/prodoutput.log 2>&1 +/usr/bin/yarn start >> logs/prodoutput.log 2>&1 diff --git a/src/config/index.ts b/src/config/index.ts index 52668c2c..e2bbc1e2 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -1,10 +1,6 @@ import dotenv from "dotenv"; dotenv.config(); -const app = require("express")(); -app.use(require("express").json()); - -const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY); const config = { port: process.env.PORT ?? 8000, "api-prefix": "api/v1", diff --git a/src/controllers/PaymentController.ts b/src/controllers/PaymentController.ts index bb746c58..4c181497 100644 --- a/src/controllers/PaymentController.ts +++ b/src/controllers/PaymentController.ts @@ -15,7 +15,6 @@ export class PaymentController { return res.json(paymentResponse); } catch (error) { - console.error("Error initiating payment:", error); return res.status(500).json({ error: "Payment initiation failed" }); } } @@ -35,7 +34,6 @@ export class PaymentController { return res.json(verificationResponse); } catch (error) { - console.error("Error verifying payment:", error); return res.status(500).json({ error: "Payment verification failed" }); } } diff --git a/src/controllers/PaymentLemonSqueezyController.ts b/src/controllers/PaymentLemonSqueezyController.ts index 935ff9f9..47f530d4 100644 --- a/src/controllers/PaymentLemonSqueezyController.ts +++ b/src/controllers/PaymentLemonSqueezyController.ts @@ -11,7 +11,6 @@ import config from "../config"; import { Payment } from "../models/payment"; import AppDataSource from "../data-source"; - /** * @swagger * /api/v1/payments/lemonsqueezy/initiate: @@ -44,14 +43,12 @@ export const makePaymentLemonSqueezy = async (req: Request, res: Response) => { `Make Payments`, ); } catch (error) { - console.error(error); res .status(500) .json({ error: "An error occurred while processing the payment" }); } }; - /** * @swagger * /api/v1/payments/lemonsqueezy/webhook: @@ -128,7 +125,6 @@ export const LemonSqueezyWebhook = async (req: Request, res: Response) => { await paymentRepository.save(payment); res.status(200).send("Webhook received"); } catch (error) { - console.error("Webhook verification failed:", error.message); res.status(400).send("Webhook verification failed"); } }; diff --git a/src/data-source.ts b/src/data-source.ts index c081a0f2..89ea2564 100644 --- a/src/data-source.ts +++ b/src/data-source.ts @@ -16,12 +16,12 @@ const AppDataSource = new DataSource({ entities: ["src/models/**/*.ts"], migrations: ["src/migrations/**/*.ts"], migrationsTableName: "migrations", - // ssl: true, - // extra: { - // ssl: { - // rejectUnauthorized: false, - // }, - // }, + ssl: true, + extra: { + ssl: { + rejectUnauthorized: false, + }, + }, }); export async function initializeDataSource() { diff --git a/src/middleware/checkUserRole.ts b/src/middleware/checkUserRole.ts index 8396a3ed..33f816ce 100644 --- a/src/middleware/checkUserRole.ts +++ b/src/middleware/checkUserRole.ts @@ -24,8 +24,7 @@ export const checkPermissions = (roles: UserRole[]) => { const user = await userRepository.findOne({ where: { id: decodedToken.userId }, }); - // console.log(user); - // if (user.role !== 'super_admin' ) + if (!user || !roles.includes(user.role)) { return res .status(403) diff --git a/src/services/org.services.ts b/src/services/org.services.ts index 97af030b..7696fa67 100644 --- a/src/services/org.services.ts +++ b/src/services/org.services.ts @@ -30,7 +30,6 @@ export class OrgService implements IOrgService { return { newOrganisation }; } catch (error) { - console.log(error); throw new BadRequest("Client error"); } } diff --git a/src/services/organisation.service.ts b/src/services/organisation.service.ts index bbc26b27..63ab5415 100644 --- a/src/services/organisation.service.ts +++ b/src/services/organisation.service.ts @@ -32,7 +32,6 @@ export class OrgService implements IOrgService { return { newOrganisation }; } catch (error) { - console.log(error); throw new BadRequest("Client error"); } } diff --git a/src/services/organization.services.ts b/src/services/organization.services.ts index a02199e9..b477010b 100644 --- a/src/services/organization.services.ts +++ b/src/services/organization.services.ts @@ -32,7 +32,6 @@ export class OrgService implements IOrgService { return { newOrganisation }; } catch (error) { - console.log(error); throw new BadRequest("Client error"); } } diff --git a/src/services/payment/flutter.service.ts b/src/services/payment/flutter.service.ts index 738cf621..bdbc3ec2 100644 --- a/src/services/payment/flutter.service.ts +++ b/src/services/payment/flutter.service.ts @@ -55,7 +55,6 @@ export const initializePayment = async ( }); return response; } catch (error) { - console.error("Error initializing payment:", error); throw error; } }; @@ -79,7 +78,6 @@ export const verifyPayment = async (transactionId: string): Promise => { return response; } catch (error) { - console.error("Error verifying payment:", error); await updatePaymentStatus(transactionId, "failed"); throw error; } diff --git a/swags.rtf b/swags.rtf new file mode 100644 index 00000000..d0d39e16 --- /dev/null +++ b/swags.rtf @@ -0,0 +1,95 @@ +{\rtf1\ansi\ansicpg1252\cocoartf2513 +\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 Menlo-Regular;} +{\colortbl;\red255\green255\blue255;\red89\green138\blue67;\red23\green23\blue23;\red202\green202\blue202; +\red70\green137\blue204;} +{\*\expandedcolortbl;;\cssrgb\c41569\c60000\c33333;\cssrgb\c11765\c11765\c11765;\cssrgb\c83137\c83137\c83137; +\cssrgb\c33725\c61176\c83922;} +\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0 +\deftab720 +\pard\pardeftab720\sl360\partightenfactor0 + +\f0\fs24 \cf2 \cb3 \expnd0\expndtw0\kerning0 +\outl0\strokewidth0 \strokec2 /**\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * \cf5 \strokec5 @swagger\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * /api/v1/admin/organisation/:id:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * patch:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * summary: Admin-Update an existing organisation\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * tags: [Admin]\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * parameters:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * - in: path\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * name: id\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * required: true\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * description: The ID of the organisation to update\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * schema:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * requestBody:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * required: true\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * content:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * application/json:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * schema:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: object\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * properties:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * name:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * email:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * slug:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * industry:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * state:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * country:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * address:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * responses:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * 200:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * description: Organisation Updated Successfully\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * content:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * application/json:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * schema:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: object\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * properties:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * success:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: boolean\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * message:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * data:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: object\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * properties:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * id:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * name:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * email:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * slug:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * industry:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * state:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * country:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * address:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * created_at:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * format: date-time\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * updated_at:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: string\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * format: date-time\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * status_code:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * type: integer\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * 400:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * description: Bad Request\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * 500:\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 * description: Internal Server Error\cf4 \cb1 \strokec4 \ +\cf2 \cb3 \strokec2 */\cf4 \cb1 \strokec4 \ +\ +} \ No newline at end of file