fixed salary call after security enhancements
This commit is contained in:
parent
19e8d8e3cb
commit
c16d029432
2
.env
2
.env
@ -2,7 +2,7 @@ CORS_ALLOWED_ORIGINS=https://dev1.aptivaai.com,http://34.16.120.118:3000,http://
|
||||
SERVER1_PORT=5000
|
||||
SERVER2_PORT=5001
|
||||
SERVER3_PORT=5002
|
||||
IMG_TAG=9365ce4-202508091934
|
||||
IMG_TAG=4cfdf84-202508101351
|
||||
|
||||
ENV_NAME=dev
|
||||
PROJECT=aptivaai-dev
|
@ -57,12 +57,12 @@ const chatLimiter = rateLimit({
|
||||
const institutionData = JSON.parse(fs.readFileSync(INSTITUTION_DATA_PATH, 'utf8'));
|
||||
|
||||
// ── DEK + canary bootstrap (use raw pool to avoid DAO interception) ──
|
||||
const db = pool.raw || pool;
|
||||
const sql = pool.raw || pool;
|
||||
|
||||
try {
|
||||
await initEncryption();
|
||||
await db.query('SELECT 1');
|
||||
await verifyCanary(db);
|
||||
await sql.query('SELECT 1');
|
||||
await verifyCanary(sql);
|
||||
} catch (e) {
|
||||
console.error('FATAL during crypto/DB bootstrap:', e?.message || e);
|
||||
process.exit(1);
|
||||
@ -84,7 +84,7 @@ app.get('/livez', (_req, res) => res.type('text').send('OK'));
|
||||
app.get('/readyz', async (_req, res) => {
|
||||
try {
|
||||
await initEncryption();
|
||||
await verifyCanary(db); // <-- use raw pool
|
||||
await verifyCanary(sql); // <-- use raw pool
|
||||
return res.type('text').send('OK');
|
||||
} catch (e) {
|
||||
console.error('[READYZ]', e.message);
|
||||
@ -122,7 +122,7 @@ app.get('/healthz', async (_req, res) => {
|
||||
// DB ping
|
||||
const t0 = Date.now();
|
||||
try {
|
||||
await db.query('SELECT 1'); // <-- use raw pool
|
||||
await sql.query('SELECT 1'); // <-- use raw pool
|
||||
out.checks.db.ok = true;
|
||||
out.checks.db.ping_ms = Date.now() - t0;
|
||||
} catch (e) {
|
||||
@ -131,7 +131,7 @@ app.get('/healthz', async (_req, res) => {
|
||||
|
||||
// canary
|
||||
try {
|
||||
await verifyCanary(db); // <-- use raw pool
|
||||
await verifyCanary(sql); // <-- use raw pool
|
||||
out.checks.canary.ok = true;
|
||||
} catch (e) {
|
||||
out.checks.canary.error = e.message;
|
||||
@ -877,10 +877,10 @@ app.get('/api/salary', async (req, res) => {
|
||||
let regionalRow = null;
|
||||
let nationalRow = null;
|
||||
|
||||
if (area) {
|
||||
regionalRow = await db.get(regionalQuery, [socCode, area]);
|
||||
if (area) {
|
||||
regionalRow = await dbSqlite.get(regionalQuery, [socCode, area]);
|
||||
}
|
||||
nationalRow = await db.get(nationalQuery, [socCode]);
|
||||
nationalRow = await dbSqlite.get(nationalQuery, [socCode]);
|
||||
|
||||
if (!regionalRow && !nationalRow) {
|
||||
console.log('No salary data found for:', { socCode, area });
|
||||
@ -926,7 +926,7 @@ app.post('/api/job-zones', async (req, res) => {
|
||||
FROM salary_data
|
||||
WHERE OCC_CODE IN (${placeholders})
|
||||
`;
|
||||
const rows = await db.all(q, formattedSocCodes);
|
||||
const rows = await dbSqlite.all(q, formattedSocCodes);
|
||||
console.log('Salary Data Query Results:', rows);
|
||||
|
||||
const jobZoneMapping = rows.reduce((acc, row) => {
|
||||
|
@ -388,14 +388,15 @@ export default function CareerRoadmap({ selectedCareer: initialCareer }) {
|
||||
const [buttonDisabled, setButtonDisabled] = useState(false);
|
||||
const [aiRisk, setAiRisk] = useState(null);
|
||||
|
||||
const { setChatSnapshot } = useContext(ChatCtx);
|
||||
const chat = useContext(ChatCtx) || {};
|
||||
const setChatSnapshot = chat?.setChatSnapshot;
|
||||
|
||||
|
||||
|
||||
const reloadScenarioAndCollege = useCallback(async () => {
|
||||
if (!careerProfileId) return;
|
||||
const s = await authFetch(
|
||||
`api/premium/career-profile/${careerProfileId}`
|
||||
`/api/premium/career-profile/${careerProfileId}`
|
||||
);
|
||||
if (s.ok) {
|
||||
const row = await s.json();
|
||||
@ -405,7 +406,7 @@ export default function CareerRoadmap({ selectedCareer: initialCareer }) {
|
||||
}
|
||||
|
||||
const c = await authFetch(
|
||||
`api/premium/college-profile?careerProfileId=${careerProfileId}`
|
||||
`/api/premium/college-profile?careerProfileId=${careerProfileId}`
|
||||
);
|
||||
if (c.ok) setCollegeProfile(await c.json());
|
||||
}, [careerProfileId]);
|
||||
@ -659,7 +660,11 @@ const uiSnap = useMemo(() => ({
|
||||
]);
|
||||
|
||||
/* push the snapshot to the chat context */
|
||||
useEffect(() => setChatSnapshot(uiSnap), [uiSnap, setChatSnapshot]);
|
||||
useEffect(() => {
|
||||
if (typeof setChatSnapshot === 'function') {
|
||||
setChatSnapshot(uiSnap);
|
||||
}
|
||||
}, [uiSnap, setChatSnapshot]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
@ -828,7 +833,7 @@ async function fetchAiRisk(socCode, careerName, description, tasks) {
|
||||
|
||||
try {
|
||||
// 1) Check server2 for existing entry
|
||||
const localRiskRes = await axios.get(`api/ai-risk/${socCode}`);
|
||||
const localRiskRes = await axios.get(`/api/ai-risk/${socCode}`);
|
||||
aiRisk = localRiskRes.data; // { socCode, riskLevel, ... }
|
||||
} catch (err) {
|
||||
// 2) If 404 => call server3
|
||||
@ -906,7 +911,7 @@ useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
const qs = new URLSearchParams({ socCode: strippedSocCode, area: userArea });
|
||||
const res = await fetch(`api/salary?${qs}`, { signal: ctrl.signal });
|
||||
const res = await fetch(`/api/salary?${qs}`, { signal: ctrl.signal });
|
||||
|
||||
if (res.ok) {
|
||||
setSalaryData(await res.json());
|
||||
@ -938,7 +943,7 @@ useEffect(() => {
|
||||
try {
|
||||
const qs = new URLSearchParams({ state: userState });
|
||||
const res = await authFetch(
|
||||
`api/projections/${strippedSocCode}?${qs}`,
|
||||
`/api/projections/${strippedSocCode}?${qs}`,
|
||||
{ signal: ctrl.signal }
|
||||
);
|
||||
|
||||
@ -965,7 +970,7 @@ useEffect(() => {
|
||||
|
||||
// fetch impacts
|
||||
const imPromises = allMilestones.map((m) =>
|
||||
authFetch(`api/premium/milestone-impacts?milestone_id=${m.id}`)
|
||||
authFetch(`/api/premium/milestone-impacts?milestone_id=${m.id}`)
|
||||
.then((r) => (r.ok ? r.json() : null))
|
||||
.then((dd) => dd?.impacts || [])
|
||||
.catch((e) => {
|
||||
@ -1285,8 +1290,8 @@ const fetchMilestones = useCallback(async () => {
|
||||
if (!careerProfileId) return;
|
||||
|
||||
const [profRes, uniRes] = await Promise.all([
|
||||
authFetch(`api/premium/milestones?careerProfileId=${careerProfileId}`),
|
||||
authFetch(`api/premium/milestones?careerProfileId=universal`)
|
||||
authFetch(`/api/premium/milestones?careerProfileId=${careerProfileId}`),
|
||||
authFetch(`/api/premium/milestones?careerProfileId=universal`)
|
||||
]);
|
||||
if (!profRes.ok || !uniRes.ok) return;
|
||||
|
||||
@ -1312,23 +1317,23 @@ const handleMilestonesCreated = useCallback(
|
||||
return (
|
||||
<div className="milestone-tracker max-w-screen-lg mx-auto px-4 py-6 space-y-4">
|
||||
|
||||
{/* 0) New CareerCoach at the top */}
|
||||
<CareerCoach
|
||||
userProfile={userProfile}
|
||||
financialProfile={financialProfile}
|
||||
scenarioRow={scenarioRow}
|
||||
setScenarioRow={setScenarioRow}
|
||||
careerProfileId={careerProfileId}
|
||||
collegeProfile={collegeProfile}
|
||||
onMilestonesCreated={handleMilestonesCreated}
|
||||
|
||||
|
||||
|
||||
onAiRiskFetched={(riskData) => {
|
||||
// store it in local state
|
||||
setAiRisk(riskData);
|
||||
}}
|
||||
/>
|
||||
{careerProfileId ? (
|
||||
<CareerCoach
|
||||
userProfile={userProfile}
|
||||
financialProfile={financialProfile}
|
||||
scenarioRow={scenarioRow}
|
||||
setScenarioRow={setScenarioRow}
|
||||
careerProfileId={careerProfileId}
|
||||
collegeProfile={collegeProfile}
|
||||
onMilestonesCreated={handleMilestonesCreated}
|
||||
onAiRiskFetched={(riskData) => { setAiRisk(riskData); }}
|
||||
/>
|
||||
) : (
|
||||
<div className="bg-white p-4 rounded shadow text-center min-h-[80px] flex items-center justify-center">
|
||||
Loading your roadmap…
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 1) Then your "Where Am I Now?" */}
|
||||
<h2 className="text-2xl font-bold mb-4">Where you are now and where you are going:</h2>
|
||||
|
Loading…
Reference in New Issue
Block a user