fixed salary call after security enhancements
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Josh 2025-08-10 14:21:24 +00:00
parent 4cfdf8443f
commit b0cbb65cc2
3 changed files with 43 additions and 38 deletions

2
.env
View File

@ -2,7 +2,7 @@ CORS_ALLOWED_ORIGINS=https://dev1.aptivaai.com,http://34.16.120.118:3000,http://
SERVER1_PORT=5000 SERVER1_PORT=5000
SERVER2_PORT=5001 SERVER2_PORT=5001
SERVER3_PORT=5002 SERVER3_PORT=5002
IMG_TAG=9365ce4-202508091934 IMG_TAG=4cfdf84-202508101351
ENV_NAME=dev ENV_NAME=dev
PROJECT=aptivaai-dev PROJECT=aptivaai-dev

View File

@ -57,12 +57,12 @@ const chatLimiter = rateLimit({
const institutionData = JSON.parse(fs.readFileSync(INSTITUTION_DATA_PATH, 'utf8')); const institutionData = JSON.parse(fs.readFileSync(INSTITUTION_DATA_PATH, 'utf8'));
// ── DEK + canary bootstrap (use raw pool to avoid DAO interception) ── // ── DEK + canary bootstrap (use raw pool to avoid DAO interception) ──
const db = pool.raw || pool; const sql = pool.raw || pool;
try { try {
await initEncryption(); await initEncryption();
await db.query('SELECT 1'); await sql.query('SELECT 1');
await verifyCanary(db); await verifyCanary(sql);
} catch (e) { } catch (e) {
console.error('FATAL during crypto/DB bootstrap:', e?.message || e); console.error('FATAL during crypto/DB bootstrap:', e?.message || e);
process.exit(1); process.exit(1);
@ -84,7 +84,7 @@ app.get('/livez', (_req, res) => res.type('text').send('OK'));
app.get('/readyz', async (_req, res) => { app.get('/readyz', async (_req, res) => {
try { try {
await initEncryption(); await initEncryption();
await verifyCanary(db); // <-- use raw pool await verifyCanary(sql); // <-- use raw pool
return res.type('text').send('OK'); return res.type('text').send('OK');
} catch (e) { } catch (e) {
console.error('[READYZ]', e.message); console.error('[READYZ]', e.message);
@ -122,7 +122,7 @@ app.get('/healthz', async (_req, res) => {
// DB ping // DB ping
const t0 = Date.now(); const t0 = Date.now();
try { 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.ok = true;
out.checks.db.ping_ms = Date.now() - t0; out.checks.db.ping_ms = Date.now() - t0;
} catch (e) { } catch (e) {
@ -131,7 +131,7 @@ app.get('/healthz', async (_req, res) => {
// canary // canary
try { try {
await verifyCanary(db); // <-- use raw pool await verifyCanary(sql); // <-- use raw pool
out.checks.canary.ok = true; out.checks.canary.ok = true;
} catch (e) { } catch (e) {
out.checks.canary.error = e.message; out.checks.canary.error = e.message;
@ -878,9 +878,9 @@ app.get('/api/salary', async (req, res) => {
let nationalRow = null; let nationalRow = null;
if (area) { if (area) {
regionalRow = await db.get(regionalQuery, [socCode, area]); regionalRow = await dbSqlite.get(regionalQuery, [socCode, area]);
} }
nationalRow = await db.get(nationalQuery, [socCode]); nationalRow = await dbSqlite.get(nationalQuery, [socCode]);
if (!regionalRow && !nationalRow) { if (!regionalRow && !nationalRow) {
console.log('No salary data found for:', { socCode, area }); console.log('No salary data found for:', { socCode, area });
@ -926,7 +926,7 @@ app.post('/api/job-zones', async (req, res) => {
FROM salary_data FROM salary_data
WHERE OCC_CODE IN (${placeholders}) 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); console.log('Salary Data Query Results:', rows);
const jobZoneMapping = rows.reduce((acc, row) => { const jobZoneMapping = rows.reduce((acc, row) => {

View File

@ -388,14 +388,15 @@ export default function CareerRoadmap({ selectedCareer: initialCareer }) {
const [buttonDisabled, setButtonDisabled] = useState(false); const [buttonDisabled, setButtonDisabled] = useState(false);
const [aiRisk, setAiRisk] = useState(null); const [aiRisk, setAiRisk] = useState(null);
const { setChatSnapshot } = useContext(ChatCtx); const chat = useContext(ChatCtx) || {};
const setChatSnapshot = chat?.setChatSnapshot;
const reloadScenarioAndCollege = useCallback(async () => { const reloadScenarioAndCollege = useCallback(async () => {
if (!careerProfileId) return; if (!careerProfileId) return;
const s = await authFetch( const s = await authFetch(
`api/premium/career-profile/${careerProfileId}` `/api/premium/career-profile/${careerProfileId}`
); );
if (s.ok) { if (s.ok) {
const row = await s.json(); const row = await s.json();
@ -405,7 +406,7 @@ export default function CareerRoadmap({ selectedCareer: initialCareer }) {
} }
const c = await authFetch( const c = await authFetch(
`api/premium/college-profile?careerProfileId=${careerProfileId}` `/api/premium/college-profile?careerProfileId=${careerProfileId}`
); );
if (c.ok) setCollegeProfile(await c.json()); if (c.ok) setCollegeProfile(await c.json());
}, [careerProfileId]); }, [careerProfileId]);
@ -659,7 +660,11 @@ const uiSnap = useMemo(() => ({
]); ]);
/* push the snapshot to the chat context */ /* push the snapshot to the chat context */
useEffect(() => setChatSnapshot(uiSnap), [uiSnap, setChatSnapshot]); useEffect(() => {
if (typeof setChatSnapshot === 'function') {
setChatSnapshot(uiSnap);
}
}, [uiSnap, setChatSnapshot]);
useEffect(() => { useEffect(() => {
@ -828,7 +833,7 @@ async function fetchAiRisk(socCode, careerName, description, tasks) {
try { try {
// 1) Check server2 for existing entry // 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, ... } aiRisk = localRiskRes.data; // { socCode, riskLevel, ... }
} catch (err) { } catch (err) {
// 2) If 404 => call server3 // 2) If 404 => call server3
@ -906,7 +911,7 @@ useEffect(() => {
(async () => { (async () => {
try { try {
const qs = new URLSearchParams({ socCode: strippedSocCode, area: userArea }); 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) { if (res.ok) {
setSalaryData(await res.json()); setSalaryData(await res.json());
@ -938,7 +943,7 @@ useEffect(() => {
try { try {
const qs = new URLSearchParams({ state: userState }); const qs = new URLSearchParams({ state: userState });
const res = await authFetch( const res = await authFetch(
`api/projections/${strippedSocCode}?${qs}`, `/api/projections/${strippedSocCode}?${qs}`,
{ signal: ctrl.signal } { signal: ctrl.signal }
); );
@ -965,7 +970,7 @@ useEffect(() => {
// fetch impacts // fetch impacts
const imPromises = allMilestones.map((m) => 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((r) => (r.ok ? r.json() : null))
.then((dd) => dd?.impacts || []) .then((dd) => dd?.impacts || [])
.catch((e) => { .catch((e) => {
@ -1285,8 +1290,8 @@ const fetchMilestones = useCallback(async () => {
if (!careerProfileId) return; if (!careerProfileId) return;
const [profRes, uniRes] = await Promise.all([ const [profRes, uniRes] = await Promise.all([
authFetch(`api/premium/milestones?careerProfileId=${careerProfileId}`), authFetch(`/api/premium/milestones?careerProfileId=${careerProfileId}`),
authFetch(`api/premium/milestones?careerProfileId=universal`) authFetch(`/api/premium/milestones?careerProfileId=universal`)
]); ]);
if (!profRes.ok || !uniRes.ok) return; if (!profRes.ok || !uniRes.ok) return;
@ -1312,7 +1317,8 @@ const handleMilestonesCreated = useCallback(
return ( return (
<div className="milestone-tracker max-w-screen-lg mx-auto px-4 py-6 space-y-4"> <div className="milestone-tracker max-w-screen-lg mx-auto px-4 py-6 space-y-4">
{/* 0) New CareerCoach at the top */}
{careerProfileId ? (
<CareerCoach <CareerCoach
userProfile={userProfile} userProfile={userProfile}
financialProfile={financialProfile} financialProfile={financialProfile}
@ -1321,14 +1327,13 @@ const handleMilestonesCreated = useCallback(
careerProfileId={careerProfileId} careerProfileId={careerProfileId}
collegeProfile={collegeProfile} collegeProfile={collegeProfile}
onMilestonesCreated={handleMilestonesCreated} onMilestonesCreated={handleMilestonesCreated}
onAiRiskFetched={(riskData) => { setAiRisk(riskData); }}
onAiRiskFetched={(riskData) => {
// store it in local state
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?" */} {/* 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> <h2 className="text-2xl font-bold mb-4">Where you are now and where you are going:</h2>