···11+# client
22+33+[](https://hex.pm/packages/client)
44+[](https://hexdocs.pm/client/)
55+66+```sh
77+gleam add client@1
88+```
99+```gleam
1010+import client
1111+1212+pub fn main() -> Nil {
1313+ // TODO: An example of the project in use
1414+}
1515+```
1616+1717+Further documentation can be found at <https://hexdocs.pm/client>.
1818+1919+## Development
2020+2121+```sh
2222+gleam run # Run the project
2323+gleam test # Run the tests
2424+```
+27
client/gleam.toml
···11+name = "client"
22+version = "1.0.0"
33+target = "javascript"
44+55+# Fill out these fields if you intend to generate HTML documentation or publish
66+# your project to the Hex package manager.
77+#
88+# description = ""
99+# licences = ["Apache-2.0"]
1010+# repository = { type = "github", user = "", repo = "" }
1111+# links = [{ title = "Website", href = "" }]
1212+#
1313+# For a full reference of all the available options, you can have a look at
1414+# https://gleam.run/writing-gleam/gleam-toml/.
1515+1616+[dependencies]
1717+gleam_stdlib = ">= 0.44.0 and < 2.0.0"
1818+lustre = ">= 5.4.0 and < 6.0.0"
1919+rsvp = ">= 1.1.3 and < 2.0.0"
2020+gleam_json = ">= 3.1.0 and < 4.0.0"
2121+gleam_http = ">= 4.3.0 and < 5.0.0"
2222+plinth = ">= 0.8.1 and < 1.0.0"
2323+shared = { path = "../shared" }
2424+2525+[dev-dependencies]
2626+gleeunit = ">= 1.0.0 and < 2.0.0"
2727+lustre_dev_tools = ">= 2.3.2 and < 3.0.0"
···11+import gleeunit
22+33+pub fn main() -> Nil {
44+ gleeunit.main()
55+}
66+77+// gleeunit test functions end in `_test`
88+pub fn hello_world_test() {
99+ let name = "Joe"
1010+ let greeting = "Hello, " <> name <> "!"
1111+1212+ assert greeting == "Hello, Joe!"
1313+}
+24
server/README.md
···11+# server
22+33+[](https://hex.pm/packages/server)
44+[](https://hexdocs.pm/server/)
55+66+```sh
77+gleam add server@1
88+```
99+```gleam
1010+import server
1111+1212+pub fn main() -> Nil {
1313+ // TODO: An example of the project in use
1414+}
1515+```
1616+1717+Further documentation can be found at <https://hexdocs.pm/server>.
1818+1919+## Development
2020+2121+```sh
2222+gleam run # Run the project
2323+gleam test # Run the tests
2424+```
···11+CREATE TABLE authors (
22+ id INTEGER PRIMARY KEY,
33+ name TEXT UNIQUE COLLATE NOCASE NOT NULL
44+55+);
66+77+CREATE TABLE ingredients (
88+id INTEGER PRIMARY KEY,
99+name TEXT UNIQUE COLLATE NOCASE NOT NULL
1010+1111+);
1212+1313+CREATE TABLE units (
1414+id INTEGER PRIMARY KEY,
1515+name TEXT UNIQUE COLLATE NOCASE NOT NULL
1616+);
1717+1818+CREATE TABLE recipes (
1919+id INTEGER PRIMARY KEY,
2020+title TEXT UNIQUE COLLATE NOCASE NOT NULL,
2121+author_id INTEGER REFERENCES authors(id) ON DELETE SET NULL,
2222+servings INT NOT NULL DEFAULT 4,
2323+description TEXT NOT NULL DEFAULT 'no description',
2424+ UNIQUE(author_id, title)
2525+);
2626+2727+CREATE TABLE recipe_ingredients (
2828+2929+id INTEGER PRIMARY KEY,
3030+recipe_id INTEGER NOT NULL REFERENCES recipes(id) ON DELETE CASCADE,
3131+ingredient_id INTEGER NOT NULL REFERENCES ingredients(id),
3232+unit_id INTEGER NOT NULL REFERENCES units(id),
3333+quantity INTEGER NOT NULL,
3434+ UNIQUE(recipe_id, ingredient_id)
3535+3636+);
3737+CREATE TABLE recipe_instructions (
3838+3939+id INTEGER PRIMARY KEY,
4040+recipe_id INTEGER NOT NULL REFERENCES recipes(id) ON DELETE CASCADE,
4141+step INTEGER NOT NULL,
4242+instruction TEXT NOT NULL,
4343+ UNIQUE(recipe_id, step)
4444+4545+);
4646+
+106
server/data/test_db.sql
···11+CREATE TABLE authors (
22+ id INTEGER PRIMARY KEY,
33+ name TEXT UNIQUE COLLATE NOCASE NOT NULL
44+55+);
66+77+CREATE TABLE ingredients (
88+id INTEGER PRIMARY KEY,
99+name TEXT UNIQUE COLLATE NOCASE NOT NULL
1010+1111+);
1212+1313+CREATE TABLE units (
1414+id INTEGER PRIMARY KEY,
1515+name TEXT UNIQUE COLLATE NOCASE NOT NULL
1616+);
1717+1818+CREATE TABLE recipes (
1919+id INTEGER PRIMARY KEY,
2020+title TEXT UNIQUE COLLATE NOCASE NOT NULL,
2121+author_id INTEGER REFERENCES authors(id) ON DELETE SET NULL,
2222+servings INT NOT NULL DEFAULT 4,
2323+description TEXT NOT NULL DEFAULT 'no description',
2424+ UNIQUE(author_id, title)
2525+);
2626+2727+CREATE TABLE recipe_ingredients (
2828+2929+id INTEGER PRIMARY KEY,
3030+recipe_id INTEGER NOT NULL REFERENCES recipes(id) ON DELETE CASCADE,
3131+ingredient_id INTEGER NOT NULL REFERENCES ingredients(id),
3232+unit_id INTEGER NOT NULL REFERENCES units(id),
3333+quantity INTEGER NOT NULL,
3434+ UNIQUE(recipe_id, ingredient_id)
3535+3636+);
3737+CREATE TABLE recipe_instructions (
3838+3939+id INTEGER PRIMARY KEY,
4040+recipe_id INTEGER NOT NULL REFERENCES recipes(id) ON DELETE CASCADE,
4141+step INTEGER NOT NULL,
4242+instruction TEXT NOT NULL,
4343+ UNIQUE(recipe_id, step)
4444+4545+);
4646+4747+pragma foreign_keys = on
4848+;
4949+begin
5050+;
5151+5252+INSERT OR IGNORE INTO authors (name) VALUES ('Mom');
5353+INSERT OR IGNORE INTO units (name) VALUES ('cup');
5454+INSERT OR IGNORE INTO units (name) VALUES ('tbsp');
5555+5656+INSERT OR IGNORE INTO ingredients (name) VALUES ('tomato');
5757+INSERT OR IGNORE INTO ingredients (name) VALUES ('onion');
5858+INSERT OR IGNORE INTO ingredients (name) VALUES ('olive oil');
5959+6060+INSERT INTO recipes (title, author_id, servings, description)
6161+VALUES (
6262+ 'Soup',
6363+ (SELECT id FROM authors WHERE name = 'Mom'),
6464+ 4,
6565+ 'It''s soup, whaddya want?'
6666+)
6767+ON CONFLICT(title) DO UPDATE SET
6868+ author_id = excluded.author_id,
6969+ servings = excluded.servings,
7070+ description = excluded.description;
7171+7272+INSERT INTO recipe_ingredients (recipe_id, ingredient_id, unit_id, quantity)
7373+VALUES
7474+(
7575+ (SELECT id FROM recipes WHERE title = 'Soup'),
7676+ (SELECT id FROM ingredients WHERE name = 'tomato'),
7777+ (SELECT id FROM units WHERE name = 'cup'),
7878+ 2
7979+),
8080+(
8181+ (SELECT id FROM recipes WHERE title = 'Soup'),
8282+ (SELECT id FROM ingredients WHERE name = 'onion'),
8383+ (SELECT id FROM units WHERE name = 'cup'),
8484+ 1
8585+),
8686+(
8787+ (SELECT id FROM recipes WHERE title = 'Soup'),
8888+ (SELECT id FROM ingredients WHERE name = 'olive oil'),
8989+ (SELECT id FROM units WHERE name = 'tbsp'),
9090+ 1
9191+)
9292+ON CONFLICT(recipe_id, ingredient_id) DO UPDATE SET
9393+ unit_id = excluded.unit_id,
9494+ quantity = excluded.quantity;
9595+9696+INSERT INTO recipe_instructions (recipe_id, step, instruction)
9797+VALUES
9898+((SELECT id FROM recipes WHERE title = 'Soup'), 1, 'Chop the onion.'),
9999+((SELECT id FROM recipes WHERE title = 'Soup'), 2, 'Simmer everything until it tastes like soup.'),
100100+((SELECT id FROM recipes WHERE title = 'Soup'), 3, 'Serve hot.')
101101+ON CONFLICT(recipe_id, step) DO UPDATE SET
102102+ instruction = excluded.instruction;
103103+104104+commit
105105+;
106106+
+29
server/gleam.toml
···11+name = "server"
22+version = "1.0.0"
33+44+# Fill out these fields if you intend to generate HTML documentation or publish
55+# your project to the Hex package manager.
66+#
77+# description = ""
88+# licences = ["Apache-2.0"]
99+# repository = { type = "github", user = "", repo = "" }
1010+# links = [{ title = "Website", href = "" }]
1111+#
1212+# For a full reference of all the available options, you can have a look at
1313+# https://gleam.run/writing-gleam/gleam-toml/.
1414+1515+[dependencies]
1616+gleam_stdlib = ">= 0.44.0 and < 2.0.0"
1717+sqlight = ">= 1.0.3 and < 2.0.0"
1818+simplifile = ">= 2.3.1 and < 3.0.0"
1919+wisp = ">= 2.1.1 and < 3.0.0"
2020+shared = { path = "../shared" }
2121+gleam_erlang = ">= 1.3.0 and < 2.0.0"
2222+gleam_http = ">= 4.3.0 and < 5.0.0"
2323+gleam_json = ">= 3.1.0 and < 4.0.0"
2424+mist = ">= 5.0.3 and < 6.0.0"
2525+lustre = ">= 5.4.0 and < 6.0.0"
2626+2727+[dev-dependencies]
2828+gleeunit = ">= 1.0.0 and < 2.0.0"
2929+birdie = ">= 1.5.3 and < 2.0.0"
···11+# shared
22+33+[](https://hex.pm/packages/shared)
44+[](https://hexdocs.pm/shared/)
55+66+```sh
77+gleam add shared@1
88+```
99+```gleam
1010+import shared
1111+1212+pub fn main() -> Nil {
1313+ // TODO: An example of the project in use
1414+}
1515+```
1616+1717+Further documentation can be found at <https://hexdocs.pm/shared>.
1818+1919+## Development
2020+2121+```sh
2222+gleam run # Run the project
2323+gleam test # Run the tests
2424+```
+20
shared/gleam.toml
···11+name = "shared"
22+version = "1.0.0"
33+44+# Fill out these fields if you intend to generate HTML documentation or publish
55+# your project to the Hex package manager.
66+#
77+# description = ""
88+# licences = ["Apache-2.0"]
99+# repository = { type = "github", user = "", repo = "" }
1010+# links = [{ title = "Website", href = "" }]
1111+#
1212+# For a full reference of all the available options, you can have a look at
1313+# https://gleam.run/writing-gleam/gleam-toml/.
1414+1515+[dependencies]
1616+gleam_stdlib = ">= 0.44.0 and < 2.0.0"
1717+gleam_json = ">= 3.1.0 and < 4.0.0"
1818+1919+[dev-dependencies]
2020+gleeunit = ">= 1.0.0 and < 2.0.0"
+13
shared/manifest.toml
···11+# This file was generated by Gleam
22+# You typically do not need to edit this file
33+44+packages = [
55+ { name = "gleam_json", version = "3.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "44FDAA8847BE8FC48CA7A1C089706BD54BADCC4C45B237A992EDDF9F2CDB2836" },
66+ { name = "gleam_stdlib", version = "0.67.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "6CE3E4189A8B8EC2F73AB61A2FBDE49F159D6C9C61C49E3B3082E439F260D3D0" },
77+ { name = "gleeunit", version = "1.9.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "DA9553CE58B67924B3C631F96FE3370C49EB6D6DC6B384EC4862CC4AAA718F3C" },
88+]
99+1010+[requirements]
1111+gleam_json = { version = ">= 3.1.0 and < 4.0.0" }
1212+gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
1313+gleeunit = { version = ">= 1.0.0 and < 2.0.0" }