Skip to content

Commit

Permalink
Resolve merge conflicts with post route
Browse files Browse the repository at this point in the history
  • Loading branch information
angelika930 committed Nov 27, 2023
1 parent 64d764e commit 974770c
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions studywell-backend/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,26 @@ import taskModel from "./task-functions.js";
const app = express();
const port = 8000;

<<<<<<< HEAD
app.use(cors());
app.use(express.json());

/* eslint-disable-next-line no-undef*/
app.listen(process.env.PORT || port, () => {
console.log("REST API is listening.");
=======
app.use(express.json());
app.use(cors());

app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
>>>>>>> backend
});

// app.listen(port, () => {
// console.log(`Example app listening at http://localhost:${port}`);
// });

//generates random ID
const generateID = () => {
const id = Math.floor(100000 + Math.random() * 900000);
const newID = id.toString();
<<<<<<< HEAD
return newID;
};

/* eslint-disable no-unused-vars */
=======
var count = 0;
return newID;
};

>>>>>>> backend
app.get("/tasks", (req, res) => {
taskModel.getTasks(req.description).then((result) => {
res.send({ task_list: result });
Expand All @@ -44,25 +33,19 @@ app.get("/tasks", (req, res) => {

app.post("/tasks", (req, res) => {
const taskToAdd = req.body;
<<<<<<< HEAD
taskToAdd.id = generateID();
taskModel
.addTasks(taskToAdd)
.then((res) => {
=======
console.log(taskToAdd);
taskToAdd.id = generateID();
taskModel
.addTasks(taskToAdd)
.then((result) => {
>>>>>>> backend
res.status(201).send(taskToAdd);
})
.catch((error) => {
console.error(error);
res.status(500).send(error);
});
});

async function deleteUserById(id) {
try {
if (await taskModel.deleteUser(id)) return true;
Expand All @@ -84,5 +67,5 @@ app.delete("/tasks/:id", async (req, res) => {
console.error(error);
res.status(500).send("Internal Server Error");
}
>>>>>>> backend
});

0 comments on commit 974770c

Please sign in to comment.