Skip to content

Commit

Permalink
fix: fixes on production deploymeny
Browse files Browse the repository at this point in the history
  • Loading branch information
incredible-phoenix246 committed Jul 25, 2024
1 parent 8600a56 commit 9cd1e0d
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 24 deletions.
2 changes: 1 addition & 1 deletion server-script/startappprod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 0 additions & 2 deletions src/controllers/PaymentController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
}
}
Expand All @@ -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" });
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/controllers/PaymentLemonSqueezyController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import config from "../config";
import { Payment } from "../models/payment";
import AppDataSource from "../data-source";


/**
* @swagger
* /api/v1/payments/lemonsqueezy/initiate:
Expand Down Expand Up @@ -44,14 +43,12 @@ export const makePaymentLemonSqueezy = async (req: Request, res: Response) => {
`<a href="https://ifeoluwa-hng-stage-5.lemonsqueezy.com/buy/bf9fee27-d226-4637-a32f-013bd717c3b3?embed=1" class="lemonsqueezy-button">Make Payments</a><script src="https://assets.lemonsqueezy.com/lemon.js" defer></script>`,
);
} catch (error) {
console.error(error);
res
.status(500)
.json({ error: "An error occurred while processing the payment" });
}
};


/**
* @swagger
* /api/v1/payments/lemonsqueezy/webhook:
Expand Down Expand Up @@ -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");
}
};
12 changes: 6 additions & 6 deletions src/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions src/middleware/checkUserRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/services/org.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export class OrgService implements IOrgService {

return { newOrganisation };
} catch (error) {
console.log(error);
throw new BadRequest("Client error");
}
}
Expand Down
1 change: 0 additions & 1 deletion src/services/organisation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export class OrgService implements IOrgService {

return { newOrganisation };
} catch (error) {
console.log(error);
throw new BadRequest("Client error");
}
}
Expand Down
1 change: 0 additions & 1 deletion src/services/organization.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export class OrgService implements IOrgService {

return { newOrganisation };
} catch (error) {
console.log(error);
throw new BadRequest("Client error");
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/services/payment/flutter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export const initializePayment = async (
});
return response;
} catch (error) {
console.error("Error initializing payment:", error);
throw error;
}
};
Expand All @@ -79,7 +78,6 @@ export const verifyPayment = async (transactionId: string): Promise<object> => {

return response;
} catch (error) {
console.error("Error verifying payment:", error);
await updatePaymentStatus(transactionId, "failed");
throw error;
}
Expand Down
95 changes: 95 additions & 0 deletions swags.rtf
Original file line number Diff line number Diff line change
@@ -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 \
\
}

0 comments on commit 9cd1e0d

Please sign in to comment.