Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

just some small stuff #450

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Kitchenly-main/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
go.work.sum

# env file
.env
8 changes: 8 additions & 0 deletions Kitchenly-main/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Kitchenly-main/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Kitchenly-main/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Kitchenly

https://echo.labstack.com/docs/cookbook/twitter

https://grafana.com/blog/2024/02/09/how-i-write-http-services-in-go-after-13-years/#the-newserver-constructor
26 changes: 26 additions & 0 deletions Kitchenly-main/cmd/server/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package server

import (
"context"
"fmt"
"os"
"io"
"os/signal"
)

func run(ctx context.Context, w io.Writer, args []string) error {
ctx, cancel := signal.NotifyContext(ctx, os.Interrupt)
defer cancel()

e := NewServer()
e.Logger.Fatal(e.Start(":80"))
// ...
}

func main() {
ctx := context.Background()
if err := run(ctx, os.Stdout, os.Args); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
}
1 change: 1 addition & 0 deletions Kitchenly-main/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package Kitchenly
3 changes: 3 additions & 0 deletions Kitchenly-main/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/ChemicalZ/Kitchenly

go 1.23.6
Empty file added Kitchenly-main/internal/.env
Empty file.
Empty file.
73 changes: 73 additions & 0 deletions Kitchenly-main/internal/database/Kitchenly.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
CREATE TYPE "recipe_type" AS ENUM (
'snack',
'main',
'side'
);

CREATE TYPE "unit_of_measure" AS ENUM (
'g',
'kg',
'oz',
'lbs',
'tsp',
'tbsp',
'cup'
);

CREATE TABLE "users" (
"id" varchar(255) PRIMARY KEY,
"email" varchar(60) UNIQUE NOT NULL,
"password_has" varchar(255) NOT NULL,
"created_at" timestamp DEFAULT (now())
);

CREATE TABLE "recipes" (
"id" bigserial PRIMARY KEY,
"user_id" varchar(255) NOT NULL,
"name" varchar(25) NOT NULL,
"image_url" varchar(255),
"description" text NOT NULL,
"servings" smallint NOT NULL,
"calories" smallint,
"fat" smallint,
"carbs" smallint,
"protein" smallint,
"recipe_type" recipe_type NOT NULL,
"created_at" timestamp DEFAULT (now())
);

CREATE TABLE "ingredient_list" (
"id" bigserial PRIMARY KEY,
"recipe_id" bigint NOT NULL,
"ingredient_id" bigint NOT NULL,
"quantity" smallint NOT NULL
);

CREATE TABLE "ingredients" (
"id" bigserial PRIMARY KEY,
"title" varchar NOT NULL,
"unit_of_measure" unit_of_measure NOT NULL,
"food_type" bigint NOT NULL
);

CREATE TABLE "recipe_data" (
"id" bigserial PRIMARY KEY,
"recipe_id" bigint NOT NULL,
"step_order" smallint UNIQUE NOT NULL,
"statement" text NOT NULL
);

CREATE TABLE "food_type" (
"id" bigserial PRIMARY KEY,
"title" varchar NOT NULL
);

ALTER TABLE "recipes" ADD FOREIGN KEY ("user_id") REFERENCES "users" ("id");

ALTER TABLE "ingredient_list" ADD FOREIGN KEY ("ingredient_id") REFERENCES "ingredients" ("id");

ALTER TABLE "ingredients" ADD FOREIGN KEY ("food_type") REFERENCES "food_type" ("id");

ALTER TABLE "ingredient_list" ADD FOREIGN KEY ("recipe_id") REFERENCES "recipes" ("id") ON DELETE CASCADE;

ALTER TABLE "recipe_data" ADD FOREIGN KEY ("recipe_id") REFERENCES "recipes" ("id") ON DELETE CASCADE;
Empty file.
14 changes: 14 additions & 0 deletions Kitchenly-main/internal/handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package handler

import (
"net/http"
"strconv"

"github.com/labstack/echo/v4"
)

type Handler struct {
DB: db
}

func (h *Handler)
5 changes: 5 additions & 0 deletions Kitchenly-main/internal/routes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package internal

func AddRoutes(e echo.Echo) {
e.GET("/register",)
}
32 changes: 32 additions & 0 deletions Kitchenly-main/internal/server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package internal

import (
"net/http"

"github.com/labstack/echo/v4"
)

func NewServer(

) *echo.Echo {
e := echo.New()

// Setup Routes
AddRoutes(e)
// Setup Middleware
e.Logger.SetLevel(log.DEBUG)
e.Use(middleware.Logger())
e.Use(echojwt.WithConfig(echojwt.Config{
SigningKey: []byte(handler.Key),
Skipper: func(c echo.Context) bool {
// Skip authentication for register and login requests
if c.Path() == "/login" || c.Path() == "/register" {
return true
}
return false
},
}))


return &e
}
15 changes: 0 additions & 15 deletions README.md

This file was deleted.