DaronSchmit / DinnerAndAMovie

A fullstack project brought to you by my teammates and I
MIT License
0 stars 2 forks source link

Set Up API Routes - Pushed to GitHub Branch Before Class Tues - 01/19/21 #9

Closed Kay0s closed 3 years ago

Kay0s commented 3 years ago

{"Title":"Blade Runner","Year":"1982","Rated":"R","Released":"25 Jun 1982","Runtime":"117 min","Genre":"Action, Sci-Fi, Thriller","Director":"Ridley Scott","Writer":"Hampton Fancher (screenplay), David Webb Peoples (screenplay), Philip K. Dick (novel)","Actors":"Harrison Ford, Rutger Hauer, Sean Young, Edward James Olmos","Plot":"A blade runner must pursue and terminate four replicants who stole a ship in space, and have returned to Earth to find their creator.","Language":"English, German, Cantonese, Japanese, Hungarian, Arabic","Country":"USA","Awards":"Nominated for 2 Oscars. Another 12 wins & 17 nominations.","Poster":"https://m.media-amazon.com/images/M/MV5BNzQzMzJhZTEtOWM4NS00MTdhLTg0YjgtMjM4MDRkZjUwZDBlXkEyXkFqcGdeQXVyNjU0OTQ0OTY@._V1_SX300.jpg","Ratings":[{"Source":"Internet Movie Database","Value":"8.1/10"},{"Source":"Rotten Tomatoes","Value":"90%"},{"Source":"Metacritic","Value":"84/100"}],"Metascore":"84","imdbRating":"8.1","imdbVotes":"691,873","imdbID":"tt0083658","Type":"movie","DVD":"N/A","BoxOffice":"$32,868,943","Production":"Blade Runner Partnership, Ladd Company","Website":"N/A","Response":"True"}

Kay0s commented 3 years ago

Filter by Area https://www.themealdb.com/api/json/v1/1/filter.php?a=Mexican

{ "meals": [ { "strMeal": "Braised Beef Chilli", "strMealThumb": "https://www.themealdb.com/images/media/meals/uuqvwu1504629254.jpg", "idMeal": "52826" }, { "strMeal": "Cajun spiced fish tacos", "strMealThumb": "https://www.themealdb.com/images/media/meals/uvuyxu1503067369.jpg", "idMeal": "52819" }, { "strMeal": "Chicken Enchilada Casserole", "strMealThumb": "https://www.themealdb.com/images/media/meals/qtuwxu1468233098.jpg", "idMeal": "52765" }, { "strMeal": "Chickpea Fajitas", "strMealThumb": "https://www.themealdb.com/images/media/meals/tvtxpq1511464705.jpg", "idMeal": "52870" }, { "strMeal": "Crock Pot Chicken Baked Tacos", "strMealThumb": "https://www.themealdb.com/images/media/meals/ypxvwv1505333929.jpg", "idMeal": "52830" } ] }

Kay0s commented 3 years ago

// Requiring our models and passport as we've configured it const db = require("../models"); const passport = require("../config/passport");

module.exports = function(app) { // Using the passport.authenticate middleware with our local strategy. // If the user has valid login credentials, send them to the members page. // Otherwise the user will be sent an error app.post("/api/login", passport.authenticate("local"), (req, res) => { // Sending back a password, even a hashed password, isn't a good idea res.json({ email: req.user.email, id: req.user.id }); });

// Route for signing up a user. The user's password is automatically hashed and stored securely thanks to // how we configured our Sequelize User Model. If the user is created successfully, proceed to log the user in, // otherwise send back an error app.post("/api/signup", (req, res) => { db.User.create({ email: req.body.email, password: req.body.password }) .then(() => { res.redirect(307, "/api/login"); }) .catch(err => { res.status(401).json(err); }); });

// Route for logging user out app.get("/logout", (req, res) => { req.logout(); res.redirect("/"); });

// Route for getting some data about our user to be used client side app.get("/api/user_data", (req, res) => { if (!req.user) { // The user is not logged in, send back an empty object res.json({}); } else { // Otherwise send back the user's email and id // Sending back a password, even a hashed password, isn't a good idea res.json({ email: req.user.email, id: req.user.id }); } }); };

Kay0s commented 3 years ago

Update API routes for history table foodapi and movie api url to pull previous searches by date.

On load user will be served a movie and food suggestion.

Kay0s commented 3 years ago

usemath.random to ramdomize onload movies and recipes