This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "client", | |
"version": "0.1.0", | |
"private": true, | |
"dependencies": { | |
"@testing-library/jest-dom": "^4.2.4", | |
"@testing-library/react": "^9.5.0", | |
"@testing-library/user-event": "^7.2.1", | |
"axios": "^0.19.2", | |
"bootstrap": "^4.5.0", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "mern-weather-app", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "node server/server.js", | |
"server": "nodemon server/server.js", | |
"client": "cd client && npm run start", | |
"dev": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\"" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component} from "react"; | |
import WeatherForm from "./WeatherForm"; | |
import WeatherPanels from "./WeatherPanels"; | |
class Container extends Component { | |
state = { | |
weatherData: '' | |
}; | |
render() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component} from 'react'; | |
import './Stylesheets/App.scss'; | |
import Container from "./Components/Container"; | |
class App extends Component { | |
render() { | |
return ( | |
<div className="App"> | |
<Container/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import "Header"; | |
@import "WeatherForm"; | |
@import "Container"; | |
@import "WeatherPanels"; | |
@font-face { | |
font-family: MajorMonoDisplay; | |
src: url("../assets/Fonts/MajorMonoDisplay-Regular.ttf"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// POST Request - dynamically get the weather data based on request body | |
router.post("/weather", async (req, res) => { | |
... | |
}); | |
// POST Request - get the weather data from the api, save it to mongo, then return the data back | |
router.post("/weatherMongo", async(req, res) => { | |
const {zipCode, tempMetric} = req.body; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const WEATHER = require("../models/Weather"); | |
... | |
class Weather { | |
... | |
/** | |
* Saves the weather data using the zipcode as the unique identifier | |
* If it already exists, replace, if not, then add. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
const WeatherSchema = new mongoose.Schema({ | |
zip: Number, | |
coord: { | |
lon: Number, | |
lat: Number | |
}, | |
weather: [ | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
// use body parser to get data from POST requests | |
... | |
// Use API routes from the api folder | |
... | |
// Connect to Mongo | |
mongoose.connect(process.env.DB, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use express's router to route all our API endpoints | |
const express = require('express'); | |
const router = express.Router(); | |
// Use the weather class we made in ./weather.js to call our method that will get the weather data from the api | |
const Weather = require("./weather"); | |
// GET Request - statically get the weather data from the weather api | |
router.get("/weather", async (req, res) => { | |
let weather = new Weather(); |