Skip to content

Commit

Permalink
Merge pull request #1582 from stakwork/feat/presigned_url
Browse files Browse the repository at this point in the history
Add Presign URL Feature
  • Loading branch information
elraphty authored Mar 4, 2024
2 parents 09829eb + 86d5e2b commit bedff15
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 31 deletions.
26 changes: 12 additions & 14 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"context"
"encoding/json"
"fmt"
"io"
Expand All @@ -11,10 +12,9 @@ import (
"strings"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/s3"
)

var Host string
Expand All @@ -34,7 +34,8 @@ var S3Url string
var AdminCheck string
var AdminDevFreePass = "FREE_PASS"

var S3Client *s3.S3
var S3Client *s3.Client
var PresignClient *s3.PresignClient

func InitConfig() {
Host = os.Getenv("LN_SERVER_BASE_URL")
Expand All @@ -54,21 +55,18 @@ func InitConfig() {
// Add to super admins
SuperAdmins = StripSuperAdmins(AdminStrings)

awsConfig := aws.Config{
Credentials: credentials.NewStaticCredentials(AwsAccess, AwsSecret, ""),
Region: aws.String(AwsRegion),
}

awsSession, err := session.NewSessionWithOptions(session.Options{
Config: awsConfig,
})
awsConfig, err := config.LoadDefaultConfig(context.TODO(),
config.WithRegion(AwsRegion),
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(AwsAccess, AwsSecret, "")),
)

if err != nil {
fmt.Println("Could not setup AWS session", err)
}

// create a s3 client session
S3Client = s3.New(awsSession)
S3Client = s3.NewFromConfig(awsConfig)
PresignClient = s3.NewPresignClient(S3Client)

// only make this call if there is a Relay auth key
if RelayAuthKey != "" {
Expand Down
2 changes: 1 addition & 1 deletion db/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (db database) GetBountiesByDateRange(r PaymentDateRange, re *http.Request)
} else {
orderQuery = " ORDER BY " + sortBy + "" + "DESC"
}
if limit > 0 {
if limit > 1 {
limitQuery = fmt.Sprintf("LIMIT %d OFFSET %d", limit, offset)
}

Expand Down
66 changes: 64 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,101 @@ module github.com/stakwork/sphinx-tribes
go 1.2

require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.16 // indirect
github.com/ClickHouse/clickhouse-go v1.4.3 // indirect
github.com/DATA-DOG/go-sqlmock v1.5.1
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ambelovsky/go-structs v1.1.0
github.com/apache/arrow/go/arrow v0.0.0-20211013220434-5962184e7a30 // indirect
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/aws/aws-sdk-go v1.49.16 // indirect
github.com/aws/aws-sdk-go-v2 v1.25.2 // indirect
github.com/aws/aws-sdk-go-v2/config v1.27.4 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.4 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.5.4 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.51.1 // indirect
github.com/btcsuite/btcd v0.23.5-0.20230905170901-80f5a0ffdf36 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2
github.com/btcsuite/btcd/btcutil v1.1.4-0.20230904040416-d4f519f5dc05 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3
github.com/btcsuite/btcwallet v0.16.10-0.20230804184612-07be54bc22cf // indirect
github.com/cockroachdb/cockroach-go/v2 v2.1.1 // indirect
github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369 // indirect
github.com/decred/dcrd/dcrec/secp256k1 v1.0.4 // indirect
github.com/dhui/dktest v0.3.16 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/fiatjaf/go-lnurl v1.13.1
github.com/fiatjaf/go-lnurl v1.13.0
github.com/form3tech-oss/jwt-go v3.2.5+incompatible
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/fsouza/fake-gcs-server v1.17.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.0 // indirect
github.com/go-chi/chi v1.5.5
github.com/go-chi/jwtauth v1.2.0
github.com/go-co-op/gocron v1.37.0
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/gobuffalo/packr/v2 v2.8.3
github.com/gocql/gocql v0.0.0-20210515062232-b7ef815b4556 // indirect
github.com/google/go-github/v39 v39.2.0
github.com/gorilla/mux v1.7.4 // indirect
github.com/gorilla/websocket v1.5.1
github.com/h2non/gock v1.2.0
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/imroc/req v0.3.2
github.com/jinzhu/gorm v1.9.16
github.com/joho/godotenv v1.5.1
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/ktrysmt/go-bitbucket v0.6.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/lib/pq v1.10.9
github.com/lightninglabs/neutrino v0.16.0 // indirect
github.com/lightningnetwork/lightning-onion v1.2.1-0.20230823005744-06182b1d7d2f // indirect
github.com/lightningnetwork/lnd v0.16.4-beta.rc1 // indirect
github.com/lightningnetwork/lnd/cert v1.2.2 // indirect
github.com/lightningnetwork/lnd/clock v1.1.1 // indirect
github.com/lightningnetwork/lnd/healthcheck v1.2.3 // indirect
github.com/lightningnetwork/lnd/kvdb v1.4.4 // indirect
github.com/lightningnetwork/lnd/queue v1.1.1 // indirect
github.com/lightningnetwork/lnd/ticker v1.1.1 // indirect
github.com/lightningnetwork/lnd/tlv v1.1.1 // indirect
github.com/lightningnetwork/lnd/tor v1.1.2 // indirect
github.com/markbates/pkger v0.15.1 // indirect
github.com/microsoft/go-mssqldb v1.0.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/mutecomm/go-sqlcipher/v4 v4.4.0 // indirect
github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8 // indirect
github.com/nbd-wtf/ln-decodepay v1.11.1
github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba // indirect
github.com/onsi/gomega v1.26.0 // indirect
github.com/ory/dockertest/v3 v3.10.0 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/redis/go-redis/v9 v9.3.0
github.com/rs/cors v1.10.1
github.com/rs/xid v1.5.0
github.com/snowflakedb/gosnowflake v1.6.3 // indirect
github.com/stretchr/testify v1.8.4
github.com/test-go/testify v1.1.4 // indirect
github.com/tuan78/jsonconv v1.0.2
github.com/xanzy/go-gitlab v0.15.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
gitlab.com/nyarla/go-crypt v0.0.0-20160106005555-d9a5dc2b789b // indirect
go.mongodb.org/mongo-driver v1.7.5 // indirect
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 // indirect
golang.org/x/oauth2 v0.15.0
google.golang.org/api v0.153.0
gopkg.in/go-playground/validator.v9 v9.31.0 // indirect
gorm.io/driver/postgres v1.5.4
gorm.io/gorm v1.25.5
modernc.org/b v1.0.0 // indirect
modernc.org/db v1.0.0 // indirect
modernc.org/file v1.0.0 // indirect
modernc.org/fileutil v1.0.0 // indirect
modernc.org/golex v1.0.0 // indirect
modernc.org/internal v1.0.0 // indirect
modernc.org/lldb v1.0.0 // indirect
modernc.org/ql v1.0.0 // indirect
modernc.org/sortutil v1.1.0 // indirect
modernc.org/zappy v1.0.0 // indirect
)
Loading

0 comments on commit bedff15

Please sign in to comment.