Skip to content

Commit

Permalink
Revert "Attempt to move server to vercel"
Browse files Browse the repository at this point in the history
This reverts commit 5ff42ee.
  • Loading branch information
mohanamisra committed Dec 30, 2024
1 parent b3246fe commit 80e1c2c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 92 deletions.
20 changes: 3 additions & 17 deletions .firebase/hosting.ZGlzdA.cache
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
index.html,1735589796933,c841884ae1de95ab9a78af079ba75a73d2415be74e57996671af39dfc1544209
tfjs_model_1/model.json,1735589796191,bcc272bfbb8570a9ff91d3261b100ff85c2bd27aff3d35a0829bac61a0550609
tfjs_model/model.json,1735589796157,d2c23f10cc960d6f0167dcfcc920877f77c195f3063bc7077ce0f41eb2fb95ff
assets/upload_image-CYrF0may.webp,1735589796930,ea294e525efed2a7bb97aa97a03a0a874c68fe6558ee3d9f8b026d650bc97c29
assets/index-BYT6_4hP.css,1735589796930,0ab6e31b0511db291a6e1294761e1b182a67923d4eb1e6fa05d1d4d19377b7cb
tfjs_model_1/group1-shard9of9.bin,1735589796190,52e91d654a120c1a896ddd72362a64f147d41ed3a3ffbbadaea3da8228603575
assets/index-BVZPkngW.js,1735589796934,1f575f292d1eb79016e16f83025b5934e9f00e710703041c0f7ac64d08b01bc3
tfjs_model/group1-shard2of2.bin,1735589796157,8dcfa660eabdd19538becd87f8c8ee692cd1fc1d3cee2861d25f83642875594b
tfjs_model_1/group1-shard2of9.bin,1735589796164,feb3eabde573b0ddb4ddbdf88132b6fdfe766d6982877097d14d9cd0217c6006
tfjs_model_1/group1-shard1of9.bin,1735589796160,dc51e6f94f53e758a3b93d0c5cdd0cdecaa43f68015637b55df4719437bff282
tfjs_model_1/group1-shard7of9.bin,1735589796185,0ee3d2ad61ca0aa68b939be69d194a32e8a84b7ab012ad29a996c9acf04c38fd
tfjs_model_1/group1-shard5of9.bin,1735589796177,6c9d04054a32f867b7acf5cce109a598bcaa39084f794ffa798ddd9ec42e82a9
tfjs_model_1/group1-shard8of9.bin,1735589796189,8eeb487a78b3879d4035161bf1efe1205ea3235bd961744bda2e31a3cc3b84eb
tfjs_model_1/group1-shard6of9.bin,1735589796181,1a44e4f8ff9e3526de683bc2db8c8b133b5f551c2e6fe7f2c080b14fc2ef8787
tfjs_model_1/group1-shard4of9.bin,1735589796173,2c62a57d1779546d18d71084ca24a7661e366918f6f9d28427cb29def70fd05e
tfjs_model/group1-shard1of2.bin,1735589796154,8212bd2a571084eff843f0e1c2ee0e237e5064058bbd1ce279b23fd201fa1068
tfjs_model_1/group1-shard3of9.bin,1735589796169,19b4b49ff4b2db2ae88500e88150aad2b24bfa7271448a32b0f86a32ba7f8a0f
index.html,1735060804991,4ae3dc26fb689f4228aee2889df38b5ec6ecee3005b854061b475a791b7a01f9
assets/index-pVAM4FhG.css,1735060804991,1d41ff68c6ef4cfd8f64716da69753245f7fe9c7557386b4ed88e3bf97556a4f
assets/index-Co2txepZ.js,1735060804991,6c5055a1c00edcc5ade70e16c3bad03287e6e80d9304a12966cef0ee47e91317
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ dist-ssr
*.sw?
.idea
.env
.venv
.vercel
.venv
52 changes: 0 additions & 52 deletions api/server.js

This file was deleted.

31 changes: 15 additions & 16 deletions src/services/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import express from 'express';
import axios from 'axios';
import cors from 'cors';
import dotenv from 'dotenv';
import { onRequest } from "firebase-functions/v2/https";

dotenv.config();
import { fetchReports } from './scraper.js'; // Adjust the path if needed
Expand Down Expand Up @@ -30,7 +29,7 @@ app.use(cors());
// console.log(`App listening at http://localhost:${port}`);
// });

app.get('/api/location', async (req, res) => {
app.get('/location', async (req, res) => {
const { locationName } = req.query;
if (!locationName) {
return res.status(400).json({ error: 'Location name is required.' });
Expand All @@ -44,30 +43,30 @@ app.get('/api/location', async (req, res) => {
}
});

app.get('/api/weather', async (req, res) => {
app.get('/weather', async(req, res) => {
const { lat, long } = req.query;
if (!lat || !long) {
return res.status(400).json({ error: 'Latitude and Longitude are required.' });
if(!lat || !long) {
return res.status(400).json({error: 'Latitude and Longitude are required.'});
}
try {
try{
const response = await axios.get(`https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${long}&units=metric&appid=${process.env.OPENWEATHER_API_KEY}`);
res.json(response.data);
} catch (error) {
res.status(500).json({ error: 'Failed to fetch weather data' });
} catch(error) {
console.error(error.response.data);
}
});
})

app.get('/api/elevation', async (req, res) => {
app.get('/elevation', async (req, res) => {
const { lat, long } = req.query;
if (!lat || !long) {
return res.status(400).json({ error: 'Latitude and Longitude are required.' });
if(!lat || !long) {
return res.status(400).json({error: 'Latitude and Longitude are required.'});
}
try {
const response = await axios.get(`https://api.opentopodata.org/v1/srtm90m?locations=${lat},${long}`);
res.json(response.data);
} catch (error) {
res.status(500).json({ error: 'Failed to fetch elevation data' });
}catch(error) {
console.error(error.response.data);
}
});
})

export const server = onRequest(app);
app.listen(3000, () => console.log('Server running on port 3000'));
17 changes: 12 additions & 5 deletions src/services/weather.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import axios from 'axios';

export const fetchLocationCoords = async (locationName) => {
return await axios.get(`/api/location`, { params: { locationName } });
console.log(locationName);
return await axios.get(`http://localhost:3000/location`, {
params: { locationName },
});
};

export const fetchWeather = async (lat, long) => {
return await axios.get(`/api/weather`, { params: { lat, long } });
return await axios.get(`http://localhost:3000/weather`, {
params: {lat, long},
});
};

export const fetchHeatWaveReport = async (lat, long) => {
return await axios.get(`/api/elevation`, { params: { lat, long } });
};
export const fetchHeatWaveReport = async(lat, long) => {
return await axios.get(`http://localhost:3000/elevation`, {
params: {lat, long},
});
};

0 comments on commit 80e1c2c

Please sign in to comment.