Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first commit #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
app:
image: golang:latest
command: sh -c "go mod download && go mod verify && go run"
ports:
- 127.0.0.1:8080:8080
volumes:
- ./transmissions-pub:/app
working_dir: /app
118 changes: 0 additions & 118 deletions front.html

This file was deleted.

8 changes: 8 additions & 0 deletions transmissions-pub/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
API_SECRET=k0MaPPXSBhMZgvVNPkdAyEmHqL5r1swH
HOST=localhost
PORT=5432
USER=postgres
PASSWORD=onerazan
DBNAME=transmissions-db
TOKEN_HOUR_LIFESPAN=2
AMQP_URL=amqp://guest:guest@localhost:5672/
8 changes: 8 additions & 0 deletions transmissions-pub/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions transmissions-pub/.idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions transmissions-pub/.idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions transmissions-pub/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions transmissions-pub/.idea/transmissions-pub.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions transmissions-pub/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions transmissions-pub/database/database.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package database

import (
"fmt"
"github.com/joho/godotenv"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"log"
"os"
)

var DB *gorm.DB

func Connect() {
err := godotenv.Load(".env")

if err != nil {
log.Fatalf("Error loading .env file")
}

dbHost := os.Getenv("HOST")
dbPort := os.Getenv("PORT")
dbUser := os.Getenv("USER")
dbPassword := os.Getenv("PASSWORD")
dbName := os.Getenv("DBNAME")

dns := fmt.Sprintf(
"host=%s port=%s user=%s password=%s dbname=%s sslmode=disable",
dbHost, dbPort, dbUser, dbPassword, dbName)

DB, err = gorm.Open(postgres.Open(dns), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
}
49 changes: 49 additions & 0 deletions transmissions-pub/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module transmissions-pub

go 1.22

require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/gin-gonic/gin v1.9.1
github.com/gorilla/websocket v1.5.1
github.com/joho/godotenv v1.5.1
golang.org/x/crypto v0.19.0
gorm.io/driver/postgres v1.5.6
gorm.io/gorm v1.25.7
)

require (
github.com/bytedance/sonic v1.11.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.18.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
github.com/jackc/pgx/v5 v5.5.3 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/rabbitmq/amqp091-go v1.9.0 // indirect
github.com/streadway/amqp v1.1.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.7.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading