A Whole Bunch Of Changes

This commit is contained in:
Annika Merris 2024-01-31 14:51:42 -05:00
parent eb45c2fae4
commit 0122fb76f1
11 changed files with 209 additions and 20 deletions

1
.dockerignore Normal file
View file

@ -0,0 +1 @@
docker/data

2
.env Normal file
View file

@ -0,0 +1,2 @@
DB_CONNECTION_STRING=postgres://isl:development@localhost:5432/isl
HTTP_PORT=3000

View file

@ -1,7 +1,14 @@
---
on: [push]
name: build
on:
push:
branches:
- main
jobs:
test:
build:
name: Build and push docker image
runs-on: docker
container: alpine:3.19
steps:
- run: echo All Good!
- name: Check out the repo
uses: actions/checkout@v4

18
Dockerfile Normal file
View file

@ -0,0 +1,18 @@
FROM golang:1.21.6-alpine3.19 AS build-stage
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN go build -v -o /isl-api *.go
FROM alpine:3.19.1 AS release
COPY --from=build-stage /isl-api /isl-api
COPY --from=build-stage /app/.env /.env
EXPOSE 3000
ENTRYPOINT [ "/isl-api" ]

View file

@ -2,7 +2,14 @@
version: '3.1'
services:
api:
image: moosetheory/isl-api:0.1.1
restart: always
environment:
- ISL_API_DB_CONNECTION_STRING=postgres://isl:development@db:5432/isl
- ISL_API_HTTP_PORT=3000
ports:
- 3000:3000
db:
image: postgres
restart: always

View file

