@based/server 4.0.1 → 4.0.2
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 +32 -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.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 +16 -0
- package/dist/functionApi/client/index.js +44 -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 +44 -30
- package/dist/functions/types.js +40 -12
- package/dist/functions/types.js.map +1 -1
- package/dist/incoming/http/authorize.d.ts +2 -2
- package/dist/incoming/http/authorize.js +4 -4
- package/dist/incoming/http/authorize.js.map +1 -1
- package/dist/incoming/http/function.d.ts +3 -4
- package/dist/incoming/http/function.js +30 -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 +23 -33
- package/dist/incoming/http/get.js.map +1 -1
- package/dist/incoming/http/index.js +49 -30
- 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/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/{network/http/streamFunction/multipartStream.js → incoming/http/streamFunction/multiPart/readFormData.js} +83 -89
- package/dist/incoming/http/streamFunction/multiPart/readFormData.js.map +1 -0
- package/dist/incoming/http/streamFunction/multipartStream.d.ts +3 -4
- package/dist/incoming/http/streamFunction/multipartStream.js +68 -66
- package/dist/incoming/http/streamFunction/multipartStream.js.map +1 -1
- package/dist/incoming/http/streamFunction/stream/createStream.d.ts +6 -0
- package/dist/incoming/http/streamFunction/stream/createStream.js +75 -0
- 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/http/streamFunction/stream.d.ts +1 -1
- 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/error.d.ts +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/observable/verify.d.ts +1 -1
- package/dist/observable/verify.js +1 -1
- package/dist/observable/verify.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 +1 -1
- package/dist/sendHttpResponse.js +29 -4
- 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/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.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/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
|
@@ -1,106 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.httpStreamFunction = void 0;
|
|
7
|
-
const stream_1 = __importDefault(require("./stream"));
|
|
8
4
|
const sendError_1 = require("../../../sendError");
|
|
9
|
-
const functions_1 = require("../../../functions");
|
|
10
|
-
const authorize_1 = require("../authorize");
|
|
11
5
|
const error_1 = require("../../../error");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const httpStreamFunction = (server, ctx,
|
|
6
|
+
const multiPart_1 = require("./multiPart");
|
|
7
|
+
const stream_1 = require("./stream");
|
|
8
|
+
const httpStreamFunction = (server, ctx, route) => {
|
|
15
9
|
if (!ctx.session) {
|
|
16
10
|
return;
|
|
17
11
|
}
|
|
18
12
|
const size = ctx.session.headers['content-length'];
|
|
19
13
|
if (route.maxPayloadSize > -1 && route.maxPayloadSize < size) {
|
|
20
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, route);
|
|
14
|
+
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, { route });
|
|
21
15
|
return;
|
|
22
16
|
}
|
|
23
17
|
const type = ctx.session.headers['content-type'];
|
|
24
|
-
// replace this with transder encoding 'chunked'
|
|
25
18
|
if (type && type.startsWith('multipart/form-data')) {
|
|
26
|
-
|
|
27
|
-
let thisIsFn;
|
|
28
|
-
(0, multipartStream_1.default)(ctx, server, payload, route, (p) => {
|
|
29
|
-
return new Promise((resolve) => {
|
|
30
|
-
(0, authorize_1.authorizeRequest)(server, ctx, p.payload, route, () => {
|
|
31
|
-
if (!thisIsFn) {
|
|
32
|
-
files.push({ p, resolve });
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
resolve(thisIsFn(p, ctx));
|
|
36
|
-
}
|
|
37
|
-
}, () => {
|
|
38
|
-
resolve(undefined);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
server.functions
|
|
43
|
-
.install(route.name)
|
|
44
|
-
.then((spec) => {
|
|
45
|
-
if (spec && !(0, functions_1.isObservableFunctionSpec)(spec) && spec.stream) {
|
|
46
|
-
thisIsFn = spec.function;
|
|
47
|
-
if (files.length) {
|
|
48
|
-
for (const file of files) {
|
|
49
|
-
console.info('File parsed before fn / auth');
|
|
50
|
-
file.resolve(thisIsFn(file.p, ctx));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, route);
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
.catch(() => {
|
|
59
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, route);
|
|
60
|
-
});
|
|
19
|
+
(0, multiPart_1.multiPart)(server, ctx, route);
|
|
61
20
|
return;
|
|
62
21
|
}
|
|
63
|
-
|
|
64
|
-
// destroy stream from context
|
|
65
|
-
(0, authorize_1.authorizeRequest)(server, ctx, payload, route, (payload) => {
|
|
66
|
-
server.functions
|
|
67
|
-
.install(route.name)
|
|
68
|
-
.then((spec) => {
|
|
69
|
-
if (spec && !(0, functions_1.isObservableFunctionSpec)(spec) && spec.stream) {
|
|
70
|
-
// const stream = createDataStream(server, route, client, size)
|
|
71
|
-
const streamPayload = { payload, stream };
|
|
72
|
-
const fn = spec.function;
|
|
73
|
-
fn(streamPayload, ctx)
|
|
74
|
-
.catch((err) => {
|
|
75
|
-
stream.destroy();
|
|
76
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionError, {
|
|
77
|
-
err,
|
|
78
|
-
route,
|
|
79
|
-
});
|
|
80
|
-
})
|
|
81
|
-
.then((r) => {
|
|
82
|
-
if (stream.readableEnded ||
|
|
83
|
-
stream.listenerCount('data') === 0) {
|
|
84
|
-
(0, sendHttpResponse_1.sendHttpResponse)(ctx, r);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
stream.on('end', () => {
|
|
88
|
-
(0, sendHttpResponse_1.sendHttpResponse)(ctx, r);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, route);
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
.catch((err) => {
|
|
98
|
-
console.error(err);
|
|
99
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, route);
|
|
100
|
-
});
|
|
101
|
-
}, () => {
|
|
102
|
-
stream.destroy();
|
|
103
|
-
});
|
|
22
|
+
(0, stream_1.singleStream)(server, ctx, route, type, size);
|
|
104
23
|
};
|
|
105
24
|
exports.httpStreamFunction = httpStreamFunction;
|
|
106
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/incoming/http/streamFunction/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/incoming/http/streamFunction/index.ts"],"names":[],"mappings":";;;AACA,kDAA8C;AAG9C,0CAA+C;AAC/C,2CAAuC;AACvC,qCAAuC;AAEhC,MAAM,kBAAkB,GAAG,CAChC,MAAmB,EACnB,GAAyB,EACzB,KAA+B,EAC/B,EAAE;IACF,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;QAChB,OAAM;KACP;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAClD,IAAI,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,cAAc,GAAG,IAAI,EAAE;QAC5D,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,sBAAc,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QACjE,OAAM;KACP;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IAChD,IAAI,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,EAAE;QAClD,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;QAC7B,OAAM;KACP;IACD,IAAA,qBAAY,EAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAC9C,CAAC,CAAA;AAnBY,QAAA,kBAAkB,sBAmB9B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { HttpSession, Context } from '@based/functions';
|
|
2
|
+
import { BasedServer } from '../../../../server';
|
|
3
|
+
import { BasedStreamFunctionRoute } from '../../../../functions';
|
|
4
|
+
export declare const multiPart: (server: BasedServer, ctx: Context<HttpSession>, route: BasedStreamFunctionRoute) => void;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.multiPart = void 0;
|
|
7
|
+
const installFn_1 = require("../../../../installFn");
|
|
8
|
+
const readFormData_1 = __importDefault(require("./readFormData"));
|
|
9
|
+
const error_1 = require("../../../../error");
|
|
10
|
+
const sendHttpResponse_1 = require("../../../../sendHttpResponse");
|
|
11
|
+
const handleFile = async (server, ctx, installedFn, file, route) => {
|
|
12
|
+
try {
|
|
13
|
+
const ok = await server.auth.authorize(server.client, ctx, route.name, file);
|
|
14
|
+
if (!ok) {
|
|
15
|
+
return {
|
|
16
|
+
error: (0, error_1.createErrorData)(error_1.BasedErrorCode.AuthorizeRejectedError, {
|
|
17
|
+
route,
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
return {
|
|
24
|
+
error: (0, error_1.createErrorData)(error_1.BasedErrorCode.AuthorizeFunctionError, {
|
|
25
|
+
route,
|
|
26
|
+
err,
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const spec = await installedFn;
|
|
31
|
+
if (spec === null) {
|
|
32
|
+
return {
|
|
33
|
+
error: (0, error_1.createErrorData)(error_1.BasedErrorCode.FunctionNotFound, {
|
|
34
|
+
route,
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const value = await spec.function(server.client, file, ctx);
|
|
40
|
+
return { value };
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
return {
|
|
44
|
+
error: (0, error_1.createErrorData)(error_1.BasedErrorCode.FunctionError, { err, route }),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const multiPart = (server, ctx, route) => {
|
|
49
|
+
ctx.session.res.cork(() => {
|
|
50
|
+
ctx.session.res.writeHeader('Access-Control-Allow-Origin', '*');
|
|
51
|
+
ctx.session.res.writeHeader('Access-Control-Allow-Headers', '*');
|
|
52
|
+
ctx.session.corsSend = true;
|
|
53
|
+
});
|
|
54
|
+
const installedFn = (0, installFn_1.installFn)(server, server.client.ctx, route);
|
|
55
|
+
const pendingFiles = [];
|
|
56
|
+
const onFile = (file) => {
|
|
57
|
+
pendingFiles.push(handleFile(server, ctx, installedFn, file, route));
|
|
58
|
+
};
|
|
59
|
+
const ready = async () => {
|
|
60
|
+
const results = await Promise.all(pendingFiles);
|
|
61
|
+
(0, sendHttpResponse_1.sendHttpResponse)(ctx, results);
|
|
62
|
+
};
|
|
63
|
+
(0, readFormData_1.default)(ctx, server, route, onFile, ready);
|
|
64
|
+
};
|
|
65
|
+
exports.multiPart = multiPart;
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/incoming/http/streamFunction/multiPart/index.ts"],"names":[],"mappings":";;;;;;AAM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,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE;QACxB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAA;QAC/D,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAA;QAChE,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAA;IAC7B,CAAC,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG,IAAA,qBAAS,EAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAE/D,MAAM,YAAY,GAAoC,EAAE,CAAA;IAExD,MAAM,MAAM,GAAG,CAAC,IAAmB,EAAE,EAAE;QACrC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;IACtE,CAAC,CAAA;IAED,MAAM,KAAK,GAAG,KAAK,IAAI,EAAE;QACvB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QAC/C,IAAA,mCAAgB,EAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAChC,CAAC,CAAA;IAED,IAAA,sBAAY,EAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AACjD,CAAC,CAAA;AAzBY,QAAA,SAAS,aAyBrB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HttpSession, Context, StreamPayload } from '@based/functions';
|
|
2
|
+
import { BasedServer } from '../../../../server';
|
|
3
|
+
import { BasedFunctionRoute } from '../../../../functions';
|
|
4
|
+
export declare type FileOptions = {
|
|
5
|
+
name?: string;
|
|
6
|
+
size?: number;
|
|
7
|
+
type: string;
|
|
8
|
+
extension: string;
|
|
9
|
+
payload: any;
|
|
10
|
+
};
|
|
11
|
+
declare const _default: (ctx: Context<HttpSession>, server: BasedServer, route: BasedFunctionRoute, onFile: (payload: StreamPayload) => void, isReady: () => void) => void;
|
|
12
|
+
export default _default;
|
|
@@ -3,43 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const DataStream_1 = require("
|
|
7
|
-
const error_1 = require("
|
|
8
|
-
const
|
|
9
|
-
const getExtension_1 = __importDefault(require("
|
|
6
|
+
const DataStream_1 = require("../DataStream");
|
|
7
|
+
const error_1 = require("../../../../error");
|
|
8
|
+
const sendError_1 = require("../../../../sendError");
|
|
9
|
+
const getExtension_1 = __importDefault(require("../getExtension"));
|
|
10
10
|
const MAX_CHUNK_SIZE = 1024 * 1024 * 5;
|
|
11
|
-
|
|
12
|
-
stream.emit('progress', 0);
|
|
13
|
-
if (size < 200000) {
|
|
14
|
-
stream.on('end', () => {
|
|
15
|
-
stream.emit('progress', 1);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
let progress = 0;
|
|
20
|
-
let total = 0;
|
|
21
|
-
let setInProgress = false;
|
|
22
|
-
const updateProgress = () => {
|
|
23
|
-
if (!setInProgress) {
|
|
24
|
-
setInProgress = true;
|
|
25
|
-
setTimeout(() => {
|
|
26
|
-
stream.emit('progress', progress);
|
|
27
|
-
setInProgress = false;
|
|
28
|
-
}, 250);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
stream.on('end', () => {
|
|
32
|
-
progress = 1;
|
|
33
|
-
updateProgress();
|
|
34
|
-
});
|
|
35
|
-
stream.on('data', (chunk) => {
|
|
36
|
-
total += chunk.byteLength;
|
|
37
|
-
progress = total / size;
|
|
38
|
-
updateProgress();
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
// only use this if you have individual file else its just all
|
|
11
|
+
// only use this if you have an individual file else its just all
|
|
43
12
|
const setHeader = (file) => {
|
|
44
13
|
file.headersSet++;
|
|
45
14
|
if (file.headersSet === 2) {
|
|
@@ -50,24 +19,54 @@ const setHeader = (file) => {
|
|
|
50
19
|
const toBuffer = (str, firstWritten) => {
|
|
51
20
|
return Buffer.from(firstWritten ? str + '\r\n' : str, 'binary');
|
|
52
21
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
22
|
+
const handleMeta = (file, line, meta, isWriting, fileCallback) => {
|
|
23
|
+
const opts = file.opts;
|
|
24
|
+
opts.name = line.match(/filename="(.*?)"/)?.[1] || 'untitled';
|
|
25
|
+
const firstCommaIndex = meta.indexOf(',');
|
|
26
|
+
if (firstCommaIndex !== -1 && meta.startsWith('size=')) {
|
|
27
|
+
const size = meta.slice(5, firstCommaIndex);
|
|
28
|
+
if (size) {
|
|
29
|
+
const sizeNr = Number(size);
|
|
30
|
+
file.opts.size = sizeNr;
|
|
31
|
+
file.stream.size = sizeNr;
|
|
32
|
+
}
|
|
33
|
+
const payloadRaw = decodeURI(meta.slice(firstCommaIndex + 1));
|
|
34
|
+
if (payloadRaw !== undefined && payloadRaw !== '') {
|
|
35
|
+
try {
|
|
36
|
+
file.opts.payload = JSON.parse(payloadRaw);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
file.opts.payload = payloadRaw;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
56
42
|
}
|
|
57
|
-
|
|
43
|
+
isWriting = setHeader(file);
|
|
44
|
+
if (isWriting) {
|
|
45
|
+
fileCallback({
|
|
46
|
+
payload: file.opts.payload || {},
|
|
47
|
+
fileName: file.opts.name,
|
|
48
|
+
mimeType: file.opts.type,
|
|
49
|
+
extension: file.opts.extension,
|
|
50
|
+
size: file.opts.size || 0,
|
|
51
|
+
stream: file.stream,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return isWriting;
|
|
55
|
+
};
|
|
56
|
+
exports.default = (ctx, server, route, onFile, isReady) => {
|
|
58
57
|
const files = [];
|
|
59
|
-
const contentLength =
|
|
60
|
-
const promiseQ = [];
|
|
58
|
+
const contentLength = ctx.session.headers['content-length'];
|
|
61
59
|
let setInProgress = false;
|
|
62
60
|
let boundary = null;
|
|
63
61
|
let prevLine;
|
|
64
62
|
let isWriting = false;
|
|
63
|
+
let collectMeta;
|
|
65
64
|
let total = 0;
|
|
66
65
|
let progress = 0;
|
|
67
|
-
|
|
66
|
+
ctx.session.res.onData((chunk, isLast) => {
|
|
68
67
|
// see if this goes ok... (clearing mem etc)
|
|
69
68
|
if (chunk.byteLength > MAX_CHUNK_SIZE) {
|
|
70
|
-
(0,
|
|
69
|
+
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.ChunkTooLarge, route);
|
|
71
70
|
for (const file of files) {
|
|
72
71
|
file.stream.destroy();
|
|
73
72
|
}
|
|
@@ -88,7 +87,6 @@ exports.default = async (client, server, payload, route, spec) => {
|
|
|
88
87
|
if (progress === 1) {
|
|
89
88
|
file.isDone = true;
|
|
90
89
|
}
|
|
91
|
-
file.stream.emit('progress', progress);
|
|
92
90
|
}
|
|
93
91
|
}
|
|
94
92
|
setInProgress = false;
|
|
@@ -115,9 +113,6 @@ exports.default = async (client, server, payload, route, spec) => {
|
|
|
115
113
|
else {
|
|
116
114
|
file.stream.end();
|
|
117
115
|
}
|
|
118
|
-
if (!file.opts.size && !file.isDone) {
|
|
119
|
-
file.stream.emit('progress', 1);
|
|
120
|
-
}
|
|
121
116
|
file.isDone = true;
|
|
122
117
|
prevLine = null;
|
|
123
118
|
if (line === boundary + '--') {
|
|
@@ -126,7 +121,7 @@ exports.default = async (client, server, payload, route, spec) => {
|
|
|
126
121
|
}
|
|
127
122
|
if (line === boundary && !isWriting) {
|
|
128
123
|
const file = {
|
|
129
|
-
stream: new DataStream_1.DataStream(),
|
|
124
|
+
stream: new DataStream_1.DataStream(0),
|
|
130
125
|
headersSet: 0,
|
|
131
126
|
opts: {},
|
|
132
127
|
isDone: false,
|
|
@@ -136,49 +131,58 @@ exports.default = async (client, server, payload, route, spec) => {
|
|
|
136
131
|
}
|
|
137
132
|
const file = files[files.length - 1];
|
|
138
133
|
if (!file) {
|
|
139
|
-
// TODO: invalid file
|
|
140
|
-
return (0,
|
|
134
|
+
// TODO: invalid file error
|
|
135
|
+
return (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.InvalidPayload, { route });
|
|
141
136
|
}
|
|
142
|
-
if (!isWriting &&
|
|
143
|
-
const
|
|
137
|
+
if (!isWriting && collectMeta) {
|
|
138
|
+
const fullMeta = collectMeta + line;
|
|
139
|
+
const meta = fullMeta.match(/name="(.*?)"/)?.[1];
|
|
144
140
|
if (!meta) {
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
collectMeta = fullMeta;
|
|
142
|
+
continue;
|
|
147
143
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
opts[k] = v;
|
|
159
|
-
}
|
|
144
|
+
collectMeta = '';
|
|
145
|
+
isWriting = handleMeta(file, line, meta, isWriting, onFile);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (!collectMeta && !isWriting && line.includes('Content-Disposition')) {
|
|
149
|
+
const meta = line.match(/name="(.*?)"/)?.[1];
|
|
150
|
+
if (!meta) {
|
|
151
|
+
if (/name="(.*?)/.test(line)) {
|
|
152
|
+
collectMeta = line;
|
|
153
|
+
continue;
|
|
160
154
|
}
|
|
155
|
+
// TODO: invalid file error
|
|
156
|
+
return (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.InvalidPayload, {
|
|
157
|
+
route,
|
|
158
|
+
});
|
|
161
159
|
}
|
|
162
|
-
|
|
163
|
-
streamProgress(file.stream, opts.size);
|
|
164
|
-
}
|
|
165
|
-
isWriting = setHeader(file);
|
|
166
|
-
if (isWriting) {
|
|
167
|
-
promiseQ.push(fn({ payload: { ...payload, ...file.opts }, stream: file.stream }, client.context));
|
|
168
|
-
}
|
|
160
|
+
isWriting = handleMeta(file, line, meta, isWriting, onFile);
|
|
169
161
|
continue;
|
|
170
162
|
}
|
|
171
163
|
if (!isWriting && line.includes('Content-Type')) {
|
|
172
164
|
const mimeType = line.match(/Content-Type: ([a-zA-Z0-9].+\/[a-zA-Z0-9].+)/)?.[1];
|
|
173
165
|
if (!mimeType) {
|
|
174
166
|
// TODO: invalid file (can speficy in route potentialy...)
|
|
175
|
-
return (0,
|
|
167
|
+
return (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.InvalidPayload, {
|
|
168
|
+
route,
|
|
169
|
+
});
|
|
176
170
|
}
|
|
177
171
|
file.opts.type = mimeType;
|
|
178
|
-
|
|
172
|
+
const extension = (0, getExtension_1.default)(mimeType);
|
|
173
|
+
if (extension) {
|
|
174
|
+
file.opts.extension = extension;
|
|
175
|
+
}
|
|
179
176
|
isWriting = setHeader(file);
|
|
180
177
|
if (isWriting) {
|
|
181
|
-
|
|
178
|
+
onFile({
|
|
179
|
+
payload: file.opts.payload,
|
|
180
|
+
fileName: file.opts.name,
|
|
181
|
+
mimeType: file.opts.type,
|
|
182
|
+
extension: file.opts.extension,
|
|
183
|
+
size: file.opts.size,
|
|
184
|
+
stream: file.stream,
|
|
185
|
+
});
|
|
182
186
|
}
|
|
183
187
|
continue;
|
|
184
188
|
}
|
|
@@ -191,18 +195,8 @@ exports.default = async (client, server, payload, route, spec) => {
|
|
|
191
195
|
}
|
|
192
196
|
}
|
|
193
197
|
if (isLast) {
|
|
194
|
-
|
|
195
|
-
const r = results.map((v) => {
|
|
196
|
-
if (v.status === 'rejected') {
|
|
197
|
-
return { err: v.reason };
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
return v.value;
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
(0, send_1.sendHttpResponse)(client, r);
|
|
204
|
-
});
|
|
198
|
+
isReady();
|
|
205
199
|
}
|
|
206
200
|
});
|
|
207
201
|
};
|
|
208
|
-
//# sourceMappingURL=
|
|
202
|
+
//# sourceMappingURL=readFormData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readFormData.js","sourceRoot":"","sources":["../../../../../src/incoming/http/streamFunction/multiPart/readFormData.ts"],"names":[],"mappings":";;;;;AAAA,8CAA0C;AAE1C,6CAAkD;AAClD,qDAAiD;AACjD,mEAA0C;AAI1C,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC,CAAA;AAiBtC,iEAAiE;AACjE,MAAM,SAAS,GAAG,CAAC,IAAoB,EAAW,EAAE;IAClD,IAAI,CAAC,UAAU,EAAE,CAAA;IACjB,IAAI,IAAI,CAAC,UAAU,KAAK,CAAC,EAAE;QACzB,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,YAAqB,EAAU,EAAE;IAC9D,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;AACjE,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CACjB,IAAoB,EACpB,IAAY,EACZ,IAAY,EACZ,SAAkB,EAClB,YAA8C,EACrC,EAAE;IACX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;IACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,UAAU,CAAA;IAC7D,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IACzC,IAAI,eAAe,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO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AI,QAAQ,EAAE;oBACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;iBACpD;gBACD,QAAQ,GAAG,IAAI,CAAA;gBACf,YAAY,GAAG,IAAI,CAAA;aACpB;SACF;QAED,IAAI,MAAM,EAAE;YACV,OAAO,EAAE,CAAA;SACV;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpSession, Context } from '
|
|
1
|
+
import { HttpSession, Context, StreamPayload } from '@based/functions';
|
|
2
2
|
import { BasedServer } from '../../../server';
|
|
3
3
|
import { BasedFunctionRoute } from '../../../functions';
|
|
4
4
|
export declare type FileOptions = {
|
|
@@ -6,8 +6,7 @@ export declare type FileOptions = {
|
|
|
6
6
|
size?: number;
|
|
7
7
|
type: string;
|
|
8
8
|
extension: string;
|
|
9
|
-
|
|
10
|
-
[key: string]: string;
|
|
9
|
+
payload: any;
|
|
11
10
|
};
|
|
12
|
-
declare const _default: (ctx: Context<HttpSession>, server: BasedServer,
|
|
11
|
+
declare const _default: (ctx: Context<HttpSession>, server: BasedServer, route: BasedFunctionRoute, fn: (payload: StreamPayload) => Promise<any>) => void;
|
|
13
12
|
export default _default;
|