![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
gitlab.com/package-sh/couchdbutils
Package to manage couchbaseDB
go get gitlab.com/package-sh/couchdbutils
EpressRouterController is a function that creates a router for a given entity
The function will create the following routes:
Return all entities with pagination
/baseURL?currentPage=1&pageSize=10&whereQuery=field1==value1|field2<in>value2,value2&orderByQuery=-field1
|
=, !=, <, >, <=, >=, <in>, !<in>
==, !==, <<, <<=, >>=, <<in>>, !<<in>>
,
Return the entities that match the search
Return the entity with the given id
Create a new entity
Update the entity with the given id
Delete the entity with the given id
type UserEntity{
UserId string `json:"user_id"`
SessionId string `json:"user_session_id"`
Name string `json:"user_name"`
LastName string `json:"user_lastname"`
UserName string `json:"user_username"`
Password string `json:"user_password"`
}
We choose to not show the password attribut throw the API
type UserDTO{
UserId string `json:"user_id"`
SessionId string `json:"user_session_id"`
Name string `json:"user_name"`
LastName string `json:"user_lastname"`
UserName string `json:"user_username"`
}
//The cluster couchBase object
var Cluster *gocb.Cluster
cluster, err = gocb.Connect(
clusterIP,
gocb.ClusterOptions{
Username: clusterAdmin,
Password: pwdCluster,
},
)
// the user couchBase object
var userCollection *gocb.Collection
userCollection= Bucket.Scope(scope).Collection("userList"),
This function will This function is called when a user entity is create of update The goal of this function is to set the right information in the entite object
hydateEntites := func(r *http.Request, id string, newUser *entities.UserEntity, isUpdate bool) error {
// Check if the writing is an update or a new document
if !isUpdate {
// if is not update > then is a creation, we set the new id generated to the entity
neUser.UserId = id
}
// ====================== Check Validity of the entity - BEGIN ======================
// Check if the body is empty
if newUser == nil {
// if the body is empty, we return an error > then the entity be not saved
return couchdbUtils.NewError(400, "Body is required")
}
// ====================== Check Validity of the entity - END ======================
// If all is ok, we return nil > then the entity will be saved
return nil
}
This function is called when a Get is requested This function add mandarory where condition
getPreWhereQuery :=func(r *http.Request) []string {
mandatoryWhereConditionList := []string{}
userId := context.Get(r, "user")
userIdFormated := userId.(string)
//Here we want just all users of the session
mandatoryWhereConditionList = append( whereConditionList , "user_session_id = '"+userIdFormated+"'")
return whereConditionList
}
expressRouterConfig := couchdbUtils.RouterConfig[entities.UserEntity, entities.UserDto]{
Cluster: Cluster,
Router: router,
BaseURL: "/users",
// the name of the id attribute of the entity
IdKey: "user_id",
Collection: UserCollection,
AuthMiddleware: nil,
WithMiddleware: false,
HydrateEntities: hydateEntites,
// the method to not expose
BlackListMethod: []string{"PUT", "POST", "DELETE"},
GetPreWhereQueryGet: getPreWhereQuery,
}
couchdbUtils.ExpressRouterController[entities.UserEntity, entities.UserDto](expressRouterConfig)
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.