-
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
beee22b
commit bc4f76e
Showing
9 changed files
with
92 additions
and
17 deletions.
There are no files selected for viewing
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,2 +1,2 @@ | ||
PORT = 5000 | ||
MONGODB_CONNECTION_URL = "mongodb+srv://luxshan:[email protected]/items?retryWrites=true&w=majority" | ||
MONGODB_CONNECTION_URL = "mongodb+srv://luxshan:[email protected]/aws-pipeline?retryWrites=true&w=majority" |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const Item = require('../modals/Item') | ||
|
||
|
||
|
||
exports.addItem = async (req,res) =>{ | ||
try{ | ||
|
||
const { name } = req.body | ||
|
||
const newItem = new Item({ name}) | ||
await newItem.save() | ||
|
||
|
||
console.log("Successfully meal added!") | ||
|
||
|
||
|
||
} catch(error){ | ||
console.log("There is an error occured in addMeal!") | ||
} | ||
} |
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 Item = require('../modals/Item') | ||
|
||
|
||
exports.getAllItem = async (req,res)=>{ | ||
|
||
try{ | ||
const items = await Item.find({}); | ||
res.json(items) | ||
}catch(err){ | ||
res.json(err) | ||
} | ||
|
||
} |
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,11 @@ | ||
const mongoose = require("mongoose") | ||
|
||
|
||
const Item = mongoose.model("items",{ | ||
name:{ | ||
type:String, | ||
required:true | ||
} | ||
}); | ||
|
||
module.exports = Item; |
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,9 @@ | ||
const express = require('express'); | ||
const router = express.Router(); | ||
const addData = require('../controllers/addData'); | ||
|
||
|
||
router.get('/items', addData.addItem) | ||
|
||
|
||
module.exports = router; |
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,9 @@ | ||
const express = require('express'); | ||
const router = express.Router(); | ||
const getData = require('../controllers/getData'); | ||
|
||
|
||
router.get('/items', getData.getAllItem) | ||
|
||
|
||
module.exports = router; |
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