Skip to content

Commit 2518ebc

Browse files
committed
module name changed to due unsupport of package aliasing
1 parent 6facf4b commit 2518ebc

File tree

250 files changed

+836
-790
lines changed

Some content is hidden

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

250 files changed

+836
-790
lines changed

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
## Fork Explanation ❤️ Pocketbase
88
[Pocketbase Documentation](https://pocketbase.io/docs)
99

10+
> Important Note: Go modules does not support module aliasing. So we changed the module name to "github.com/pocketbase/pocketbase" to "github.com/AlperRehaYAZGAN/postgresbase" in go.mod file and all imported package prefixes. You could change it back to "github.com/pocketbase/pocketbase" if you want to customize the project.
11+
12+
1013
Pocketbase is a great product and very efficient for small-mid projects. It has no any additional setup for any other features and it is very easy to use on a single server.
1114

1215
In our use-case we really need to use postgres as a main database and operate it manually. Also we love what Pocketbase does with CRUD operation and RBAC implementations via simple notations. So we want to use it. Thus we forked it and make it compatible with postgres using its own library called ["pocketbase/dbx"](https://github.com/pocketbase/dbx).
@@ -18,6 +21,13 @@ We just added a following features additinonally to the Pocketbase:
1821
- We converted [created and updated columns](https://github.com/AlperRehaYAZGAN/postgresbase/blob/master/migrations/1640988000_init.go#L73-L74) to postgres native date types `TIMESTAMPTZ` to support native date operations
1922
- We write [json functions for postgres](https://github.com/AlperRehaYAZGAN/postgresbase/blob/master/migrations/1640988000_init.go) in migration files to support json equivalent operations from Pocketbase.
2023
- We add support [RSA256 JWT Public Private Keys](https://github.com/AlperRehaYAZGAN/postgresbase/blob/master/tools/security/jwt.go) while encoding and decoding token. In our case we need to implement Pocketbase to our existing project with RSA keypair. Currently (Pocketbase v0.20.5) supports symmetric encoding only and we extend it.
24+
- We add [Dockerfile](./Dockerfile) and [docker-compose.yml](./docker-compose.yml) for building and running the project.
25+
26+
## TODO
27+
28+
29+
- [ ] OAuth2 challenge and state keys stored in cache on single instance. We need to make it remote cache or database to support oauth2 on deployed multiple instances.
30+
- [ ] Jwt Extra Claims support on after login and register.
2131

2232

2333
## Usage
@@ -54,7 +64,7 @@ export JWT_PUBLIC_KEY=$(cat ./keys/public.pem)
5464
CGO_ENABLED=0 \
5565
LOGS_DATABASE="postgresql://user:pass@localhost/logs?sslmode=disable" \
5666
DATABASE="postgresql://user:pass@localhost/postgres?sslmode=disable" \
57-
go run -tags pq github.com/pocketbase/pocketbase/examples/base serve
67+
go run -tags pq ./examples/base serve
5868

5969
```
6070

@@ -78,3 +88,39 @@ docker run -d --name postgresbase \
7888
-e JWT_PUBLIC_KEY="$(cat $PWD/keys/public.pem)" \
7989
<your-name>/postgresbase:1.0.0
8090
```
91+
92+
## Extend Pocketbase (Postgresbase)
93+
We just changed the database connection and added some features to Pocketbase. So you can use all features of current Pocketbase v0.25.0. You could check the [Pocketbase Documentation](https://pocketbase.io/docs) for more information. You can easily use Pocketbase as a library and extend it like shown below.
94+
95+
- Install library
96+
```bash
97+
go get github.com/AlperRehaYAZGAN/postgresbase # go version v1.21 or higher
98+
```
99+
100+
- You can use everything like Pocketbase but only change the import path
101+
```go
102+
package main
103+
104+
import (
105+
"log"
106+
"os"
107+
"time"
108+
109+
pocketbase "github.com/AlperRehaYAZGAN/postgresbase" // ! Just change the import path
110+
"github.com/AlperRehaYAZGAN/postgresbase/core" // ! Just change the import path
111+
"github.com/AlperRehaYAZGAN/postgresbase/plugins/migratecmd" // ! Just change the import path
112+
)
113+
114+
func main() {
115+
app := pocketbase.New()
116+
117+
app.OnAfterBootstrap().PreAdd(func(e *core.BootstrapEvent) error {
118+
app.Dao().ModelQueryTimeout = time.Duration(queryTimeout) * time.Second
119+
return nil
120+
})
121+
122+
if err := app.Start(); err != nil {
123+
log.Fatal(err)
124+
}
125+
}
126+
```

apis/admin.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package apis
33
import (
44
"net/http"
55

6+
"github.com/AlperRehaYAZGAN/postgresbase/core"
7+
"github.com/AlperRehaYAZGAN/postgresbase/forms"
8+
"github.com/AlperRehaYAZGAN/postgresbase/models"
9+
"github.com/AlperRehaYAZGAN/postgresbase/tokens"
10+
"github.com/AlperRehaYAZGAN/postgresbase/tools/routine"
11+
"github.com/AlperRehaYAZGAN/postgresbase/tools/search"
612
"github.com/labstack/echo/v5"
7-
"github.com/pocketbase/pocketbase/core"
8-
"github.com/pocketbase/pocketbase/forms"
9-
"github.com/pocketbase/pocketbase/models"
10-
"github.com/pocketbase/pocketbase/tokens"
11-
"github.com/pocketbase/pocketbase/tools/routine"
12-
"github.com/pocketbase/pocketbase/tools/search"
1313
)
1414

1515
// bindAdminApi registers the admin api endpoints and the corresponding handlers.

apis/admin_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import (
77
"testing"
88
"time"
99

10+
"github.com/AlperRehaYAZGAN/postgresbase/core"
11+
"github.com/AlperRehaYAZGAN/postgresbase/daos"
12+
"github.com/AlperRehaYAZGAN/postgresbase/models"
13+
"github.com/AlperRehaYAZGAN/postgresbase/tests"
14+
"github.com/AlperRehaYAZGAN/postgresbase/tools/types"
1015
"github.com/labstack/echo/v5"
1116
"github.com/pocketbase/dbx"
12-
"github.com/pocketbase/pocketbase/core"
13-
"github.com/pocketbase/pocketbase/daos"
14-
"github.com/pocketbase/pocketbase/models"
15-
"github.com/pocketbase/pocketbase/tests"
16-
"github.com/pocketbase/pocketbase/tools/types"
1717
)
1818

1919
func TestAdminAuthWithPassword(t *testing.T) {

apis/api_error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"net/http"
55
"strings"
66

7+
"github.com/AlperRehaYAZGAN/postgresbase/tools/inflector"
78
validation "github.com/go-ozzo/ozzo-validation/v4"
8-
"github.com/pocketbase/pocketbase/tools/inflector"
99
)
1010

1111
// ApiError defines the struct for a basic api error response.

apis/api_error_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"errors"
66
"testing"
77

8+
"github.com/AlperRehaYAZGAN/postgresbase/apis"
89
validation "github.com/go-ozzo/ozzo-validation/v4"
9-
"github.com/pocketbase/pocketbase/apis"
1010
)
1111

1212
func TestNewApiErrorWithRawData(t *testing.T) {

apis/backup.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import (
66
"path/filepath"
77
"time"
88

9+
"github.com/AlperRehaYAZGAN/postgresbase/core"
10+
"github.com/AlperRehaYAZGAN/postgresbase/forms"
11+
"github.com/AlperRehaYAZGAN/postgresbase/models"
12+
"github.com/AlperRehaYAZGAN/postgresbase/tools/filesystem"
13+
"github.com/AlperRehaYAZGAN/postgresbase/tools/rest"
14+
"github.com/AlperRehaYAZGAN/postgresbase/tools/types"
915
"github.com/labstack/echo/v5"
10-
"github.com/pocketbase/pocketbase/core"
11-
"github.com/pocketbase/pocketbase/forms"
12-
"github.com/pocketbase/pocketbase/models"
13-
"github.com/pocketbase/pocketbase/tools/filesystem"
14-
"github.com/pocketbase/pocketbase/tools/rest"
15-
"github.com/pocketbase/pocketbase/tools/types"
1616
"github.com/spf13/cast"
1717
)
1818

apis/backup_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"strings"
1111
"testing"
1212

13+
"github.com/AlperRehaYAZGAN/postgresbase/core"
14+
"github.com/AlperRehaYAZGAN/postgresbase/tests"
1315
"github.com/labstack/echo/v5"
14-
"github.com/pocketbase/pocketbase/core"
15-
"github.com/pocketbase/pocketbase/tests"
1616
"gocloud.dev/blob"
1717
)
1818

apis/base.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import (
1313
"strings"
1414
"time"
1515

16+
"github.com/AlperRehaYAZGAN/postgresbase/core"
17+
"github.com/AlperRehaYAZGAN/postgresbase/tools/rest"
18+
"github.com/AlperRehaYAZGAN/postgresbase/ui"
1619
"github.com/labstack/echo/v5"
1720
"github.com/labstack/echo/v5/middleware"
18-
"github.com/pocketbase/pocketbase/core"
19-
"github.com/pocketbase/pocketbase/tools/rest"
20-
"github.com/pocketbase/pocketbase/ui"
2121
"github.com/spf13/cast"
2222
)
2323

apis/base_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"strings"
99
"testing"
1010

11+
"github.com/AlperRehaYAZGAN/postgresbase/apis"
12+
"github.com/AlperRehaYAZGAN/postgresbase/tests"
1113
"github.com/labstack/echo/v5"
12-
"github.com/pocketbase/pocketbase/apis"
13-
"github.com/pocketbase/pocketbase/tests"
1414
"github.com/spf13/cast"
1515
)
1616

apis/collection.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package apis
33
import (
44
"net/http"
55

6+
"github.com/AlperRehaYAZGAN/postgresbase/core"
7+
"github.com/AlperRehaYAZGAN/postgresbase/forms"
8+
"github.com/AlperRehaYAZGAN/postgresbase/models"
9+
"github.com/AlperRehaYAZGAN/postgresbase/tools/search"
610
"github.com/labstack/echo/v5"
7-
"github.com/pocketbase/pocketbase/core"
8-
"github.com/pocketbase/pocketbase/forms"
9-
"github.com/pocketbase/pocketbase/models"
10-
"github.com/pocketbase/pocketbase/tools/search"
1111
)
1212

1313
// bindCollectionApi registers the collection api endpoints and the corresponding handlers.

0 commit comments

Comments
 (0)