-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
180246c
commit ae2fe39
Showing
10 changed files
with
168 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
package database | ||
|
||
import ( | ||
"context" | ||
"os" | ||
|
||
"github.com/go-redis/redis/v8" | ||
"github.com/thuongtruong109/gouse/connection" | ||
) | ||
|
||
var Ctx = context.Background() | ||
|
||
func CreateClient(dbNo int) *redis.Client { | ||
rdb := redis.NewClient(&redis.Options{ | ||
Addr: os.Getenv("DB_ADDR"), | ||
Password : os.Getenv("DB_PASS"), | ||
DB: dbNo, | ||
}) | ||
addr := os.Getenv("DB_ADDR") | ||
pass := os.Getenv("DB_PASS") | ||
rdb := connection.Redis(addr, pass, dbNo) | ||
|
||
return rdb | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
module github.com/thuongtruong1009/short1url | ||
module github.com/thuongtruong109/onelink | ||
|
||
go 1.20 | ||
go 1.21 | ||
|
||
toolchain go1.22.3 | ||
|
||
require ( | ||
github.com/PuerkitoBio/goquery v1.8.1 | ||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 | ||
github.com/go-redis/redis/v8 v8.11.5 | ||
github.com/gofiber/fiber/v2 v2.46.0 | ||
github.com/google/uuid v1.3.0 | ||
github.com/google/uuid v1.6.0 | ||
github.com/joho/godotenv v1.5.1 | ||
github.com/valyala/fasthttp v1.47.0 | ||
github.com/thuongtruong109/gouse v0.0.0-20240808112245-1d582102d4ac | ||
) | ||
|
||
require ( | ||
github.com/andybalholm/brotli v1.0.5 // indirect | ||
github.com/andybalholm/cascadia v1.3.1 // indirect | ||
github.com/cespare/xxhash/v2 v2.1.2 // indirect | ||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect | ||
github.com/klauspost/compress v1.16.3 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.18 // indirect | ||
github.com/mattn/go-runewidth v0.0.14 // indirect | ||
github.com/mattn/go-isatty v0.0.19 // indirect | ||
github.com/mattn/go-runewidth v0.0.15 // indirect | ||
github.com/philhofer/fwd v1.1.2 // indirect | ||
github.com/rivo/uniseg v0.2.0 // indirect | ||
github.com/rivo/uniseg v0.4.4 // indirect | ||
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 // indirect | ||
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect | ||
github.com/tinylib/msgp v1.1.8 // indirect | ||
github.com/valyala/bytebufferpool v1.0.0 // indirect | ||
github.com/valyala/fasthttp v1.47.0 // indirect | ||
github.com/valyala/tcplisten v1.0.0 // indirect | ||
golang.org/x/net v0.8.0 // indirect | ||
golang.org/x/sys v0.8.0 // indirect | ||
golang.org/x/sys v0.20.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package helpers | ||
|
||
import "context" | ||
|
||
var Ctx = context.Background() | ||
|
||
const ( | ||
// API_QUOTA string = "API_QUOTA" | ||
// DOMAIN string = "DOMAIN" | ||
// DOMAIN_RETURN string = "DOMAIN_RETURN" | ||
CANNOT_PARSE_ENV string = "cannot parse ENV keys" | ||
) | ||
|
||
const ( | ||
HTTP_PREFIX string = "http" | ||
HTTP string = "http://" | ||
HTTPS string = "https://" | ||
WWW string = "www." | ||
) | ||
|
||
const ( | ||
COUNTER string = "counter" | ||
INDEX string = "index:" | ||
|
||
CANNOT_CONNECT_TO_DB string = "cannot connect to database" | ||
URL_NOT_FOUND string = "URL not found in database" | ||
CANNOT_RETRIEVE_TO_DB string = "cannot retrieve to database" | ||
CANNOT_RETRIEVE_CLIENT string = "cannot retrieve client" | ||
CANNOT_RETRIEVE_URLS_OF_CLIENT string = "cannot retrieve URLs of client" | ||
CANNOT_RETRIEVE_ALL_URLS string = "cannot retrieve all URLs" | ||
INVALID_URL string = "invalid URL" | ||
CANNOT_SHORTEN_URL string = "cannot shorten this URL" | ||
SHORT_LINK_EXISTS string = "short link already exists" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.