🌜 An Introduction to the project.
✨✨✨✨ TASKS
- Create/List/Remove/Delete Locations they are interested in
- Get historical forecasted temperature values for locations they are interested in
😫💭
- --> The datebase represent weather forcast and locations of a single user
- --> The user won't require authentication to carry out CRUD functions.
- --> The user cannot create multiple location with the same
slug
*** All db Models are defined in the src/model.js**
To add a favorite location to the database call the .../addlocation/:slug?long=&lat=
This function checks the forcast for that day using the 7Timer api, returns this values in a clean json format and stores this data to the database.
A simple url to check the present day forcast without storing it's values in the database
.../getforcast?long=&lat=
Let's say you want the user to update a slug name (eg. myhome from certain location(lat,lng) to another location details).
call the .../updateforcast/:slug?lat=&long=
The user has relocated and has a newhome and has no need for the old myhome slug. You can just call the
.../deleteforcast/:slug
The user is interested in seeing the history of forcast around a date range. Just call the
.../getforcast/:slug?start_date=&end_date= the dates should be in DATE type alone YYYY-MM-DD
New Forcast for user's slug is checked every midnight... 00 00
-
--> User can undergo simple authentication by being given a
unique identifierat the beginning to addlocation and for every operation by the user, the user must add thisunique identifierto match with what's on the system. -
--> A new users table can be set where each user is given a unique
idorapi_keywhere this key would be added to the url get request for every query done on thelocationdatabase
he exercise requires Node.js to be installed. We recommend using the LTS version.
-
Start by cloning this repository.
-
In the repo root directory, run
npm installto gather all dependencies. -
Next,
npm run seedwill seed the local SQLite database. Warning: This will drop the database if it exists. The database lives in a local filedatabase.sqlite3. -
Then run
npm startwhich should start both the server and the React client. -
The database is the
LOCATIONdatabase.
-
The server is running with nodemon.
-
The database provider is SQLite, which will store data in a file local to your repository called
database.sqlite3. The ORM Sequelize is on top of it. -
The server is running on port 3001.
-
For Authentication I've created a little checker in the middleware folder that checks for a user's account details accessing location details, although not functional, this function can be called inside every get function in the
app.jsfile.
--> You can easily test the codes by running localhost using the information above
--> Access the database.sqlite file to access already existing file from date 2022-04-26 and 2022-04-27