@based/server 4.0.1 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/defaultConfig.d.ts +3 -0
- package/dist/auth/defaultConfig.js +12 -0
- package/dist/auth/defaultConfig.js.map +1 -0
- package/dist/auth/index.d.ts +12 -6
- package/dist/auth/index.js +31 -20
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/parseAuthState.d.ts +2 -1
- package/dist/auth/parseAuthState.js +28 -6
- package/dist/auth/parseAuthState.js.map +1 -1
- package/dist/authorize.d.ts +9 -0
- package/dist/authorize.js +59 -0
- package/dist/authorize.js.map +1 -0
- package/dist/compress.js +3 -0
- package/dist/compress.js.map +1 -1
- package/dist/createSimpleServer.d.ts +20 -10
- package/dist/createSimpleServer.js +64 -53
- package/dist/createSimpleServer.js.map +1 -1
- package/dist/error/errorTypeHandlers.js +31 -12
- package/dist/error/errorTypeHandlers.js.map +1 -1
- package/dist/error/index.d.ts +11 -1
- package/dist/error/index.js +9 -10
- package/dist/error/index.js.map +1 -1
- package/dist/error/types.d.ts +41 -45
- package/dist/error/types.js +3 -1
- package/dist/error/types.js.map +1 -1
- package/dist/functionApi/callFunction copy.d.ts +3 -0
- package/dist/functionApi/callFunction copy.js +29 -0
- package/dist/functionApi/callFunction copy.js.map +1 -0
- package/dist/functionApi/callFunction.d.ts +3 -0
- package/dist/functionApi/callFunction.js +29 -0
- package/dist/functionApi/callFunction.js.map +1 -0
- package/dist/functionApi/client/index.d.ts +17 -0
- package/dist/functionApi/client/index.js +54 -0
- package/dist/functionApi/client/index.js.map +1 -0
- package/dist/functionApi/client/query.d.ts +11 -0
- package/dist/functionApi/client/query.js +32 -0
- package/dist/functionApi/client/query.js.map +1 -0
- package/dist/functionApi/get.d.ts +3 -0
- package/dist/functionApi/get.js +71 -0
- package/dist/functionApi/get.js.map +1 -0
- package/dist/functionApi/index.d.ts +5 -0
- package/dist/functionApi/index.js +25 -0
- package/dist/functionApi/index.js.map +1 -0
- package/dist/functionApi/observe.d.ts +4 -0
- package/dist/functionApi/observe.js +44 -0
- package/dist/functionApi/observe.js.map +1 -0
- package/dist/functionApi/stream.d.ts +3 -0
- package/dist/functionApi/stream.js +30 -0
- package/dist/functionApi/stream.js.map +1 -0
- package/dist/functions/index.d.ts +16 -8
- package/dist/functions/index.js +39 -10
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/timeout.d.ts +3 -3
- package/dist/functions/timeout.js.map +1 -1
- package/dist/functions/types.d.ts +45 -31
- package/dist/functions/types.js +40 -12
- package/dist/functions/types.js.map +1 -1
- package/dist/incoming/http/function.d.ts +3 -4
- package/dist/incoming/http/function.js +29 -35
- package/dist/incoming/http/function.js.map +1 -1
- package/dist/incoming/http/get.d.ts +3 -3
- package/dist/incoming/http/get.js +44 -43
- package/dist/incoming/http/get.js.map +1 -1
- package/dist/incoming/http/index.js +50 -31
- package/dist/incoming/http/index.js.map +1 -1
- package/dist/incoming/http/parseQuery.d.ts +1 -1
- package/dist/incoming/http/parseQuery.js +3 -1
- package/dist/incoming/http/parseQuery.js.map +1 -1
- package/dist/incoming/http/query.d.ts +4 -0
- package/dist/incoming/http/query.js +165 -0
- package/dist/incoming/http/query.js.map +1 -0
- package/dist/incoming/http/readBody.d.ts +4 -3
- package/dist/incoming/http/readBody.js +32 -8
- package/dist/incoming/http/readBody.js.map +1 -1
- package/dist/incoming/http/streamFunction/DataStream.d.ts +8 -0
- package/dist/incoming/http/streamFunction/DataStream.js +42 -3
- package/dist/incoming/http/streamFunction/DataStream.js.map +1 -1
- package/dist/incoming/http/streamFunction/getExtension.d.ts +1 -1
- package/dist/incoming/http/streamFunction/index.d.ts +3 -3
- package/dist/incoming/http/streamFunction/index.js +6 -87
- package/dist/incoming/http/streamFunction/index.js.map +1 -1
- package/dist/incoming/http/streamFunction/multiPart/index.d.ts +4 -0
- package/dist/incoming/http/streamFunction/multiPart/index.js +66 -0
- package/dist/incoming/http/streamFunction/multiPart/index.js.map +1 -0
- package/dist/incoming/http/streamFunction/multiPart/readFormData.d.ts +12 -0
- package/dist/incoming/http/streamFunction/{multipartStream.js → multiPart/readFormData.js} +80 -86
- package/dist/incoming/http/streamFunction/multiPart/readFormData.js.map +1 -0
- package/dist/incoming/http/streamFunction/stream/createStream.d.ts +6 -0
- package/dist/incoming/http/streamFunction/{stream.js → stream/createStream.js} +5 -38
- package/dist/incoming/http/streamFunction/stream/createStream.js.map +1 -0
- package/dist/incoming/http/streamFunction/stream/index.d.ts +4 -0
- package/dist/incoming/http/streamFunction/stream/index.js +70 -0
- package/dist/incoming/http/streamFunction/stream/index.js.map +1 -0
- package/dist/incoming/index.d.ts +1 -1
- package/dist/incoming/index.js +13 -11
- package/dist/incoming/index.js.map +1 -1
- package/dist/incoming/upgrade.js +18 -9
- package/dist/incoming/upgrade.js.map +1 -1
- package/dist/incoming/ws/auth.d.ts +4 -4
- package/dist/incoming/ws/auth.js +37 -19
- package/dist/incoming/ws/auth.js.map +1 -1
- package/dist/incoming/ws/function.d.ts +2 -3
- package/dist/incoming/ws/function.js +21 -73
- package/dist/incoming/ws/function.js.map +1 -1
- package/dist/incoming/ws/get.d.ts +2 -3
- package/dist/incoming/ws/get.js +33 -54
- package/dist/incoming/ws/get.js.map +1 -1
- package/dist/incoming/ws/index.d.ts +1 -1
- package/dist/incoming/ws/index.js +2 -1
- package/dist/incoming/ws/index.js.map +1 -1
- package/dist/incoming/ws/observable.d.ts +7 -6
- package/dist/incoming/ws/observable.js +25 -49
- package/dist/incoming/ws/observable.js.map +1 -1
- package/dist/incoming/ws/types.d.ts +3 -0
- package/dist/{auth → incoming/ws}/types.js +0 -0
- package/dist/{auth → incoming/ws}/types.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/installFn.d.ts +4 -0
- package/dist/installFn.js +94 -0
- package/dist/installFn.js.map +1 -0
- package/dist/observable/create.d.ts +1 -1
- package/dist/observable/create.js +5 -1
- package/dist/observable/create.js.map +1 -1
- package/dist/observable/destroy.js +1 -1
- package/dist/observable/destroy.js.map +1 -1
- package/dist/observable/index.d.ts +0 -1
- package/dist/observable/index.js +0 -1
- package/dist/observable/index.js.map +1 -1
- package/dist/observable/send.d.ts +3 -3
- package/dist/observable/send.js +2 -8
- package/dist/observable/send.js.map +1 -1
- package/dist/observable/start/error.d.ts +2 -1
- package/dist/observable/start/error.js +13 -11
- package/dist/observable/start/error.js.map +1 -1
- package/dist/observable/start/index.js +17 -8
- package/dist/observable/start/index.js.map +1 -1
- package/dist/observable/subscribe.d.ts +3 -3
- package/dist/observable/subscribe.js +6 -12
- package/dist/observable/subscribe.js.map +1 -1
- package/dist/observable/types.d.ts +6 -5
- package/dist/observable/unsub.d.ts +1 -1
- package/dist/observable/unsub.js.map +1 -1
- package/dist/protocol.d.ts +1 -0
- package/dist/protocol.js +11 -1
- package/dist/protocol.js.map +1 -1
- package/dist/security.d.ts +1 -1
- package/dist/security.js +1 -1
- package/dist/security.js.map +1 -1
- package/dist/sendError.d.ts +3 -2
- package/dist/sendError.js +30 -16
- package/dist/sendError.js.map +1 -1
- package/dist/sendHttpResponse.d.ts +3 -2
- package/dist/sendHttpResponse.js +62 -10
- package/dist/sendHttpResponse.js.map +1 -1
- package/dist/server.d.ts +10 -3
- package/dist/server.js +16 -4
- package/dist/server.js.map +1 -1
- package/dist/verifyRoute.d.ts +14 -0
- package/dist/verifyRoute.js +99 -0
- package/dist/verifyRoute.js.map +1 -0
- package/package.json +4 -2
- package/dist/BasedServerClient.d.ts +0 -71
- package/dist/BasedServerClient.js +0 -390
- package/dist/BasedServerClient.js.map +0 -1
- package/dist/Client.d.ts +0 -75
- package/dist/Client.js +0 -277
- package/dist/Client.js.map +0 -1
- package/dist/Params.d.ts +0 -20
- package/dist/Params.js +0 -48
- package/dist/Params.js.map +0 -1
- package/dist/api/index.d.ts +0 -7
- package/dist/api/index.js +0 -173
- package/dist/api/index.js.map +0 -1
- package/dist/auth/authorize.d.ts +0 -2
- package/dist/auth/authorize.js +0 -8
- package/dist/auth/authorize.js.map +0 -1
- package/dist/auth/dummyAuth.d.ts +0 -2
- package/dist/auth/dummyAuth.js +0 -8
- package/dist/auth/dummyAuth.js.map +0 -1
- package/dist/auth/types.d.ts +0 -10
- package/dist/clientContext.d.ts +0 -0
- package/dist/clientContext.js +0 -83
- package/dist/clientContext.js.map +0 -1
- package/dist/closeListener.d.ts +0 -4
- package/dist/closeListener.js +0 -13
- package/dist/closeListener.js.map +0 -1
- package/dist/context.d.ts +0 -54
- package/dist/context.js +0 -18
- package/dist/context.js.map +0 -1
- package/dist/error.d.ts +0 -66
- package/dist/error.js +0 -149
- package/dist/error.js.map +0 -1
- package/dist/findPrefix.d.ts +0 -3
- package/dist/findPrefix.js +0 -20
- package/dist/findPrefix.js.map +0 -1
- package/dist/functions/workerPool.d.ts +0 -0
- package/dist/functions/workerPool.js +0 -5
- package/dist/functions/workerPool.js.map +0 -1
- package/dist/getFromConfig.d.ts +0 -3
- package/dist/getFromConfig.js +0 -50
- package/dist/getFromConfig.js.map +0 -1
- package/dist/handlers/authorize.d.ts +0 -5
- package/dist/handlers/authorize.js +0 -196
- package/dist/handlers/authorize.js.map +0 -1
- package/dist/handlers/bulkUpdate/index.d.ts +0 -5
- package/dist/handlers/bulkUpdate/index.js +0 -26
- package/dist/handlers/bulkUpdate/index.js.map +0 -1
- package/dist/handlers/configuration/index.d.ts +0 -10
- package/dist/handlers/configuration/index.js +0 -74
- package/dist/handlers/configuration/index.js.map +0 -1
- package/dist/handlers/configuration/observable/index.d.ts +0 -46
- package/dist/handlers/configuration/observable/index.js +0 -277
- package/dist/handlers/configuration/observable/index.js.map +0 -1
- package/dist/handlers/configure/index.d.ts +0 -5
- package/dist/handlers/configure/index.js +0 -44
- package/dist/handlers/configure/index.js.map +0 -1
- package/dist/handlers/copy/index.d.ts +0 -8
- package/dist/handlers/copy/index.js +0 -135
- package/dist/handlers/copy/index.js.map +0 -1
- package/dist/handlers/delete/index.d.ts +0 -5
- package/dist/handlers/delete/index.js +0 -34
- package/dist/handlers/delete/index.js.map +0 -1
- package/dist/handlers/digest/index.d.ts +0 -5
- package/dist/handlers/digest/index.js +0 -23
- package/dist/handlers/digest/index.js.map +0 -1
- package/dist/handlers/functions/call.d.ts +0 -6
- package/dist/handlers/functions/call.js +0 -54
- package/dist/handlers/functions/call.js.map +0 -1
- package/dist/handlers/functions/observable/Observable.d.ts +0 -49
- package/dist/handlers/functions/observable/Observable.js +0 -290
- package/dist/handlers/functions/observable/Observable.js.map +0 -1
- package/dist/handlers/functions/observable/SharedObservable.d.ts +0 -45
- package/dist/handlers/functions/observable/SharedObservable.js +0 -291
- package/dist/handlers/functions/observable/SharedObservable.js.map +0 -1
- package/dist/handlers/functions/observable/index.d.ts +0 -14
- package/dist/handlers/functions/observable/index.js +0 -130
- package/dist/handlers/functions/observable/index.js.map +0 -1
- package/dist/handlers/get/index.d.ts +0 -5
- package/dist/handlers/get/index.js +0 -23
- package/dist/handlers/get/index.js.map +0 -1
- package/dist/handlers/getConfig/index.d.ts +0 -5
- package/dist/handlers/getConfig/index.js +0 -38
- package/dist/handlers/getConfig/index.js.map +0 -1
- package/dist/handlers/handleRequests.d.ts +0 -5
- package/dist/handlers/handleRequests.js +0 -78
- package/dist/handlers/handleRequests.js.map +0 -1
- package/dist/handlers/index.d.ts +0 -4
- package/dist/handlers/index.js +0 -49
- package/dist/handlers/index.js.map +0 -1
- package/dist/handlers/messageParser.d.ts +0 -5
- package/dist/handlers/messageParser.js +0 -122
- package/dist/handlers/messageParser.js.map +0 -1
- package/dist/handlers/removeField/index.d.ts +0 -5
- package/dist/handlers/removeField/index.js +0 -42
- package/dist/handlers/removeField/index.js.map +0 -1
- package/dist/handlers/removeType/index.d.ts +0 -5
- package/dist/handlers/removeType/index.js +0 -30
- package/dist/handlers/removeType/index.js.map +0 -1
- package/dist/handlers/rest/file/DataStream.d.ts +0 -7
- package/dist/handlers/rest/file/DataStream.js +0 -17
- package/dist/handlers/rest/file/DataStream.js.map +0 -1
- package/dist/handlers/rest/file/formStream.d.ts +0 -4
- package/dist/handlers/rest/file/formStream.js +0 -188
- package/dist/handlers/rest/file/formStream.js.map +0 -1
- package/dist/handlers/rest/file/getExtenstion.d.ts +0 -2
- package/dist/handlers/rest/file/getExtenstion.js +0 -22
- package/dist/handlers/rest/file/getExtenstion.js.map +0 -1
- package/dist/handlers/rest/file/index.d.ts +0 -4
- package/dist/handlers/rest/file/index.js +0 -53
- package/dist/handlers/rest/file/index.js.map +0 -1
- package/dist/handlers/rest/file/storeFile.d.ts +0 -6
- package/dist/handlers/rest/file/storeFile.js +0 -44
- package/dist/handlers/rest/file/storeFile.js.map +0 -1
- package/dist/handlers/rest/file/stream.d.ts +0 -5
- package/dist/handlers/rest/file/stream.js +0 -104
- package/dist/handlers/rest/file/stream.js.map +0 -1
- package/dist/handlers/rest/file/types.d.ts +0 -9
- package/dist/handlers/rest/file/types.js +0 -3
- package/dist/handlers/rest/file/types.js.map +0 -1
- package/dist/handlers/rest/getReqMessage.d.ts +0 -3
- package/dist/handlers/rest/getReqMessage.js +0 -92
- package/dist/handlers/rest/getReqMessage.js.map +0 -1
- package/dist/handlers/rest/index.d.ts +0 -4
- package/dist/handlers/rest/index.js +0 -121
- package/dist/handlers/rest/index.js.map +0 -1
- package/dist/handlers/rest/invalidReq.d.ts +0 -4
- package/dist/handlers/rest/invalidReq.js +0 -20
- package/dist/handlers/rest/invalidReq.js.map +0 -1
- package/dist/handlers/rest/parseResponse.d.ts +0 -6
- package/dist/handlers/rest/parseResponse.js +0 -230
- package/dist/handlers/rest/parseResponse.js.map +0 -1
- package/dist/handlers/rest/playground/index.d.ts +0 -5
- package/dist/handlers/rest/playground/index.js +0 -308
- package/dist/handlers/rest/playground/index.js.map +0 -1
- package/dist/handlers/rest/readBody.d.ts +0 -3
- package/dist/handlers/rest/readBody.js +0 -45
- package/dist/handlers/rest/readBody.js.map +0 -1
- package/dist/handlers/set/index.d.ts +0 -5
- package/dist/handlers/set/index.js +0 -20
- package/dist/handlers/set/index.js.map +0 -1
- package/dist/handlers/subscription/index.d.ts +0 -32
- package/dist/handlers/subscription/index.js +0 -223
- package/dist/handlers/subscription/index.js.map +0 -1
- package/dist/handlers/token.d.ts +0 -5
- package/dist/handlers/token.js +0 -122
- package/dist/handlers/token.js.map +0 -1
- package/dist/handlers/track/index.d.ts +0 -7
- package/dist/handlers/track/index.js +0 -102
- package/dist/handlers/track/index.js.map +0 -1
- package/dist/handlers/userAuth/index.d.ts +0 -5
- package/dist/handlers/userAuth/index.js +0 -78
- package/dist/handlers/userAuth/index.js.map +0 -1
- package/dist/incoming/http/authorize.d.ts +0 -4
- package/dist/incoming/http/authorize.js +0 -37
- package/dist/incoming/http/authorize.js.map +0 -1
- package/dist/incoming/http/streamFunction/multipartStream.d.ts +0 -13
- package/dist/incoming/http/streamFunction/multipartStream.js.map +0 -1
- package/dist/incoming/http/streamFunction/stream.d.ts +0 -6
- package/dist/incoming/http/streamFunction/stream.js.map +0 -1
- package/dist/network/http/authorize.d.ts +0 -3
- package/dist/network/http/authorize.js +0 -28
- package/dist/network/http/authorize.js.map +0 -1
- package/dist/network/http/compress.d.ts +0 -6
- package/dist/network/http/compress.js +0 -56
- package/dist/network/http/compress.js.map +0 -1
- package/dist/network/http/end.d.ts +0 -4
- package/dist/network/http/end.js +0 -19
- package/dist/network/http/end.js.map +0 -1
- package/dist/network/http/function.d.ts +0 -3
- package/dist/network/http/function.js +0 -47
- package/dist/network/http/function.js.map +0 -1
- package/dist/network/http/get.d.ts +0 -3
- package/dist/network/http/get.js +0 -129
- package/dist/network/http/get.js.map +0 -1
- package/dist/network/http/index.d.ts +0 -3
- package/dist/network/http/index.js +0 -122
- package/dist/network/http/index.js.map +0 -1
- package/dist/network/http/readBody.d.ts +0 -3
- package/dist/network/http/readBody.js +0 -112
- package/dist/network/http/readBody.js.map +0 -1
- package/dist/network/http/send.d.ts +0 -5
- package/dist/network/http/send.js +0 -60
- package/dist/network/http/send.js.map +0 -1
- package/dist/network/http/streamFunction/DataStream.d.ts +0 -7
- package/dist/network/http/streamFunction/DataStream.js +0 -19
- package/dist/network/http/streamFunction/DataStream.js.map +0 -1
- package/dist/network/http/streamFunction/getExtension.d.ts +0 -2
- package/dist/network/http/streamFunction/getExtension.js +0 -29
- package/dist/network/http/streamFunction/getExtension.js.map +0 -1
- package/dist/network/http/streamFunction/index.d.ts +0 -3
- package/dist/network/http/streamFunction/index.js +0 -81
- package/dist/network/http/streamFunction/index.js.map +0 -1
- package/dist/network/http/streamFunction/multipartStream.d.ts +0 -12
- package/dist/network/http/streamFunction/multipartStream.js +0 -208
- package/dist/network/http/streamFunction/multipartStream.js.map +0 -1
- package/dist/network/http/streamFunction/stream.d.ts +0 -5
- package/dist/network/http/streamFunction/stream.js +0 -103
- package/dist/network/http/streamFunction/stream.js.map +0 -1
- package/dist/network/index.d.ts +0 -4
- package/dist/network/index.js +0 -84
- package/dist/network/index.js.map +0 -1
- package/dist/network/message/auth.d.ts +0 -4
- package/dist/network/message/auth.js +0 -32
- package/dist/network/message/auth.js.map +0 -1
- package/dist/network/message/function.d.ts +0 -3
- package/dist/network/message/function.js +0 -67
- package/dist/network/message/function.js.map +0 -1
- package/dist/network/message/get.d.ts +0 -3
- package/dist/network/message/get.js +0 -109
- package/dist/network/message/get.js.map +0 -1
- package/dist/network/message/index.d.ts +0 -3
- package/dist/network/message/index.js +0 -62
- package/dist/network/message/index.js.map +0 -1
- package/dist/network/message/observable.d.ts +0 -5
- package/dist/network/message/observable.js +0 -103
- package/dist/network/message/observable.js.map +0 -1
- package/dist/network/message/send.d.ts +0 -4
- package/dist/network/message/send.js +0 -11
- package/dist/network/message/send.js.map +0 -1
- package/dist/network/upgrade.d.ts +0 -4
- package/dist/network/upgrade.js +0 -49
- package/dist/network/upgrade.js.map +0 -1
- package/dist/network/worker/get.d.ts +0 -0
- package/dist/network/worker/get.js +0 -122
- package/dist/network/worker/get.js.map +0 -1
- package/dist/network/worker/observable.d.ts +0 -0
- package/dist/network/worker/observable.js +0 -120
- package/dist/network/worker/observable.js.map +0 -1
- package/dist/observable/error.d.ts +0 -4
- package/dist/observable/error.js +0 -17
- package/dist/observable/error.js.map +0 -1
- package/dist/observable/verify.d.ts +0 -4
- package/dist/observable/verify.js +0 -18
- package/dist/observable/verify.js.map +0 -1
- package/dist/openListener.d.ts +0 -4
- package/dist/openListener.js +0 -13
- package/dist/openListener.js.map +0 -1
- package/dist/secrets.d.ts +0 -9
- package/dist/secrets.js +0 -150
- package/dist/secrets.js.map +0 -1
- package/dist/security/index.d.ts +0 -3
- package/dist/security/index.js +0 -66
- package/dist/security/index.js.map +0 -1
- package/dist/types.d.ts +0 -129
- package/dist/types.js +0 -17
- package/dist/types.js.map +0 -1
- package/dist/upgradeListener.d.ts +0 -4
- package/dist/upgradeListener.js +0 -47
- package/dist/upgradeListener.js.map +0 -1
- package/dist/worker/authorize.d.ts +0 -5
- package/dist/worker/authorize.js +0 -15
- package/dist/worker/authorize.js.map +0 -1
- package/dist/worker/fnMap.d.ts +0 -2
- package/dist/worker/fnMap.js +0 -5
- package/dist/worker/fnMap.js.map +0 -1
- package/dist/worker/functions.d.ts +0 -3
- package/dist/worker/functions.js +0 -8
- package/dist/worker/functions.js.map +0 -1
- package/dist/worker/http/function.d.ts +0 -4
- package/dist/worker/http/function.js +0 -75
- package/dist/worker/http/function.js.map +0 -1
- package/dist/worker/index.d.ts +0 -1
- package/dist/worker/index.js +0 -101
- package/dist/worker/index.js.map +0 -1
- package/dist/worker/observable.d.ts +0 -15
- package/dist/worker/observable.js +0 -110
- package/dist/worker/observable.js.map +0 -1
- package/dist/worker/ws/function.d.ts +0 -3
- package/dist/worker/ws/function.js +0 -42
- package/dist/worker/ws/function.js.map +0 -1
- package/dist/workers/index.d.ts +0 -0
- package/dist/workers/index.js +0 -20
- package/dist/workers/index.js.map +0 -1
- package/dist/workers/workerCode.d.ts +0 -12
- package/dist/workers/workerCode.js +0 -46
- package/dist/workers/workerCode.js.map +0 -1
package/dist/sendError.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BasedServer } from './server';
|
|
2
|
-
import { HttpSession, WebSocketSession, Context } from '
|
|
3
|
-
import { BasedErrorCode, ErrorPayload } from './error';
|
|
2
|
+
import { HttpSession, WebSocketSession, Context } from '@based/functions';
|
|
3
|
+
import { BasedErrorCode, ErrorPayload, BasedErrorData } from './error';
|
|
4
4
|
export declare function sendHttpError<T extends BasedErrorCode>(server: BasedServer, ctx: Context<HttpSession>, basedCode: T, payload: ErrorPayload[T]): void;
|
|
5
|
+
export declare function sendErrorData(ctx: Context<WebSocketSession | HttpSession>, errorData: BasedErrorData): void;
|
|
5
6
|
export declare function sendError<T extends BasedErrorCode>(server: BasedServer, ctx: Context<WebSocketSession | HttpSession>, basedCode: T, payload: ErrorPayload[T]): void;
|
package/dist/sendError.js
CHANGED
|
@@ -1,38 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendError = exports.sendHttpError = void 0;
|
|
3
|
+
exports.sendError = exports.sendErrorData = exports.sendHttpError = void 0;
|
|
4
4
|
const sendHttpResponse_1 = require("./sendHttpResponse");
|
|
5
|
-
const
|
|
5
|
+
const functions_1 = require("@based/functions");
|
|
6
6
|
const protocol_1 = require("./protocol");
|
|
7
7
|
const error_1 = require("./error");
|
|
8
|
-
const
|
|
9
|
-
const { code, message, statusCode, statusMessage } =
|
|
10
|
-
res.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
const sendHttpErrorData = (errorData, ctx) => {
|
|
9
|
+
const { code, message, statusCode, statusMessage } = errorData;
|
|
10
|
+
ctx.session.res.cork(() => {
|
|
11
|
+
ctx.session.res.writeStatus(`${statusCode} ${statusMessage}`);
|
|
12
|
+
if (ctx.session.method !== 'options') {
|
|
13
|
+
ctx.session.res.writeHeader('Content-Type', 'application/json');
|
|
14
|
+
}
|
|
15
|
+
(0, sendHttpResponse_1.end)(ctx, JSON.stringify({
|
|
16
|
+
error: message,
|
|
17
|
+
code,
|
|
18
|
+
}));
|
|
17
19
|
});
|
|
18
20
|
};
|
|
19
21
|
function sendHttpError(server, ctx, basedCode, payload) {
|
|
20
22
|
if (!ctx.session) {
|
|
21
23
|
return;
|
|
22
24
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
25
|
+
const errData = (0, error_1.createError)(server, ctx, basedCode, payload);
|
|
26
|
+
sendHttpErrorData(errData, ctx);
|
|
26
27
|
}
|
|
27
28
|
exports.sendHttpError = sendHttpError;
|
|
29
|
+
function sendErrorData(ctx, errorData) {
|
|
30
|
+
if (!ctx.session) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if ((0, functions_1.isHttpContext)(ctx)) {
|
|
34
|
+
sendHttpErrorData(errorData, ctx);
|
|
35
|
+
}
|
|
36
|
+
else if ((0, functions_1.isWsSession)(ctx.session)) {
|
|
37
|
+
const ws = ctx.session;
|
|
38
|
+
ws.send((0, protocol_1.encodeErrorResponse)((0, protocol_1.valueToBuffer)(errorData)), true, false);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.sendErrorData = sendErrorData;
|
|
28
42
|
function sendError(server, ctx, basedCode, payload) {
|
|
29
43
|
if (!ctx.session) {
|
|
30
44
|
return;
|
|
31
45
|
}
|
|
32
|
-
if ((0,
|
|
46
|
+
if ((0, functions_1.isHttpContext)(ctx)) {
|
|
33
47
|
return sendHttpError(server, ctx, basedCode, payload);
|
|
34
48
|
}
|
|
35
|
-
else if ((0,
|
|
49
|
+
else if ((0, functions_1.isWsSession)(ctx.session)) {
|
|
36
50
|
const errorData = (0, error_1.createError)(server, ctx, basedCode, payload);
|
|
37
51
|
const ws = ctx.session;
|
|
38
52
|
ws.send((0, protocol_1.encodeErrorResponse)((0, protocol_1.valueToBuffer)(errorData)), true, false);
|
package/dist/sendError.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendError.js","sourceRoot":"","sources":["../src/sendError.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"sendError.js","sourceRoot":"","sources":["../src/sendError.ts"],"names":[],"mappings":";;;AAAA,yDAAwC;AAExC,gDAMyB;AACzB,yCAA+D;AAC/D,mCAKgB;AAEhB,MAAM,iBAAiB,GAAG,CACxB,SAAyB,EACzB,GAAyB,EACzB,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,SAAS,CAAA;IAC9D,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE;QACxB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,UAAU,IAAI,aAAa,EAAE,CAAC,CAAA;QAC7D,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;YACpC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAA;SAChE;QACD,IAAA,sBAAG,EACD,GAAG,EACH,IAAI,CAAC,SAAS,CAAC;YACb,KAAK,EAAE,OAAO;YACd,IAAI;SACL,CAAC,CACH,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,SAAgB,aAAa,CAC3B,MAAmB,EACnB,GAAyB,EACzB,SAAY,EACZ,OAAwB;IAExB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;QAChB,OAAM;KACP;IACD,MAAM,OAAO,GAAG,IAAA,mBAAW,EAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;IAC5D,iBAAiB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC;AAXD,sCAWC;AAED,SAAgB,aAAa,CAC3B,GAA4C,EAC5C,SAAyB;IAEzB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;QAChB,OAAM;KACP;IACD,IAAI,IAAA,yBAAa,EAAC,GAAG,CAAC,EAAE;QACtB,iBAAiB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;KAClC;SAAM,IAAI,IAAA,uBAAW,EAAC,GAAG,CAAC,OAAO,CAAC,EAAE;QACnC,MAAM,EAAE,GAAqB,GAAG,CAAC,OAAO,CAAA;QACxC,EAAE,CAAC,IAAI,CAAC,IAAA,8BAAmB,EAAC,IAAA,wBAAa,EAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;KACpE;AACH,CAAC;AAbD,sCAaC;AAED,SAAgB,SAAS,CACvB,MAAmB,EACnB,GAA4C,EAC5C,SAAY,EACZ,OAAwB;IAExB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;QAChB,OAAM;KACP;IACD,IAAI,IAAA,yBAAa,EAAC,GAAG,CAAC,EAAE;QACtB,OAAO,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;KACtD;SAAM,IAAI,IAAA,uBAAW,EAAC,GAAG,CAAC,OAAO,CAAC,EAAE;QACnC,MAAM,SAAS,GAAG,IAAA,mBAAW,EAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAC9D,MAAM,EAAE,GAAqB,GAAG,CAAC,OAAO,CAAA;QACxC,EAAE,CAAC,IAAI,CAAC,IAAA,8BAAmB,EAAC,IAAA,wBAAa,EAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;KACpE;AACH,CAAC;AAhBD,8BAgBC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Context, HttpSession } from '
|
|
2
|
+
import { Context, HttpSession, HttpHeaders } from '@based/functions';
|
|
3
3
|
export declare const end: (ctx: Context<HttpSession>, payload?: string | Buffer | Uint8Array) => void;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const sendHeaders: (ctx: Context<HttpSession>, headers: HttpHeaders) => void;
|
|
5
|
+
export declare const sendHttpResponse: (ctx: Context<HttpSession>, result: any, headers?: HttpHeaders, statusCode?: string) => void;
|
package/dist/sendHttpResponse.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendHttpResponse = exports.end = void 0;
|
|
3
|
+
exports.sendHttpResponse = exports.sendHeaders = exports.end = void 0;
|
|
4
|
+
const stream_1 = require("stream");
|
|
4
5
|
const compress_1 = require("./compress");
|
|
5
6
|
const end = (ctx, payload) => {
|
|
6
7
|
if (!ctx.session) {
|
|
7
8
|
return;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
// check for 'headers set'
|
|
11
|
+
if (!ctx.session.corsSend) {
|
|
12
|
+
ctx.session.res.writeHeader('Access-Control-Allow-Origin', '*');
|
|
13
|
+
ctx.session.res.writeHeader('Access-Control-Allow-Headers', '*');
|
|
14
|
+
}
|
|
15
|
+
if (payload === undefined || ctx.session.method === 'options') {
|
|
13
16
|
ctx.session.res.end();
|
|
14
17
|
}
|
|
15
18
|
else {
|
|
@@ -20,7 +23,23 @@ const end = (ctx, payload) => {
|
|
|
20
23
|
ctx.session = null;
|
|
21
24
|
};
|
|
22
25
|
exports.end = end;
|
|
23
|
-
const
|
|
26
|
+
const sendHeaders = (ctx, headers) => {
|
|
27
|
+
for (const header in headers) {
|
|
28
|
+
const value = headers[header];
|
|
29
|
+
ctx.session.res.writeHeader(header, Array.isArray(value)
|
|
30
|
+
? value.join(',')
|
|
31
|
+
: typeof value === 'string'
|
|
32
|
+
? value
|
|
33
|
+
: String(value));
|
|
34
|
+
if (header === 'Access-Control-Allow-Origin' ||
|
|
35
|
+
header === 'access-control-allow-origin') {
|
|
36
|
+
ctx.session.corsSend = true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.sendHeaders = sendHeaders;
|
|
41
|
+
const sendHttpResponse = (ctx, result, headers, statusCode = '200 OK') => {
|
|
42
|
+
// handle custom http response here...
|
|
24
43
|
if (!ctx.session) {
|
|
25
44
|
return;
|
|
26
45
|
}
|
|
@@ -31,16 +50,49 @@ const sendHttpResponse = (ctx, result) => {
|
|
|
31
50
|
cType = 'text/plain';
|
|
32
51
|
parsed = result;
|
|
33
52
|
}
|
|
53
|
+
else if (result instanceof stream_1.Readable || result instanceof stream_1.Duplex) {
|
|
54
|
+
// received stream....
|
|
55
|
+
ctx.session.res.cork(() => {
|
|
56
|
+
ctx.session.res.writeStatus(statusCode);
|
|
57
|
+
if (headers) {
|
|
58
|
+
(0, exports.sendHeaders)(ctx, headers);
|
|
59
|
+
}
|
|
60
|
+
if (!ctx.session.corsSend) {
|
|
61
|
+
ctx.session.res.writeHeader('Access-Control-Allow-Origin', '*');
|
|
62
|
+
ctx.session.res.writeHeader('Access-Control-Allow-Headers', '*');
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
result.on('data', (d) => {
|
|
66
|
+
ctx.session?.res.write(d);
|
|
67
|
+
});
|
|
68
|
+
result.on('end', () => {
|
|
69
|
+
ctx.session?.res.end();
|
|
70
|
+
});
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
34
73
|
else {
|
|
35
74
|
cType = 'application/json';
|
|
36
75
|
parsed = JSON.stringify(result);
|
|
37
76
|
}
|
|
38
|
-
(0, compress_1.compress)(parsed,
|
|
77
|
+
(0, compress_1.compress)(parsed, headers && ('Content-Encoding' in headers || 'content-encoding' in headers)
|
|
78
|
+
? undefined
|
|
79
|
+
: ctx.session.headers.encoding).then(({ payload, encoding }) => {
|
|
39
80
|
if (ctx.session.res) {
|
|
40
81
|
ctx.session.res.cork(() => {
|
|
41
|
-
ctx.session.res.writeStatus(
|
|
42
|
-
|
|
43
|
-
|
|
82
|
+
ctx.session.res.writeStatus(statusCode);
|
|
83
|
+
if (headers) {
|
|
84
|
+
(0, exports.sendHeaders)(ctx, headers);
|
|
85
|
+
if (!('Cache-Control' in headers || 'cache-control' in headers)) {
|
|
86
|
+
ctx.session.res.writeHeader('Cache-Control', 'max-age=0, must-revalidate');
|
|
87
|
+
}
|
|
88
|
+
if (!('Content-Type' in headers || 'content-type' in headers)) {
|
|
89
|
+
ctx.session.res.writeHeader('Content-Type', cType);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
ctx.session.res.writeHeader('Cache-Control', 'max-age=0, must-revalidate');
|
|
94
|
+
ctx.session.res.writeHeader('Content-Type', cType);
|
|
95
|
+
}
|
|
44
96
|
if (encoding) {
|
|
45
97
|
ctx.session.res.writeHeader('Content-Encoding', encoding);
|
|
46
98
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendHttpResponse.js","sourceRoot":"","sources":["../src/sendHttpResponse.ts"],"names":[],"mappings":";;;AACA,yCAAqC;AAE9B,MAAM,GAAG,GAAG,CACjB,GAAyB,EACzB,OAAsC,EACtC,EAAE;IACF,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;QAChB,OAAM;KACP;
|
|
1
|
+
{"version":3,"file":"sendHttpResponse.js","sourceRoot":"","sources":["../src/sendHttpResponse.ts"],"names":[],"mappings":";;;AACA,mCAAyC;AACzC,yCAAqC;AAE9B,MAAM,GAAG,GAAG,CACjB,GAAyB,EACzB,OAAsC,EACtC,EAAE;IACF,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;QAChB,OAAM;KACP;IAED,0BAA0B;IAC1B,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE;QACzB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAA;QAC/D,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,WAA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AC,CAAC,CAAA;AACJ,CAAC,CAAA;AA7EY,QAAA,gBAAgB,oBA6E5B"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { Context, BasedFunctionClient } from '@based/functions';
|
|
3
4
|
import type { ActiveObservable } from './observable';
|
|
4
5
|
import uws from '@based/uws';
|
|
5
6
|
import { BasedFunctions, FunctionConfig } from './functions';
|
|
6
7
|
import { BasedAuth, AuthConfig } from './auth';
|
|
7
8
|
import { BasedErrorCode, BasedErrorData } from './error';
|
|
9
|
+
import { BasedFunctionClient as BasedServerFunctionClient } from './functionApi';
|
|
10
|
+
import util from 'node:util';
|
|
8
11
|
declare type EventMap = {
|
|
9
12
|
error: BasedErrorData;
|
|
10
13
|
ratelimit: void;
|
|
11
14
|
log: any;
|
|
12
15
|
};
|
|
13
16
|
declare type Event = keyof EventMap;
|
|
14
|
-
declare type Listener<T> = (context: Context, data?: T, err?: Error) => void;
|
|
17
|
+
declare type Listener<T> = (context: Context, data?: T, err?: Error | string) => void;
|
|
15
18
|
declare type RateLimit = {
|
|
16
19
|
ws: number;
|
|
17
20
|
http: number;
|
|
@@ -20,9 +23,11 @@ declare type RateLimit = {
|
|
|
20
23
|
export declare type ServerOptions = {
|
|
21
24
|
port?: number;
|
|
22
25
|
key?: string;
|
|
26
|
+
disableRest?: boolean;
|
|
23
27
|
cert?: string;
|
|
24
28
|
functions?: FunctionConfig;
|
|
25
29
|
rateLimit?: RateLimit;
|
|
30
|
+
client?: (server: BasedServer) => BasedFunctionClient;
|
|
26
31
|
auth?: AuthConfig;
|
|
27
32
|
workerRequest?: (type: string, payload?: any) => void | Promise<any>;
|
|
28
33
|
ws?: {
|
|
@@ -35,6 +40,7 @@ export declare type ServerOptions = {
|
|
|
35
40
|
};
|
|
36
41
|
};
|
|
37
42
|
export declare class BasedServer {
|
|
43
|
+
client: BasedServerFunctionClient;
|
|
38
44
|
functions: BasedFunctions;
|
|
39
45
|
auth: BasedAuth;
|
|
40
46
|
port: number;
|
|
@@ -57,8 +63,9 @@ export declare class BasedServer {
|
|
|
57
63
|
[E in Event]?: Listener<EventMap[E]>[];
|
|
58
64
|
};
|
|
59
65
|
workerRequest: (type: string, payload?: any) => void | Promise<any>;
|
|
66
|
+
[util.inspect.custom](): string;
|
|
60
67
|
constructor(opts: ServerOptions);
|
|
61
|
-
emit(type: Event, client: Context, val: EventMap[Event], err?: Error): void;
|
|
68
|
+
emit(type: Event, client: Context, val: EventMap[Event], err?: Error | string): void;
|
|
62
69
|
on(type: Event, fn: Listener<EventMap[Event]>): void;
|
|
63
70
|
removeAllListeners(): void;
|
|
64
71
|
once(type: Event, fn: Listener<EventMap[Event]>): void;
|
package/dist/server.js
CHANGED
|
@@ -9,6 +9,9 @@ const incoming_1 = __importDefault(require("./incoming"));
|
|
|
9
9
|
const functions_1 = require("./functions");
|
|
10
10
|
const auth_1 = require("./auth");
|
|
11
11
|
const utils_1 = require("@saulx/utils");
|
|
12
|
+
const picocolors = require("picocolors");
|
|
13
|
+
const functionApi_1 = require("./functionApi");
|
|
14
|
+
const node_util_1 = __importDefault(require("node:util"));
|
|
12
15
|
// extend emitter
|
|
13
16
|
class BasedServer {
|
|
14
17
|
constructor(opts) {
|
|
@@ -29,6 +32,13 @@ class BasedServer {
|
|
|
29
32
|
this.listeners = {};
|
|
30
33
|
this.functions = new functions_1.BasedFunctions(this, opts.functions);
|
|
31
34
|
this.auth = new auth_1.BasedAuth(this, opts.auth);
|
|
35
|
+
if (opts.client) {
|
|
36
|
+
// @ts-ignore - allow different ones if you want a special client
|
|
37
|
+
this.client = opts.client(this);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.client = new functionApi_1.BasedFunctionClient(this);
|
|
41
|
+
}
|
|
32
42
|
if (opts.workerRequest) {
|
|
33
43
|
this.workerRequest = opts.workerRequest;
|
|
34
44
|
}
|
|
@@ -37,6 +47,9 @@ class BasedServer {
|
|
|
37
47
|
}
|
|
38
48
|
(0, incoming_1.default)(this, opts);
|
|
39
49
|
}
|
|
50
|
+
[node_util_1.default.inspect.custom]() {
|
|
51
|
+
return `BasedServer [${this.port}]`;
|
|
52
|
+
}
|
|
40
53
|
emit(type, client, val, err) {
|
|
41
54
|
if (this.listeners[type]) {
|
|
42
55
|
this.listeners[type].forEach((fn) => fn(client, val, err));
|
|
@@ -87,20 +100,19 @@ class BasedServer {
|
|
|
87
100
|
return new Promise((resolve, reject) => {
|
|
88
101
|
this.uwsApp.listen(this.port, sharedSocket ? 0 : 1, (listenSocket) => {
|
|
89
102
|
if (listenSocket) {
|
|
90
|
-
console.info('
|
|
91
|
-
// do this better wrap a nice thing arround it
|
|
103
|
+
console.info(' Based-server listening on port:', this.port);
|
|
92
104
|
this.listenSocket = listenSocket;
|
|
93
105
|
resolve(this);
|
|
94
106
|
}
|
|
95
107
|
else {
|
|
96
|
-
console.info('🤮 Based-
|
|
108
|
+
console.info(picocolors.red('🤮 Based-server error on port:'), this.port);
|
|
97
109
|
reject(new Error('Cannot start based-server on port: ' + this.port));
|
|
98
110
|
}
|
|
99
111
|
});
|
|
100
112
|
});
|
|
101
113
|
}
|
|
102
114
|
async destroy() {
|
|
103
|
-
console.info('
|
|
115
|
+
console.info(picocolors.gray(' Destroy Based-server\n'));
|
|
104
116
|
if (this.listenSocket) {
|
|
105
117
|
uws_1.default.us_listen_socket_close(this.listenSocket);
|
|
106
118
|
this.listenSocket = null;
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;AAEA,qDAA4B;AAC5B,0DAAoC;AACpC,2CAA4D;AAC5D,iCAA8C;AAE9C,wCAAmC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;AAEA,qDAA4B;AAC5B,0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,KAAK,CAAC,OAAO;QACX,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC,CAAA;QAC3D,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,aAAG,CAAC,sBAAsB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;YAC7C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;SACzB;QACD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;IACpB,CAAC;CACF;AAzJD,kCAyJC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Context } from '@based/functions';
|
|
2
|
+
import { BasedFunctionRoute, BasedQueryFunctionRoute, BasedRoute, BasedStreamFunctionRoute } from './functions';
|
|
3
|
+
import { BasedServer } from './server';
|
|
4
|
+
declare type FnType = 'query' | 'stream' | 'fn';
|
|
5
|
+
export declare const verifyRoute: <T extends FnType>(server: BasedServer, ctx: Context, type: T, route: BasedRoute | null, name: string, id?: number) => T extends "query" ? BasedQueryFunctionRoute : T extends "stream" ? BasedStreamFunctionRoute : {
|
|
6
|
+
name: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
maxPayloadSize?: number;
|
|
9
|
+
rateLimitTokens?: number;
|
|
10
|
+
public?: boolean;
|
|
11
|
+
headers?: string[];
|
|
12
|
+
internalOnly?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyRoute = void 0;
|
|
4
|
+
const functions_1 = require("@based/functions");
|
|
5
|
+
const functions_2 = require("./functions");
|
|
6
|
+
const sendError_1 = require("./sendError");
|
|
7
|
+
const error_1 = require("./error");
|
|
8
|
+
const verifyRoute = (server, ctx = server.client.ctx, type, route, name, id) => {
|
|
9
|
+
if (!ctx.session) {
|
|
10
|
+
// console.warn('VERIFY ROUTE NO SESSION', name)
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
if (!route) {
|
|
14
|
+
if (!(0, functions_1.isClientContext)(ctx)) {
|
|
15
|
+
throw (0, error_1.createError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, {
|
|
16
|
+
route: {
|
|
17
|
+
name,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, type === 'query'
|
|
22
|
+
? {
|
|
23
|
+
route: { name },
|
|
24
|
+
observableId: id,
|
|
25
|
+
}
|
|
26
|
+
: {
|
|
27
|
+
route: { name },
|
|
28
|
+
requestId: id,
|
|
29
|
+
});
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
if (route.internalOnly === true && (0, functions_1.isClientContext)(ctx)) {
|
|
33
|
+
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, type === 'query'
|
|
34
|
+
? {
|
|
35
|
+
route: { name },
|
|
36
|
+
observableId: id,
|
|
37
|
+
}
|
|
38
|
+
: {
|
|
39
|
+
route: { name },
|
|
40
|
+
requestId: id,
|
|
41
|
+
});
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if (type === 'query') {
|
|
45
|
+
if (!(0, functions_2.isQueryFunctionRoute)(route)) {
|
|
46
|
+
if (!(0, functions_1.isClientContext)(ctx)) {
|
|
47
|
+
throw (0, error_1.createError)(server, ctx, error_1.BasedErrorCode.FunctionIsNotObservable, {
|
|
48
|
+
route,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionIsNotObservable, {
|
|
52
|
+
route: { name },
|
|
53
|
+
observableId: id,
|
|
54
|
+
});
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (type === 'stream') {
|
|
59
|
+
if (!(0, functions_2.isStreamFunctionRoute)(route)) {
|
|
60
|
+
if (!(0, functions_1.isClientContext)(ctx)) {
|
|
61
|
+
throw (0, error_1.createError)(server, ctx, error_1.BasedErrorCode.FunctionIsNotStream, {
|
|
62
|
+
route,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionIsNotStream, {
|
|
66
|
+
route: { name },
|
|
67
|
+
requestId: id,
|
|
68
|
+
});
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (type === 'fn' && !(0, functions_2.isFunctionRoute)(route)) {
|
|
73
|
+
if (!(0, functions_1.isClientContext)(ctx)) {
|
|
74
|
+
if ((0, functions_2.isStreamFunctionRoute)(route)) {
|
|
75
|
+
throw (0, error_1.createError)(server, ctx, error_1.BasedErrorCode.FunctionIsNotObservable, {
|
|
76
|
+
route,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
throw (0, error_1.createError)(server, ctx, error_1.BasedErrorCode.FunctionIsObservable, {
|
|
80
|
+
route,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if ((0, functions_2.isStreamFunctionRoute)(route)) {
|
|
84
|
+
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionIsStream, {
|
|
85
|
+
route,
|
|
86
|
+
requestId: id,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionIsObservable, {
|
|
90
|
+
route,
|
|
91
|
+
requestId: id,
|
|
92
|
+
});
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
// @ts-ignore fixed by checking the routes
|
|
96
|
+
return route;
|
|
97
|
+
};
|
|
98
|
+
exports.verifyRoute = verifyRoute;
|
|
99
|
+
//# sourceMappingURL=verifyRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyRoute.js","s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M,IAAA,mBAAW,EAAC,MAAM,EAAE,GAAG,EAAE,sBAAc,CAAC,oBAAoB,EAAE;gBAClE,KAAK;aACN,CAAC,CAAA;SACH;QACD,IAAI,IAAA,iCAAqB,EAAC,KAAK,CAAC,EAAE;YAChC,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,sBAAc,CAAC,gBAAgB,EAAE;gBACtD,KAAK;gBACL,SAAS,EAAE,EAAE;aACd,CAAC,CAAA;SACH;QACD,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,sBAAc,CAAC,oBAAoB,EAAE;YAC1D,KAAK;YACL,SAAS,EAAE,EAAE;SACd,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;KACZ;IAED,0CAA0C;IAC1C,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAtHY,QAAA,WAAW,eAsHvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@based/server",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -22,13 +22,15 @@
|
|
|
22
22
|
"@based/uws": "2.4.0",
|
|
23
23
|
"@saulx/diff": "^1.1.3",
|
|
24
24
|
"@saulx/hash": "^1.1.0",
|
|
25
|
-
"@saulx/utils": "^2.
|
|
25
|
+
"@saulx/utils": "^3.2.0",
|
|
26
26
|
"picocolors": "^1.0.0",
|
|
27
27
|
"jsonexport": "^3.2.0",
|
|
28
28
|
"jsonwebtoken": "^8.5.1",
|
|
29
29
|
"mime-types": "^2.1.31"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
+
"@types/mime-types": "2.1.1",
|
|
33
|
+
"@based/functions": "^1.0.0",
|
|
32
34
|
"@types/node": "^17.0.23",
|
|
33
35
|
"ts-node": "^10.1.0",
|
|
34
36
|
"typescript": "^4.3.5",
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Query, SetOptions, GetOptions, GenericObject, Copy, Configuration, Based as BasedAdminClient, TrackOpts } from '@based/client';
|
|
2
|
-
import RedisSelvaClient from '@saulx/selva/dist/src/redis';
|
|
3
|
-
import { Params } from './Params';
|
|
4
|
-
import { SignOptions } from 'jsonwebtoken';
|
|
5
|
-
declare class BasedServerClient {
|
|
6
|
-
private _params;
|
|
7
|
-
private _noAuth;
|
|
8
|
-
constructor(params: Params, noAuth?: boolean);
|
|
9
|
-
opts: {
|
|
10
|
-
cluster: string;
|
|
11
|
-
org: string;
|
|
12
|
-
project: string;
|
|
13
|
-
env: string;
|
|
14
|
-
};
|
|
15
|
-
get state(): GenericObject;
|
|
16
|
-
get redis(): RedisSelvaClient;
|
|
17
|
-
destroy(): void;
|
|
18
|
-
private _authorize;
|
|
19
|
-
event(type: string, params: {
|
|
20
|
-
[key: string]: string | number | boolean;
|
|
21
|
-
}, opts?: TrackOpts): Promise<void>;
|
|
22
|
-
clearAnalytics(type: string, params?: {
|
|
23
|
-
[key: string]: number | string | boolean;
|
|
24
|
-
}): Promise<void>;
|
|
25
|
-
observeUntil(query: Query, condition: (data: GenericObject, checksum: number) => boolean, onData?: (data: any, checksum: number) => void): Promise<GenericObject>;
|
|
26
|
-
admin(key: string): Promise<BasedAdminClient>;
|
|
27
|
-
observe(query: Query, onData: (data: any, checksum: number) => void, onErr?: (err: Error) => void): Promise<() => void>;
|
|
28
|
-
observe(name: string, onData: (data: any, checksum: number) => void, onErr?: (err: Error) => void): Promise<() => void>;
|
|
29
|
-
observe(name: string, payload: any, onData: (data: any, checksum: number) => void, onErr?: (err: Error) => void): Promise<() => void>;
|
|
30
|
-
get(query: GetOptions): Promise<GenericObject>;
|
|
31
|
-
get(name: string, payload?: any): Promise<GenericObject>;
|
|
32
|
-
copy(payload: Copy): Promise<{
|
|
33
|
-
ids: string[];
|
|
34
|
-
}>;
|
|
35
|
-
id(type: string, opts?: any): Promise<string>;
|
|
36
|
-
call(name: string, payload?: any): Promise<GenericObject>;
|
|
37
|
-
delete(payload: {
|
|
38
|
-
$id: string;
|
|
39
|
-
$db?: string;
|
|
40
|
-
}): Promise<{
|
|
41
|
-
isDeleted: boolean;
|
|
42
|
-
}>;
|
|
43
|
-
set(payload: SetOptions): Promise<{
|
|
44
|
-
id: string;
|
|
45
|
-
}>;
|
|
46
|
-
schema(): Promise<Configuration>;
|
|
47
|
-
updateSchema(configuration: {
|
|
48
|
-
schema?: GenericObject;
|
|
49
|
-
db?: string;
|
|
50
|
-
}): Promise<GenericObject>;
|
|
51
|
-
encode(payload: string | object, privateKeySecret: string | {
|
|
52
|
-
secret: string;
|
|
53
|
-
} | {
|
|
54
|
-
key: string;
|
|
55
|
-
}, type?: 'jwt', signOptions?: SignOptions): Promise<string>;
|
|
56
|
-
decode(payload: string, secretOrPublicKey: string | {
|
|
57
|
-
publicKey: string;
|
|
58
|
-
}, type?: 'jwt'): Promise<any>;
|
|
59
|
-
secret(secret: string): Promise<any>;
|
|
60
|
-
digest(payload: string): Promise<string>;
|
|
61
|
-
sendEmail(payload: {
|
|
62
|
-
to: string;
|
|
63
|
-
subject: string;
|
|
64
|
-
body: string;
|
|
65
|
-
from?: string;
|
|
66
|
-
}): Promise<{
|
|
67
|
-
status: 'ok';
|
|
68
|
-
message?: string;
|
|
69
|
-
}>;
|
|
70
|
-
}
|
|
71
|
-
export default BasedServerClient;
|