Skip to content

Commit

Permalink
Implemented 7-day Weather Forecast
Browse files Browse the repository at this point in the history
  * Added Data for countries and cities
  * Implemented API call to fetch 7-day weather data for the selected city
  * Fetch weather data for those countries which have no cities
  * Proper error handling
  * Made website mobile responsive
  * Added a properly documented README file
  • Loading branch information
usmanasif committed Dec 28, 2022
0 parents commit 273e1b2
Show file tree
Hide file tree
Showing 887 changed files with 3,368,291 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PORT = 8000
FORECA_TOKEN = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9wZmEuZm9yZWNhLmNvbVwvYXV0aG9yaXplXC90b2tlbiIsImlhdCI6MTY3MDg2NDkxMiwiZXhwIjo5OTk5OTk5OTk5LCJuYmYiOjE2NzA4NjQ5MTIsImp0aSI6IjNiZTZmYzJkODY5NjUxMzYiLCJzdWIiOiJ5YXNpci1xYWRlZXIiLCJmbXQiOiJYRGNPaGpDNDArQUxqbFlUdGpiT2lBPT0ifQ.JmoFmksJb6hfWzO1_ddEOKLwSbGFQFAiRHXT_VMx87M
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PORT = 8000
FORECA_TOKEN = SomETokEnVaLuE
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ForeCast

Weekly Forecast that allows users to view the 7-day forecast for any user-specified
location in the world.

# Getting Started
## Pre-requisites
Please meet the following requirements:

- node version 14.21.1 installed
- Foreca API key (This web app Uses third part api from foreca (https://developer.foreca.com/) to fetch weather records. The user can select country form the list and then is able to select city from respective country)
## How to install
- Do `npm install` in terminal opened in current folder
- Add your `FORECA_TOKEN` in .env
- For running in dev env, do `npm run dev` else do `npm start`

## How to Run Web Server
- For running in dev env, do `npm run dev` else do `npm start`
45 changes: 45 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const express = require('express')
const dotenv = require('dotenv')
const path = require('path')
const MainRoutes = require('./src/routes')
const viewPath = require('./src/middleware/viewPath')

// Using env variables
dotenv.config()

const PORT = process.env.PORT || 8080

// Start Express App in node server
const app = express()
app.use(express.json())

// Static folder
app.use('/static', express.static(path.join(__dirname, '/src/public')))

// Setting view templating engine
app.set('view engine', 'ejs')

// Setting default view folder
app.set('views', path.join(__dirname, '/src/views'))

// Using MainRouter
app.use('/', viewPath, MainRoutes)

app.listen(PORT, () => {
console.log(PORT)
console.log(`started listening to port ${PORT}`)
})

// Error function handler
app.use((err, req, res, next) => {
res.locals.message = err.message
const status = err.statusCode || err.status || 500
res.locals.status = status
res.locals.error = req.app.get('env') === 'development' ? err : {}
res.status(status).json({
error: {
statusCode: status,
messages: err.message,
},
})
})
1 change: 1 addition & 0 deletions node_modules/.bin/ejs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/jake

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 273e1b2

Please sign in to comment.