1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-01-23 14:07:13 +02:00

exported .gzip() and .bodyLimit(bytes) JSVM middlewares

This commit is contained in:
Gani Georgiev 2024-01-21 17:13:22 +02:00
parent 702b4aa1c2
commit ba56623245
5 changed files with 3067 additions and 3032 deletions

View File

@ -14,6 +14,8 @@
_Previously on redirect error we were returning directly a standard json error response. Now on redirect error we'll redirect to a generic OAuth2 failure screen (similar to the success one) and will attempt to auto close the OAuth2 popup._
_The SDKs are also updated to handle the OAuth2 redirect error and it will be returned as Promise rejection for the `authWithOAuth2()` call._
- Exposed `$apis.gzip()` and `$apis.bodyLimit(bytes)` middlewares to the JSVM.
- Minor Admin UI improvements (reduced the min table row height, added new TinyMCE codesample plugin languages, hide the collection sync settings when the `Settings.Meta.HideControls` is enabled, etc.)

View File

@ -18,6 +18,7 @@ import (
"github.com/dop251/goja"
validation "github.com/go-ozzo/ozzo-validation/v4"
"github.com/labstack/echo/v5"
"github.com/labstack/echo/v5/middleware"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/apis"
"github.com/pocketbase/pocketbase/core"
@ -618,6 +619,8 @@ func apisBinds(vm *goja.Runtime) {
obj.Set("requireAdminOrRecordAuth", apis.RequireAdminOrRecordAuth)
obj.Set("requireAdminOrOwnerAuth", apis.RequireAdminOrOwnerAuth)
obj.Set("activityLogger", apis.ActivityLogger)
obj.Set("gzip", middleware.Gzip)
obj.Set("bodyLimit", middleware.BodyLimit)
// record helpers
obj.Set("requestInfo", apis.RequestInfo)

View File

@ -956,7 +956,7 @@ func TestApisBindsCount(t *testing.T) {
apisBinds(vm)
testBindsCount(vm, "this", 6, t)
testBindsCount(vm, "$apis", 12, t)
testBindsCount(vm, "$apis", 14, t)
}
func TestApisBindsApiError(t *testing.T) {

File diff suppressed because it is too large Load Diff

View File

@ -978,6 +978,8 @@ declare namespace $apis {
let activityLogger: apis.activityLogger
let requestInfo: apis.requestInfo
let recordAuthResponse: apis.recordAuthResponse
let gzip: middleware.gzip
let bodyLimit: middleware.bodyLimit
let enrichRecord: apis.enrichRecord
let enrichRecords: apis.enrichRecords
}
@ -1053,6 +1055,7 @@ func main() {
gen := tygoja.New(tygoja.Config{
Packages: map[string][]string{
"github.com/labstack/echo/v5/middleware": {"Gzip", "BodyLimit"},
"github.com/go-ozzo/ozzo-validation/v4": {"Error"},
"github.com/pocketbase/dbx": {"*"},
"github.com/pocketbase/pocketbase/tools/security": {"*"},