Skip to content

Commit c2f0efd

Browse files
authored
Merge branch 'development' into add-oidc-middleware
2 parents 9f29991 + 513473b commit c2f0efd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+7503
-1063
lines changed

.github/workflows/go.yml

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -275,45 +275,45 @@ jobs:
275275
name: submodule-coverage-reports
276276
path: coverage_reports/*.cov
277277

278-
# Job for uploading coverage to external services (CodeClimate)
279-
# upload_coverage:
280-
# name: Upload Coverage📊
281-
# runs-on: ubuntu-latest
282-
# # This job only needs example and pkg test results, not submodules
283-
# needs: [Example-Unit-Testing, PKG-Unit-Testing]
284-
# # Only run this job on pushes to the development branch
285-
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development'}}
286-
# steps:
287-
# - name: Check out code into the Go module directory
288-
# uses: actions/checkout@v5
289-
#
290-
# # Download coverage artifacts
291-
# - name: Download Coverage Report
292-
# uses: actions/download-artifact@v5
293-
# with:
294-
# path: artifacts
295-
#
296-
# # Merge coverage from example and pkg tests only
297-
# - name: Merge Coverage Files
298-
# working-directory: artifacts
299-
# run: |
300-
# echo "mode: set" > merged_profile.cov
301-
# tail -n +2 ./Example-Test-Report/profile.cov >> merged_profile.cov
302-
# tail -n +2 ./PKG-Coverage-Report/profile.cov >> merged_profile.cov
303-
#
304-
# # Generate and print total coverage percentage
305-
# echo "Total Coverage:"
306-
# go tool cover -func=merged_profile.cov | tail -n 1
307-
# shell: bash
308-
#
309-
# # Upload merged coverage to CodeClimate for analysis
310-
# - name: Upload
311-
# uses: paambaati/[email protected]
312-
# env:
313-
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
314-
# with:
315-
# coverageLocations: artifacts/merged_profile.cov:gocov
316-
# prefix: gofr.dev
278+
# Job for uploading coverage to external services (qlty.sh)
279+
upload_coverage:
280+
name: Upload Coverage📊
281+
runs-on: ubuntu-latest
282+
# This job only needs example and pkg test results, not submodules
283+
needs: [Example-Unit-Testing, PKG-Unit-Testing]
284+
# Only run this job on pushes to the development branch
285+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development'}}
286+
steps:
287+
- name: Check out code into the Go module directory
288+
uses: actions/checkout@v5
289+
290+
- name: Install qlty CLI
291+
run: curl -s https://qlty.sh/install | bash
292+
293+
# Download coverage artifacts
294+
- name: Download Coverage Report
295+
uses: actions/download-artifact@v5
296+
with:
297+
path: artifacts
298+
299+
# Merge coverage from example and pkg tests only
300+
- name: Merge Coverage Files
301+
working-directory: artifacts
302+
run: |
303+
echo "mode: set" > merged_profile.cov
304+
tail -n +2 ./Example-Test-Report/profile.cov >> merged_profile.cov
305+
tail -n +2 ./PKG-Coverage-Report/profile.cov >> merged_profile.cov
306+
307+
# Generate and print total coverage percentage
308+
echo "Total Coverage:"
309+
go tool cover -func=merged_profile.cov | tail -n 1
310+
shell: bash
311+
312+
# Upload merged coverage to CodeClimate for analysis
313+
- name: Upload
314+
run: qlty coverage publish --input merged_profile.cov
315+
env:
316+
QLTY_TOKEN: ${{ secrets.QLTY_TOKEN }}
317317

318318
# Job for code quality checks
319319
code_quality:

.github/workflows/typos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
- name: Checkout Code
1212
uses: actions/checkout@v5
1313
- name: typos-action
14-
uses: crate-ci/[email protected].3
14+
uses: crate-ci/[email protected].5

.qlty/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*
2+
!configs
3+
!configs/**
4+
!hooks
5+
!hooks/**
6+
!qlty.toml
7+
!.gitignore

.qlty/configs/.hadolint.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ignored:
2+
- DL3008

.qlty/configs/.yamllint.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
rules:
2+
document-start: disable
3+
quoted-strings:
4+
required: only-when-needed
5+
extra-allowed: ["{|}"]
6+
key-duplicates: {}
7+
octal-values:
8+
forbid-implicit-octal: true

.qlty/qlty.toml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# This file was automatically generated by `qlty init`.
2+
# You can modify it to suit your needs.
3+
# We recommend you to commit this file to your repository.
4+
#
5+
# This configuration is used by both Qlty CLI and Qlty Cloud.
6+
#
7+
# Qlty CLI -- Code quality toolkit for developers
8+
# Qlty Cloud -- Fully automated Code Health Platform
9+
#
10+
# Try Qlty Cloud: https://qlty.sh
11+
#
12+
# For a guide to configuration, visit https://qlty.sh/d/config
13+
# Or for a full reference, visit https://qlty.sh/d/qlty-toml
14+
config_version = "0"
15+
16+
exclude_patterns = [
17+
"*_min.*",
18+
"*-min.*",
19+
"*.min.*",
20+
"**/.yarn/**",
21+
"**/*.d.ts",
22+
"**/assets/**",
23+
"**/bower_components/**",
24+
"**/build/**",
25+
"**/cache/**",
26+
"**/config/**",
27+
"**/db/**",
28+
"**/deps/**",
29+
"**/dist/**",
30+
"**/extern/**",
31+
"**/external/**",
32+
"**/generated/**",
33+
"**/Godeps/**",
34+
"**/gradlew/**",
35+
"**/mvnw/**",
36+
"**/node_modules/**",
37+
"**/protos/**",
38+
"**/seed/**",
39+
"**/target/**",
40+
"**/templates/**",
41+
"**/testdata/**",
42+
"**/vendor/**", "**/mock_*", "**/*_test.go",
43+
]
44+
45+
test_patterns = [
46+
"**/test/**",
47+
"**/spec/**",
48+
"**/*.test.*",
49+
"**/*.spec.*",
50+
"**/*_test.*",
51+
"**/*_spec.*",
52+
"**/test_*.*",
53+
"**/spec_*.*",
54+
]
55+
56+
[smells]
57+
mode = "comment"
58+
59+
[smells.boolean_logic]
60+
threshold = 10
61+
enabled = true
62+
63+
[smells.file_complexity]
64+
threshold = 66
65+
enabled = true
66+
67+
[smells.return_statements]
68+
threshold = 8
69+
enabled = true
70+
71+
[smells.nested_control_flow]
72+
threshold = 4
73+
enabled = true
74+
75+
[smells.function_parameters]
76+
threshold = 6
77+
enabled = true
78+
79+
[smells.function_complexity]
80+
threshold = 13
81+
enabled = true
82+
83+
[smells.duplication]
84+
enabled = false
85+
86+
[[source]]
87+
name = "default"
88+
default = true

CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ docker run -d --name arangodb \
9696
-e ARANGO_ROOT_PASSWORD=rootpassword \
9797
--pull always \
9898
arangodb:latest
99+
<<<<<<< HEAD
100+
docker run -d --name db -p 8091-8096:8091-8096 -p 11210-11211:11210-11211 couchbase
101+
=======
102+
docker login container-registry.oracle.com
103+
docker pull container-registry.oracle.com/database/free:latest
104+
docker run -d --name oracle-free -p 1521:1521 -e ORACLE_PWD=YourPasswordHere container-registry.oracle.com/database/free:latest
105+
>>>>>>> origin
99106
```
100107

101108
> [!NOTE]

docs/datasources/couchbase/page.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
## Couchbase
2+
3+
GoFr supports injecting `Couchbase` that implements the following interface. Any driver that implements the interface can be
4+
added using the `app.AddCouchbase()` method, and users can use Couchbase across the application with `gofr.Context`.
5+
6+
```go
7+
type Couchbase interface {
8+
Get(ctx context.Context, key string, result any) error
9+
10+
Insert(ctx context.Context, key string, document, result any) error
11+
12+
Upsert(ctx context.Context, key string, document any, result any) error
13+
14+
Remove(ctx context.Context, key string) error
15+
16+
Query(ctx context.Context, statement string, params map[string]any, result any) error
17+
18+
AnalyticsQuery(ctx context.Context, statement string, params map[string]any, result any) error
19+
}
20+
```
21+
22+
Users can easily inject a driver that supports this interface, providing usability without compromising the extensibility to use multiple databases.
23+
Don't forget to serup the Couchbase cluster in Couchbase Web Console first. [Follow for more details](https://docs.couchbase.com/server/current/install/getting-started-docker.html#section_jvt_zvj_42b).
24+
To begin using Couchbase in your GoFr application, you need to import the Couchbase datasource package:
25+
26+
```shell
27+
go get gofr.dev/pkg/gofr/datasource/couchbase@latest
28+
```
29+
30+
### Example
31+
32+
Here is an example of how to use the Couchbase datasource in a GoFr application:
33+
34+
```go
35+
package main
36+
37+
import (
38+
"context"
39+
"fmt"
40+
"log"
41+
42+
"gofr.dev/pkg/gofr"
43+
"gofr.dev/pkg/gofr/datasource/couchbase"
44+
)
45+
46+
type User struct {
47+
ID string `json:"id"`
48+
Name string `json:"name"`
49+
Age int `json:"age"`
50+
}
51+
52+
func main() {
53+
// Create a new GoFr application
54+
a := gofr.New()
55+
56+
// Add the Couchbase datasource to the application
57+
a.AddCouchbase(couchbase.New(&couchbase.Config{
58+
Host: "localhost",
59+
User: "Administrator",
60+
Password: "password",
61+
Bucket: "test-bucket",
62+
}))
63+
64+
// Add the routes
65+
a.GET("/users/{id}", getUser)
66+
a.POST("/users", createUser)
67+
a.DELETE("/users/{id}", deleteUser)
68+
69+
// Run the application
70+
a.Run()
71+
}
72+
73+
func getUser(c *gofr.Context) (any, error) {
74+
// Get the user ID from the URL path
75+
id := c.PathParam("id")
76+
77+
// Get the user from Couchbase
78+
var user User
79+
if err := c.Couchbase.Get(c, id, &user); err != nil {
80+
return nil, err
81+
}
82+
83+
return user, nil
84+
}
85+
86+
func createUser(c *gofr.Context) (any, error) {
87+
// Get the user from the request body
88+
var user User
89+
if err := c.Bind(&user); err != nil {
90+
return nil, err
91+
}
92+
93+
// Insert the user into Couchbase
94+
if err := c.Couchbase.Insert(c, user.ID, user, nil); err != nil {
95+
return nil, err
96+
}
97+
98+
return "user created successfully", nil
99+
}
100+
101+
func deleteUser(c *gofr.Context) (any, error) {
102+
// Get the user ID from the URL path
103+
id := c.PathParam("id")
104+
105+
// Remove the user from Couchbase
106+
if err := c.Couchbase.Remove(c, id); err != nil {
107+
return nil, err
108+
}
109+
110+
return "user deleted successfully", nil
111+
}
112+
```

docs/datasources/mongodb/page.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func main() {
6666
app.AddMongo(db)
6767

6868
app.POST("/mongo", Insert)
69-
app.GET("/mongo", Get)
69+
app.GET("/mongo/{name}", Get)
7070

7171
app.Run()
7272
}
@@ -89,7 +89,7 @@ func Insert(ctx *gofr.Context) (any, error) {
8989
func Get(ctx *gofr.Context) (any, error) {
9090
var result Person
9191

92-
p := ctx.Param("name")
92+
p := ctx.PathParam("name")
9393

9494
err := ctx.Mongo.FindOne(ctx, "collection", bson.D{{"name", p}} /* valid filter */, &result)
9595
if err != nil {

0 commit comments

Comments
 (0)