@ -0,0 +1,72 @@
-- Adminer 4.8.1 PostgreSQL 16.1 (Debian 16.1-1.pgdg120+1) dump
\connect "isl";
DROP TABLE IF EXISTS "poweritem";
CREATE TABLE "public"."poweritem" (
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
"itemtype" integer NOT NULL,
"iconurl" text NOT NULL,
"itemname" text NOT NULL,
"minitempower" integer NOT NULL,
"maxitempower" integer NOT NULL,
"rarity" integer NOT NULL,
"origin" text NOT NULL,
"tooltip" text,
"iseventitem" boolean,
CONSTRAINT "poweritem_pkey" PRIMARY KEY ("id")
) WITH (oids = false);
INSERT INTO "poweritem" ("id", "itemtype", "iconurl", "itemname", "minitempower", "maxitempower", "rarity", "origin", "tooltip", "iseventitem") VALUES
('d9def40f-6deb-45af-b8d1-d8af8a997b58', 1, 'flower_necklace.png', 'Flower Necklace', 1, 1, 2, 'Multiple', 'A romantic necklace made of flowers. Give it to a family member to increase their Blessing Power by 1.', 't'),
('facb5102-34d8-4813-ab06-ac2b8e9f3ed9', 1, 'jewel_necklace.png', 'Jewel Necklace', 2, 2, 3, 'Multiple', 'Elegant Jewel Necklace. Give it to a family member to increase their Blessing Power by 2.', 'f'),
('636b7384-1389-4012-933c-9063baa7a38d', 1, 'isl_logo.png', 'Grassy Bunny', 3, 6, 2, 'Picnic in the Forest', 'A common animal monster. Its roundy body is covered in fluffy fluff. Feels good to pet. Used to increase a Family Member''s Blessing Power by 3 to 6.', 't'),
('e2472929-1218-4cd6-a73b-b783c17bbc31', 1, 'isl_logo.png', 'Flaming Lion', 14, 48, 4, 'Picnic in the Forest', 'An extremely rare monster. Elegant but arrogant. Selective of its friends, and It''ll seize its flame before approaching. Used to increase a Family Member''s Blessing Power by 14 to 48.', 't'),
('e736d2b9-a8ec-4a4e-a721-24880c8a6038', 1, 'isl_logo.png', 'Blooming Fox', 7, 24, 3, 'Picnic in the Forest', 'An uncommon and elegant monster. It will exchange its treasured flower for food. Used to increase a Family Member''s Blessing Power by 7 to 24.', 't'),
('0e21a6ea-8262-44f7-91c3-0c51ace7613f', 1, 'isl_logo.png', 'Touno Souvenir 1', 5, 5, 4, 'Touno Island', '', 't'),
('c1e029ff-b82c-48bd-a1f1-ea6291fad948', 1, 'isl_logo.png', 'Mandrake', 1, 3, 1, 'Picnic in the Forest', 'A very common plant monster. Being very timid, it always checks to be sure there is no danger before showing up. Used to increase a Family Member''s Blessing Power by 1 to 3.', 't'),
('9fb7f9ba-e7ed-4e99-b161-386f48299443', 1, 'isl_logo.png', 'Frozen Dragon', 10, 32, 4, 'Picnic in the Forest', 'An extremely rare monster. It looks cold and distant. But just one sandwich, and you can romp playfully together. Used to increase a Family Member''s Blessing Power by 10 to 32.', 't'),
('54e9bcf5-f1a5-4350-a75d-88af02b4fc13', 1, 'isl_logo.png', 'Gorgeous Horse', 5, 16, 3, 'Picnic in the Forest', 'An uncommon monster. Elegant and beautiful, it will bow gracefully to the person who feeds it. Used to increase a Family Member''s Blessing Power by 5 to 16.', 't'),
('2563b5f8-8fd5-4795-af86-33200605cf3e', 1, 'isl_logo.png', 'Chirping Chick', 4, 10, 2, 'Picnic in the Forest', 'A common animal monster. It will make cheerful chirping sounds when given delicious food. Used to increase a Family Member''s Blessing Power by 4 to 10.', 't'),
('700ffd61-c0bf-4f41-abd1-b6fd74a645bb', 1, 'isl_logo.png', 'Touno Souvenir 2', 10, 10, 5, 'Touno Island', '', 't'),
('ddd29671-ca7f-4132-8784-80346e154059', 1, 'isl_logo.png', 'Blessing Power Gachapon', 10, 30, 4, 'Unknown', 'A gachapon with mysterious smell. Open to obtain Rare Necklaces of different energy level, which can be used to increase a Family''s blessing power by 10 to 30.', 't'),
('52cd4a48-ff8a-4493-8030-b4e7754cd227', 1, 'isl_logo.png', 'Muddled Mushroom', 2, 5, 1, 'Picnic in the Forest', 'A friendly monster, very common in the forest. It loves juice very much, even soaking itself in juice sometimes. Used to increase a Family Member''s Blessing Power by 2 to 5.', 't'),
('223aafe8-450f-4343-8df3-d96117d28642', 2, 'isl_logo.png', 'Touno Speciality 2', 10, 10, 5, 'Touno Island', '', 't'),
('09b1fff4-c1a3-49d5-acf1-b996d93a7217', 2, 'isl_logo.png', 'Song: "Unhappy Elder"', 2, 5, 1, 'Camping Under the Stars', '"How old-school and serious elf elder is~ Yet his son fell in love with a bunny girl~?" Used to increase a Family Member''s Intimacy by 2 to 5', 't'),
('0dbbda4c-0e4c-4cc2-b204-0301178ae667', 2, 'gold_ring.png', 'Gold Ring', 1, 1, 2, 'Multiple', 'An exquisite ring made of pure gold. Give it to a family member to increase their Intimacy by 1.', 'f'),
('910cfd8f-9e75-4ca1-b776-e6b4df78e80b', 2, 'isl_logo.png', 'Song: "Starry Love"', 1, 3, 1, 'Camping Under the Stars', '"The Warrior Star meets the Demon Star again~ Shall their difficult love in past lives be continued?" Used to increase a Family Member''s Intimacy by 1 to 3', 't'),
('6459b278-9e0d-48ab-b6bb-aa4bfc88011b', 2, 'isl_logo.png', 'Touno Speciality 1', 5, 5, 4, 'Touno Island', '', 't'),
('62c5fe6d-92d2-458d-8ce4-c206eeb6245a', 2, 'isl_logo.png', 'Song: "Prince''s Wish"', 4, 10, 2, 'Camping Under the Stars', '"For his beloved maid~ The prince wishes for his fiancee to find happiness in the cave~?" Used to increase a Family Member''s Intimacy by 4 to 10', 't'),
('b2536feb-7dcb-4cec-93e5-581bc64e693b', 2, 'isl_logo.png', 'Song: "Princess''s Wish"', 3, 6, 2, 'Camping Under the Stars', '"For her beloved monster~ The princess wishes to be captured again in the cave~?" Used to increase a Family Member''s Intimacy by 3 to 6', 't'),
('bcd9068a-c3b1-4914-ac50-af3369a7a8e5', 2, 'isl_logo.png', 'Intamacy Gachapon', 10, 30, 4, 'Unknown', '', 't'),
('67e7598f-f687-4ea0-b9f5-f89aaa965d44', 2, 'isl_logo.png', 'Song: "Otherworld Stars"', 7, 24, 3, 'Camping Under the Stars', 'The Lord occasionally hums this, "Twinkle, twinkle, little star, how I wonder what you are..." Used to increase a Family Member''s Intimacy by 7 to 24', 't'),
('73ddfbbf-3071-4103-9893-b9b77af05ce9', 2, 'isl_logo.png', 'Song: "Single Golden Mushroom"', 5, 16, 3, 'Camping Under the Stars', '"I wonder which lucky girl will be able to accompany him~?" Used to increase a Family Member''s Intimacy by 5 to 16', 't'),
('b2ebc786-79c3-47df-b0d9-330bb8e85a5f', 2, 'isl_logo.png', 'Song: "Unlucky Succubus"', 14, 48, 4, 'Camping Under the Stars', '"The succubus think she could charm the strong warrior~ Yet was conquered, body and soul~" Used to increase a Family Member''s Intimacy by 14 to 48', 't'),
('d5eb513d-68e0-4cd3-bb44-e3e8d36cfecd', 2, 'gemstone_ring.png', 'Gemstone Ring', 2, 2, 3, 'Multiple', 'A ring inlaid with jewels. Give it to a family member to increase their Intimacy by 2.', 'f'),
('590ebe99-0fdd-4216-bb51-88d48f07d518', 2, 'isl_logo.png', 'Song: "Forbidden Love"', 10, 32, 4, 'Camping Under the Stars', '"The holy priest~ Yet the lip prints and bite marks under robe ~ The proof of entanglement with the Dark Lord~?" Used to increase a Family Member''s Intimacy by 10 to 32', 't'),
('71c7537b-ef33-4f64-91d4-e7e9c3915cad', 2, 'diamond_ring.png', 'Diamond Ring', 5, 5, 4, 'Multiple', 'A luxurious ring inlaid with diamonds. Give it to a family member to increase their Intimacy by 5.', 'f'),
('1f7aff96-030d-4007-9a70-82db7a8be3e3', 3, 'isl_logo.png', 'Contestant Portrait (Wolf)', 15000, 40000, 3, 'Wrestling Championship', 'A portrait kissed by a star contestant with a confident declaration of victory on the back. Used to increase a Fellow''s Power by 15,000 to 40,000', 't'),
('2006c92e-8e32-4c9f-a913-3b2d1ed8dea0', 3, 'potion_of_bravery.png', 'Potion of Bravery', 800, 800, 3, 'Multiple', 'A magic potion that can awaken the potential of one''s courage. Used to incrase the Power of a random Brave type Fellow by 800.', 'f'),
('3eccaaac-5afe-415a-ac8f-55df213cf015', 3, 'potion_of_freedom.png', 'Potion of Freedom', 800, 800, 3, 'Multiple', 'A magic potion that can awaken the potential of one''s ambition. Used to incrase the Power of a random Unfettered type Fellow by 800.', 'f'),
('a44b763b-833b-49d0-91d6-e5fcb8c6ce7c', 3, 'isl_logo.png', 'Signed Handkerchief (Yellow)', 2000, 5000, 1, 'Wrestling Championship', 'A handkerchief for fans signed by wrestlers. Used to increase a Fellow''s Power by 2,000 to 5,000', 't'),
('ce522371-80bd-4266-b473-8f5ace7099c7', 3, 'isl_logo.png', 'Signed Handkerchief (Red)', 3000, 8000, 1, 'Wrestling Championship', 'A gift from a wrestler. Can only be obtained when watching a match ringside. Used to increase a Fellow''s Power by 3,000 to 8,000.', 't'),
('fff5a89a-1691-47ea-af30-c811f1c1dbfc', 3, 'isl_logo.png', 'Fairy Shuttlecock', 10000, 25000, 3, 'Muscle Hustle Gym', 'A light shuttlecock that seems to understand words. If you shout loudly while playing, it will fly to the target position. Used to increase a Fellow''s Power by 10,000 to 25,000.', 't'),
('30d05d98-a615-4e3a-94da-8aa6e4ad03a9', 3, 'basic_elixir.png', 'Basic Elixir', 3000, 3000, 3, 'Multiple', 'A potion that partially awakens one''s potential. Used to increase a designated Fellow''s Power by 3,000', 'f'),
('762a2775-ca50-4c13-8797-2f03b045ed10', 3, 'isl_logo.png', 'Contestant Portrait (Lion)', 10000, 25000, 3, 'Wrestling Championship', 'A portrait kissed by a star contestant with a message to a fan on the back. Used to increase a Fellow''s Power by 10,000 to 25,000', 't'),
('9c95396d-e5d8-4f7d-9d37-1469e7dc0ee1', 3, 'isl_logo.png', 'Signed Towel (Yellow)', 4500, 10000, 2, 'Wrestling Championship', 'A towel for fans signed by wrestlers. Used to increase a Fellow''s Power by 4,500 to 10,000.', 't'),
('6214eeeb-c77b-415c-a055-6d15b04ca026', 3, 'isl_logo.png', 'Steel Barbell', 15000, 40000, 3, 'Muscle Hustle Gym', 'Looks small but weighs a lot. Be cautious when using it, or you might strain your waist. Used to increase a Fellow''s Power by 15,000 to 40,000.', 't'),
('daca4964-69c4-4167-b7bf-2e8eb49a8f1b', 3, 'isl_logo.png', 'Ivy Jump Rope', 2000, 5000, 1, 'Muscle Hustle Gym', 'A jump rope made from vines of some plant monster, very tough. Used to increase a Fellow''s Power by 2,000 to 5,000.', 't'),
('b282b9cb-1802-4563-88a1-e7e267a0bcd4', 3, 'isl_logo.png', 'Rock Kettlebell', 6000, 15000, 2, 'Muscle Hustle Gym', 'A kettlebell made of rocks with extremely high density. The slime version is the most popular. Used to increase a Fellow''s Power by 6,000 to 15,000.', 't'),
('bf1611c0-ddec-4ad8-8299-a2e19818186f', 3, 'isl_logo.png', 'Screaming Punching Bag', 30000, 80000, 4, 'Muscle Hustle Gym', 'It makes funny scream when hit. It might be nice to bring it home as a toy. Used to increase a Fellow''s Power by 30,000 to 80,000.', 't'),
('7075da2f-a617-42a1-b142-fe2401ad87ec', 3, 'potion_of_inspiration.png', 'Potion of Inspiration', 800, 800, 3, 'Multiple', 'A magic potion that can awaken the potential of the soul. Used to incrase the Power of a random Inspiring type Fellow by 800.', 'f'),
('bc5fc5c6-65e1-41c8-822d-d6e06ec0894e', 3, 'advanced_elixir.png', 'Advanced Elixir', 30000, 30000, 4, 'Multiple', 'A potion that awakens one''s full potential. Used to increase a designated Fellow''s Power by 30,000.', 'f'),
('cd50f711-36a4-4b3b-b4ef-84b52c8a18e2', 3, 'isl_logo.png', 'Champion''s Statue', 30000, 80000, 4, 'Wrestling Championship', '', 't'),
('472d229e-3541-4115-8104-53af579f24a4', 3, 'isl_logo.png', 'Demonic Exercise Bike', 20000, 50000, 4, 'Muscle Hustle Gym', 'This advanced bike can automatically set cycling distance according to user''s physical condition, very useful. Used to increase a Fellow''s Power by 20,000 to 50,000.', 't'),
('a64b4819-5b32-41c5-8fe0-293ea8695a0c', 3, 'isl_logo.png', 'Stone Dumbbell', 3000, 8000, 1, 'Muscle Hustle Gym', 'A pair of little dumbells. Even a beginner can lift them easily after a little exerciase. Used to increase a Fellow''s Power by 3,000 to 8,000.', 't'),
('68a7a68a-2123-4a8e-b64d-9dbdf0637521', 3, 'potion_of_erudition.png', 'Potion of Erudition', 800, 800, 3, 'Multiple', 'A magic potion that can awaken the potential of one''s wisdom. Used to incrase the Power of a random Informed type Fellow by 800.', 'f'),
('a351a27b-765b-46b5-95fc-99c47e63176d', 3, 'potion_of_diligence.png', 'Potion of Diligence', 800, 800, 3, 'Multiple', 'A magic potion that can awaken the potential of the body. Used to incrase the Power of a random Diligent type Fellow by 800.', 'f'),
('d7d705d3-9562-4f03-98d8-3b0da81fcf47', 3, 'isl_logo.png', 'Champion''s Belt', 20000, 50000, 4, 'Wrestling Championship', 'A champion''s belt memorializing the time in the ring. Used to increase a Fellow''s Power by 20,000 to 50,000.', 't'),
('ed1663c2-aff0-41b4-b5ed-7f86463c1d69', 3, 'isl_logo.png', 'Signed Towel (Red)', 6000, 15000, 2, 'Wrestling Championship', 'A towel of the same type used by wrestlers. Can only be obtained on the spot. Used to increase a Fellow''s Power by 6,000 to 15,000.', 't'),
('732f16e3-6de7-4bc7-af77-9cdbaf68b695', 3, 'isl_logo.png', 'Pac-Ball', 4500, 10000, 2, 'Muscle Hustle Gym', 'It will show various expressions when used. Maybe a gym ball has its own feelings...? Used to increase a Fellow''s Power by 4,500 to 10,000.', 't');
-- 2024-01-29 04:09:08.649384+00

