Refactored project paths, fixed NGINX configs, updated API routes, and improved error handling.
This commit is contained in:
parent
0276bc60ae
commit
4b95b92261
@ -12,7 +12,7 @@ import jwt from 'jsonwebtoken'; // For token-based authentication
|
|||||||
// Derive __dirname for ES modules
|
// Derive __dirname for ES modules
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
const dbPath = path.resolve('/home/jcoakley/user_profile.db');
|
const dbPath = path.resolve('/home/jcoakley/aptiva-dev1-app/backend/user_profile.db');
|
||||||
|
|
||||||
const db = new sqlite3.Database(dbPath, (err) => {
|
const db = new sqlite3.Database(dbPath, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -22,7 +22,7 @@ const db = new sqlite3.Database(dbPath, (err) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dotenv.config({ path: path.resolve(__dirname, '.env') }); // Load environment variables
|
dotenv.config({ path: path.resolve(__dirname, '../backend/.env') }); // Load environment variables
|
||||||
const SECRET_KEY = process.env.SECRET_KEY || 'supersecurekey'; // Use a secure key in production
|
const SECRET_KEY = process.env.SECRET_KEY || 'supersecurekey'; // Use a secure key in production
|
||||||
console.log('ONET_USERNAME:', process.env.ONET_USERNAME);
|
console.log('ONET_USERNAME:', process.env.ONET_USERNAME);
|
||||||
console.log('ONET_PASSWORD:', process.env.ONET_PASSWORD);
|
console.log('ONET_PASSWORD:', process.env.ONET_PASSWORD);
|
||||||
@ -243,7 +243,7 @@ app.get('/api/areas', (req, res) => {
|
|||||||
return res.status(400).json({ error: 'State parameter is required' });
|
return res.status(400).json({ error: 'State parameter is required' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const dbPath = path.resolve('/home/jcoakley/salary_info.db'); // Path to salary_info.db
|
const dbPath = path.resolve('/home/jcoakley/aptiva-dev1-app/salary_info.db'); // Path to salary_info.db
|
||||||
const db = new sqlite3.Database(dbPath, sqlite3.OPEN_READONLY, (err) => {
|
const db = new sqlite3.Database(dbPath, sqlite3.OPEN_READONLY, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('Error connecting to database:', err.message);
|
console.error('Error connecting to database:', err.message);
|
||||||
@ -273,6 +273,6 @@ app.get('/api/areas', (req, res) => {
|
|||||||
|
|
||||||
|
|
||||||
// Start the server
|
// Start the server
|
||||||
app.listen(PORT, '0.0.0.0', () => {
|
app.listen(PORT, () => {
|
||||||
console.log(`Server running on http://34.16.120.118:${PORT}`);
|
console.log(`Server running on http://localhost:${PORT}`);
|
||||||
});
|
});
|
||||||
|
@ -90,6 +90,11 @@ app.use((req, res, next) => {
|
|||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.use('/CIP_institution_mapping_fixed.json', (req, res) => {
|
||||||
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||||
|
res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
|
||||||
|
res.sendFile(path.join(__dirname, 'CIP_institution_mapping_fixed.json'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Middleware to parse JSON bodies
|
// Middleware to parse JSON bodies
|
||||||
|
BIN
backend/user_profile.db
Normal file
BIN
backend/user_profile.db
Normal file
Binary file not shown.
18951
package-lock.json
generated
18951
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@ -2,11 +2,25 @@
|
|||||||
"name": "aptiva-dev1-app",
|
"name": "aptiva-dev1-app",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"axios": "^1.7.9",
|
||||||
|
"bcrypt": "^5.1.1",
|
||||||
|
"chart.js": "^4.4.7",
|
||||||
|
"cors": "^2.8.5",
|
||||||
"cra-template": "1.2.0",
|
"cra-template": "1.2.0",
|
||||||
"react": "^19.0.0",
|
"dotenv": "^16.4.7",
|
||||||
"react-dom": "^19.0.0",
|
"helmet": "^8.0.0",
|
||||||
"react-scripts": "^5.0.1"
|
"jsonwebtoken": "^9.0.2",
|
||||||
|
"jwt-decode": "^4.0.0",
|
||||||
|
"react": "^18.2.0",
|
||||||
|
"react-chartjs-2": "^5.2.0",
|
||||||
|
"react-dom": "^18.2.0",
|
||||||
|
"react-router-dom": "^7.0.2",
|
||||||
|
"react-scripts": "^3.0.1",
|
||||||
|
"react-spinners": "^0.15.0",
|
||||||
|
"sqlite3": "^5.1.7",
|
||||||
|
"web-vitals": "^4.2.4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
|
@ -5,7 +5,14 @@ import axios from 'axios';
|
|||||||
function EconomicProjections({ socCode }) {
|
function EconomicProjections({ socCode }) {
|
||||||
const [projections, setProjections] = useState(null);
|
const [projections, setProjections] = useState(null);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
|
const projections = {
|
||||||
|
"2022 Employment": projectionsData?.['2022 Employment'] || 'N/A',
|
||||||
|
"2032 Employment": projectionsData?.['2032 Employment'] || 'N/A',
|
||||||
|
"Total Change": projectionsData?.['Total Change'] || 'N/A',
|
||||||
|
"Annual Openings": projectionsData?.['Annual Openings'] || 'N/A',
|
||||||
|
"Projected Growth": projectionsData?.['Projected Growth'] || 'N/A',
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (socCode) {
|
if (socCode) {
|
||||||
const cleanedSocCode = socCode.split('.')[0]; // Clean the SOC code inside the component
|
const cleanedSocCode = socCode.split('.')[0]; // Clean the SOC code inside the component
|
||||||
|
@ -93,7 +93,7 @@ const InterestInventory = () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
const response = await fetch('/server2/api/onet/submit_answers', {
|
const response = await fetch('/api/onet/submit_answers', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ answers }),
|
body: JSON.stringify({ answers }),
|
||||||
|
@ -26,7 +26,7 @@ function SignIn({ setIsAuthenticated }) {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// Make a POST request to the backend for authentication
|
// Make a POST request to the backend for authentication
|
||||||
const response = await fetch('/api/signin', {
|
const response = await fetch('https://dev.aptivaai.com/api/signin', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
Loading…
Reference in New Issue
Block a user