-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
76 lines (69 loc) · 1.87 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import express from "express";
import routes from "./startup/routes.js";
// import bodyParser from "body-parser";
const app = express();
// app.use(bodyParser.json());
// routes
routes(app);
const port = process.env.PORT || 5001;
app.listen(port, () => {
console.log("Server has started on port 5001");
});
// create/post a job
// app.post("/jobs", async (req, res) => {
// try {
// const { description } = req.body;
// const newJob = await pool.query(
// "INSERT INTO job (description) VALUES($1) RETURNING * ",
// [description]
// );
// res.json(newJob.rows[0]);
// } catch (err) {
// console.error(err.message);
// }
// });
// // get all jobs
// app.get("/jobs", async (req, res) => {
// try {
// const allJobs = await pool.query("SELECT * FROM job");
// res.json(allJobs.rows);
// } catch (err) {
// console.error(err.message);
// }
// });
// // get a job
// app.get("/jobs/:id", async (req, res) => {
// try {
// const { id } = req.params;
// const job = await pool.query("SELECT * FROM job WHERE job_id = $1", [id]);
// res.json(job.rows[0]);
// } catch (err) {
// console.error(err.message);
// }
// });
// // update a job
// app.put("/jobs/:id", async (req, res) => {
// try {
// const { id } = req.params;
// const { description } = req.body;
// const updateJob = await pool.query(
// "UPDATE job SET description = $1 WHERE job_id = $2",
// [description, id]
// );
// res.json("Job updated");
// } catch (err) {
// console.error(err.message);
// }
// });
// // delete a job
// app.delete("/jobs/:id", async (req, res) => {
// try {
// const { id } = req.params;
// const deleteJob = await pool.query("DELETE FROM job WHERE job_id = $1", [
// id,
// ]);
// res.json("Job deleted");
// } catch (arr) {
// console.error(err.message);
// }
// });