Skip to content

Commit 62db922

Browse files
Merge pull request #10 from upayanmazumder-DevLabs/dev
fix imports, resources
2 parents c9055d4 + 12fd2c0 commit 62db922

File tree

10 files changed

+567
-109
lines changed

10 files changed

+567
-109
lines changed

api/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"passport-github2": "^0.1.12",
3333
"passport-google-oauth20": "^2.0.0",
3434
"passport-local": "^1.0.0",
35-
"razorpay": "^2.9.6",
3635
"rimraf": "^6.0.1",
3736
"ts-node": "^10.9.2",
3837
"ts-node-dev": "^2.0.0",

api/src/config/env.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ const REQUIRED_ENV_VARS = [
2323
'INGRESS_BASE_DOMAIN',
2424
'MANIFESTS_DIR',
2525
'GROQ',
26-
'RAZORPAY_KEY_ID',
27-
'RAZORPAY_KEY_SECRET',
2826
'PROMETHEUS_URL',
2927
];
3028

@@ -72,11 +70,6 @@ const env = {
7270
// GROQ API key or endpoint
7371
GROQ: process.env.GROQ,
7472

75-
// Razorpay
76-
RAZORPAY_KEY_ID: process.env.RAZORPAY_KEY_ID,
77-
RAZORPAY_KEY_SECRET: process.env.RAZORPAY_KEY_SECRET,
78-
RAZORPAY_WEBHOOK_SECRET: process.env.RAZORPAY_WEBHOOK_SECRET,
79-
8073
// Prometheus URL for metrics
8174
PROMETHEUS_URL: process.env.PROMETHEUS_URL || 'http://localhost:9090',
8275

api/src/controllers/plans/razorpay.controller.ts

Lines changed: 0 additions & 70 deletions
This file was deleted.

api/src/models/plan.model.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const planSchema = new Schema<IPlan & Document>(
1111
limits: ResourceSchema,
1212
},
1313
isDefault: { type: Boolean, default: false },
14-
price: { type: Number /* Price in paise (integer) */ },
1514
isActive: { type: Boolean, default: true },
1615
},
1716
{ timestamps: true }

api/src/routes/plan.routes.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
// Plan routes for managing subscription plans and handling payments
1+
// Plan routes for managing subscription plans
22
import { Router } from 'express';
33
import { ensureAdmin } from '../auth/role.middleware';
44
import asyncHandler from '../utils/handlers/asyncHandler';
5-
import express from 'express';
65
import getPlanByID from '../controllers/plans/getPlanByID.controller';
76
import createPlan from '../controllers/plans/createPlan.controller';
87
import getPlans from '../controllers/plans/getPlans.controller';
98
import updatePlan from '../controllers/plans/updatePlan.controller';
109
import deletePlan from '../controllers/plans/deletePlan.controller';
11-
import { createOrder, verifyPayment } from '../controllers/plans/razorpay.controller';
1210

1311
const router = Router();
1412

@@ -17,12 +15,6 @@ router.get('/:id', asyncHandler(getPlanByID));
1715
// Public: Get all plans
1816
router.get('/', asyncHandler(getPlans));
1917

20-
// Razorpay payment endpoints (public)
21-
router.post('/:id/create-order', asyncHandler(createOrder));
22-
router.post('/verify-payment', express.json(), (req, res) => {
23-
verifyPayment(req, res);
24-
});
25-
2618
// All plan management routes below require admin privileges
2719
router.use(ensureAdmin);
2820

api/src/types/plan.types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@ export default interface IPlan {
1010
limits?: Resource;
1111
};
1212
isDefault?: boolean;
13-
/** Price in paise (integer) */
14-
price?: number;
1513
isActive?: boolean;
1614
}

api/src/utils/k8s/helpers/toK8sResource.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,34 @@ export default function toK8sResource(
33
type: 'cpu' | 'memory'
44
): string {
55
if (val === undefined || val === null || val === '') return type === 'cpu' ? '0m' : '0Mi';
6+
7+
// Frontend/base units:
8+
// - CPU is provided in millicores (m)
9+
// - Memory is provided in megabytes (MB ~ MiB)
610
if (typeof val === 'number') {
711
if (type === 'cpu') {
8-
// CPU is in cores (e.g., 0.25 = 250m, 1 = 1000m)
9-
if (val < 1) return `${Math.round(val * 1000)}m`;
10-
return `${Math.round(val * 1000)}m`;
12+
// CPU already in millicores
13+
return `${Math.round(val)}m`;
1114
}
1215
if (type === 'memory') {
13-
// Memory is in bytes, convert to MiB for K8s
14-
return `${Math.round(val / (1024 * 1024))}Mi`;
16+
// Memory already in MB -> use Mi in K8s
17+
return `${Math.round(val)}Mi`;
1518
}
1619
}
20+
1721
if (typeof val === 'string') {
18-
// If already ends with m, Mi, Gi, etc., return as is
22+
// If already ends with appropriate unit, return as-is
1923
if (type === 'cpu' && /m$/.test(val)) return val;
2024
if (type === 'memory' && /(Mi|Gi)$/.test(val)) return val;
21-
// If it's a plain number string, parse and convert
25+
26+
// If it's a plain number string, interpret using base units above
2227
const numVal = parseFloat(val);
2328
if (!isNaN(numVal)) {
24-
if (type === 'cpu') {
25-
return `${Math.round(numVal * 1000)}m`;
26-
}
27-
return `${Math.round(numVal / (1024 * 1024))}Mi`;
29+
if (type === 'cpu') return `${Math.round(numVal)}m`;
30+
return `${Math.round(numVal)}Mi`;
2831
}
2932
return val;
3033
}
34+
3135
return type === 'cpu' ? '0m' : '0Mi';
3236
}

example.env

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,8 @@ MANIFESTS_DIR=
4444
# GROQ
4545
GROQ=
4646

47-
# Razorpay
48-
RAZORPAY_KEY_ID=
49-
RAZORPAY_KEY_SECRET=
50-
5147
# Prometheus URL for metrics
5248
PROMETHEUS_URL= # Use http://localhost:9090 or your prometheus url
5349

5450
# Persistent volume root directory
55-
VOLUME_ROOT_PATH=
51+
VOLUME_ROOT_PATH=

0 commit comments

Comments
 (0)