checkpoint

This commit is contained in:
fred 2025-07-09 14:43:45 -07:00
parent 925135d08c
commit 22e2dab830
7 changed files with 155 additions and 2 deletions

View file

@ -7,7 +7,9 @@ const app = express();
app.use(cors()); // to remove cors origin error in dev TODO: remove when dockerized
app.use(express.json());
// routes
// ####### ROUTES #######
// ### GET ALL RECIPES ###
app.get("/recipes", async (req, res) => {
try {
const recipes = await db('recipes').select('id', 'name');
@ -18,6 +20,7 @@ app.get("/recipes", async (req, res) => {
}
});
// ### GET RECIPE ###
app.get("/recipe/:id", async (req, res) => {
const id = req.params.id
try {
@ -52,6 +55,7 @@ app.get("/recipe/:id", async (req, res) => {
}
});
// ### ADD RECIPE ###
app.post("/add-recipe", async (req, res) => {
const { name, cuisine, ingredients, steps } = req.body;
try {
@ -99,6 +103,7 @@ app.post("/add-recipe", async (req, res) => {
}
});
// ### DELETE RECIPE ###
app.delete("/delete-recipe", async (req, res) => {
const { id } = req.body;
try {