From 5362d2ba30eef2873aa4ed3b9fd2d64778022278 Mon Sep 17 00:00:00 2001 From: aleidk Date: Thu, 13 Feb 2025 11:00:46 -0300 Subject: [PATCH 1/4] chore: init cargo project --- .gitignore | 5 +++++ .justfile | 2 +- Cargo.lock | 7 +++++++ Cargo.toml | 6 ++++++ src/main.rs | 3 +++ 5 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore index 59cc215..56509c6 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,8 @@ # Allow to presever folder structure in excluded folers, should be the last rule !**/.gitkeep + + +# Added by cargo + +/target diff --git a/.justfile b/.justfile index a442fcc..f89f26a 100644 --- a/.justfile +++ b/.justfile @@ -2,4 +2,4 @@ mod repo ".devfiles/justfile" dev: - @echo "Edit the .justfile to setup the dev task!" + cargo run diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..d86c66f --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "compendium" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..186e6f8 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "compendium" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} From ca2ea919769351d7923d08812103edf3ded07358 Mon Sep 17 00:00:00 2001 From: aleidk Date: Thu, 13 Feb 2025 12:03:40 -0300 Subject: [PATCH 2/4] feat: add database service as dev dependency --- .devfiles/docker/docker-compose.dev.yaml | 29 + .env.example | 4 + .gitignore | 1 + .justfile | 12 + .../20250205190533_create_sources_table.sql | 13 + ...250206220324_create_logic_groups_table.sql | 15 + ...07152518_add_table_desambiguator_types.sql | 35 + .../20250207174953_add_table_entries.sql | 77 ++ db/schema.sql | 861 ++++++++++++++++++ 9 files changed, 1047 insertions(+) create mode 100644 .devfiles/docker/docker-compose.dev.yaml create mode 100644 .env.example create mode 100644 db/migrations/20250205190533_create_sources_table.sql create mode 100644 db/migrations/20250206220324_create_logic_groups_table.sql create mode 100644 db/migrations/20250207152518_add_table_desambiguator_types.sql create mode 100644 db/migrations/20250207174953_add_table_entries.sql create mode 100644 db/schema.sql diff --git a/.devfiles/docker/docker-compose.dev.yaml b/.devfiles/docker/docker-compose.dev.yaml new file mode 100644 index 0000000..ffe73f3 --- /dev/null +++ b/.devfiles/docker/docker-compose.dev.yaml @@ -0,0 +1,29 @@ +services: + db: + image: postgres:17-alpine + ports: + - 5432:5432 + environment: + POSTGRES_USER: ${CPD_DB_USER} + POSTGRES_PASSWORD: ${CPD_DB_PASSWORD} + POSTGRES_DB: ${CPD_DB_NAME} + + adminer: + image: ghcr.io/shyim/adminerevo:latest + ports: + - 8080:8080 + environment: + ADMINER_DEFAULT_DRIVER: psql + ADMINER_DEFAULT_SERVER: db + ADMINER_DEFAULT_USER: ${CPD_DB_USER} + ADMINER_DEFAULT_PASSWORD: ${CPD_DB_PASSWORD} + ADMINER_DEFAULT_DB: ${CPD_DB_NAME} + + dbmate: + image: ghcr.io/amacneil/dbmate + restart: no + command: ["--wait", "migrate"] + volumes: + - ${PWD}/db:/db + environment: + DATABASE_URL: postgres://${CPD_DB_USER}:${CPD_DB_PASSWORD}@db:5432/${CPD_DB_NAME}?sslmode=disable diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..c3cd5a8 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +CPD_DB_HOST=localhost +CPD_DB_USER=postgres +CPD_DB_PASSWORD=postgres +CPD_DB_NAME=compendium diff --git a/.gitignore b/.gitignore index 56509c6..d44f2b5 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ # Added by cargo /target +.env diff --git a/.justfile b/.justfile index f89f26a..589a424 100644 --- a/.justfile +++ b/.justfile @@ -1,5 +1,17 @@ # Repo management tasks mod repo ".devfiles/justfile" +set dotenv-load := true + +[private] +docker-compose +ARGS: + docker compose --file .devfiles/docker/docker-compose.dev.yaml --env-file .env --project-name compendium {{ARGS}} + +start-dev-services: (docker-compose "up --remove-orphans") + dev: cargo run + +migrate: (docker-compose "run dbmate migrate") + +rollback: (docker-compose "run dbmate rollback") diff --git a/db/migrations/20250205190533_create_sources_table.sql b/db/migrations/20250205190533_create_sources_table.sql new file mode 100644 index 0000000..36dac58 --- /dev/null +++ b/db/migrations/20250205190533_create_sources_table.sql @@ -0,0 +1,13 @@ +-- migrate:up +CREATE TABLE public.sources ( + id serial PRIMARY KEY, + name character varying(20) NOT NULL, + uid character varying(8) NOT NULL, + uri character varying, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone + ); + +-- migrate:down +DROP TABLE public.sources; diff --git a/db/migrations/20250206220324_create_logic_groups_table.sql b/db/migrations/20250206220324_create_logic_groups_table.sql new file mode 100644 index 0000000..2537c20 --- /dev/null +++ b/db/migrations/20250206220324_create_logic_groups_table.sql @@ -0,0 +1,15 @@ +-- migrate:up +CREATE TABLE public.logic_groups ( + id serial PRIMARY KEY, + name character varying(20) NOT NULL, + uid character varying(8) NOT NULL, + uri character varying, + source_id int, + created_at timestamp WITH time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp WITH time zone, + deleted_at timestamp WITH time zone, + CONSTRAINT fk_source FOREIGN KEY (source_id) REFERENCES public.sources(id) +); + +-- migrate:down +DROP TABLE public.logic_groups; diff --git a/db/migrations/20250207152518_add_table_desambiguator_types.sql b/db/migrations/20250207152518_add_table_desambiguator_types.sql new file mode 100644 index 0000000..b311997 --- /dev/null +++ b/db/migrations/20250207152518_add_table_desambiguator_types.sql @@ -0,0 +1,35 @@ +-- migrate:up +CREATE TABLE public.desambiguator_types( + id serial PRIMARY KEY, + name varchar(15) NOT NULL, + input_type varchar(15) NOT NULL, + placeholder varchar(30), + created_at timestamp WITH time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp WITH time zone, + deleted_at timestamp WITH time zone +); + +INSERT INTO + public.desambiguator_types(name, input_type, placeholder) +VALUES + ('Text', 'text', 'XXX-XXX-XXX'), + ('Date', 'date', '2020-12-31'); + +ALTER TABLE + public.sources +ADD + COLUMN desambiguator_type_id int NOT NULL DEFAULT 1; + +ALTER TABLE + public.sources +ADD + CONSTRAINT fk_desambiguator_type FOREIGN KEY (desambiguator_type_id) REFERENCES public.desambiguator_types(id); + +-- migrate:down +ALTER TABLE + public.sources DROP CONSTRAINT fk_desambiguator_type; + +ALTER TABLE + public.sources DROP COLUMN desambiguator_type_id; + +DROP TABLE public.desambiguator_types; diff --git a/db/migrations/20250207174953_add_table_entries.sql b/db/migrations/20250207174953_add_table_entries.sql new file mode 100644 index 0000000..a0fc42e --- /dev/null +++ b/db/migrations/20250207174953_add_table_entries.sql @@ -0,0 +1,77 @@ +-- migrate:up +CREATE TABLE public.entries ( + id serial NOT NULL, + uid varchar NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp WITH time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp WITH time zone, + deleted_at timestamp WITH time zone, + PRIMARY KEY (id, created_at), + CONSTRAINT fk_logic_group FOREIGN KEY (logic_group_id) REFERENCES public.logic_groups(id) +) PARTITION BY RANGE (created_at); + +CREATE INDEX index_entries_uid ON ONLY public.entries USING btree (uid); + +CREATE SCHEMA entries_partitions; + +CREATE TABLE entries_partitions.e2020 PARTITION OF public.entries FOR +VALUES +FROM + ('2020-01-01') TO ('2021-01-01'); + +CREATE TABLE entries_partitions.e2021 PARTITION OF public.entries FOR +VALUES +FROM + ('2021-01-01') TO ('2022-01-01'); + +CREATE TABLE entries_partitions.e2022 PARTITION OF public.entries FOR +VALUES +FROM + ('2022-01-01') TO ('2023-01-01'); + +CREATE TABLE entries_partitions.e2023 PARTITION OF public.entries FOR +VALUES +FROM + ('2023-01-01') TO ('2024-01-01'); + +CREATE TABLE entries_partitions.e2024 PARTITION OF public.entries FOR +VALUES +FROM + ('2024-01-01') TO ('2025-01-01'); + +CREATE TABLE entries_partitions.e2025 PARTITION OF public.entries FOR +VALUES +FROM + ('2025-01-01') TO ('2026-01-01'); + +CREATE TABLE entries_partitions.e2026 PARTITION OF public.entries FOR +VALUES +FROM + ('2026-01-01') TO ('2027-01-01'); + +CREATE TABLE entries_partitions.e2027 PARTITION OF public.entries FOR +VALUES +FROM + ('2027-01-01') TO ('2028-01-01'); + +CREATE TABLE entries_partitions.e2028 PARTITION OF public.entries FOR +VALUES +FROM + ('2028-01-01') TO ('2029-01-01'); + +CREATE TABLE entries_partitions.e2029 PARTITION OF public.entries FOR +VALUES +FROM + ('2029-01-01') TO ('2030-01-01'); + +CREATE TABLE entries_partitions.e2030 PARTITION OF public.entries FOR +VALUES +FROM + ('2030-01-01') TO ('2031-01-01'); + +-- migrate:down +DROP TABLE public.entries; + +DROP schema entries_partitions; diff --git a/db/schema.sql b/db/schema.sql new file mode 100644 index 0000000..825bf15 --- /dev/null +++ b/db/schema.sql @@ -0,0 +1,861 @@ +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET transaction_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +-- +-- Name: entries_partitions; Type: SCHEMA; Schema: -; Owner: - +-- + +CREATE SCHEMA entries_partitions; + + +SET default_tablespace = ''; + +-- +-- Name: entries; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.entries ( + id integer NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +) +PARTITION BY RANGE (created_at); + + +-- +-- Name: entries_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.entries_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.entries_id_seq OWNED BY public.entries.id; + + +SET default_table_access_method = heap; + +-- +-- Name: e2020; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2020 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2021; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2021 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2022; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2022 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2023; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2023 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2024; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2024 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2025; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2025 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2026; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2026 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2027; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2027 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2028; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2028 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2029; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2029 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: e2030; Type: TABLE; Schema: entries_partitions; Owner: - +-- + +CREATE TABLE entries_partitions.e2030 ( + id integer DEFAULT nextval('public.entries_id_seq'::regclass) NOT NULL, + uid character varying NOT NULL, + desambiguator text NOT NULL, + text text, + logic_group_id integer NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: desambiguator_types; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.desambiguator_types ( + id integer NOT NULL, + name character varying(15) NOT NULL, + input_type character varying(15) NOT NULL, + placeholder character varying(30), + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: desambiguator_types_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.desambiguator_types_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: desambiguator_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.desambiguator_types_id_seq OWNED BY public.desambiguator_types.id; + + +-- +-- Name: logic_groups; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.logic_groups ( + id integer NOT NULL, + name character varying(20) NOT NULL, + uid character varying(8) NOT NULL, + uri character varying, + source_id integer, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone +); + + +-- +-- Name: logic_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.logic_groups_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: logic_groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.logic_groups_id_seq OWNED BY public.logic_groups.id; + + +-- +-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.schema_migrations ( + version character varying(128) NOT NULL +); + + +-- +-- Name: sources; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.sources ( + id integer NOT NULL, + name character varying(20) NOT NULL, + uid character varying(8) NOT NULL, + uri character varying, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone, + deleted_at timestamp with time zone, + desambiguator_type_id integer DEFAULT 1 NOT NULL +); + + +-- +-- Name: sources_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.sources_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: sources_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.sources_id_seq OWNED BY public.sources.id; + + +-- +-- Name: e2020; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2020 FOR VALUES FROM ('2020-01-01 00:00:00+00') TO ('2021-01-01 00:00:00+00'); + + +-- +-- Name: e2021; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2021 FOR VALUES FROM ('2021-01-01 00:00:00+00') TO ('2022-01-01 00:00:00+00'); + + +-- +-- Name: e2022; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2022 FOR VALUES FROM ('2022-01-01 00:00:00+00') TO ('2023-01-01 00:00:00+00'); + + +-- +-- Name: e2023; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2023 FOR VALUES FROM ('2023-01-01 00:00:00+00') TO ('2024-01-01 00:00:00+00'); + + +-- +-- Name: e2024; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2024 FOR VALUES FROM ('2024-01-01 00:00:00+00') TO ('2025-01-01 00:00:00+00'); + + +-- +-- Name: e2025; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2025 FOR VALUES FROM ('2025-01-01 00:00:00+00') TO ('2026-01-01 00:00:00+00'); + + +-- +-- Name: e2026; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2026 FOR VALUES FROM ('2026-01-01 00:00:00+00') TO ('2027-01-01 00:00:00+00'); + + +-- +-- Name: e2027; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2027 FOR VALUES FROM ('2027-01-01 00:00:00+00') TO ('2028-01-01 00:00:00+00'); + + +-- +-- Name: e2028; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2028 FOR VALUES FROM ('2028-01-01 00:00:00+00') TO ('2029-01-01 00:00:00+00'); + + +-- +-- Name: e2029; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2029 FOR VALUES FROM ('2029-01-01 00:00:00+00') TO ('2030-01-01 00:00:00+00'); + + +-- +-- Name: e2030; Type: TABLE ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY public.entries ATTACH PARTITION entries_partitions.e2030 FOR VALUES FROM ('2030-01-01 00:00:00+00') TO ('2031-01-01 00:00:00+00'); + + +-- +-- Name: desambiguator_types id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.desambiguator_types ALTER COLUMN id SET DEFAULT nextval('public.desambiguator_types_id_seq'::regclass); + + +-- +-- Name: entries id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.entries ALTER COLUMN id SET DEFAULT nextval('public.entries_id_seq'::regclass); + + +-- +-- Name: logic_groups id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.logic_groups ALTER COLUMN id SET DEFAULT nextval('public.logic_groups_id_seq'::regclass); + + +-- +-- Name: sources id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.sources ALTER COLUMN id SET DEFAULT nextval('public.sources_id_seq'::regclass); + + +-- +-- Name: entries entries_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.entries + ADD CONSTRAINT entries_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2020 e2020_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2020 + ADD CONSTRAINT e2020_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2021 e2021_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2021 + ADD CONSTRAINT e2021_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2022 e2022_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2022 + ADD CONSTRAINT e2022_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2023 e2023_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2023 + ADD CONSTRAINT e2023_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2024 e2024_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2024 + ADD CONSTRAINT e2024_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2025 e2025_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2025 + ADD CONSTRAINT e2025_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2026 e2026_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2026 + ADD CONSTRAINT e2026_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2027 e2027_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2027 + ADD CONSTRAINT e2027_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2028 e2028_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2028 + ADD CONSTRAINT e2028_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2029 e2029_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2029 + ADD CONSTRAINT e2029_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: e2030 e2030_pkey; Type: CONSTRAINT; Schema: entries_partitions; Owner: - +-- + +ALTER TABLE ONLY entries_partitions.e2030 + ADD CONSTRAINT e2030_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: desambiguator_types desambiguator_types_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.desambiguator_types + ADD CONSTRAINT desambiguator_types_pkey PRIMARY KEY (id); + + +-- +-- Name: logic_groups logic_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.logic_groups + ADD CONSTRAINT logic_groups_pkey PRIMARY KEY (id); + + +-- +-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.schema_migrations + ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); + + +-- +-- Name: sources sources_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.sources + ADD CONSTRAINT sources_pkey PRIMARY KEY (id); + + +-- +-- Name: index_entries_uid; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_entries_uid ON ONLY public.entries USING btree (uid); + + +-- +-- Name: e2020_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2020_uid_idx ON entries_partitions.e2020 USING btree (uid); + + +-- +-- Name: e2021_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2021_uid_idx ON entries_partitions.e2021 USING btree (uid); + + +-- +-- Name: e2022_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2022_uid_idx ON entries_partitions.e2022 USING btree (uid); + + +-- +-- Name: e2023_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2023_uid_idx ON entries_partitions.e2023 USING btree (uid); + + +-- +-- Name: e2024_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2024_uid_idx ON entries_partitions.e2024 USING btree (uid); + + +-- +-- Name: e2025_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2025_uid_idx ON entries_partitions.e2025 USING btree (uid); + + +-- +-- Name: e2026_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2026_uid_idx ON entries_partitions.e2026 USING btree (uid); + + +-- +-- Name: e2027_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2027_uid_idx ON entries_partitions.e2027 USING btree (uid); + + +-- +-- Name: e2028_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2028_uid_idx ON entries_partitions.e2028 USING btree (uid); + + +-- +-- Name: e2029_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2029_uid_idx ON entries_partitions.e2029 USING btree (uid); + + +-- +-- Name: e2030_uid_idx; Type: INDEX; Schema: entries_partitions; Owner: - +-- + +CREATE INDEX e2030_uid_idx ON entries_partitions.e2030 USING btree (uid); + + +-- +-- Name: e2020_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2020_pkey; + + +-- +-- Name: e2020_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2020_uid_idx; + + +-- +-- Name: e2021_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2021_pkey; + + +-- +-- Name: e2021_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2021_uid_idx; + + +-- +-- Name: e2022_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2022_pkey; + + +-- +-- Name: e2022_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2022_uid_idx; + + +-- +-- Name: e2023_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2023_pkey; + + +-- +-- Name: e2023_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2023_uid_idx; + + +-- +-- Name: e2024_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2024_pkey; + + +-- +-- Name: e2024_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2024_uid_idx; + + +-- +-- Name: e2025_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2025_pkey; + + +-- +-- Name: e2025_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2025_uid_idx; + + +-- +-- Name: e2026_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2026_pkey; + + +-- +-- Name: e2026_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2026_uid_idx; + + +-- +-- Name: e2027_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2027_pkey; + + +-- +-- Name: e2027_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2027_uid_idx; + + +-- +-- Name: e2028_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2028_pkey; + + +-- +-- Name: e2028_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2028_uid_idx; + + +-- +-- Name: e2029_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2029_pkey; + + +-- +-- Name: e2029_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2029_uid_idx; + + +-- +-- Name: e2030_pkey; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.entries_pkey ATTACH PARTITION entries_partitions.e2030_pkey; + + +-- +-- Name: e2030_uid_idx; Type: INDEX ATTACH; Schema: entries_partitions; Owner: - +-- + +ALTER INDEX public.index_entries_uid ATTACH PARTITION entries_partitions.e2030_uid_idx; + + +-- +-- Name: sources fk_desambiguator_type; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.sources + ADD CONSTRAINT fk_desambiguator_type FOREIGN KEY (desambiguator_type_id) REFERENCES public.desambiguator_types(id); + + +-- +-- Name: entries fk_logic_group; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE public.entries + ADD CONSTRAINT fk_logic_group FOREIGN KEY (logic_group_id) REFERENCES public.logic_groups(id); + + +-- +-- Name: logic_groups fk_source; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.logic_groups + ADD CONSTRAINT fk_source FOREIGN KEY (source_id) REFERENCES public.sources(id); + + +-- +-- PostgreSQL database dump complete +-- + + +-- +-- Dbmate schema migrations +-- + +INSERT INTO public.schema_migrations (version) VALUES + ('20250205190533'), + ('20250206220324'), + ('20250207152518'), + ('20250207174953'); From 0923ac18410d9ffc334a784e6005894a748d8cd0 Mon Sep 17 00:00:00 2001 From: aleidk Date: Thu, 13 Feb 2025 12:11:27 -0300 Subject: [PATCH 3/4] feat: add axium hello world --- Cargo.lock | 606 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 + src/main.rs | 11 +- 3 files changed, 617 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d86c66f..af97221 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,612 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "axum" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d6fd624c75e18b3b4c6b9caf42b1afe24437daaee904069137d8bab077be8b8" +dependencies = [ + "axum-core", + "bytes", + "form_urlencoded", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1362f362fd16024ae199c1970ce98f9661bf5ef94b9808fee734bc3698b733" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets", +] + +[[package]] +name = "bytes" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + [[package]] name = "compendium" version = "0.1.0" +dependencies = [ + "axum", + "tokio", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "http" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2d708df4e7140240a16cd6ab0ab65c972d7433ab77819ea693fde9c43811e2a" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", +] + +[[package]] +name = "hyper-util" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "itoa" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" + +[[package]] +name = "libc" +version = "0.2.169" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" + +[[package]] +name = "log" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" + +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3b1c9bd4fe1f0f8b387f6eb9eb3b4a1aa26185e5750efb9140301703f62cd1b" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +dependencies = [ + "libc", + "wasi", + "windows-sys", +] + +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustversion" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" + +[[package]] +name = "ryu" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" + +[[package]] +name = "serde" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.138" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" +dependencies = [ + "itoa", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "syn" +version = "2.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + +[[package]] +name = "tokio" +version = "1.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +dependencies = [ + "backtrace", + "libc", + "mio", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys", +] + +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "log", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +dependencies = [ + "once_cell", +] + +[[package]] +name = "unicode-ident" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/Cargo.toml b/Cargo.toml index 186e6f8..e51e3c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,3 +4,5 @@ version = "0.1.0" edition = "2021" [dependencies] +axum = "0.8.1" +tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread"] } diff --git a/src/main.rs b/src/main.rs index e7a11a9..6e21a6a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,10 @@ -fn main() { - println!("Hello, world!"); +use axum::routing::get; +use axum::Router; + +#[tokio::main] +async fn main() { + let app = Router::new().route("/", get(|| async { "Hello, World!" })); + + let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); + axum::serve(listener, app).await.unwrap(); } From b6c909f6f44b34f8fe9ff522f7fa5592f0f22026 Mon Sep 17 00:00:00 2001 From: aleidk Date: Thu, 13 Feb 2025 13:03:39 -0300 Subject: [PATCH 4/4] chore: add live reload features --- .justfile | 2 +- Cargo.lock | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 2 + src/main.rs | 7 ++- 4 files changed, 184 insertions(+), 5 deletions(-) diff --git a/.justfile b/.justfile index 589a424..da5dbc6 100644 --- a/.justfile +++ b/.justfile @@ -10,7 +10,7 @@ docker-compose +ARGS: start-dev-services: (docker-compose "up --remove-orphans") dev: - cargo run + watchexec --restart --clear --watch src cargo run migrate: (docker-compose "run dbmate migrate") diff --git a/Cargo.lock b/Cargo.lock index af97221..a4bdc19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,6 +86,18 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" + [[package]] name = "bytes" version = "1.10.0" @@ -103,7 +115,21 @@ name = "compendium" version = "0.1.0" dependencies = [ "axum", + "notify", "tokio", + "tower-livereload", +] + +[[package]] +name = "filetime" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" +dependencies = [ + "cfg-if", + "libc", + "libredox", + "windows-sys 0.59.0", ] [[package]] @@ -121,6 +147,15 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fsevent-sys" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2" +dependencies = [ + "libc", +] + [[package]] name = "futures-channel" version = "0.3.31" @@ -241,18 +276,69 @@ dependencies = [ "tower-service", ] +[[package]] +name = "inotify" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" +dependencies = [ + "bitflags 2.8.0", + "inotify-sys", + "libc", +] + +[[package]] +name = "inotify-sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" +dependencies = [ + "libc", +] + [[package]] name = "itoa" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +[[package]] +name = "kqueue" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c" +dependencies = [ + "kqueue-sys", + "libc", +] + +[[package]] +name = "kqueue-sys" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" +dependencies = [ + "bitflags 1.3.2", + "libc", +] + [[package]] name = "libc" version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.8.0", + "libc", + "redox_syscall", +] + [[package]] name = "log" version = "0.4.25" @@ -293,10 +379,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", + "log", "wasi", - "windows-sys", + "windows-sys 0.52.0", ] +[[package]] +name = "notify" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fee8403b3d66ac7b26aee6e40a897d85dc5ce26f44da36b8b73e987cc52e943" +dependencies = [ + "bitflags 2.8.0", + "filetime", + "fsevent-sys", + "inotify", + "kqueue", + "libc", + "log", + "mio", + "notify-types", + "walkdir", + "windows-sys 0.59.0", +] + +[[package]] +name = "notify-types" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d" + [[package]] name = "object" version = "0.36.7" @@ -348,6 +460,15 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "redox_syscall" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +dependencies = [ + "bitflags 2.8.0", +] + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -366,6 +487,15 @@ version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "serde" version = "1.0.217" @@ -433,7 +563,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -465,7 +595,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -501,6 +631,20 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" +[[package]] +name = "tower-livereload" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa6b29b17d4540f2bd9ec304ad39d280c4bdf291d0ea6c4123eeba10939af84" +dependencies = [ + "bytes", + "http", + "http-body", + "pin-project-lite", + "tokio", + "tower", +] + [[package]] name = "tower-service" version = "0.3.3" @@ -533,12 +677,31 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "windows-sys" version = "0.52.0" @@ -548,6 +711,15 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-targets" version = "0.52.6" diff --git a/Cargo.toml b/Cargo.toml index e51e3c9..214691e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,4 +5,6 @@ edition = "2021" [dependencies] axum = "0.8.1" +notify = "8.0.0" tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread"] } +tower-livereload = "0.9.6" diff --git a/src/main.rs b/src/main.rs index 6e21a6a..d90740f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,14 @@ +use axum::response::Html; use axum::routing::get; use axum::Router; #[tokio::main] async fn main() { - let app = Router::new().route("/", get(|| async { "Hello, World!" })); + let app = Router::new().route("/", get(|| async { Html("

Hello, World! 2

") })); + + // Add hot reload only on dev mode + #[cfg(debug_assertions)] + let app = app.layer(tower_livereload::LiveReloadLayer::new()); let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); axum::serve(listener, app).await.unwrap();