diff --git a/Kitchenly-main/.gitignore b/Kitchenly-main/.gitignore new file mode 100644 index 0000000000..6f72f89261 --- /dev/null +++ b/Kitchenly-main/.gitignore @@ -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 diff --git a/Kitchenly-main/.idea/.gitignore b/Kitchenly-main/.idea/.gitignore new file mode 100644 index 0000000000..13566b81b0 --- /dev/null +++ b/Kitchenly-main/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/Kitchenly-main/.idea/encodings.xml b/Kitchenly-main/.idea/encodings.xml new file mode 100644 index 0000000000..df87cf951f --- /dev/null +++ b/Kitchenly-main/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Kitchenly-main/README.md b/Kitchenly-main/README.md new file mode 100644 index 0000000000..3f23395366 --- /dev/null +++ b/Kitchenly-main/README.md @@ -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 \ No newline at end of file diff --git a/Kitchenly-main/cmd/server/main.go b/Kitchenly-main/cmd/server/main.go new file mode 100644 index 0000000000..9f28d44516 --- /dev/null +++ b/Kitchenly-main/cmd/server/main.go @@ -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) + } +} \ No newline at end of file diff --git a/Kitchenly-main/config.go b/Kitchenly-main/config.go new file mode 100644 index 0000000000..cc0316928a --- /dev/null +++ b/Kitchenly-main/config.go @@ -0,0 +1 @@ +package Kitchenly diff --git a/Kitchenly-main/go.mod b/Kitchenly-main/go.mod new file mode 100644 index 0000000000..b4bae178cc --- /dev/null +++ b/Kitchenly-main/go.mod @@ -0,0 +1,3 @@ +module github.com/ChemicalZ/Kitchenly + +go 1.23.6 diff --git a/Kitchenly-main/internal/.env b/Kitchenly-main/internal/.env new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Kitchenly-main/internal/config.go b/Kitchenly-main/internal/config.go new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Kitchenly-main/internal/database/Kitchenly.sql b/Kitchenly-main/internal/database/Kitchenly.sql new file mode 100644 index 0000000000..103f77688f --- /dev/null +++ b/Kitchenly-main/internal/database/Kitchenly.sql @@ -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; diff --git a/Kitchenly-main/internal/database/database.go b/Kitchenly-main/internal/database/database.go new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Kitchenly-main/internal/handler.go b/Kitchenly-main/internal/handler.go new file mode 100644 index 0000000000..1263a65acb --- /dev/null +++ b/Kitchenly-main/internal/handler.go @@ -0,0 +1,14 @@ +package handler + +import ( + "net/http" + "strconv" + + "github.com/labstack/echo/v4" +) + +type Handler struct { + DB: db +} + +func (h *Handler) \ No newline at end of file diff --git a/Kitchenly-main/internal/routes.go b/Kitchenly-main/internal/routes.go new file mode 100644 index 0000000000..deeade82b4 --- /dev/null +++ b/Kitchenly-main/internal/routes.go @@ -0,0 +1,5 @@ +package internal + +func AddRoutes(e echo.Echo) { + e.GET("/register",) +} \ No newline at end of file diff --git a/Kitchenly-main/internal/server.go b/Kitchenly-main/internal/server.go new file mode 100644 index 0000000000..4513ef7a3c --- /dev/null +++ b/Kitchenly-main/internal/server.go @@ -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 +} \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 09c54afa69..0000000000 --- a/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# What is this? - -The github.dev web-based editor is a lightweight editing experience that runs entirely in your browser. You can navigate files and source code repositories from GitHub, and make and commit code changes. - -There are two ways to go directly to a VS Code environment in your browser and start coding: - -* Press the . key on any repository or pull request. -* Swap `.com` with `.dev` in the URL. For example, this repo https://github.com/github/dev becomes http://github.dev/github/dev - -Preview the gif below to get a quick demo of github.dev in action. - -![github dev](https://user-images.githubusercontent.com/856858/130119109-4769f2d7-9027-4bc4-a38c-10f297499e8f.gif) - -# Why? -It’s a quick way to edit and navigate code. It's especially useful if you want to edit multiple files at a time or take advantage of all the powerful code editing features of Visual Studio Code when making a quick change. For more information, see our [documentation](https://github.co/codespaces-editor-help).