Releases: kodefluence/monorepo
Release list
v1.4.0 Upgrade Go & Support Error Source in JSONAPI Package
Release Notes
New Features
- Error Source Parameter Support:
The jsonapi package now supports specifying error sources using theWithSourcePointer,WithSourceParameter, andWithSourceHeaderoptions. These options allow developers to provide detailed references to the primary source of an error, such as JSON pointers, query parameters, or request headers.
Example usage:response := jsonapi.BuildResponse( jsonapi.WithException("ERR400", http.StatusBadRequest, exception.Throw( errors.New("complex error"), exception.WithDetail("Complex error with multiple sources"), exception.WithTitle("Bad Request"), ), jsonapi.WithSourcePointer("/data"), jsonapi.WithSourceParameter("sort"), jsonapi.WithSourceHeader("X-Custom"), ), )
Updates
- Go Version Upgrade:
The project has been updated to use Go 1.24, ensuring compatibility with the latest language features, performance improvements, and security updates. Developers are encouraged to update their Go environment to version 1.24 to take full advantage of these enhancements.
Notes
- Ensure that your Go environment is updated to version 1.24 before building or running the project.
- The new error source options enhance error reporting and debugging, making it easier to identify and resolve issues in API requests.
Full Changelog: v1.3.1...v1.4.0
v1.3.1 Regenerate mock for DB package
Highlight
Re-generate mock for db package
v1.3.0 small addition to db package
Highlight
We're adding new method into db package to eject adapted *sql.DB, in some usecase this would be helpful.
Changes
Added
DB
Easily eject adapted sql.DB
sql := db.Adapt(sqldb)
sqldb = sql.Eject()
v1.2.0 small addition to jsonapi package
Highlight
We're adding new method into jsonapi package to make easier assign set of errors into jsonapi body.
Changes
Added
JSONAPI
WithErrors jsonapi option. This method however would not assign error if the errors is already in the response.
jsonapi.BuildResponse(jsonapi.WithErrors(response.Errors))v1.1.0 codefluence-x renaming, jsonapi package and other additional feature
Highlight
- Change codefluence-x branding into kodefluence
- New jsonapi package which follow the standards of https://jsonapi.org.
- More exception type
Important Notes
We're change our package name into kodefluence. This would be full rebranding for all of our repository and others.
Changes
Added
JSONAPI
jsonapi work as a standard grpc or http response. Usage:
Create new json response.
jsonapi.BuildResponse(jsonapi.WithData(map[string]interface{}{
"name": "testing",
}))It would results with this output
{"data":{"name":"testing"}}Create new json error response with exception
exc1 := exception.Throw(
errors.New("unexpected error"),
exception.WithDetail("detail"),
exception.WithTitle("title"),
)
exc2 := exception.Throw(
errors.New("unexpected error"),
exception.WithDetail("detail_2"),
exception.WithTitle("title_2"),
)
jsonapi.BuildResponse(
jsonapi.WithException("ERR401", http.StatusNotFound, exc1),
jsonapi.WithExceptionMeta("ERR401", http.StatusNotFound, exc2, jsonapi.Meta{
"sample": "sample",
}),
jsonapi.WithMeta("show_error", true),
)Exception
Create 2 new exception, to support more dynamic exception error.
exception.Unauthorized
exception.ForbiddenDB
Add new GetInstance method to get previously defined databases.
sqldb, err = db.FabricateMySQL("main_db", config, db.WithConnMaxLifetime(time.Second), db.WithMaxIdleConn(100), db.WithMaxOpenConn(100))
sqldbvalue, err := db.GetInstance("main_db")v1.0.1 Bug Fix
Monorepo 1.0.0
v1.0.0 is Here!
In this version you could use some of the packages that we're developing which we will describe in this release:
Command
Command is a wrapper for cobra.Command. Usage:
// fabricating command
cmd := command.Fabricate(command.Config{
Name: "altair",
Short: "Open Source API-Gateway",
})DB
DB is a wrapper for any sql.DB which support better unit test functionality and centralized connection control.
// fabricating db
config := db.Config{
Username: "root",
Password: "rootpw",
Host: "localhost",
Port: "3306",
Name: "test_database",
}
sqldb, err := db.FabricateMySQL("main_db", config, db.WithConnMaxLifetime(time.Second), db.WithMaxIdleConn(100), db.WithMaxOpenConn(100))
// next time you open connection, it will return previously created connection instead of creating a new one
sqldb, err := db.FabricateMySQL("main_db", config, db.WithConnMaxLifetime(time.Second), db.WithMaxIdleConn(100), db.WithMaxOpenConn(100))
// close all database connection
db.CloseAll()MemoryStore
MemoryStore is a wrapper for any cache implementation, currently only supporting memcached. But in the future it will also support redis, keydb and other helpful stack.
// fabricate new memcached
memcached := memorystore.FabricateMemcached("main_cache", memorystore.Config{})Exception
Golang rich error wrapper
// throw new exception
err := errors.New("unexpected error")
exceptionType := exception.NotFound
detail := "data not found in the databases because of deletion"
title := "data is not exists"
exc := exception.Throw(err, exception.WithType(exceptionType), exception.WithTitle(title), exception.WithDetail(detail))
if exc.Type() == exception.NotFound {
fmt.Println("The data is not found")
}Context
Golang rich context wrapper
// create new kontext
ctx := context.Background()
ktx := kontext.Fabricate(kontext.WithDefaultContext(ctx))
// pass context in your function and it will keep the variable it gets along the way
key := "some-value"
val := 100
ktx.Set(key, val)
returnedValue, exists := ktx.Get(key)What's Next?
- Distributed rate limiter package
- In-app Queue
- In-app Cronjob