diff --git a/Makefile b/Makefile index 88e0986..a6d7d0e 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,9 @@ DB_USER=test DB_PASS=test DB_DSN_DEV=postgres://$(DB_USER):$(DB_PASS)@127.0.0.1:5432/dev?sslmode=disable -DB_DSN_TEST=postgres://$(DB_USER):$(DB_PASS)@127.0.0.1:5432/test?sslmode=disable -MIGRATION=migrate -url '$(DB_DSN_DEV)' -MIGRATION_SCHEMA=./sql/migration -MIGRATION_TEST_DATA=./sql/dev +MIGRATION=migrate -database '$(DB_DSN_DEV)' +MIGRATION_SCHEMA=./migrations DOCKER_COMPOSE_FILE=./docker/docker-compose.yml DOCKER_COMPOSE=docker-compose -f $(DOCKER_COMPOSE_FILE) @@ -28,20 +26,17 @@ build_docker_image: rm -rf canapeapp mkdir canapeapp cp -R docker/run.sh canapeapp/run.sh - cp -R sql/migration canapeapp/migrations + cp -R migrations canapeapp/migrations cp $$GOPATH/bin/migrate canapeapp/migrate yarn build - go build -v -o canapeapp/app src/*.go + go build -v -o canapeapp/app backend/*.go docker build --tag canapeapp:latest --file docker/Dockerfile-production . rm -rf canapeapp migration-schema: docker $(MIGRATION) -path $(MIGRATION_SCHEMA) up -migration-dev-data: docker migration-schema - $(MIGRATION) -path $(MIGRATION_TEST_DATA) up - -migration: migration-schema migration-dev-data +migration: migration-schema dev: docker migration watch-go @@ -49,6 +44,3 @@ clean: -rm -r ./build $(DOCKER_COMPOSE) stop $(DOCKER_COMPOSE) rm --force -v - -test: docker - POSTGRES_DSN="$(DB_DSN_TEST)" go test -v -p=1 ./... diff --git a/README.md b/README.md index 3851b05..88e344c 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,9 @@ go get ./... go tools: ``` -go get -v github.com/pilu/fresh -go get -v github.com/mattes/migrate +go get -v -u github.com/pilu/fresh +go get -v -u github.com/mattes/migrate +go build -tags 'postgres' -o $GOPATH/bin/migrate github.com/mattes/migrate/cli ``` ## Dev @@ -50,7 +51,14 @@ yarn start docker run -it --rm -e PGPASSWORD=test --link canape_postgresql_dev:postgres postgres:9.5 psql -h postgres -U test -d dev ``` -## Default users +## Setup the dev users + +Connect to the database and enter this sql queries: + +``` +INSERT INTO users (name, hash, admin, activated) VALUES ('test', '$2a$10$QHx07iyuxO1RcehgtjMgjOzv03Bx2eeSKvsxkoj9oR2NJ4cklh6ue', false, true); +INSERT INTO users (name, hash, admin, activated) VALUES ('admin', '$2a$10$qAbyDZsHtcnhXhjhQZkD2uKlX72eMHsX8Hi2Cnl1vJUqHQiey2qa6', true, true); +``` This users are defined with this parameters: pepper: "pepper" diff --git a/src/internal/admins/stats.go b/backend/admins/stats.go similarity index 97% rename from src/internal/admins/stats.go rename to backend/admins/stats.go index 10e0422..1177333 100644 --- a/src/internal/admins/stats.go +++ b/backend/admins/stats.go @@ -5,7 +5,7 @@ import ( "github.com/jmoiron/sqlx" "github.com/sirupsen/logrus" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/web" + "gitlab.quimbo.fr/odwrtw/canape/backend/web" ) const ( diff --git a/src/internal/admins/users.go b/backend/admins/users.go similarity index 90% rename from src/internal/admins/users.go rename to backend/admins/users.go index 04947bd..726d718 100644 --- a/src/internal/admins/users.go +++ b/backend/admins/users.go @@ -5,9 +5,9 @@ import ( "fmt" "net/http" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/config" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/users" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/web" + "gitlab.quimbo.fr/odwrtw/canape/backend/config" + "gitlab.quimbo.fr/odwrtw/canape/backend/users" + "gitlab.quimbo.fr/odwrtw/canape/backend/web" "github.com/sirupsen/logrus" ) diff --git a/src/internal/auth/auth.go b/backend/auth/auth.go similarity index 100% rename from src/internal/auth/auth.go rename to backend/auth/auth.go diff --git a/src/internal/auth/middleware.go b/backend/auth/middleware.go similarity index 100% rename from src/internal/auth/middleware.go rename to backend/auth/middleware.go diff --git a/src/internal/backend/backend.go b/backend/backend/backend.go similarity index 79% rename from src/internal/backend/backend.go rename to backend/backend/backend.go index 4fac62d..5e1db45 100644 --- a/src/internal/backend/backend.go +++ b/backend/backend/backend.go @@ -1,8 +1,8 @@ package backend import ( - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/auth" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/users" + "gitlab.quimbo.fr/odwrtw/canape/backend/auth" + "gitlab.quimbo.fr/odwrtw/canape/backend/users" "github.com/jmoiron/sqlx" ) diff --git a/src/internal/backend/detailer.go b/backend/backend/detailer.go similarity index 100% rename from src/internal/backend/detailer.go rename to backend/backend/detailer.go diff --git a/src/internal/backend/episode_torrents.go b/backend/backend/episode_torrents.go similarity index 100% rename from src/internal/backend/episode_torrents.go rename to backend/backend/episode_torrents.go diff --git a/src/internal/backend/episodes.go b/backend/backend/episodes.go similarity index 100% rename from src/internal/backend/episodes.go rename to backend/backend/episodes.go diff --git a/src/internal/backend/explorer.go b/backend/backend/explorer.go similarity index 96% rename from src/internal/backend/explorer.go rename to backend/backend/explorer.go index c229649..fb2e96d 100644 --- a/src/internal/backend/explorer.go +++ b/backend/backend/explorer.go @@ -1,10 +1,9 @@ package backend import ( - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/sqly" - "github.com/jmoiron/sqlx" "github.com/lib/pq" + "gitlab.quimbo.fr/odwrtw/canape/backend/sqly" ) const ( diff --git a/src/internal/backend/movie_torrents.go b/backend/backend/movie_torrents.go similarity index 100% rename from src/internal/backend/movie_torrents.go rename to backend/backend/movie_torrents.go diff --git a/src/internal/backend/movie_wishlist.go b/backend/backend/movie_wishlist.go similarity index 100% rename from src/internal/backend/movie_wishlist.go rename to backend/backend/movie_wishlist.go diff --git a/src/internal/backend/movies.go b/backend/backend/movies.go similarity index 100% rename from src/internal/backend/movies.go rename to backend/backend/movies.go diff --git a/src/internal/backend/show_wishlist.go b/backend/backend/show_wishlist.go similarity index 100% rename from src/internal/backend/show_wishlist.go rename to backend/backend/show_wishlist.go diff --git a/src/internal/backend/shows.go b/backend/backend/shows.go similarity index 100% rename from src/internal/backend/shows.go rename to backend/backend/shows.go diff --git a/src/internal/backend/torrenter.go b/backend/backend/torrenter.go similarity index 100% rename from src/internal/backend/torrenter.go rename to backend/backend/torrenter.go diff --git a/src/internal/config/canape.go b/backend/config/canape.go similarity index 100% rename from src/internal/config/canape.go rename to backend/config/canape.go diff --git a/src/internal/config/polochon.go b/backend/config/polochon.go similarity index 100% rename from src/internal/config/polochon.go rename to backend/config/polochon.go diff --git a/src/internal/external_medias/external_medias.go b/backend/external_medias/external_medias.go similarity index 96% rename from src/internal/external_medias/external_medias.go rename to backend/external_medias/external_medias.go index fc864b2..8075007 100644 --- a/src/internal/external_medias/external_medias.go +++ b/backend/external_medias/external_medias.go @@ -3,13 +3,12 @@ package extmedias import ( "fmt" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/backend" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/movies" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/shows" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/web" - polochon "github.com/odwrtw/polochon/lib" "github.com/sirupsen/logrus" + "gitlab.quimbo.fr/odwrtw/canape/backend/backend" + "gitlab.quimbo.fr/odwrtw/canape/backend/movies" + "gitlab.quimbo.fr/odwrtw/canape/backend/shows" + "gitlab.quimbo.fr/odwrtw/canape/backend/web" ) // NewExplorer returns a polochon.Explorer from the list of Explorers in the config diff --git a/src/internal/external_medias/handlers.go b/backend/external_medias/handlers.go similarity index 94% rename from src/internal/external_medias/handlers.go rename to backend/external_medias/handlers.go index 05ffab2..3533c1b 100644 --- a/src/internal/external_medias/handlers.go +++ b/backend/external_medias/handlers.go @@ -4,15 +4,14 @@ import ( "errors" "net/http" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/auth" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/backend" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/movies" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/shows" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/users" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/web" - polochon "github.com/odwrtw/polochon/lib" "github.com/sirupsen/logrus" + "gitlab.quimbo.fr/odwrtw/canape/backend/auth" + "gitlab.quimbo.fr/odwrtw/canape/backend/backend" + "gitlab.quimbo.fr/odwrtw/canape/backend/movies" + "gitlab.quimbo.fr/odwrtw/canape/backend/shows" + "gitlab.quimbo.fr/odwrtw/canape/backend/users" + "gitlab.quimbo.fr/odwrtw/canape/backend/web" ) // RefreshHandler refresh the explored movies diff --git a/src/main.go b/backend/main.go similarity index 86% rename from src/main.go rename to backend/main.go index 554c46e..9e1ab1c 100644 --- a/src/main.go +++ b/backend/main.go @@ -5,11 +5,11 @@ import ( "net/http" "os" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/auth" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/backend" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/config" - extmedias "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/external_medias" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/web" + "gitlab.quimbo.fr/odwrtw/canape/backend/auth" + "gitlab.quimbo.fr/odwrtw/canape/backend/backend" + "gitlab.quimbo.fr/odwrtw/canape/backend/config" + extmedias "gitlab.quimbo.fr/odwrtw/canape/backend/external_medias" + "gitlab.quimbo.fr/odwrtw/canape/backend/web" "github.com/jmoiron/sqlx" _ "github.com/lib/pq" diff --git a/src/modules.go b/backend/modules.go similarity index 100% rename from src/modules.go rename to backend/modules.go diff --git a/src/internal/movies/handlers.go b/backend/movies/handlers.go similarity index 96% rename from src/internal/movies/handlers.go rename to backend/movies/handlers.go index d9424ee..958c44e 100644 --- a/src/internal/movies/handlers.go +++ b/backend/movies/handlers.go @@ -10,13 +10,12 @@ import ( "github.com/odwrtw/papi" polochon "github.com/odwrtw/polochon/lib" "github.com/sirupsen/logrus" - - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/auth" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/backend" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/config" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/subtitles" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/users" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/web" + "gitlab.quimbo.fr/odwrtw/canape/backend/auth" + "gitlab.quimbo.fr/odwrtw/canape/backend/backend" + "gitlab.quimbo.fr/odwrtw/canape/backend/config" + "gitlab.quimbo.fr/odwrtw/canape/backend/subtitles" + "gitlab.quimbo.fr/odwrtw/canape/backend/users" + "gitlab.quimbo.fr/odwrtw/canape/backend/web" ) // PolochonMoviesHandler will returns movies from Polochon diff --git a/src/internal/movies/movies.go b/backend/movies/movies.go similarity index 96% rename from src/internal/movies/movies.go rename to backend/movies/movies.go index b69d161..1d5d2a0 100644 --- a/src/internal/movies/movies.go +++ b/backend/movies/movies.go @@ -10,11 +10,10 @@ import ( "github.com/odwrtw/papi" "github.com/odwrtw/polochon/lib" "github.com/sirupsen/logrus" - - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/backend" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/subtitles" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/users" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/web" + "gitlab.quimbo.fr/odwrtw/canape/backend/backend" + "gitlab.quimbo.fr/odwrtw/canape/backend/subtitles" + "gitlab.quimbo.fr/odwrtw/canape/backend/users" + "gitlab.quimbo.fr/odwrtw/canape/backend/web" ) // Movie represents a movie diff --git a/src/internal/random/random.go b/backend/random/random.go similarity index 100% rename from src/internal/random/random.go rename to backend/random/random.go diff --git a/src/routes.go b/backend/routes.go similarity index 91% rename from src/routes.go rename to backend/routes.go index b2af6c0..e972443 100644 --- a/src/routes.go +++ b/backend/routes.go @@ -1,13 +1,13 @@ package main import ( - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/admins" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/external_medias" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/movies" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/shows" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/torrents" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/users" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/web" + admin "gitlab.quimbo.fr/odwrtw/canape/backend/admins" + extmedias "gitlab.quimbo.fr/odwrtw/canape/backend/external_medias" + "gitlab.quimbo.fr/odwrtw/canape/backend/movies" + "gitlab.quimbo.fr/odwrtw/canape/backend/shows" + "gitlab.quimbo.fr/odwrtw/canape/backend/torrents" + "gitlab.quimbo.fr/odwrtw/canape/backend/users" + "gitlab.quimbo.fr/odwrtw/canape/backend/web" ) func setupRoutes(env *web.Env) { diff --git a/src/internal/shows/episodes.go b/backend/shows/episodes.go similarity index 96% rename from src/internal/shows/episodes.go rename to backend/shows/episodes.go index c1904db..c8ba9c6 100644 --- a/src/internal/shows/episodes.go +++ b/backend/shows/episodes.go @@ -7,10 +7,9 @@ import ( "github.com/odwrtw/papi" polochon "github.com/odwrtw/polochon/lib" "github.com/sirupsen/logrus" - - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/backend" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/subtitles" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/web" + "gitlab.quimbo.fr/odwrtw/canape/backend/backend" + "gitlab.quimbo.fr/odwrtw/canape/backend/subtitles" + "gitlab.quimbo.fr/odwrtw/canape/backend/web" ) // Episode represents an episode diff --git a/src/internal/shows/handlers.go b/backend/shows/handlers.go similarity index 97% rename from src/internal/shows/handlers.go rename to backend/shows/handlers.go index 7b12ea0..7924c14 100644 --- a/src/internal/shows/handlers.go +++ b/backend/shows/handlers.go @@ -7,17 +7,16 @@ import ( "log" "strconv" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/auth" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/backend" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/subtitles" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/users" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/web" - "net/http" "github.com/gorilla/mux" "github.com/odwrtw/papi" polochon "github.com/odwrtw/polochon/lib" + "gitlab.quimbo.fr/odwrtw/canape/backend/auth" + "gitlab.quimbo.fr/odwrtw/canape/backend/backend" + "gitlab.quimbo.fr/odwrtw/canape/backend/subtitles" + "gitlab.quimbo.fr/odwrtw/canape/backend/users" + "gitlab.quimbo.fr/odwrtw/canape/backend/web" ) // ErrPolochonUnavailable is an error returned if the polochon server is not available diff --git a/src/internal/shows/shows.go b/backend/shows/shows.go similarity index 97% rename from src/internal/shows/shows.go rename to backend/shows/shows.go index a2f4b3d..2efd663 100644 --- a/src/internal/shows/shows.go +++ b/backend/shows/shows.go @@ -7,13 +7,12 @@ import ( "path/filepath" "strings" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/backend" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/users" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/web" - "github.com/odwrtw/papi" "github.com/odwrtw/polochon/lib" "github.com/sirupsen/logrus" + "gitlab.quimbo.fr/odwrtw/canape/backend/backend" + "gitlab.quimbo.fr/odwrtw/canape/backend/users" + "gitlab.quimbo.fr/odwrtw/canape/backend/web" ) // Show represents a show diff --git a/backend/sqly/sqly.go b/backend/sqly/sqly.go new file mode 100644 index 0000000..96bf61a --- /dev/null +++ b/backend/sqly/sqly.go @@ -0,0 +1,12 @@ +package sqly + +import ( + "time" +) + +// BaseModel have to be embeded in all your struct which reflect a table +type BaseModel struct { + ID string `json:"id"` + Updated time.Time `db:"updated_at" json:"updated_at"` + Created time.Time `db:"created_at" json:"created_at"` +} diff --git a/src/internal/subtitles/handler.go b/backend/subtitles/handler.go similarity index 100% rename from src/internal/subtitles/handler.go rename to backend/subtitles/handler.go diff --git a/src/internal/subtitles/subtitles.go b/backend/subtitles/subtitles.go similarity index 100% rename from src/internal/subtitles/subtitles.go rename to backend/subtitles/subtitles.go diff --git a/src/internal/torrents/handlers.go b/backend/torrents/handlers.go similarity index 95% rename from src/internal/torrents/handlers.go rename to backend/torrents/handlers.go index ca124a8..3a17c9a 100644 --- a/src/internal/torrents/handlers.go +++ b/backend/torrents/handlers.go @@ -10,10 +10,9 @@ import ( "github.com/gorilla/mux" "github.com/odwrtw/polochon/lib" "github.com/sirupsen/logrus" - - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/auth" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/users" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/web" + "gitlab.quimbo.fr/odwrtw/canape/backend/auth" + "gitlab.quimbo.fr/odwrtw/canape/backend/users" + "gitlab.quimbo.fr/odwrtw/canape/backend/web" ) // DownloadHandler downloads a movie via polochon diff --git a/src/internal/users/handlers.go b/backend/users/handlers.go similarity index 95% rename from src/internal/users/handlers.go rename to backend/users/handlers.go index d07223c..2815ca2 100644 --- a/src/internal/users/handlers.go +++ b/backend/users/handlers.go @@ -8,9 +8,9 @@ import ( jwt "github.com/dgrijalva/jwt-go" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/auth" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/config" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/web" + "gitlab.quimbo.fr/odwrtw/canape/backend/auth" + "gitlab.quimbo.fr/odwrtw/canape/backend/config" + "gitlab.quimbo.fr/odwrtw/canape/backend/web" ) // SignupPOSTHandler handles the user's Signup diff --git a/src/internal/users/users.go b/backend/users/users.go similarity index 97% rename from src/internal/users/users.go rename to backend/users/users.go index 90633de..00ba547 100644 --- a/src/internal/users/users.go +++ b/backend/users/users.go @@ -10,9 +10,9 @@ import ( "github.com/jmoiron/sqlx/types" "github.com/odwrtw/papi" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/config" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/random" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/sqly" + "gitlab.quimbo.fr/odwrtw/canape/backend/config" + "gitlab.quimbo.fr/odwrtw/canape/backend/random" + "gitlab.quimbo.fr/odwrtw/canape/backend/sqly" ) const ( diff --git a/src/internal/web/download.go b/backend/web/download.go similarity index 100% rename from src/internal/web/download.go rename to backend/web/download.go diff --git a/src/internal/web/env.go b/backend/web/env.go similarity index 94% rename from src/internal/web/env.go rename to backend/web/env.go index a235a89..4d8388b 100644 --- a/src/internal/web/env.go +++ b/backend/web/env.go @@ -1,8 +1,8 @@ package web import ( - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/auth" - "gitlab.quimbo.fr/odwrtw/canape-sql/src/internal/config" + "gitlab.quimbo.fr/odwrtw/canape/backend/auth" + "gitlab.quimbo.fr/odwrtw/canape/backend/config" "github.com/gorilla/mux" "github.com/jmoiron/sqlx" diff --git a/src/internal/web/handler.go b/backend/web/handler.go similarity index 100% rename from src/internal/web/handler.go rename to backend/web/handler.go diff --git a/src/internal/web/render.go b/backend/web/render.go similarity index 100% rename from src/internal/web/render.go rename to backend/web/render.go diff --git a/docker/run.sh b/docker/run.sh index af000c9..0d0dfa5 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -2,7 +2,7 @@ echo "Running migrations..." /opt/canapeapp/migrate \ - -url postgres://${DB_USER}:${DB_PASS}@database:5432/${DB_ENV}?sslmode=disable \ + -database "postgres://$DB_USER:$DB_PASS@database:5432/$DB_ENV?sslmode=disable" \ -path /opt/canapeapp/migrations \ up echo "Migrations done" diff --git a/fresh.conf b/fresh.conf index ac8617c..d184255 100644 --- a/fresh.conf +++ b/fresh.conf @@ -1,5 +1,6 @@ -ignored: node_modules,src/public build_name: dev-build build_log: dev-build.log tmp_path: ./build -root: ./src +valid_ext: .go +root: ./backend +colors: 1 diff --git a/src/public/img/android-chrome-192x192.png b/frontend/img/android-chrome-192x192.png similarity index 100% rename from src/public/img/android-chrome-192x192.png rename to frontend/img/android-chrome-192x192.png diff --git a/src/public/img/android-chrome-512x512.png b/frontend/img/android-chrome-512x512.png similarity index 100% rename from src/public/img/android-chrome-512x512.png rename to frontend/img/android-chrome-512x512.png diff --git a/src/public/img/apple-touch-icon.png b/frontend/img/apple-touch-icon.png similarity index 100% rename from src/public/img/apple-touch-icon.png rename to frontend/img/apple-touch-icon.png diff --git a/src/public/img/favicon-16x16.png b/frontend/img/favicon-16x16.png similarity index 100% rename from src/public/img/favicon-16x16.png rename to frontend/img/favicon-16x16.png diff --git a/src/public/img/favicon-32x32.png b/frontend/img/favicon-32x32.png similarity index 100% rename from src/public/img/favicon-32x32.png rename to frontend/img/favicon-32x32.png diff --git a/src/public/img/favicon.ico b/frontend/img/favicon.ico similarity index 100% rename from src/public/img/favicon.ico rename to frontend/img/favicon.ico diff --git a/src/public/img/noimage.png b/frontend/img/noimage.png similarity index 100% rename from src/public/img/noimage.png rename to frontend/img/noimage.png diff --git a/src/public/img/safari-pinned-tab.svg b/frontend/img/safari-pinned-tab.svg similarity index 100% rename from src/public/img/safari-pinned-tab.svg rename to frontend/img/safari-pinned-tab.svg diff --git a/src/public/index.html b/frontend/index.html similarity index 100% rename from src/public/index.html rename to frontend/index.html diff --git a/src/public/js/actions/admins.js b/frontend/js/actions/admins.js similarity index 100% rename from src/public/js/actions/admins.js rename to frontend/js/actions/admins.js diff --git a/src/public/js/actions/alerts.js b/frontend/js/actions/alerts.js similarity index 100% rename from src/public/js/actions/alerts.js rename to frontend/js/actions/alerts.js diff --git a/src/public/js/actions/movies.js b/frontend/js/actions/movies.js similarity index 100% rename from src/public/js/actions/movies.js rename to frontend/js/actions/movies.js diff --git a/src/public/js/actions/shows.js b/frontend/js/actions/shows.js similarity index 100% rename from src/public/js/actions/shows.js rename to frontend/js/actions/shows.js diff --git a/src/public/js/actions/subtitles.js b/frontend/js/actions/subtitles.js similarity index 100% rename from src/public/js/actions/subtitles.js rename to frontend/js/actions/subtitles.js diff --git a/src/public/js/actions/torrents.js b/frontend/js/actions/torrents.js similarity index 100% rename from src/public/js/actions/torrents.js rename to frontend/js/actions/torrents.js diff --git a/src/public/js/actions/users.js b/frontend/js/actions/users.js similarity index 100% rename from src/public/js/actions/users.js rename to frontend/js/actions/users.js diff --git a/src/public/js/app.js b/frontend/js/app.js similarity index 100% rename from src/public/js/app.js rename to frontend/js/app.js diff --git a/src/public/js/components/admins/panel.js b/frontend/js/components/admins/panel.js similarity index 100% rename from src/public/js/components/admins/panel.js rename to frontend/js/components/admins/panel.js diff --git a/src/public/js/components/admins/stats.js b/frontend/js/components/admins/stats.js similarity index 100% rename from src/public/js/components/admins/stats.js rename to frontend/js/components/admins/stats.js diff --git a/src/public/js/components/admins/users.js b/frontend/js/components/admins/users.js similarity index 100% rename from src/public/js/components/admins/users.js rename to frontend/js/components/admins/users.js diff --git a/src/public/js/components/alerts/alert.js b/frontend/js/components/alerts/alert.js similarity index 100% rename from src/public/js/components/alerts/alert.js rename to frontend/js/components/alerts/alert.js diff --git a/src/public/js/components/buttons/actions.js b/frontend/js/components/buttons/actions.js similarity index 100% rename from src/public/js/components/buttons/actions.js rename to frontend/js/components/buttons/actions.js diff --git a/src/public/js/components/buttons/download.js b/frontend/js/components/buttons/download.js similarity index 100% rename from src/public/js/components/buttons/download.js rename to frontend/js/components/buttons/download.js diff --git a/src/public/js/components/buttons/imdb.js b/frontend/js/components/buttons/imdb.js similarity index 100% rename from src/public/js/components/buttons/imdb.js rename to frontend/js/components/buttons/imdb.js diff --git a/src/public/js/components/buttons/refresh.js b/frontend/js/components/buttons/refresh.js similarity index 100% rename from src/public/js/components/buttons/refresh.js rename to frontend/js/components/buttons/refresh.js diff --git a/src/public/js/components/buttons/subtitles.js b/frontend/js/components/buttons/subtitles.js similarity index 100% rename from src/public/js/components/buttons/subtitles.js rename to frontend/js/components/buttons/subtitles.js diff --git a/src/public/js/components/list/details.js b/frontend/js/components/list/details.js similarity index 100% rename from src/public/js/components/list/details.js rename to frontend/js/components/list/details.js diff --git a/src/public/js/components/list/explorerOptions.js b/frontend/js/components/list/explorerOptions.js similarity index 100% rename from src/public/js/components/list/explorerOptions.js rename to frontend/js/components/list/explorerOptions.js diff --git a/src/public/js/components/list/filter.js b/frontend/js/components/list/filter.js similarity index 100% rename from src/public/js/components/list/filter.js rename to frontend/js/components/list/filter.js diff --git a/src/public/js/components/list/poster.js b/frontend/js/components/list/poster.js similarity index 100% rename from src/public/js/components/list/poster.js rename to frontend/js/components/list/poster.js diff --git a/src/public/js/components/list/posters.js b/frontend/js/components/list/posters.js similarity index 100% rename from src/public/js/components/list/posters.js rename to frontend/js/components/list/posters.js diff --git a/src/public/js/components/loader/loader.js b/frontend/js/components/loader/loader.js similarity index 100% rename from src/public/js/components/loader/loader.js rename to frontend/js/components/loader/loader.js diff --git a/src/public/js/components/movies/actions.js b/frontend/js/components/movies/actions.js similarity index 100% rename from src/public/js/components/movies/actions.js rename to frontend/js/components/movies/actions.js diff --git a/src/public/js/components/movies/list.js b/frontend/js/components/movies/list.js similarity index 100% rename from src/public/js/components/movies/list.js rename to frontend/js/components/movies/list.js diff --git a/src/public/js/components/movies/torrents.js b/frontend/js/components/movies/torrents.js similarity index 100% rename from src/public/js/components/movies/torrents.js rename to frontend/js/components/movies/torrents.js diff --git a/src/public/js/components/navbar.js b/frontend/js/components/navbar.js similarity index 100% rename from src/public/js/components/navbar.js rename to frontend/js/components/navbar.js diff --git a/src/public/js/components/shows/details.js b/frontend/js/components/shows/details.js similarity index 100% rename from src/public/js/components/shows/details.js rename to frontend/js/components/shows/details.js diff --git a/src/public/js/components/shows/list.js b/frontend/js/components/shows/list.js similarity index 100% rename from src/public/js/components/shows/list.js rename to frontend/js/components/shows/list.js diff --git a/src/public/js/components/shows/listButtons.js b/frontend/js/components/shows/listButtons.js similarity index 100% rename from src/public/js/components/shows/listButtons.js rename to frontend/js/components/shows/listButtons.js diff --git a/src/public/js/components/torrents/list.js b/frontend/js/components/torrents/list.js similarity index 100% rename from src/public/js/components/torrents/list.js rename to frontend/js/components/torrents/list.js diff --git a/src/public/js/components/torrents/search.js b/frontend/js/components/torrents/search.js similarity index 100% rename from src/public/js/components/torrents/search.js rename to frontend/js/components/torrents/search.js diff --git a/src/public/js/components/users/activation.js b/frontend/js/components/users/activation.js similarity index 100% rename from src/public/js/components/users/activation.js rename to frontend/js/components/users/activation.js diff --git a/src/public/js/components/users/edit.js b/frontend/js/components/users/edit.js similarity index 100% rename from src/public/js/components/users/edit.js rename to frontend/js/components/users/edit.js diff --git a/src/public/js/components/users/login.js b/frontend/js/components/users/login.js similarity index 100% rename from src/public/js/components/users/login.js rename to frontend/js/components/users/login.js diff --git a/src/public/js/components/users/signup.js b/frontend/js/components/users/signup.js similarity index 100% rename from src/public/js/components/users/signup.js rename to frontend/js/components/users/signup.js diff --git a/src/public/js/reducers/admins.js b/frontend/js/reducers/admins.js similarity index 100% rename from src/public/js/reducers/admins.js rename to frontend/js/reducers/admins.js diff --git a/src/public/js/reducers/alerts.js b/frontend/js/reducers/alerts.js similarity index 100% rename from src/public/js/reducers/alerts.js rename to frontend/js/reducers/alerts.js diff --git a/src/public/js/reducers/index.js b/frontend/js/reducers/index.js similarity index 100% rename from src/public/js/reducers/index.js rename to frontend/js/reducers/index.js diff --git a/src/public/js/reducers/movies.js b/frontend/js/reducers/movies.js similarity index 100% rename from src/public/js/reducers/movies.js rename to frontend/js/reducers/movies.js diff --git a/src/public/js/reducers/show.js b/frontend/js/reducers/show.js similarity index 100% rename from src/public/js/reducers/show.js rename to frontend/js/reducers/show.js diff --git a/src/public/js/reducers/shows.js b/frontend/js/reducers/shows.js similarity index 100% rename from src/public/js/reducers/shows.js rename to frontend/js/reducers/shows.js diff --git a/src/public/js/reducers/torrents.js b/frontend/js/reducers/torrents.js similarity index 100% rename from src/public/js/reducers/torrents.js rename to frontend/js/reducers/torrents.js diff --git a/src/public/js/reducers/users.js b/frontend/js/reducers/users.js similarity index 100% rename from src/public/js/reducers/users.js rename to frontend/js/reducers/users.js diff --git a/src/public/js/requests.js b/frontend/js/requests.js similarity index 100% rename from src/public/js/requests.js rename to frontend/js/requests.js diff --git a/src/public/js/routes.js b/frontend/js/routes.js similarity index 100% rename from src/public/js/routes.js rename to frontend/js/routes.js diff --git a/src/public/js/store.js b/frontend/js/store.js similarity index 100% rename from src/public/js/store.js rename to frontend/js/store.js diff --git a/src/public/less/app.less b/frontend/less/app.less similarity index 100% rename from src/public/less/app.less rename to frontend/less/app.less diff --git a/src/public/manifest.json b/frontend/manifest.json similarity index 100% rename from src/public/manifest.json rename to frontend/manifest.json diff --git a/sql/migration/0001_initial.down.sql b/migrations/0001_initial.down.sql similarity index 100% rename from sql/migration/0001_initial.down.sql rename to migrations/0001_initial.down.sql diff --git a/sql/migration/0001_initial.up.sql b/migrations/0001_initial.up.sql similarity index 100% rename from sql/migration/0001_initial.up.sql rename to migrations/0001_initial.up.sql diff --git a/sql/migration/0002_external_medias.down.sql b/migrations/0002_external_medias.down.sql similarity index 100% rename from sql/migration/0002_external_medias.down.sql rename to migrations/0002_external_medias.down.sql diff --git a/sql/migration/0002_external_medias.up.sql b/migrations/0002_external_medias.up.sql similarity index 100% rename from sql/migration/0002_external_medias.up.sql rename to migrations/0002_external_medias.up.sql diff --git a/sql/migration/0003_torrents.down.sql b/migrations/0003_torrents.down.sql similarity index 100% rename from sql/migration/0003_torrents.down.sql rename to migrations/0003_torrents.down.sql diff --git a/sql/migration/0003_torrents.up.sql b/migrations/0003_torrents.up.sql similarity index 100% rename from sql/migration/0003_torrents.up.sql rename to migrations/0003_torrents.up.sql diff --git a/sql/migration/0004_change_media_category.down.sql b/migrations/0004_change_media_category.down.sql similarity index 100% rename from sql/migration/0004_change_media_category.down.sql rename to migrations/0004_change_media_category.down.sql diff --git a/sql/migration/0004_change_media_category.up.sql b/migrations/0004_change_media_category.up.sql similarity index 100% rename from sql/migration/0004_change_media_category.up.sql rename to migrations/0004_change_media_category.up.sql diff --git a/sql/migration/0005__user_activation.down.sql b/migrations/0005__user_activation.down.sql similarity index 100% rename from sql/migration/0005__user_activation.down.sql rename to migrations/0005__user_activation.down.sql diff --git a/sql/migration/0005__user_activation.up.sql b/migrations/0005__user_activation.up.sql similarity index 100% rename from sql/migration/0005__user_activation.up.sql rename to migrations/0005__user_activation.up.sql diff --git a/sql/dev/101_data.down.sql b/sql/dev/101_data.down.sql deleted file mode 100644 index 6f114a7..0000000 --- a/sql/dev/101_data.down.sql +++ /dev/null @@ -1 +0,0 @@ -DELETE FROM users; diff --git a/sql/dev/101_data.up.sql b/sql/dev/101_data.up.sql deleted file mode 100644 index ec5228f..0000000 --- a/sql/dev/101_data.up.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO users (name, hash, admin, activated) VALUES ('test', '$2a$10$QHx07iyuxO1RcehgtjMgjOzv03Bx2eeSKvsxkoj9oR2NJ4cklh6ue', false, true); -INSERT INTO users (name, hash, admin, activated) VALUES ('admin', '$2a$10$qAbyDZsHtcnhXhjhQZkD2uKlX72eMHsX8Hi2Cnl1vJUqHQiey2qa6', true, true); diff --git a/src/internal/sqly/sqly.go b/src/internal/sqly/sqly.go deleted file mode 100644 index b83f42a..0000000 --- a/src/internal/sqly/sqly.go +++ /dev/null @@ -1,49 +0,0 @@ -package sqly - -import ( - "os" - "testing" - "time" - - "github.com/jmoiron/sqlx" - "github.com/mattes/migrate/migrate" -) - -var migrationPath string - -func init() { - migrationPath = os.Getenv("MIGRATION_PATH") - if migrationPath == "" { - migrationPath = "../../../sql/migration" - } -} - -// BaseModel have to be embeded in all your struct which reflect a table -type BaseModel struct { - ID string `json:"id"` - Updated time.Time `db:"updated_at" json:"updated_at"` - Created time.Time `db:"created_at" json:"created_at"` -} - -// RunWithLastestMigration runs your test with database migration set to the lastest -func RunWithLastestMigration(db *sqlx.DB, pgdsn string, t *testing.T, test func(db *sqlx.DB, t *testing.T)) { - defer func() { - allErrors, ok := migrate.DownSync(pgdsn, migrationPath) - if !ok { - for _, err := range allErrors { - t.Log(err) - t.Fatal("We get some errors when reset the database schema") - } - } - }() - - allErrors, ok := migrate.UpSync(pgdsn, migrationPath) - if !ok { - for _, err := range allErrors { - t.Log(err) - t.Fatal("Impossible to run test we get some errors when initialize the database schema") - } - } - - test(db, t) -} diff --git a/webpack.config.js b/webpack.config.js index 6f62ca2..5562033 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -6,7 +6,7 @@ if (process.env.NODE_ENV === "production") { BUILD_DIR = path.resolve(__dirname, "canapeapp/public/"); } -var SRC_DIR = path.resolve(__dirname, "src/public/js"); +var SRC_DIR = path.resolve(__dirname, "frontend/js"); const config = { entry: path.join(SRC_DIR, "app.js"),