Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b21a4c7
Update api.go
mycodedoesnotcompile2 Jun 3, 2025
20e2679
Update api.go
mycodedoesnotcompile2 Jun 3, 2025
9607e4f
Update config.go
mycodedoesnotcompile2 Dec 13, 2025
3b4c17e
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
86823cb
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
56458d4
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
29b5f5f
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
8f75e96
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
e0e8a19
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
f2b44c6
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
07949db
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
0a4e286
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
3c9cda5
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
2d48af0
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
c59e028
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
4ae0b3c
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
21bea85
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
500eca3
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
3e95bb5
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
7d6e0c0
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
39a72c9
Update id_converter.go
mycodedoesnotcompile2 Dec 13, 2025
49c695a
Update id_converter.go
mycodedoesnotcompile2 Dec 13, 2025
94a0f17
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
fd56a32
Update medium_client.go
mycodedoesnotcompile2 Dec 13, 2025
36e5fe6
Update id_converter.go
mycodedoesnotcompile2 Dec 13, 2025
9bb6d7e
Update medium_client.go
mycodedoesnotcompile2 Dec 13, 2025
6c0f2a1
Update id_converter.go
mycodedoesnotcompile2 Dec 13, 2025
f3beb86
Update medium_client.go
mycodedoesnotcompile2 Dec 13, 2025
2965aeb
Update medium_client.go
mycodedoesnotcompile2 Dec 13, 2025
93f30a5
Update medium_client.go
mycodedoesnotcompile2 Dec 13, 2025
d416eba
Update medium_client.go
mycodedoesnotcompile2 Dec 13, 2025
e501775
Update medium_client.go
mycodedoesnotcompile2 Dec 13, 2025
6c9ba43
Update medium_client.go
mycodedoesnotcompile2 Dec 13, 2025
d055ff6
Update medium_client.go
mycodedoesnotcompile2 Dec 13, 2025
348e4e2
Update medium_client.go
mycodedoesnotcompile2 Dec 13, 2025
8b00007
Update medium_client.go
mycodedoesnotcompile2 Dec 13, 2025
9a6d287
Update id_converter.go
mycodedoesnotcompile2 Dec 13, 2025
b387a6d
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
e549b25
Update api.go
mycodedoesnotcompile2 Dec 13, 2025
b5784f6
Update medium_client.go
mycodedoesnotcompile2 Dec 13, 2025
13b3abb
Rename postcss.config.ts to postcss.config.cjs
mycodedoesnotcompile2 Dec 13, 2025
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: 8 additions & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"

"sync"

"github.com/medium.rip/api/routes"
Expand All @@ -16,12 +17,14 @@ import (
)

func RegisterRoutes(ctx context.Context, wg *sync.WaitGroup, engine *html.Engine, fs http.FileSystem) {
// more Fiber options at https://docs.gofiber.io/api/fiber/
app := fiber.New(fiber.Config{
StreamRequestBody: true,
ServerHeader: "Katbox",
AppName: "Katbox",
DisableStartupMessage: true,
Views: engine,
Network: "tcp",
})

// static file server
Expand All @@ -30,6 +33,10 @@ func RegisterRoutes(ctx context.Context, wg *sync.WaitGroup, engine *html.Engine
Browse: config.Conf.Env == "dev",
}))

if config.Conf.Proxy != "" {
log.Printf("Using proxy: %s", config.Conf.Proxy)
}

routes.RegisterRoutes(app)

go func(app *fiber.App) {
Expand All @@ -48,4 +55,4 @@ func RegisterRoutes(ctx context.Context, wg *sync.WaitGroup, engine *html.Engine
log.Warn("Server shutdown Failed: ", err)
}
wg.Done()
}
}
File renamed without changes.
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Config struct {
S3Endpoint string `koanf:"S3_ENDPOINT"`
Env string `koanf:"ENV"`
SecretKey string `koanf:"SECRET_KEY"`
Proxy string `koanf:"PROXY"`
}

var Conf *Config
Expand Down
32 changes: 28 additions & 4 deletions pkg/client/medium_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"net/http"
"os"
"strings"
"net/url"
"crypto/tls"

log "github.com/sirupsen/logrus"

Expand All @@ -30,13 +32,35 @@ func PostData(postId string) (*entities.MediumResponse, error) {
}

// http client to post data
url := "https://medium.com/_/graphql"
urlreq := "https://medium.com/_/graphql"
method := "POST"

payload := strings.NewReader(fmt.Sprintf("{\"query\":\"query {\\n post(id: \\\"%s\\\") {\\n title\\n createdAt\\n creator {\\n id\\n name\\n }\\n content {\\n bodyModel {\\n paragraphs {\\n name\\n text\\n type\\n href\\n layout\\n markups {\\n title\\n type\\n href\\n userId\\n start\\n end\\n anchorType\\n }\\n iframe {\\n mediaResource {\\n href\\n iframeSrc\\n iframeWidth\\n iframeHeight\\n }\\n }\\n metadata {\\n id\\n originalWidth\\n originalHeight\\n }\\n }\\n }\\n }\\n }\\n }\",\"variables\":{}}", postId))

client := &http.Client{}
req, err := http.NewRequest(method, url, payload)
//log.Printf("Article ID: %s", postId)
//log.Printf("PAYLOAD: %s", payload)

var client *http.Client

if config.Conf.Proxy != "" {
proxyURL, err := url.Parse(config.Conf.Proxy)
if err != nil {
panic(err)
}
client = &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(proxyURL),
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}
} else {
client = &http.Client{}
}

req, err := http.NewRequest(method, urlreq, payload)
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36")
if err != nil {
log.Printf("Error constructing request %v\n", err)
return nil, err
Expand Down