Refactored project paths, fixed NGINX configs, updated API routes, and improved error handling.

This commit is contained in:
Josh 2024-12-23 20:05:22 +00:00
parent 0276bc60ae
commit 4b95b92261
8 changed files with 11234 additions and 7765 deletions

View File

@ -12,7 +12,7 @@ import jwt from 'jsonwebtoken'; // For token-based authentication
// Derive __dirname for ES modules
const __filename = fileURLToPath(import.meta.url);
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) => {
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
console.log('ONET_USERNAME:', process.env.ONET_USERNAME);
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' });
}
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) => {
if (err) {
console.error('Error connecting to database:', err.message);
@ -273,6 +273,6 @@ app.get('/api/areas', (req, res) => {
// Start the server
app.listen(PORT, '0.0.0.0', () => {
console.log(`Server running on http://34.16.120.118:${PORT}`);
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
});

View File

@ -90,6 +90,11 @@ app.use((req, res, 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

BIN
backend/user_profile.db Normal file

Binary file not shown.

18951
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,11 +2,25 @@
"name": "aptiva-dev1-app",
"version": "0.1.0",
"private": true,
"type": "module",
"dependencies": {
"axios": "^1.7.9",
"bcrypt": "^5.1.1",
"chart.js": "^4.4.7",
"cors": "^2.8.5",
"cra-template": "1.2.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-scripts": "^5.0.1"
"dotenv": "^16.4.7",
"helmet": "^8.0.0",
"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": {
"start": "react-scripts start",

View File

@ -5,7 +5,14 @@ import axios from 'axios';
function EconomicProjections({ socCode }) {
const [projections, setProjections] = 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(() => {
if (socCode) {
const cleanedSocCode = socCode.split('.')[0]; // Clean the SOC code inside the component

View File

@ -93,7 +93,7 @@ const InterestInventory = () => {
try {
setIsSubmitting(true);
const response = await fetch('/server2/api/onet/submit_answers', {
const response = await fetch('/api/onet/submit_answers', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ answers }),

View File

@ -26,7 +26,7 @@ function SignIn({ setIsAuthenticated }) {
}
try {
// 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',
headers: {
'Content-Type': 'application/json',