-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
588a41c
commit eda6439
Showing
6 changed files
with
24 additions
and
30 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
full-stack-javascript/21-inventory-application/server/controllers/pokeController.js
This file contains 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
13 changes: 13 additions & 0 deletions
13
full-stack-javascript/21-inventory-application/server/controllers/userController.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const Users = require("../models/users"); | ||
|
||
exports.getUser = async function (req, res, next) { | ||
try { | ||
const currUser = await Users.findOne({ email: "[email protected]" }) | ||
.populate("favorites") | ||
.exec(); | ||
|
||
res.status(200).json(currUser); | ||
} catch (error) { | ||
return next(error); | ||
} | ||
}; |
19 changes: 0 additions & 19 deletions
19
full-stack-javascript/21-inventory-application/server/models/favorites.js
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ const userArgs = process.argv.slice(2); | |
|
||
const Pokemons = require("./models/pokemons"); | ||
const PokeDetails = require("./models/pokeDetails"); | ||
const Favorites = require("./models/favorites"); | ||
const Users = require("./models/users"); | ||
|
||
const mongoose = require("mongoose"); | ||
|
@@ -109,11 +108,6 @@ async function createNewUser() { | |
email: "[email protected]", | ||
}); | ||
|
||
const newFavorites = new Favorites({ | ||
user: newUser, | ||
}); | ||
|
||
await newUser.save(); | ||
await newFavorites.save(); | ||
console.log("Initial User Created"); | ||
} |
7 changes: 3 additions & 4 deletions
7
full-stack-javascript/21-inventory-application/server/routes/users.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
var express = require('express'); | ||
var express = require("express"); | ||
var router = express.Router(); | ||
const userController = require("../controllers/userController"); | ||
|
||
/* GET users listing. */ | ||
router.get('/', function(req, res, next) { | ||
res.send('respond with a resource'); | ||
}); | ||
router.get("/", userController.getUser); | ||
|
||
module.exports = router; |