(getServe)
| 99 | } |
| 100 | |
| 101 | function buildAsyncLocalStorage(getServe) { |
| 102 | const asyncLocalStorage = new AsyncLocalStorage(); |
| 103 | const server = createServer((req, res) => { |
| 104 | asyncLocalStorage.run({}, () => { |
| 105 | getServe(getCLS, setCLS)(req, res); |
| 106 | }); |
| 107 | }); |
| 108 | |
| 109 | return { |
| 110 | server, |
| 111 | close, |
| 112 | }; |
| 113 | |
| 114 | function getCLS() { |
| 115 | const store = asyncLocalStorage.getStore(); |
| 116 | if (store === undefined) { |
| 117 | return null; |
| 118 | } |
| 119 | return store.state; |
| 120 | } |
| 121 | |
| 122 | function setCLS(state) { |
| 123 | const store = asyncLocalStorage.getStore(); |
| 124 | if (store === undefined) { |
| 125 | return; |
| 126 | } |
| 127 | store.state = state; |
| 128 | } |
| 129 | |
| 130 | function close() { |
| 131 | asyncLocalStorage.disable(); |
| 132 | server.close(); |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | function getServeAwait(getCLS, setCLS) { |
| 137 | return async function serve(req, res) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…