File tree Expand file tree Collapse file tree 1 file changed +0
-43
lines changed
Expand file tree Collapse file tree 1 file changed +0
-43
lines changed Original file line number Diff line number Diff line change @@ -33,49 +33,6 @@ function getNodejsStreamFuncs() {
3333 }
3434}
3535
36- /**
37- * The stream functions that work in Cloudflare Workers
38- */
39- function getCloudflareStreamFuncs ( ) {
40- function getStream ( ssl ) {
41- const { CloudflareSocket } = require ( 'pg-cloudflare' )
42- return new CloudflareSocket ( ssl )
43- }
44-
45- function getSecureStream ( options ) {
46- options . socket . startTls ( options )
47- return options . socket
48- }
49- return {
50- getStream,
51- getSecureStream,
52- }
53- }
54-
55- /**
56- * Are we running in a Cloudflare Worker?
57- *
58- * @returns true if the code is currently running inside a Cloudflare Worker.
59- */
60- function isCloudflareRuntime ( ) {
61- // Since 2022-03-21 the `global_navigator` compatibility flag is on for Cloudflare Workers
62- // which means that `navigator.userAgent` will be defined.
63- if ( typeof navigator === 'object' && navigator !== null && typeof navigator . userAgent === 'string' ) {
64- return navigator . userAgent === 'Cloudflare-Workers'
65- }
66- // In case `navigator` or `navigator.userAgent` is not defined then try a more sneaky approach
67- if ( typeof Response === 'function' ) {
68- const resp = new Response ( null , { cf : { thing : true } } )
69- if ( typeof resp . cf === 'object' && resp . cf !== null && resp . cf . thing ) {
70- return true
71- }
72- }
73- return false
74- }
75-
7636function getStreamFuncs ( ) {
77- if ( isCloudflareRuntime ( ) ) {
78- return getCloudflareStreamFuncs ( )
79- }
8037 return getNodejsStreamFuncs ( )
8138}
You can’t perform that action at this time.
0 commit comments