-
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
0 parents
commit e993a3b
Showing
1,759 changed files
with
346,720 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,120 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const express = require("express"); | ||
const mongoose = require("mongoose"); | ||
const app = express(); | ||
const port = 3000; | ||
var bodyParser = require('body-parser'); | ||
mongoose.connect("mongodb+srv://Lenilk:[email protected]/Refrigurator"); | ||
const databased = mongoose.connection; | ||
const InRefrigurator = require("./model/inRefriguratorModel"); | ||
const Want = require("./model/wantModel"); | ||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded({ extended: false })); | ||
databased.on('error', (error) => { | ||
console.log(error); | ||
}); | ||
databased.once('connected', () => { | ||
console.log('Database Connected'); | ||
}); | ||
app.get("/getRf", (req, res) => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
const data = yield InRefrigurator.find(); | ||
res.json(data); | ||
} | ||
catch (error) { | ||
res.status(500).json({ message: error.message }); | ||
} | ||
})); | ||
app.get("/getWant", (req, res) => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
const data = yield Want.find(); | ||
res.json(data); | ||
} | ||
catch (error) { | ||
res.status(500).json({ message: error.message }); | ||
} | ||
})); | ||
app.post("/postRf", (req, res) => __awaiter(void 0, void 0, void 0, function* () { | ||
const data = InRefrigurator({ | ||
name: req.body.name, | ||
Amount: req.body.Amount | ||
}); | ||
try { | ||
const dataToSave = yield data.save(); | ||
res.status(200).json(dataToSave); | ||
} | ||
catch (error) { | ||
res.status(400).json({ message: error.message }); | ||
} | ||
})); | ||
app.post("/postWant", (req, res) => __awaiter(void 0, void 0, void 0, function* () { | ||
const data = Want({ | ||
name: req.body.name, | ||
Amount: req.body.Amount, | ||
Comment: req.body.Comment | ||
}); | ||
try { | ||
const dataToSave = yield data.save(); | ||
res.status(200).json(dataToSave); | ||
} | ||
catch (error) { | ||
res.status(400).json({ message: error.message }); | ||
} | ||
})); | ||
app.delete("/deleteRf/:id", (req, res) => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
const id = req.params.id; | ||
const data = yield InRefrigurator.findByIdAndDelete(id); | ||
res.send(`Document with ${data.name} has been deleted..`); | ||
} | ||
catch (error) { | ||
res.status(400).json({ message: error.message }); | ||
} | ||
})); | ||
app.delete("/deleteWant/:id", (req, res) => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
const id = req.params.id; | ||
const data = yield Want.findByIdAndDelete(id); | ||
res.send(`Document with ${data.name} has been deleted..`); | ||
} | ||
catch (error) { | ||
res.status(400).json({ message: error.message }); | ||
} | ||
})); | ||
app.patch('/updateRf/:id', (req, res) => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
const id = req.params.id; | ||
const updatedData = req.body; | ||
const options = { new: true }; | ||
const result = yield InRefrigurator.findByIdAndUpdate(id, updatedData, options); | ||
res.send(result); | ||
} | ||
catch (error) { | ||
res.status(400).json({ message: error.message }); | ||
} | ||
})); | ||
app.patch('/updateWant/:id', (req, res) => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
const id = req.params.id; | ||
const updatedData = req.body; | ||
const options = { new: true }; | ||
const result = yield Want.findByIdAndUpdate(id, updatedData, options); | ||
res.send(result); | ||
} | ||
catch (error) { | ||
res.status(400).json({ message: error.message }); | ||
} | ||
})); | ||
app.listen(port, () => { | ||
console.log(`start in ${port}`); | ||
}); |
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,133 @@ | ||
import { Response,Request } from "express"; | ||
const express= require("express"); | ||
const mongoose = require("mongoose"); | ||
const app =express(); | ||
const port =3000; | ||
var bodyParser = require('body-parser') | ||
mongoose.connect("mongodb+srv://Lenilk:[email protected]/Refrigurator"); | ||
const databased = mongoose.connection | ||
const InRefrigurator=require("./model/inRefriguratorModel"); | ||
const Want=require("./model/wantModel"); | ||
app.use(bodyParser.json()) | ||
app.use(bodyParser.urlencoded({ extended: false })) | ||
|
||
|
||
databased.on('error', (error:Error) => { | ||
console.log(error) | ||
}) | ||
|
||
databased.once('connected', () => { | ||
console.log('Database Connected'); | ||
}) | ||
|
||
|
||
app.get("/getRf",async(req:Request,res:Response)=>{ | ||
try{ | ||
const data = await InRefrigurator.find(); | ||
res.json(data) | ||
} | ||
catch(error:any){ | ||
res.status(500).json({message: error.message}) | ||
} | ||
}) | ||
|
||
app.get("/getWant",async(req:Request,res:Response)=>{ | ||
try{ | ||
const data = await Want.find(); | ||
res.json(data) | ||
} | ||
catch(error:any){ | ||
res.status(500).json({message: error.message}) | ||
} | ||
}) | ||
|
||
|
||
app.post("/postRf", async(req:Request,res:Response)=>{ | ||
const data= InRefrigurator({ | ||
name:req.body.name, | ||
Amount:req.body.Amount | ||
}) | ||
try { | ||
const dataToSave = await data.save(); | ||
res.status(200).json(dataToSave) | ||
} | ||
catch (error:any) { | ||
res.status(400).json({message: error.message}) | ||
} | ||
}) | ||
|
||
app.post("/postWant",async(req:Request,res:Response)=>{ | ||
const data= Want({ | ||
name:req.body.name, | ||
Amount:req.body.Amount, | ||
Comment:req.body.Comment | ||
}) | ||
try { | ||
const dataToSave = await data.save(); | ||
res.status(200).json(dataToSave) | ||
} | ||
catch (error:any) { | ||
res.status(400).json({message: error.message}) | ||
} | ||
}) | ||
|
||
|
||
app.delete("/deleteRf/:id",async(req:Request,res:Response)=>{ | ||
try { | ||
const id = req.params.id; | ||
const data = await InRefrigurator.findByIdAndDelete(id) | ||
res.send(`Document with ${data.name} has been deleted..`) | ||
} | ||
catch (error:any) { | ||
res.status(400).json({ message: error.message }) | ||
} | ||
}) | ||
|
||
app.delete("/deleteWant/:id",async(req:Request,res:Response)=>{ | ||
try { | ||
const id = req.params.id; | ||
const data = await Want.findByIdAndDelete(id) | ||
res.send(`Document with ${data.name} has been deleted..`) | ||
} | ||
catch (error:any) { | ||
res.status(400).json({ message: error.message }) | ||
} | ||
}) | ||
|
||
app.patch('/updateRf/:id', async (req:Request, res:Response) => { | ||
try { | ||
const id = req.params.id; | ||
const updatedData = req.body; | ||
const options = { new: true }; | ||
|
||
const result = await InRefrigurator.findByIdAndUpdate( | ||
id, updatedData, options | ||
) | ||
|
||
res.send(result) | ||
} | ||
catch (error:any) { | ||
res.status(400).json({ message: error.message }) | ||
} | ||
}) | ||
|
||
app.patch('/updateWant/:id', async (req:Request, res:Response) => { | ||
try { | ||
const id = req.params.id; | ||
const updatedData = req.body; | ||
const options = { new: true }; | ||
|
||
const result = await Want.findByIdAndUpdate( | ||
id, updatedData, options | ||
) | ||
|
||
res.send(result) | ||
} | ||
catch (error:any) { | ||
res.status(400).json({ message: error.message }) | ||
} | ||
}) | ||
|
||
app.listen(port,()=>{ | ||
console.log(`start in ${port}`); | ||
}) |
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 @@ | ||
DATABASE_URL=mongodb+srv://Lenilk:[email protected]/Refrigurator |
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 mongoose = require("mongoose"); | ||
|
||
const InRefrigurator = mongoose.Schema({ | ||
name:{ | ||
required:true, | ||
type:String | ||
}, | ||
Amount:{ | ||
required:true, | ||
type:String | ||
} | ||
}); | ||
module.exports =mongoose.model("InRefrigurator",InRefrigurator); |
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,17 @@ | ||
const mongoose = require("mongoose"); | ||
|
||
const Want = mongoose.Schema({ | ||
name:{ | ||
required:true, | ||
type:String | ||
}, | ||
Amount:{ | ||
required:true, | ||
type:String | ||
}, | ||
Comment:{ | ||
type:String, | ||
default:"" | ||
} | ||
}); | ||
module.exports =mongoose.model("Want",Want); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
e993a3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
refrigurator-api – ./
refrigurator-api.vercel.app
refrigurator-api-lenilk.vercel.app
refrigurator-api-git-main-lenilk.vercel.app
e993a3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
refrigurator-api-98yx – ./
refrigurator-api-98yx.vercel.app
refrigurator-api-98yx-git-main-lenilk.vercel.app
refrigurator-api-98yx-lenilk.vercel.app