View file

@ -1,12 +0,0 @@
CREATE TABLE powerItem (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
itemType int NOT NULL,
iconURL text NOT NULL,
itemName text NOT NULL,
minItemPower integer NOT NULL,
maxItemPower integer NOT NULL,
rarity int NOT NULL,
origin text NOT NULL,
tooltip text NULL,
isEventItem boolean
)

6
envConfigs.go Normal file
View file

@ -0,0 +1,6 @@
package main
type EnvConfigs struct {
HttpPort string `mapstructure:"HTTP_PORT"`
ConnectionString string `mapstructure:"DB_CONNECTION_STRING"`
}

23
go.mod
View file

@ -10,12 +10,31 @@ require (
)
require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.2 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/text v0.7.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.18.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

45
go.sum
View file

@ -8,6 +8,9 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
@ -16,6 +19,8 @@ github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRx
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
@ -80,25 +85,47 @@ github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
@ -113,15 +140,23 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
@ -138,6 +173,10 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
@ -166,6 +205,8 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@ -178,6 +219,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
@ -197,6 +240,8 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

28
main.go
View file

@ -11,18 +11,42 @@ import (
"github.com/jackc/pgx/v4"
"github.com/julienschmidt/httprouter"
"github.com/spf13/viper"
)
var conf *EnvConfigs
func init() {
setupConfig()
}
func main() {
deps := dependencies{}
deps.initializeDependencies()
deps.router.HandlerFunc("GET", "/", index)
err := http.ListenAndServe(":3000", deps.router)
err := http.ListenAndServe(fmt.Sprintf(":%v", conf.HttpPort), deps.router)
log.Fatal(err)
}
func setupConfig() {
viper.AddConfigPath(".")
viper.SetConfigName(".env")
viper.SetConfigType("env")
viper.SetEnvPrefix("isl_api")
viper.AutomaticEnv()
if err := viper.ReadInConfig(); err != nil {
fmt.Printf("Error reading env file: %v\n", err)
}
if err := viper.Unmarshal(&conf); err != nil {
log.Fatal(err)
}
}
type dependencies struct {
router *httprouter.Router
postgresConnection *pgx.Conn
@ -37,7 +61,7 @@ func (d *dependencies) initializeDependencies() error {
d.router = httprouter.New()
d.context = context.Background()
d.postgresConnection, err = pgx.Connect(d.context, "postgres://isl:development@localhost:5432/isl")
d.postgresConnection, err = pgx.Connect(d.context, conf.ConnectionString)
if err != nil {
return err
}