Skip to content
Merged
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
17 changes: 9 additions & 8 deletions .github/workflows/builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.25.1'
go-version: '1.25.5'

- name: Build
run: go build -v ./...
- name: Build Servers
run: |
go build ./servers/bullion/main-server/main.go
go build ./servers/jwelly/mysql-to-surreal/main.go
go build ./servers/jwelly/main-server/main.go
go build ./servers/jwelly/mysql-backup/main.go
go build ./servers/jwelly/mysql-to-mysql/main.go
go build ./servers/link-shortner/main.go
go build ./servers/whatsapp-server/main.go
go build -v -ldflags "-s -w" ./servers/bullion/main-server/main.go
go build -v -ldflags "-s -w" ./servers/jwelly/mysql-to-surreal/main.go
go build -v -ldflags "-s -w" ./servers/jwelly/main-server/main.go
go build -v -ldflags "-s -w" ./servers/jwelly/mysql-backup/main.go
go build -v -ldflags "-s -w" ./servers/jwelly/mysql-to-mysql/main.go
go build -v -ldflags "-s -w" ./servers/link-shortner/main.go
go build -v -ldflags "-s -w" ./servers/whatsapp-server/main.go
go build -v -ldflags "-s -w" ./servers/http-dump/dump-server/main.go
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
"args": ["--dev"],
"program": "${workspaceFolder}/servers/bullion/main-server/main.go"
},
{
"name": "Run Dump Server",
"type": "go",
"request": "launch",
"mode": "auto",
"args": ["--dev"],
"program": "${workspaceFolder}/servers/http-dump-server/main.go"
},
{
"name": "Run Whatsapp Server",
"type": "go",
Expand Down
1 change: 1 addition & 0 deletions env/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const FIREBASE_DATABASE_URL_KEY = "FIREBASE_DATABASE_URL"
const REDIS_DB_HOST_KEY = "REDIS_DB_HOST"
const REDIS_DB_PORT_KEY = "REDIS_DB_PORT"
const REDIS_DB_PASSWORD_KEY = "REDIS_DB_PASSWORD"
const REDIS_DB_USERNAME_KEY = "REDIS_DB_USERNAME"
const REDIS_DB_DATABASE_KEY = "REDIS_DB_DATABASE"

// SURREAL DB KEYS
Expand Down
Binary file added http-dump
Binary file not shown.
5 changes: 2 additions & 3 deletions servers/bullion/main-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"time"

"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
j "github.com/golang-jwt/jwt/v5"
"github.com/rpsoftech/golang-servers/env"
"github.com/rpsoftech/golang-servers/interfaces"
Expand All @@ -15,9 +17,6 @@ import (
"github.com/rpsoftech/golang-servers/utility/jwt"
"github.com/rpsoftech/golang-servers/utility/mongodb"
"github.com/rpsoftech/golang-servers/utility/redis"

"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
)

func deferMainFunc() {
Expand Down
12 changes: 12 additions & 0 deletions servers/http-dump/dump-server/api/apis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package dump_server_apis

import (
"github.com/gofiber/fiber/v2"
)

func AddApis(app fiber.Router) {
app.All("/dump/:id<guid>", DumpData)
// auth.AddAuthPackages(app.Group("/auth"))
// data.AddDataPackage(app.Group("/data"))
// order.AddOrderPackage(app.Group("/order"))
}
34 changes: 34 additions & 0 deletions servers/http-dump/dump-server/api/dump.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package dump_server_apis

import (
"net/http"

"github.com/gofiber/fiber/v2"
"github.com/rpsoftech/golang-servers/interfaces"
dump_server_services "github.com/rpsoftech/golang-servers/servers/http-dump/dump-server/services"
)

func DumpData(c *fiber.Ctx) error {
id := c.Params("id")
if id == "" {
return &interfaces.RequestError{
StatusCode: http.StatusBadRequest,
Code: interfaces.ERROR_INVALID_INPUT,
Message: "Please Pass Valid UUID Endpoint",
Name: "INVALID_INPUT",
}
}

bodyBytes := c.Body()

// Convert the byte slice to a string if needed
bodyString := string(bodyBytes)

// You can then manually unmarshal it using the standard "encoding/json" package
// var data map[string]interface{}
// if err := json.Unmarshal(bodyBytes, &data); err != nil {
// return c.Status(fiber.StatusBadRequest).SendString(err.Error())
// }
return dump_server_services.EndPointService.DumpData(id, bodyString)

}
24 changes: 24 additions & 0 deletions servers/http-dump/dump-server/env/index.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dump_server_env

import "github.com/rpsoftech/golang-servers/env"

type dumpEnv struct {
DefaultEnv *env.DefaultEnvInterface
REDIS_DEFAULT_KEY string `json:"REDIS_DEFAULT_KEY" validate:"required,min=3"`
REDIS_DEFAULT_CHANNEL string `json:"REDIS_DEFAULT_CHANNEL" validate:"required,min=3"`
}

var Env *dumpEnv

func init() {
env.LoadEnv("http-dump-server.env")
println("Dump Server Env Initialized")
Env = &dumpEnv{
DefaultEnv: env.Env,
REDIS_DEFAULT_KEY: env.Env.GetEnv("REDIS_DEFAULT_KEY"),
REDIS_DEFAULT_CHANNEL: env.Env.GetEnv("REDIS_DEFAULT_CHANNEL"),
// ACCESS_TOKEN_KEY: env.Env.GetEnv("ACCESS_TOKEN_KEY"),
// REFRESH_TOKEN_KEY: env.Env.GetEnv("REFRESH_TOKEN_KEY"),
}
env.ValidateEnv(Env)
}
10 changes: 10 additions & 0 deletions servers/http-dump/dump-server/env/redis.key-env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dump_server_env

import "fmt"

func GetRedisKey(key string) string {
return fmt.Sprintf("%s%s", Env.REDIS_DEFAULT_KEY, key)
}
func GetRedisEventKey(key string) string {
return fmt.Sprintf("%s%s", Env.REDIS_DEFAULT_CHANNEL, key)
}
25 changes: 25 additions & 0 deletions servers/http-dump/dump-server/events/dump-base.event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package dump_server_events

import (
"encoding/json"
"fmt"

"github.com/rpsoftech/golang-servers/events"
dump_server_env "github.com/rpsoftech/golang-servers/servers/http-dump/dump-server/env"
)

type DumpServerBaseEvent struct {
*events.BaseEvent `bson:"inline"`
DumpId string `bson:"dumpId" json:"dumpId" validate:"required,uuid"`
}

func (base *DumpServerBaseEvent) GetPayloadString() string {
if base.DataString != "" {
return base.DataString
}
payload, _ := json.Marshal(base)
return string(payload)
}
func (base *DumpServerBaseEvent) GetEventName() string {
return dump_server_env.GetRedisEventKey(fmt.Sprintf("event/%s/%s", base.DumpId, base.EventName))
}
29 changes: 29 additions & 0 deletions servers/http-dump/dump-server/events/dump-details.event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package dump_server_events

import "github.com/rpsoftech/golang-servers/events"

type dumpDataEvent struct {
*DumpServerBaseEvent `bson:"inline"`
}

func (base *dumpDataEvent) Add() *dumpDataEvent {
base.ParentNames = []string{base.EventName, "BankDetailsEvent"}
base.DumpServerBaseEvent.CreateBaseEvent()
return base
}

func CreateDumpEvent(id string, data string) *DumpServerBaseEvent {
event := &dumpDataEvent{
DumpServerBaseEvent: &DumpServerBaseEvent{
BaseEvent: &events.BaseEvent{
KeyId: id,
Payload: data,
DataString: data,
EventName: "DumpDataEvent",
},
DumpId: id,
},
}
event.Add()
return event.DumpServerBaseEvent
}
26 changes: 26 additions & 0 deletions servers/http-dump/dump-server/interfaces/admin-user.entity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package dump_server_interfaces

import "github.com/rpsoftech/golang-servers/interfaces"

type EndPoint struct {
*interfaces.BaseEntity `bson:"inline"`
Name string `bson:"name" json:"name" validate:"required,min=3,max=100"`
Desc string `bson:"desc,omitempty" json:"desc,omitempty" validate:"required,min=3,max=100"`
CustomChanel string `bson:"customChanel" json:"customChanel" validate:"required,min=3,max=100"`
}

func (endPoint *EndPoint) CreateNewEntity(Name string, Desc string, CustomChanel string) *EndPoint {
endPoint.BaseEntity = &interfaces.BaseEntity{}
endPoint.Desc = Desc
endPoint.Name = Name
endPoint.CustomChanel = CustomChanel
endPoint.CreateNewId()
return endPoint
}

func (endPoint *EndPoint) GetChanel() string {
if endPoint.CustomChanel == "" {
endPoint.CustomChanel = endPoint.ID
}
return endPoint.CustomChanel
}
57 changes: 57 additions & 0 deletions servers/http-dump/dump-server/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package main

import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/rpsoftech/golang-servers/env"
"github.com/rpsoftech/golang-servers/interfaces"
dump_server_apis "github.com/rpsoftech/golang-servers/servers/http-dump/dump-server/api"
_ "github.com/rpsoftech/golang-servers/servers/http-dump/dump-server/env"
"github.com/rpsoftech/golang-servers/utility/mongodb"
"github.com/rpsoftech/golang-servers/utility/redis"
)

func deferMainFunc() {
println("Closing...")
mongodb.DeferFunction()
redis.DeferFunction()
}

func main() {
defer deferMainFunc()
// env.LoadEnv("http-dump-server.env")
println("Http Dump Server Env Initialized")
app := fiber.New(fiber.Config{
ServerHeader: "Http Dump Server V1.0.0",
ErrorHandler: func(c *fiber.Ctx, err error) error {
mappedError, ok := err.(*interfaces.RequestError)
if !ok {
println(err.Error())
return c.Status(500).JSON(interfaces.RequestError{
Code: interfaces.ERROR_INTERNAL_SERVER,
Message: "Some Internal Error",
Name: "Global Error Handler Function",
})
}
if mappedError.LogTheDetails {
//Todo: Store The Details Of the Error With Body And Other Extra Details Like AUTH KEY AND ETC
}
return c.Status(mappedError.StatusCode).JSON(mappedError)
},
})
app.Use(logger.New())
dump_server_apis.AddApis(app.Group("/v1"))
app.Use(func(c *fiber.Ctx) error {
return c.Status(fiber.StatusNotFound).SendString("Sorry can't find that!")
})
// entity := new(dump_server_interfaces.EndPoint)
// entity.CreateNewEntity("Testing", "TESTING LOCAL", "56397cab-7246-4d1c-ac14-c3446317e67b")
// entity.BaseEntity.ID = "56397cab-7246-4d1c-ac14-c3446317e67b"
// dump_server_repos.EndPointRepo.Save(entity)
hostAndPort := ""
if env.Env.APP_ENV == env.APP_ENV_LOCAL || env.Env.APP_ENV == env.APP_ENV_DEVELOPE {
hostAndPort = "127.0.0.1"
}
hostAndPort = hostAndPort + ":" + env.GetServerPort(env.PORT_KEY)
app.Listen(hostAndPort)
}
Loading