acrylblends 0.2.0 → 0.4.0
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/index.d.ts +22 -16
- package/dist/index.js +65 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/plugins/acryl-inspect/LICENSE +21 -0
- package/plugins/acryl-inspect/plugin.json +12 -0
- package/plugins/acryl-inspect/src/index.ts +3 -0
- package/plugins/acryl-inspect/src/report.ts +126 -0
- package/plugins/acryl-inspect/src/service.ts +68 -0
- package/plugins/acryl-inspect/tests/report.spec.ts +63 -0
- package/plugins/acryl-inspect/tests/service.spec.ts +121 -0
- package/plugins/acryl-inspect/upstream.json +18 -0
- package/plugins/acryl-node-server/LICENSE +47 -0
- package/plugins/acryl-node-server/plugin.json +13 -0
- package/plugins/acryl-node-server/src/adapter/conninfo.ts +23 -0
- package/plugins/acryl-node-server/src/adapter/early-hints.ts +55 -0
- package/plugins/acryl-node-server/src/adapter/error.ts +11 -0
- package/plugins/acryl-node-server/src/adapter/headers.ts +249 -0
- package/plugins/acryl-node-server/src/adapter/index.ts +6 -0
- package/plugins/acryl-node-server/src/adapter/listener.ts +540 -0
- package/plugins/acryl-node-server/src/adapter/request.ts +797 -0
- package/plugins/acryl-node-server/src/adapter/response.ts +186 -0
- package/plugins/acryl-node-server/src/adapter/serve-static.ts +238 -0
- package/plugins/acryl-node-server/src/adapter/server.ts +36 -0
- package/plugins/acryl-node-server/src/adapter/types.ts +82 -0
- package/plugins/acryl-node-server/src/adapter/url.ts +42 -0
- package/plugins/acryl-node-server/src/adapter/utils/response/constants.ts +1 -0
- package/plugins/acryl-node-server/src/adapter/utils/response.ts +4 -0
- package/plugins/acryl-node-server/src/adapter/utils/stream.ts +88 -0
- package/plugins/acryl-node-server/src/adapter/utils.ts +96 -0
- package/plugins/acryl-node-server/src/adapter/websocket-types.ts +45 -0
- package/plugins/acryl-node-server/src/adapter/websocket.ts +375 -0
- package/plugins/acryl-node-server/src/index.ts +107 -0
- package/plugins/acryl-node-server/tests/adapter/app.ts +76 -0
- package/plugins/acryl-node-server/tests/adapter/assets/.static/plain.txt +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/favicon.ico +0 -0
- package/plugins/acryl-node-server/tests/adapter/assets/secret.txt +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/acryl.html +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/admin/secret.txt +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/data.json +5 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/extensionless +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/foo..bar.txt +0 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/index.html +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static/plain.txt +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-context-path/plain.txt +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.bin +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.bin.br +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt.br +1 -0
- package/plugins/acryl-node-server/tests/adapter/assets/static-with-precompressed/hello.txt.zst +1 -0
- package/plugins/acryl-node-server/tests/adapter/conninfo.test.ts +34 -0
- package/plugins/acryl-node-server/tests/adapter/content-length.test.ts +248 -0
- package/plugins/acryl-node-server/tests/adapter/early-hints.test.ts +457 -0
- package/plugins/acryl-node-server/tests/adapter/fixtures/keys/agent1-cert.pem +23 -0
- package/plugins/acryl-node-server/tests/adapter/fixtures/keys/agent1-key.pem +27 -0
- package/plugins/acryl-node-server/tests/adapter/headers.test.ts +252 -0
- package/plugins/acryl-node-server/tests/adapter/helpers/request.ts +190 -0
- package/plugins/acryl-node-server/tests/adapter/listener.test.ts +727 -0
- package/plugins/acryl-node-server/tests/adapter/request-client-disconnect.test.ts +189 -0
- package/plugins/acryl-node-server/tests/adapter/request.test.ts +1230 -0
- package/plugins/acryl-node-server/tests/adapter/response.test.ts +285 -0
- package/plugins/acryl-node-server/tests/adapter/serve-static.test.ts +849 -0
- package/plugins/acryl-node-server/tests/adapter/server-socket.test.ts +790 -0
- package/plugins/acryl-node-server/tests/adapter/server.test.ts +1302 -0
- package/plugins/acryl-node-server/tests/adapter/setup.ts +16 -0
- package/plugins/acryl-node-server/tests/adapter/url.test.ts +76 -0
- package/plugins/acryl-node-server/tests/adapter/utils/response.test.ts +23 -0
- package/plugins/acryl-node-server/tests/adapter/utils/stream.test.ts +75 -0
- package/plugins/acryl-node-server/tests/adapter/utils.test.ts +235 -0
- package/plugins/acryl-node-server/tests/adapter/websocket.test.ts +260 -0
- package/plugins/acryl-node-server/tests/server.spec.ts +141 -0
- package/plugins/acryl-node-server/upstream.json +18 -0
- package/plugins/acryl-router/LICENSE +47 -0
- package/plugins/acryl-router/plugin.json +13 -0
- package/plugins/acryl-router/src/client.ts +2 -0
- package/plugins/acryl-router/src/connection.ts +42 -0
- package/plugins/acryl-router/src/core/app-base.ts +544 -0
- package/plugins/acryl-router/src/core/app.test.ts +3833 -0
- package/plugins/acryl-router/src/core/app.ts +34 -0
- package/plugins/acryl-router/src/core/client/client.test.ts +2313 -0
- package/plugins/acryl-router/src/core/client/client.ts +249 -0
- package/plugins/acryl-router/src/core/client/fetch-result-please.ts +95 -0
- package/plugins/acryl-router/src/core/client/index.ts +17 -0
- package/plugins/acryl-router/src/core/client/types.test.ts +149 -0
- package/plugins/acryl-router/src/core/client/types.ts +393 -0
- package/plugins/acryl-router/src/core/client/utils.test.ts +405 -0
- package/plugins/acryl-router/src/core/client/utils.ts +117 -0
- package/plugins/acryl-router/src/core/compose.test.ts +751 -0
- package/plugins/acryl-router/src/core/compose.ts +73 -0
- package/plugins/acryl-router/src/core/context.test.ts +629 -0
- package/plugins/acryl-router/src/core/context.ts +781 -0
- package/plugins/acryl-router/src/core/helper/accepts/accepts.test.ts +344 -0
- package/plugins/acryl-router/src/core/helper/accepts/accepts.ts +96 -0
- package/plugins/acryl-router/src/core/helper/accepts/index.ts +6 -0
- package/plugins/acryl-router/src/core/helper/adapter/index.test.ts +55 -0
- package/plugins/acryl-router/src/core/helper/adapter/index.ts +90 -0
- package/plugins/acryl-router/src/core/helper/conninfo/index.ts +6 -0
- package/plugins/acryl-router/src/core/helper/conninfo/types.ts +45 -0
- package/plugins/acryl-router/src/core/helper/cookie/index.test.ts +510 -0
- package/plugins/acryl-router/src/core/helper/cookie/index.ts +146 -0
- package/plugins/acryl-router/src/core/helper/factory/index.test.ts +434 -0
- package/plugins/acryl-router/src/core/helper/factory/index.ts +375 -0
- package/plugins/acryl-router/src/core/helper/html/index.test.ts +78 -0
- package/plugins/acryl-router/src/core/helper/html/index.ts +57 -0
- package/plugins/acryl-router/src/core/helper/route/index.test.ts +259 -0
- package/plugins/acryl-router/src/core/helper/route/index.ts +144 -0
- package/plugins/acryl-router/src/core/helper/streaming/index.ts +9 -0
- package/plugins/acryl-router/src/core/helper/streaming/sse.ts +101 -0
- package/plugins/acryl-router/src/core/helper/streaming/stream.test.ts +128 -0
- package/plugins/acryl-router/src/core/helper/streaming/stream.ts +45 -0
- package/plugins/acryl-router/src/core/helper/streaming/text.test.ts +34 -0
- package/plugins/acryl-router/src/core/helper/streaming/text.ts +15 -0
- package/plugins/acryl-router/src/core/helper/streaming/utils.ts +11 -0
- package/plugins/acryl-router/src/core/helper/testing/index.test.ts +42 -0
- package/plugins/acryl-router/src/core/helper/testing/index.ts +28 -0
- package/plugins/acryl-router/src/core/helper/websocket/index.test.ts +124 -0
- package/plugins/acryl-router/src/core/helper/websocket/index.ts +140 -0
- package/plugins/acryl-router/src/core/http-exception.test.ts +45 -0
- package/plugins/acryl-router/src/core/http-exception.ts +77 -0
- package/plugins/acryl-router/src/core/index.ts +53 -0
- package/plugins/acryl-router/src/core/middleware/basic-auth/index.test.ts +434 -0
- package/plugins/acryl-router/src/core/middleware/basic-auth/index.ts +152 -0
- package/plugins/acryl-router/src/core/middleware/bearer-auth/index.test.ts +1018 -0
- package/plugins/acryl-router/src/core/middleware/bearer-auth/index.ts +220 -0
- package/plugins/acryl-router/src/core/middleware/body-limit/index.test.ts +273 -0
- package/plugins/acryl-router/src/core/middleware/body-limit/index.ts +110 -0
- package/plugins/acryl-router/src/core/middleware/combine/index.test.ts +355 -0
- package/plugins/acryl-router/src/core/middleware/combine/index.ts +171 -0
- package/plugins/acryl-router/src/core/middleware/compress/index.test.ts +535 -0
- package/plugins/acryl-router/src/core/middleware/compress/index.ts +142 -0
- package/plugins/acryl-router/src/core/middleware/context-storage/index.test.ts +43 -0
- package/plugins/acryl-router/src/core/middleware/context-storage/index.ts +58 -0
- package/plugins/acryl-router/src/core/middleware/cors/index.test.ts +532 -0
- package/plugins/acryl-router/src/core/middleware/cors/index.ts +163 -0
- package/plugins/acryl-router/src/core/middleware/csrf/index.test.ts +534 -0
- package/plugins/acryl-router/src/core/middleware/csrf/index.ts +150 -0
- package/plugins/acryl-router/src/core/middleware/etag/digest.test.ts +21 -0
- package/plugins/acryl-router/src/core/middleware/etag/digest.ts +95 -0
- package/plugins/acryl-router/src/core/middleware/etag/index.test.ts +503 -0
- package/plugins/acryl-router/src/core/middleware/etag/index.ts +135 -0
- package/plugins/acryl-router/src/core/middleware/ip-restriction/index.test.ts +217 -0
- package/plugins/acryl-router/src/core/middleware/ip-restriction/index.ts +278 -0
- package/plugins/acryl-router/src/core/middleware/jwk/index.test.ts +1135 -0
- package/plugins/acryl-router/src/core/middleware/jwk/index.ts +1 -0
- package/plugins/acryl-router/src/core/middleware/jwk/jwk.ts +195 -0
- package/plugins/acryl-router/src/core/middleware/jwk/keys.test.json +48 -0
- package/plugins/acryl-router/src/core/middleware/jwt/index.test.ts +802 -0
- package/plugins/acryl-router/src/core/middleware/jwt/index.ts +9 -0
- package/plugins/acryl-router/src/core/middleware/jwt/jwt.ts +189 -0
- package/plugins/acryl-router/src/core/middleware/language/index.test.ts +552 -0
- package/plugins/acryl-router/src/core/middleware/language/index.ts +12 -0
- package/plugins/acryl-router/src/core/middleware/language/language.ts +314 -0
- package/plugins/acryl-router/src/core/middleware/logger/index.test.ts +204 -0
- package/plugins/acryl-router/src/core/middleware/logger/index.ts +95 -0
- package/plugins/acryl-router/src/core/middleware/method-not-allowed/index.test.ts +292 -0
- package/plugins/acryl-router/src/core/middleware/method-not-allowed/index.ts +141 -0
- package/plugins/acryl-router/src/core/middleware/method-override/index.test.ts +221 -0
- package/plugins/acryl-router/src/core/middleware/method-override/index.ts +147 -0
- package/plugins/acryl-router/src/core/middleware/powered-by/index.test.ts +37 -0
- package/plugins/acryl-router/src/core/middleware/powered-by/index.ts +35 -0
- package/plugins/acryl-router/src/core/middleware/pretty-json/index.test.ts +218 -0
- package/plugins/acryl-router/src/core/middleware/pretty-json/index.ts +67 -0
- package/plugins/acryl-router/src/core/middleware/request-id/index.test.ts +168 -0
- package/plugins/acryl-router/src/core/middleware/request-id/index.ts +7 -0
- package/plugins/acryl-router/src/core/middleware/request-id/request-id.ts +59 -0
- package/plugins/acryl-router/src/core/middleware/secure-headers/index.test.ts +671 -0
- package/plugins/acryl-router/src/core/middleware/secure-headers/index.ts +8 -0
- package/plugins/acryl-router/src/core/middleware/secure-headers/permissions-policy.ts +101 -0
- package/plugins/acryl-router/src/core/middleware/secure-headers/secure-headers.ts +340 -0
- package/plugins/acryl-router/src/core/middleware/serve-static/index.test.ts +450 -0
- package/plugins/acryl-router/src/core/middleware/serve-static/index.ts +135 -0
- package/plugins/acryl-router/src/core/middleware/serve-static/path.test.ts +50 -0
- package/plugins/acryl-router/src/core/middleware/serve-static/path.ts +25 -0
- package/plugins/acryl-router/src/core/middleware/timeout/index.test.ts +70 -0
- package/plugins/acryl-router/src/core/middleware/timeout/index.ts +58 -0
- package/plugins/acryl-router/src/core/middleware/timing/index.test.ts +310 -0
- package/plugins/acryl-router/src/core/middleware/timing/index.ts +8 -0
- package/plugins/acryl-router/src/core/middleware/timing/timing.ts +256 -0
- package/plugins/acryl-router/src/core/middleware/trailing-slash/index.test.ts +381 -0
- package/plugins/acryl-router/src/core/middleware/trailing-slash/index.ts +156 -0
- package/plugins/acryl-router/src/core/request/constants.ts +1 -0
- package/plugins/acryl-router/src/core/request.test.ts +751 -0
- package/plugins/acryl-router/src/core/request.ts +502 -0
- package/plugins/acryl-router/src/core/router/common.case.test.ts +1132 -0
- package/plugins/acryl-router/src/core/router/linear-router/index.ts +6 -0
- package/plugins/acryl-router/src/core/router/linear-router/router.test.ts +80 -0
- package/plugins/acryl-router/src/core/router/linear-router/router.ts +152 -0
- package/plugins/acryl-router/src/core/router/pattern-router/index.ts +6 -0
- package/plugins/acryl-router/src/core/router/pattern-router/router.test.ts +46 -0
- package/plugins/acryl-router/src/core/router/pattern-router/router.ts +54 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/index.ts +7 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/matcher.ts +33 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/node.ts +170 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/prepared-router.test.ts +154 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/prepared-router.ts +165 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/router.test.ts +265 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/router.ts +174 -0
- package/plugins/acryl-router/src/core/router/reg-exp-router/trie.ts +84 -0
- package/plugins/acryl-router/src/core/router/smart-router/index.ts +6 -0
- package/plugins/acryl-router/src/core/router/smart-router/router.test.ts +13 -0
- package/plugins/acryl-router/src/core/router/smart-router/router.ts +70 -0
- package/plugins/acryl-router/src/core/router/trie-router/index.ts +6 -0
- package/plugins/acryl-router/src/core/router/trie-router/node.test.ts +896 -0
- package/plugins/acryl-router/src/core/router/trie-router/node.ts +221 -0
- package/plugins/acryl-router/src/core/router/trie-router/router.test.ts +8 -0
- package/plugins/acryl-router/src/core/router/trie-router/router.ts +18 -0
- package/plugins/acryl-router/src/core/router/utils.ts +1 -0
- package/plugins/acryl-router/src/core/router.ts +103 -0
- package/plugins/acryl-router/src/core/types.test.ts +4134 -0
- package/plugins/acryl-router/src/core/types.ts +2782 -0
- package/plugins/acryl-router/src/core/utils/accept.test.ts +299 -0
- package/plugins/acryl-router/src/core/utils/accept.ts +268 -0
- package/plugins/acryl-router/src/core/utils/basic-auth.test.ts +56 -0
- package/plugins/acryl-router/src/core/utils/basic-auth.ts +26 -0
- package/plugins/acryl-router/src/core/utils/body.test.ts +496 -0
- package/plugins/acryl-router/src/core/utils/body.ts +263 -0
- package/plugins/acryl-router/src/core/utils/buffer.test.ts +147 -0
- package/plugins/acryl-router/src/core/utils/buffer.ts +117 -0
- package/plugins/acryl-router/src/core/utils/color.test.ts +23 -0
- package/plugins/acryl-router/src/core/utils/color.ts +56 -0
- package/plugins/acryl-router/src/core/utils/compress.ts +10 -0
- package/plugins/acryl-router/src/core/utils/concurrent.test.ts +69 -0
- package/plugins/acryl-router/src/core/utils/concurrent.ts +55 -0
- package/plugins/acryl-router/src/core/utils/constants.ts +4 -0
- package/plugins/acryl-router/src/core/utils/cookie.test.ts +460 -0
- package/plugins/acryl-router/src/core/utils/cookie.ts +281 -0
- package/plugins/acryl-router/src/core/utils/crypto.test.ts +43 -0
- package/plugins/acryl-router/src/core/utils/crypto.ts +58 -0
- package/plugins/acryl-router/src/core/utils/encode.test.ts +61 -0
- package/plugins/acryl-router/src/core/utils/encode.ts +34 -0
- package/plugins/acryl-router/src/core/utils/filepath.test.ts +78 -0
- package/plugins/acryl-router/src/core/utils/filepath.ts +60 -0
- package/plugins/acryl-router/src/core/utils/handler.ts +15 -0
- package/plugins/acryl-router/src/core/utils/headers.ts +355 -0
- package/plugins/acryl-router/src/core/utils/html.test.ts +16 -0
- package/plugins/acryl-router/src/core/utils/html.ts +182 -0
- package/plugins/acryl-router/src/core/utils/http-status.ts +72 -0
- package/plugins/acryl-router/src/core/utils/ipaddr.test.ts +149 -0
- package/plugins/acryl-router/src/core/utils/ipaddr.ts +374 -0
- package/plugins/acryl-router/src/core/utils/jwt/index.ts +7 -0
- package/plugins/acryl-router/src/core/utils/jwt/jwa.test.ts +86 -0
- package/plugins/acryl-router/src/core/utils/jwt/jwa.ts +38 -0
- package/plugins/acryl-router/src/core/utils/jwt/jws.ts +235 -0
- package/plugins/acryl-router/src/core/utils/jwt/jwt.test.ts +1788 -0
- package/plugins/acryl-router/src/core/utils/jwt/jwt.ts +292 -0
- package/plugins/acryl-router/src/core/utils/jwt/types.ts +157 -0
- package/plugins/acryl-router/src/core/utils/jwt/utf8.ts +7 -0
- package/plugins/acryl-router/src/core/utils/mime.test.ts +64 -0
- package/plugins/acryl-router/src/core/utils/mime.ts +94 -0
- package/plugins/acryl-router/src/core/utils/stream.test.ts +212 -0
- package/plugins/acryl-router/src/core/utils/stream.ts +107 -0
- package/plugins/acryl-router/src/core/utils/types.test.ts +295 -0
- package/plugins/acryl-router/src/core/utils/types.ts +123 -0
- package/plugins/acryl-router/src/core/utils/url.test.ts +384 -0
- package/plugins/acryl-router/src/core/utils/url.ts +337 -0
- package/plugins/acryl-router/src/core/validator/index.ts +8 -0
- package/plugins/acryl-router/src/core/validator/utils.test.ts +82 -0
- package/plugins/acryl-router/src/core/validator/utils.ts +69 -0
- package/plugins/acryl-router/src/core/validator/validator.test.ts +1488 -0
- package/plugins/acryl-router/src/core/validator/validator.ts +185 -0
- package/plugins/acryl-router/src/helpers/index.ts +13 -0
- package/plugins/acryl-router/src/helpers/schema-validator.ts +35 -0
- package/plugins/acryl-router/src/index.ts +6 -0
- package/plugins/acryl-router/src/middleware/index.ts +25 -0
- package/plugins/acryl-router/src/middleware/loopback-only.ts +88 -0
- package/plugins/acryl-router/src/service.ts +356 -0
- package/plugins/acryl-router/tests/docs-examples.spec.ts +152 -0
- package/plugins/acryl-router/tests/live-install.spec.ts +64 -0
- package/plugins/acryl-router/tests/loader.spec.ts +72 -0
- package/plugins/acryl-router/tests/service.spec.ts +409 -0
- package/plugins/acryl-router/tests/shadow-state.spec.ts +79 -0
- package/plugins/acryl-router/upstream.json +20 -0
- package/plugins/acryl-router-http/LICENSE +21 -0
- package/plugins/acryl-router-http/plugin.json +12 -0
- package/plugins/acryl-router-http/src/bridge.ts +54 -0
- package/plugins/acryl-router-http/src/index.ts +63 -0
- package/plugins/acryl-router-http/src/serve.ts +24 -0
- package/plugins/acryl-router-http/tests/adapter.spec.ts +174 -0
- package/plugins/acryl-router-http/tests/stream.spec.ts +133 -0
- package/plugins/acryl-router-http/tests/surfaces.spec.ts +101 -0
- package/plugins/acryl-router-http/upstream.json +22 -0
- package/plugins/acryl-state/LICENSE +21 -0
- package/plugins/acryl-state/NOTICE +30 -0
- package/plugins/acryl-state/plugin.json +12 -0
- package/plugins/acryl-state/src/cell.ts +67 -0
- package/plugins/acryl-state/src/index.ts +3 -0
- package/plugins/acryl-state/src/react.ts +11 -0
- package/plugins/acryl-state/src/service.ts +119 -0
- package/plugins/acryl-state/tests/cell.spec.ts +71 -0
- package/plugins/acryl-state/tests/react.spec.ts +39 -0
- package/plugins/acryl-state/tests/service.spec.ts +132 -0
- package/plugins/acryl-state/upstream.json +22 -0
- package/plugins/builder/script.ts +6 -10
- package/plugins/extensions/index.ts +20 -3
- package/plugins/extensions/resolve.ts +28 -3
- package/plugins/openai/prompt.ts +12 -6
- package/plugins/tasks/index.ts +14 -0
- package/plugins/tsconfig.json +14 -5
- package/templates/agent/blend.yaml +5 -7
- package/templates/agent/src/app.ts +8 -8
- package/templates/agent/src/routes.ts +39 -38
- package/templates/agent/template.json +3 -3
- package/templates/agent/test/builder.test.ts +22 -14
- package/templates/agent/test/model.test.ts +3 -3
- package/templates/agent/tsconfig.json +8 -5
- package/templates/{app → blank}/blend.yaml +3 -3
- package/templates/{app → blank}/src/app.ts +5 -5
- package/templates/blank/src/routes.ts +16 -0
- package/templates/blank/template.json +1 -0
- package/templates/{app → blank}/test/app.test.ts +1 -1
- package/templates/{app → blank}/tsconfig.json +2 -4
- package/templates/todo/README.md +27 -0
- package/templates/todo/blend.yaml +25 -0
- package/templates/todo/gitignore +2 -0
- package/templates/todo/package.json +23 -0
- package/templates/todo/src/app.ts +71 -0
- package/templates/todo/src/main.ts +19 -0
- package/templates/todo/src/page.ts +28 -0
- package/templates/todo/src/todo.ts +123 -0
- package/templates/todo/template.json +1 -0
- package/templates/todo/test/todo.test.ts +145 -0
- package/templates/todo/tsconfig.json +17 -0
- package/templates/todo/upstream.json +12 -0
- package/plugins/events/index.ts +0 -42
- package/plugins/events/plugin.json +0 -9
- package/plugins/http/index.ts +0 -64
- package/plugins/http/plugin.json +0 -10
- package/plugins/server/index.ts +0 -138
- package/plugins/server/plugin.json +0 -10
- package/templates/app/src/routes.ts +0 -14
- package/templates/app/template.json +0 -1
- /package/templates/{app → blank}/README.md +0 -0
- /package/templates/{app → blank}/gitignore +0 -0
- /package/templates/{app → blank}/package.json +0 -0
- /package/templates/{app → blank}/src/main.ts +0 -0
|
@@ -0,0 +1,849 @@
|
|
|
1
|
+
import { App } from '../../../acryl-router/src/index.ts'
|
|
2
|
+
import type * as fs from 'node:fs'
|
|
3
|
+
import {
|
|
4
|
+
chmodSync,
|
|
5
|
+
createReadStream,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
mkdtempSync,
|
|
8
|
+
rmSync,
|
|
9
|
+
statSync,
|
|
10
|
+
symlinkSync,
|
|
11
|
+
writeFileSync,
|
|
12
|
+
} from 'node:fs'
|
|
13
|
+
import { tmpdir } from 'node:os'
|
|
14
|
+
import path from 'node:path'
|
|
15
|
+
import { serveStatic } from '../../src/adapter/serve-static.ts'
|
|
16
|
+
import { createAdaptorServer } from '../../src/adapter/server.ts'
|
|
17
|
+
import { requestServer } from './helpers/request.ts'
|
|
18
|
+
|
|
19
|
+
vi.mock('node:fs', async (importOriginal) => {
|
|
20
|
+
const originalFs = await importOriginal<typeof fs>()
|
|
21
|
+
return {
|
|
22
|
+
...originalFs,
|
|
23
|
+
statSync: vi.fn(originalFs.statSync),
|
|
24
|
+
createReadStream: vi.fn(originalFs.createReadStream),
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
describe('Serve Static Middleware', () => {
|
|
29
|
+
const app = new App<{
|
|
30
|
+
Variables: {
|
|
31
|
+
path: string
|
|
32
|
+
}
|
|
33
|
+
}>()
|
|
34
|
+
|
|
35
|
+
app.use(
|
|
36
|
+
'/static/*',
|
|
37
|
+
serveStatic({
|
|
38
|
+
root: './tests/adapter/assets',
|
|
39
|
+
onFound: (path, c) => {
|
|
40
|
+
c.header('X-Custom', `Found the file at ${path}`)
|
|
41
|
+
if (c.req.query('type')) {
|
|
42
|
+
c.header('Content-Type', c.req.query('type'))
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
})
|
|
46
|
+
)
|
|
47
|
+
app.use('/favicon.ico', serveStatic({ path: './tests/adapter/assets/favicon.ico' }))
|
|
48
|
+
app.use(
|
|
49
|
+
'/dot-static/*',
|
|
50
|
+
serveStatic({
|
|
51
|
+
root: './tests/adapter/assets',
|
|
52
|
+
rewriteRequestPath: (path) => path.replace(/^\/dot-static/, '/.static'),
|
|
53
|
+
})
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
app.use(
|
|
57
|
+
'/static-with-context-path-route/*',
|
|
58
|
+
async (c, next) => {
|
|
59
|
+
c.set('path', '/static-with-context-path')
|
|
60
|
+
await next()
|
|
61
|
+
},
|
|
62
|
+
serveStatic({
|
|
63
|
+
root: './tests/adapter/assets',
|
|
64
|
+
rewriteRequestPath: (path, c) =>
|
|
65
|
+
path.replace('static-with-context-path-route', c.get('path')),
|
|
66
|
+
})
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
let notFoundMessage = ''
|
|
70
|
+
app.use(
|
|
71
|
+
'/on-not-found/*',
|
|
72
|
+
serveStatic({
|
|
73
|
+
root: './not-found',
|
|
74
|
+
onNotFound: (path, c) => {
|
|
75
|
+
notFoundMessage = `${path} is not found, request to ${c.req.path}`
|
|
76
|
+
},
|
|
77
|
+
})
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
app.use(
|
|
81
|
+
'/static-with-precompressed/*',
|
|
82
|
+
serveStatic({
|
|
83
|
+
root: './tests/adapter/assets',
|
|
84
|
+
precompressed: true,
|
|
85
|
+
})
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
const server = createAdaptorServer(app)
|
|
89
|
+
|
|
90
|
+
describe('HTTP methods', () => {
|
|
91
|
+
beforeEach(() => {
|
|
92
|
+
vi.mocked(statSync).mockClear()
|
|
93
|
+
vi.mocked(createReadStream).mockClear()
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it.each(['POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'PROPFIND'])(
|
|
97
|
+
'Should pass %s requests to the next handler without accessing files',
|
|
98
|
+
async (method) => {
|
|
99
|
+
const rewriteRequestPath = vi.fn((path: string) => path)
|
|
100
|
+
const onFound = vi.fn()
|
|
101
|
+
const onNotFound = vi.fn()
|
|
102
|
+
const app = new App().use(
|
|
103
|
+
'/static/*',
|
|
104
|
+
serveStatic({ root: './tests/adapter/assets', rewriteRequestPath, onFound, onNotFound })
|
|
105
|
+
)
|
|
106
|
+
app.on(method, '/static/plain.txt', (c) => c.text('Handled downstream', 202))
|
|
107
|
+
|
|
108
|
+
const res = await requestServer(createAdaptorServer(app), {
|
|
109
|
+
method,
|
|
110
|
+
path: '/static/plain.txt',
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
expect(res.status).toBe(202)
|
|
114
|
+
expect(await res.text()).toBe('Handled downstream')
|
|
115
|
+
expect(rewriteRequestPath).not.toHaveBeenCalled()
|
|
116
|
+
expect(statSync).not.toHaveBeenCalled()
|
|
117
|
+
expect(createReadStream).not.toHaveBeenCalled()
|
|
118
|
+
expect(onFound).not.toHaveBeenCalled()
|
|
119
|
+
expect(onNotFound).not.toHaveBeenCalled()
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
it.each(['/static/plain.txt', '/static/does-not-exist.html'])(
|
|
124
|
+
'Should return 404 for an unhandled POST request regardless of file existence - %s',
|
|
125
|
+
async (path) => {
|
|
126
|
+
const res = await requestServer(server, { method: 'POST', path })
|
|
127
|
+
|
|
128
|
+
expect(res.status).toBe(404)
|
|
129
|
+
expect(await res.text()).toBe('404 Not Found')
|
|
130
|
+
expect(statSync).not.toHaveBeenCalled()
|
|
131
|
+
expect(createReadStream).not.toHaveBeenCalled()
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
it('Should return index.html', async () => {
|
|
137
|
+
const res = await requestServer(server, { method: 'GET', path: '/static/' })
|
|
138
|
+
expect(res.status).toBe(200)
|
|
139
|
+
expect(await res.text()).toBe('<h1>Hello App</h1>')
|
|
140
|
+
expect(res.headers.get('content-type')).toBe('text/html; charset=utf-8')
|
|
141
|
+
expect(res.headers.get('x-custom')).toMatch(
|
|
142
|
+
/Found the file at tests[\/\\]adapter[\/\\]assets[\/\\]static[\/\\]index\.html$/
|
|
143
|
+
)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
it('Should return acryl.html', async () => {
|
|
147
|
+
const res = await requestServer(server, { method: 'GET', path: '/static/acryl.html' })
|
|
148
|
+
expect(res.status).toBe(200)
|
|
149
|
+
expect(await res.text()).toBe('<h1>This is App.html</h1>')
|
|
150
|
+
expect(res.headers.get('content-type')).toBe('text/html; charset=utf-8')
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
it('Should return correct headers for icons', async () => {
|
|
154
|
+
const res = await requestServer(server, { method: 'GET', path: '/favicon.ico' })
|
|
155
|
+
expect(res.status).toBe(200)
|
|
156
|
+
expect(res.headers.get('content-type')).toBe('image/x-icon')
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
it('Should return correct headers and data for json files', async () => {
|
|
160
|
+
const res = await requestServer(server, { method: 'GET', path: '/static/data.json' })
|
|
161
|
+
expect(res.status).toBe(200)
|
|
162
|
+
expect(await res.json()).toEqual({
|
|
163
|
+
id: 1,
|
|
164
|
+
name: 'Foo Bar',
|
|
165
|
+
flag: true,
|
|
166
|
+
})
|
|
167
|
+
expect(res.headers.get('content-type')).toBe('application/json')
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
it('Should return correct headers and data for text', async () => {
|
|
171
|
+
const res = await requestServer(server, { method: 'GET', path: '/static/plain.txt' })
|
|
172
|
+
const stats = statSync(path.join(__dirname, 'assets', 'static', 'plain.txt'))
|
|
173
|
+
expect(res.status).toBe(200)
|
|
174
|
+
expect(res.headers.get('content-type')).toBe('text/plain; charset=utf-8')
|
|
175
|
+
expect(res.headers.get('last-modified')).toBe(stats.mtime.toUTCString())
|
|
176
|
+
expect(await res.text()).toBe('This is plain.txt')
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
it('Should return 404 for non-existent files', async () => {
|
|
180
|
+
const res = await requestServer(server, {
|
|
181
|
+
method: 'GET',
|
|
182
|
+
path: '/static/does-not-exist.html',
|
|
183
|
+
})
|
|
184
|
+
expect(res.status).toBe(404)
|
|
185
|
+
expect(res.headers.get('content-type')).toBe('text/plain; charset=UTF-8')
|
|
186
|
+
expect(await res.text()).toBe('404 Not Found')
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
it('Should return 200 with rewriteRequestPath', async () => {
|
|
190
|
+
const res = await requestServer(server, { method: 'GET', path: '/dot-static/plain.txt' })
|
|
191
|
+
expect(res.status).toBe(200)
|
|
192
|
+
expect(res.headers.get('content-type')).toBe('text/plain; charset=utf-8')
|
|
193
|
+
expect(await res.text()).toBe('This is plain.txt')
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
it('Should return 404 with rewriteRequestPath', async () => {
|
|
197
|
+
const res = await requestServer(server, {
|
|
198
|
+
method: 'GET',
|
|
199
|
+
path: '/dot-static/does-no-exists.txt',
|
|
200
|
+
})
|
|
201
|
+
expect(res.status).toBe(404)
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
it('Should return 200 with rewriteRequestPath with the context', async () => {
|
|
205
|
+
const res = await requestServer(server, {
|
|
206
|
+
method: 'GET',
|
|
207
|
+
path: '/static-with-context-path-route/plain.txt',
|
|
208
|
+
})
|
|
209
|
+
expect(res.status).toBe(200)
|
|
210
|
+
expect(res.headers.get('content-type')).toBe('text/plain; charset=utf-8')
|
|
211
|
+
expect(await res.text()).toBe('This is plain.txt')
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
it('Should return 200 response to HEAD request', async () => {
|
|
215
|
+
const res = await requestServer(server, { method: 'HEAD', path: '/static/plain.txt' })
|
|
216
|
+
const stats = statSync(path.join(__dirname, 'assets', 'static', 'plain.txt'))
|
|
217
|
+
expect(res.status).toBe(200)
|
|
218
|
+
expect(res.headers.get('content-type')).toBe('text/plain; charset=utf-8')
|
|
219
|
+
expect(res.headers.get('content-length')).toBe('17')
|
|
220
|
+
expect(res.headers.get('last-modified')).toBe(stats.mtime.toUTCString())
|
|
221
|
+
expect(res.body).toBeNull()
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
it('Should return correct headers and data with range headers', async () => {
|
|
225
|
+
let res = await requestServer(server, {
|
|
226
|
+
method: 'GET',
|
|
227
|
+
path: '/static/plain.txt',
|
|
228
|
+
headers: { range: '0-9' },
|
|
229
|
+
})
|
|
230
|
+
const stats = statSync(path.join(__dirname, 'assets', 'static', 'plain.txt'))
|
|
231
|
+
expect(res.status).toBe(206)
|
|
232
|
+
expect(res.headers.get('content-type')).toBe('text/plain; charset=utf-8')
|
|
233
|
+
expect(res.headers.get('content-length')).toBe('10')
|
|
234
|
+
expect(res.headers.get('content-range')).toBe('bytes 0-9/17')
|
|
235
|
+
expect(res.headers.get('last-modified')).toBe(stats.mtime.toUTCString())
|
|
236
|
+
expect(res.headers.get('date')).not.toBe(stats.mtime.toUTCString())
|
|
237
|
+
expect(res.headers.get('date')).not.toBe(stats.birthtime.toUTCString())
|
|
238
|
+
let text = await res.text()
|
|
239
|
+
expect(text.length).toBe(10)
|
|
240
|
+
expect(text).toBe('This is pl')
|
|
241
|
+
|
|
242
|
+
res = await requestServer(server, {
|
|
243
|
+
method: 'GET',
|
|
244
|
+
path: '/static/plain.txt',
|
|
245
|
+
headers: { range: '10-16' },
|
|
246
|
+
})
|
|
247
|
+
expect(res.status).toBe(206)
|
|
248
|
+
expect(res.headers.get('content-type')).toBe('text/plain; charset=utf-8')
|
|
249
|
+
expect(res.headers.get('content-length')).toBe('7')
|
|
250
|
+
expect(res.headers.get('content-range')).toBe('bytes 10-16/17')
|
|
251
|
+
text = await res.text()
|
|
252
|
+
expect(text.length).toBe(7)
|
|
253
|
+
expect(text).toBe('ain.txt')
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
it('Should return correct headers and data if client range exceeds the data size', async () => {
|
|
257
|
+
const res = await requestServer(server, {
|
|
258
|
+
method: 'GET',
|
|
259
|
+
path: '/static/plain.txt',
|
|
260
|
+
headers: { range: '0-20' },
|
|
261
|
+
})
|
|
262
|
+
expect(res.status).toBe(206)
|
|
263
|
+
expect(res.headers.get('content-type')).toBe('text/plain; charset=utf-8')
|
|
264
|
+
expect(res.headers.get('content-length')).toBe('17')
|
|
265
|
+
expect(res.headers.get('content-range')).toBe('bytes 0-16/17')
|
|
266
|
+
const text = await res.text()
|
|
267
|
+
expect(text.length).toBe(17)
|
|
268
|
+
expect(text).toBe('This is plain.txt')
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
it('Should handle invalid range header gracefully without NaN error', async () => {
|
|
272
|
+
const res = await requestServer(server, {
|
|
273
|
+
method: 'GET',
|
|
274
|
+
path: '/static/plain.txt',
|
|
275
|
+
headers: { range: 'hello' },
|
|
276
|
+
})
|
|
277
|
+
expect(res.status).toBe(206)
|
|
278
|
+
expect(res.headers.get('content-length')).toBe('17')
|
|
279
|
+
expect(res.headers.get('content-range')).toBe('bytes 0-16/17')
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
it('Should return the last N bytes for a suffix range', async () => {
|
|
283
|
+
const res = await requestServer(server, {
|
|
284
|
+
method: 'GET',
|
|
285
|
+
path: '/static/plain.txt',
|
|
286
|
+
headers: { range: 'bytes=-5' },
|
|
287
|
+
})
|
|
288
|
+
expect(res.status).toBe(206)
|
|
289
|
+
expect(res.headers.get('content-length')).toBe('5')
|
|
290
|
+
expect(res.headers.get('content-range')).toBe('bytes 12-16/17')
|
|
291
|
+
expect(await res.text()).toBe('n.txt')
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
it('Should return the whole file for a suffix range exceeding the file size', async () => {
|
|
295
|
+
const res = await requestServer(server, {
|
|
296
|
+
method: 'GET',
|
|
297
|
+
path: '/static/plain.txt',
|
|
298
|
+
headers: { range: 'bytes=-100' },
|
|
299
|
+
})
|
|
300
|
+
expect(res.status).toBe(206)
|
|
301
|
+
expect(res.headers.get('content-range')).toBe('bytes 0-16/17')
|
|
302
|
+
expect(await res.text()).toBe('This is plain.txt')
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
it('Should return exactly 1 byte for range bytes=0-0', async () => {
|
|
306
|
+
const res = await requestServer(server, {
|
|
307
|
+
method: 'GET',
|
|
308
|
+
path: '/static/plain.txt',
|
|
309
|
+
headers: { range: 'bytes=0-0' },
|
|
310
|
+
})
|
|
311
|
+
expect(res.status).toBe(206)
|
|
312
|
+
expect(res.headers.get('content-length')).toBe('1')
|
|
313
|
+
expect(res.headers.get('content-range')).toBe('bytes 0-0/17')
|
|
314
|
+
expect(await res.text()).toBe('T')
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
it('Should return 416 when the range start is beyond the end of the file', async () => {
|
|
318
|
+
const res = await requestServer(server, {
|
|
319
|
+
method: 'GET',
|
|
320
|
+
path: '/static/plain.txt',
|
|
321
|
+
headers: { range: 'bytes=100-200' },
|
|
322
|
+
})
|
|
323
|
+
expect(res.status).toBe(416)
|
|
324
|
+
expect(res.headers.get('content-range')).toBe('bytes */17')
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
it('Should return 416 when the range start is beyond the file size, even if the window is small', async () => {
|
|
328
|
+
const res = await requestServer(server, {
|
|
329
|
+
method: 'GET',
|
|
330
|
+
path: '/static/plain.txt',
|
|
331
|
+
headers: { range: 'bytes=20-25' },
|
|
332
|
+
})
|
|
333
|
+
expect(res.status).toBe(416)
|
|
334
|
+
expect(res.headers.get('content-range')).toBe('bytes */17')
|
|
335
|
+
})
|
|
336
|
+
|
|
337
|
+
it('Should return 416 when the range start is after the range end', async () => {
|
|
338
|
+
const res = await requestServer(server, {
|
|
339
|
+
method: 'GET',
|
|
340
|
+
path: '/static/plain.txt',
|
|
341
|
+
headers: { range: 'bytes=10-5' },
|
|
342
|
+
})
|
|
343
|
+
expect(res.status).toBe(416)
|
|
344
|
+
expect(res.headers.get('content-range')).toBe('bytes */17')
|
|
345
|
+
})
|
|
346
|
+
|
|
347
|
+
it('Should return 416 for a zero-length suffix range', async () => {
|
|
348
|
+
const res = await requestServer(server, {
|
|
349
|
+
method: 'GET',
|
|
350
|
+
path: '/static/plain.txt',
|
|
351
|
+
headers: { range: 'bytes=-0' },
|
|
352
|
+
})
|
|
353
|
+
expect(res.status).toBe(416)
|
|
354
|
+
expect(res.headers.get('content-range')).toBe('bytes */17')
|
|
355
|
+
})
|
|
356
|
+
|
|
357
|
+
it.each(['bytes=0-1x', 'bytes=x-1', 'bytes=0-1-2', 'bytes=-5-extra'])(
|
|
358
|
+
'Should treat a malformed range as the whole file: %s',
|
|
359
|
+
async (range) => {
|
|
360
|
+
const res = await requestServer(server, {
|
|
361
|
+
method: 'GET',
|
|
362
|
+
path: '/static/plain.txt',
|
|
363
|
+
headers: { range },
|
|
364
|
+
})
|
|
365
|
+
expect(res.status).toBe(206)
|
|
366
|
+
expect(res.headers.get('content-range')).toBe('bytes 0-16/17')
|
|
367
|
+
expect(await res.text()).toBe('This is plain.txt')
|
|
368
|
+
}
|
|
369
|
+
)
|
|
370
|
+
|
|
371
|
+
it('Should return 416 instead of crashing for a range request on an empty file', async () => {
|
|
372
|
+
const res = await requestServer(server, {
|
|
373
|
+
method: 'GET',
|
|
374
|
+
path: '/static/foo..bar.txt',
|
|
375
|
+
headers: { range: 'bytes=0-0' },
|
|
376
|
+
})
|
|
377
|
+
expect(res.status).toBe(416)
|
|
378
|
+
expect(res.headers.get('content-range')).toBe('bytes */0')
|
|
379
|
+
})
|
|
380
|
+
|
|
381
|
+
it('Should return 416 instead of crashing for a malformed range on an empty file', async () => {
|
|
382
|
+
const res = await requestServer(server, {
|
|
383
|
+
method: 'GET',
|
|
384
|
+
path: '/static/foo..bar.txt',
|
|
385
|
+
headers: { range: 'hello' },
|
|
386
|
+
})
|
|
387
|
+
expect(res.status).toBe(416)
|
|
388
|
+
expect(res.headers.get('content-range')).toBe('bytes */0')
|
|
389
|
+
})
|
|
390
|
+
|
|
391
|
+
it('Should handle the `onNotFound` option', async () => {
|
|
392
|
+
const res = await requestServer(server, { method: 'GET', path: '/on-not-found/foo.txt' })
|
|
393
|
+
expect(res.status).toBe(404)
|
|
394
|
+
expect(notFoundMessage).toMatch(
|
|
395
|
+
/not-found[\/\\]on-not-found[\/\\]foo\.txt is not found, request to \/on-not-found\/foo\.txt$/
|
|
396
|
+
)
|
|
397
|
+
})
|
|
398
|
+
|
|
399
|
+
it('Should handle the `onFound` option', async () => {
|
|
400
|
+
const res = await requestServer(server, {
|
|
401
|
+
method: 'GET',
|
|
402
|
+
path: '/static/data.json?type=application/json;%20charset=utf-8',
|
|
403
|
+
})
|
|
404
|
+
expect(res.status).toBe(200)
|
|
405
|
+
expect(res.headers.get('content-type')).toBe('application/json; charset=utf-8')
|
|
406
|
+
})
|
|
407
|
+
|
|
408
|
+
it('Should handle double dots in URL', async () => {
|
|
409
|
+
const res = await requestServer(server, { method: 'GET', path: '/static/../secret.txt' })
|
|
410
|
+
expect(res.status).toBe(404)
|
|
411
|
+
})
|
|
412
|
+
|
|
413
|
+
// Skip on Windows as symlink behavior is different
|
|
414
|
+
;(process.platform === 'win32' ? it.skip : it)('Should follow symlinks', async () => {
|
|
415
|
+
const symlinkPath = path.join(__dirname, 'assets', 'static', 'symlink.html')
|
|
416
|
+
const symlinkTarget = path.join(__dirname, 'assets', 'static', 'index.html')
|
|
417
|
+
try {
|
|
418
|
+
// force: true so it doesn't throw if the symlink doesn't exist
|
|
419
|
+
rmSync(symlinkPath, { force: true })
|
|
420
|
+
symlinkSync(symlinkTarget, symlinkPath)
|
|
421
|
+
|
|
422
|
+
const res = await requestServer(server, { method: 'GET', path: '/static/symlink.html' })
|
|
423
|
+
expect(res.status).toBe(200)
|
|
424
|
+
expect(await res.text()).toBe('<h1>Hello App</h1>')
|
|
425
|
+
} finally {
|
|
426
|
+
rmSync(symlinkPath, { force: true })
|
|
427
|
+
}
|
|
428
|
+
})
|
|
429
|
+
|
|
430
|
+
it('Should handle URIError thrown while decoding URI component', async () => {
|
|
431
|
+
const res = await requestServer(server, { method: 'GET', path: '/static/%c0%afsecret.txt' })
|
|
432
|
+
expect(res.status).toBe(404)
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
it('Should handle an extension less files', async () => {
|
|
436
|
+
const res = await requestServer(server, { method: 'GET', path: '/static/extensionless' })
|
|
437
|
+
expect(res.status).toBe(200)
|
|
438
|
+
expect(res.headers.get('content-type')).toBe('application/octet-stream')
|
|
439
|
+
expect(await res.text()).toBe('Extensionless')
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
it('Should return a pre-compressed zstd response - /static-with-precompressed/hello.txt', async () => {
|
|
443
|
+
// Check if it returns a normal response
|
|
444
|
+
let res = await requestServer(server, {
|
|
445
|
+
method: 'GET',
|
|
446
|
+
path: '/static-with-precompressed/hello.txt',
|
|
447
|
+
})
|
|
448
|
+
let stats = statSync(path.join(__dirname, 'assets', 'static-with-precompressed', 'hello.txt'))
|
|
449
|
+
expect(res.status).toBe(200)
|
|
450
|
+
expect(res.headers.get('content-length')).toBe('20')
|
|
451
|
+
expect(res.headers.get('last-modified')).toBe(stats.mtime.toUTCString())
|
|
452
|
+
expect(await res.text()).toBe('Hello Not Compressed')
|
|
453
|
+
|
|
454
|
+
res = await requestServer(server, {
|
|
455
|
+
method: 'GET',
|
|
456
|
+
path: '/static-with-precompressed/hello.txt',
|
|
457
|
+
headers: { 'accept-encoding': 'zstd' },
|
|
458
|
+
})
|
|
459
|
+
stats = statSync(path.join(__dirname, 'assets', 'static-with-precompressed', 'hello.txt.zst'))
|
|
460
|
+
expect(res.status).toBe(200)
|
|
461
|
+
expect(res.headers.get('content-length')).toBe('21')
|
|
462
|
+
expect(res.headers.get('content-encoding')).toBe('zstd')
|
|
463
|
+
expect(res.headers.get('last-modified')).toBe(stats.mtime.toUTCString())
|
|
464
|
+
expect(res.headers.get('vary')).toBe('Accept-Encoding')
|
|
465
|
+
// the .zst asset is not really compressed, so the raw body can be asserted directly
|
|
466
|
+
expect(await res.text()).toBe('Hello zstd Compressed')
|
|
467
|
+
})
|
|
468
|
+
|
|
469
|
+
it('Should return a pre-compressed brotli response - /static-with-precompressed/hello.txt', async () => {
|
|
470
|
+
const res = await requestServer(server, {
|
|
471
|
+
method: 'GET',
|
|
472
|
+
path: '/static-with-precompressed/hello.txt',
|
|
473
|
+
headers: { 'accept-encoding': 'wompwomp, gzip, br, deflate, zstd' },
|
|
474
|
+
})
|
|
475
|
+
expect(res.status).toBe(200)
|
|
476
|
+
expect(res.headers.get('content-length')).toBe('19')
|
|
477
|
+
expect(res.headers.get('content-encoding')).toBe('br')
|
|
478
|
+
expect(res.headers.get('vary')).toBe('Accept-Encoding')
|
|
479
|
+
// the .br asset is not really compressed, so the raw body can be asserted directly
|
|
480
|
+
expect(await res.text()).toBe('Hello br Compressed')
|
|
481
|
+
})
|
|
482
|
+
|
|
483
|
+
it('Should not return a pre-compressed response - /static-with-precompressed/hello.txt', async () => {
|
|
484
|
+
const res = await requestServer(server, {
|
|
485
|
+
method: 'GET',
|
|
486
|
+
path: '/static-with-precompressed/hello.txt',
|
|
487
|
+
headers: { 'accept-encoding': 'wompwomp, unknown' },
|
|
488
|
+
})
|
|
489
|
+
expect(res.status).toBe(200)
|
|
490
|
+
expect(res.headers.get('content-encoding')).toBeNull()
|
|
491
|
+
expect(res.headers.get('vary')).toBeNull()
|
|
492
|
+
expect(await res.text()).toBe('Hello Not Compressed')
|
|
493
|
+
})
|
|
494
|
+
|
|
495
|
+
it('Should return a pre-compressed response for an octet-stream file - /static-with-precompressed/hello.bin', async () => {
|
|
496
|
+
const res = await requestServer(server, {
|
|
497
|
+
method: 'GET',
|
|
498
|
+
path: '/static-with-precompressed/hello.bin',
|
|
499
|
+
headers: { 'accept-encoding': 'gzip, br, zstd' },
|
|
500
|
+
})
|
|
501
|
+
expect(res.status).toBe(200)
|
|
502
|
+
expect(res.headers.get('content-type')).toBe('application/octet-stream')
|
|
503
|
+
expect(res.headers.get('content-length')).toBe('19')
|
|
504
|
+
expect(res.headers.get('content-encoding')).toBe('br')
|
|
505
|
+
expect(res.headers.get('vary')).toBe('Accept-Encoding')
|
|
506
|
+
// the .br asset is not really compressed, so the raw body can be asserted directly
|
|
507
|
+
expect(await res.text()).toBe('Hello br Compressed')
|
|
508
|
+
})
|
|
509
|
+
|
|
510
|
+
describe('Absolute path', () => {
|
|
511
|
+
const rootPaths = [
|
|
512
|
+
path.join(__dirname, 'assets'),
|
|
513
|
+
__dirname + path.sep + '..' + path.sep + 'adapter' + path.sep + 'assets',
|
|
514
|
+
]
|
|
515
|
+
rootPaths.forEach((root) => {
|
|
516
|
+
describe(root, () => {
|
|
517
|
+
const app = new App()
|
|
518
|
+
const server = createAdaptorServer(app)
|
|
519
|
+
app.use('/static/*', serveStatic({ root }))
|
|
520
|
+
app.use('/favicon.ico', serveStatic({ path: root + path.sep + 'favicon.ico' }))
|
|
521
|
+
|
|
522
|
+
it('Should return index.html', async () => {
|
|
523
|
+
const res = await requestServer(server, { method: 'GET', path: '/static' })
|
|
524
|
+
expect(res.status).toBe(200)
|
|
525
|
+
expect(res.headers.get('content-type')).toBe('text/html; charset=utf-8')
|
|
526
|
+
expect(await res.text()).toBe('<h1>Hello App</h1>')
|
|
527
|
+
})
|
|
528
|
+
|
|
529
|
+
it('Should return correct headers and data for text', async () => {
|
|
530
|
+
const res = await requestServer(server, { method: 'GET', path: '/static/plain.txt' })
|
|
531
|
+
expect(res.status).toBe(200)
|
|
532
|
+
expect(res.headers.get('content-type')).toBe('text/plain; charset=utf-8')
|
|
533
|
+
expect(await res.text()).toBe('This is plain.txt')
|
|
534
|
+
})
|
|
535
|
+
it('Should return correct headers for icons', async () => {
|
|
536
|
+
const res = await requestServer(server, { method: 'GET', path: '/favicon.ico' })
|
|
537
|
+
expect(res.status).toBe(200)
|
|
538
|
+
expect(res.headers.get('content-type')).toBe('image/x-icon')
|
|
539
|
+
})
|
|
540
|
+
})
|
|
541
|
+
})
|
|
542
|
+
})
|
|
543
|
+
|
|
544
|
+
describe('Root and path combination tests', () => {
|
|
545
|
+
const rootPaths = [
|
|
546
|
+
path.join(__dirname, 'assets'),
|
|
547
|
+
path.join(__dirname, 'assets'),
|
|
548
|
+
__dirname + path.sep + '..' + path.sep + 'adapter' + path.sep + 'assets',
|
|
549
|
+
]
|
|
550
|
+
const optionPaths = ['favicon.ico', '/favicon.ico']
|
|
551
|
+
rootPaths.forEach((root) => {
|
|
552
|
+
optionPaths.forEach((optionPath) => {
|
|
553
|
+
describe(`${root} + ${optionPath}`, () => {
|
|
554
|
+
const app = new App()
|
|
555
|
+
const server = createAdaptorServer(app)
|
|
556
|
+
|
|
557
|
+
app.use(
|
|
558
|
+
'/favicon.ico',
|
|
559
|
+
serveStatic({
|
|
560
|
+
root,
|
|
561
|
+
path: optionPath,
|
|
562
|
+
})
|
|
563
|
+
)
|
|
564
|
+
|
|
565
|
+
it('Should return 200 response if both root and path set', async () => {
|
|
566
|
+
const res = await requestServer(server, { method: 'GET', path: '/favicon.ico' })
|
|
567
|
+
expect(res.status).toBe(200)
|
|
568
|
+
expect(res.headers.get('content-type')).toBe('image/x-icon')
|
|
569
|
+
})
|
|
570
|
+
})
|
|
571
|
+
})
|
|
572
|
+
})
|
|
573
|
+
})
|
|
574
|
+
|
|
575
|
+
describe('Path traversal security tests', () => {
|
|
576
|
+
const app = new App()
|
|
577
|
+
const server = createAdaptorServer(app)
|
|
578
|
+
app.use('/static/*', serveStatic({ root: './tests/adapter/assets' }))
|
|
579
|
+
|
|
580
|
+
it('Should prevent path traversal attacks with double dots', async () => {
|
|
581
|
+
const res = await requestServer(server, { method: 'GET', path: '/static/../secret.txt' })
|
|
582
|
+
expect(res.status).toBe(404)
|
|
583
|
+
})
|
|
584
|
+
|
|
585
|
+
it('Should prevent path traversal attacks with multiple levels', async () => {
|
|
586
|
+
const res = await requestServer(server, {
|
|
587
|
+
method: 'GET',
|
|
588
|
+
path: '/static/../../package.json',
|
|
589
|
+
})
|
|
590
|
+
expect(res.status).toBe(404)
|
|
591
|
+
})
|
|
592
|
+
|
|
593
|
+
it('Should prevent path traversal attacks with mixed separators', async () => {
|
|
594
|
+
const res = await requestServer(server, {
|
|
595
|
+
method: 'GET',
|
|
596
|
+
path: '/static/..\\..\\package.json',
|
|
597
|
+
})
|
|
598
|
+
expect(res.status).toBe(404)
|
|
599
|
+
})
|
|
600
|
+
|
|
601
|
+
it('Should prevent path traversal attacks with encoded dots', async () => {
|
|
602
|
+
const res = await requestServer(server, {
|
|
603
|
+
method: 'GET',
|
|
604
|
+
path: '/static/%2e%2e%2fsecret.txt',
|
|
605
|
+
})
|
|
606
|
+
expect(res.status).toBe(404)
|
|
607
|
+
})
|
|
608
|
+
|
|
609
|
+
it('Should accept filename with double dots', async () => {
|
|
610
|
+
const res = await requestServer(server, { method: 'GET', path: '/static/foo..bar.txt' })
|
|
611
|
+
expect(res.status).toBe(200)
|
|
612
|
+
})
|
|
613
|
+
})
|
|
614
|
+
|
|
615
|
+
describe('Path mismatch security tests', () => {
|
|
616
|
+
const app = new App()
|
|
617
|
+
const server = createAdaptorServer(app)
|
|
618
|
+
|
|
619
|
+
app.use('/static/admin/*', async (c, next) => {
|
|
620
|
+
c.header('X-Authorized', 'true')
|
|
621
|
+
await next()
|
|
622
|
+
})
|
|
623
|
+
|
|
624
|
+
app.use('/static/*', serveStatic({ root: './tests/adapter/assets' }))
|
|
625
|
+
|
|
626
|
+
it('Should not allow bypass via path mismatch between middleware and serveStatic', async () => {
|
|
627
|
+
const res = await requestServer(server, { method: 'GET', path: '/static/admin/secret.txt' })
|
|
628
|
+
expect(res.headers.get('x-authorized')).toBe('true')
|
|
629
|
+
expect(await res.text()).toBe('secret')
|
|
630
|
+
|
|
631
|
+
const res2 = await requestServer(server, {
|
|
632
|
+
method: 'GET',
|
|
633
|
+
path: '/static/admin%2Fsecret.txt',
|
|
634
|
+
})
|
|
635
|
+
expect(res2.status).toBe(404)
|
|
636
|
+
expect(res2.headers.get('x-authorized')).toBeNull()
|
|
637
|
+
expect(await res2.text()).not.toBe('secret')
|
|
638
|
+
|
|
639
|
+
const res3 = await requestServer(server, {
|
|
640
|
+
method: 'GET',
|
|
641
|
+
path: '/static//admin/secret.txt',
|
|
642
|
+
})
|
|
643
|
+
expect(res3.status).toBe(404)
|
|
644
|
+
|
|
645
|
+
const res4 = await requestServer(server, {
|
|
646
|
+
method: 'GET',
|
|
647
|
+
path: '/static/admin%5Csecret.txt',
|
|
648
|
+
})
|
|
649
|
+
expect(res4.status).toBe(404)
|
|
650
|
+
expect(res4.headers.get('x-authorized')).toBeNull()
|
|
651
|
+
expect(await res4.text()).not.toBe('secret')
|
|
652
|
+
})
|
|
653
|
+
})
|
|
654
|
+
|
|
655
|
+
describe('Percent signs in request paths', () => {
|
|
656
|
+
const root = mkdtempSync(path.join(tmpdir(), 'node-server-serve-static-'))
|
|
657
|
+
const staticRoot = path.join(root, 'static')
|
|
658
|
+
for (const filePath of [
|
|
659
|
+
'100%.txt',
|
|
660
|
+
'100%/hello.txt',
|
|
661
|
+
'%2Fadmin/secret.txt',
|
|
662
|
+
'hello world.txt',
|
|
663
|
+
'炎.txt',
|
|
664
|
+
]) {
|
|
665
|
+
const fullPath = path.join(staticRoot, filePath)
|
|
666
|
+
mkdirSync(path.dirname(fullPath), { recursive: true })
|
|
667
|
+
writeFileSync(fullPath, `Hello in static/${filePath}`)
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
afterAll(() => rmSync(root, { recursive: true, force: true }))
|
|
671
|
+
|
|
672
|
+
it.each([
|
|
673
|
+
['/static/%E7%82%8E.txt', 'static/炎.txt'],
|
|
674
|
+
['/static/hello%20world.txt', 'static/hello world.txt'],
|
|
675
|
+
])('Should decode URI strings - %s', async (url, filePath) => {
|
|
676
|
+
const fileApp = new App().use('/static/*', serveStatic({ root }))
|
|
677
|
+
const res = await requestServer(createAdaptorServer(fileApp), {
|
|
678
|
+
method: 'GET',
|
|
679
|
+
path: url,
|
|
680
|
+
})
|
|
681
|
+
expect(res.status).toBe(200)
|
|
682
|
+
expect(res.headers.get('content-type')).toMatch(/^text\/plain/)
|
|
683
|
+
expect(await res.text()).toBe(`Hello in ${filePath}`)
|
|
684
|
+
})
|
|
685
|
+
|
|
686
|
+
it.each(['/static/100%25.txt', '/static/100%25/hello.txt', '/static/%2Fadmin/secret.txt'])(
|
|
687
|
+
'Should skip paths containing percent signs by default - %s',
|
|
688
|
+
async (url) => {
|
|
689
|
+
const onNotFound = vi.fn()
|
|
690
|
+
const rewriteRequestPath = vi.fn((filePath: string) => filePath)
|
|
691
|
+
const fileApp = new App().use(
|
|
692
|
+
'/static/*',
|
|
693
|
+
serveStatic({ root, onNotFound, rewriteRequestPath })
|
|
694
|
+
)
|
|
695
|
+
|
|
696
|
+
const res = await requestServer(createAdaptorServer(fileApp), { method: 'GET', path: url })
|
|
697
|
+
|
|
698
|
+
expect(res.status).toBe(404)
|
|
699
|
+
expect(rewriteRequestPath).not.toHaveBeenCalled()
|
|
700
|
+
expect(onNotFound).toHaveBeenCalledWith(url, expect.anything())
|
|
701
|
+
}
|
|
702
|
+
)
|
|
703
|
+
|
|
704
|
+
it.each([
|
|
705
|
+
['/static/100%25.txt', 'static/100%.txt'],
|
|
706
|
+
['/static/100%25/hello.txt', 'static/100%/hello.txt'],
|
|
707
|
+
['/static/%2Fadmin/secret.txt', 'static/%2Fadmin/secret.txt'],
|
|
708
|
+
])('Should allow percent signs when opted in - %s', async (url, filePath) => {
|
|
709
|
+
const fileApp = new App().use('/static/*', serveStatic({ root, allowPercentInPath: true }))
|
|
710
|
+
|
|
711
|
+
const res = await requestServer(createAdaptorServer(fileApp), { method: 'GET', path: url })
|
|
712
|
+
|
|
713
|
+
expect(res.status).toBe(200)
|
|
714
|
+
expect(await res.text()).toBe(`Hello in ${filePath}`)
|
|
715
|
+
})
|
|
716
|
+
|
|
717
|
+
it('Should not bypass authentication through a second decode', async () => {
|
|
718
|
+
const protectedApp = new App()
|
|
719
|
+
const rewriteRequestPath = vi.fn((filePath: string) => filePath)
|
|
720
|
+
protectedApp.use('/static/admin/*', async (c) => c.text('Unauthorized', 401))
|
|
721
|
+
protectedApp.use('/static/*', serveStatic({ root: './tests/adapter/assets', rewriteRequestPath }))
|
|
722
|
+
const protectedServer = createAdaptorServer(protectedApp)
|
|
723
|
+
|
|
724
|
+
for (const url of ['/static/admin/secret.txt', '/static/%61dmin/secret.txt']) {
|
|
725
|
+
const protectedRes = await requestServer(protectedServer, { method: 'GET', path: url })
|
|
726
|
+
expect(protectedRes.status).toBe(401)
|
|
727
|
+
expect(await protectedRes.text()).toBe('Unauthorized')
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
const res = await requestServer(protectedServer, {
|
|
731
|
+
method: 'GET',
|
|
732
|
+
path: '/static/%%36%31dmin/secret.txt',
|
|
733
|
+
})
|
|
734
|
+
expect(res.status).toBe(404)
|
|
735
|
+
expect(rewriteRequestPath).not.toHaveBeenCalled()
|
|
736
|
+
expect(await res.text()).not.toBe('secret')
|
|
737
|
+
})
|
|
738
|
+
|
|
739
|
+
it('Should pass the routed path and context to onNotFound, then continue', async () => {
|
|
740
|
+
const fileApp = new App()
|
|
741
|
+
let hookPath: string | undefined
|
|
742
|
+
let contextPath: string | undefined
|
|
743
|
+
fileApp.use(
|
|
744
|
+
'/static/*',
|
|
745
|
+
serveStatic({
|
|
746
|
+
root,
|
|
747
|
+
onNotFound: (requestPath, c) => {
|
|
748
|
+
hookPath = requestPath
|
|
749
|
+
contextPath = c.req.path
|
|
750
|
+
},
|
|
751
|
+
})
|
|
752
|
+
)
|
|
753
|
+
fileApp.get('/static/*', (c) => c.text('next handler', 202))
|
|
754
|
+
|
|
755
|
+
const res = await requestServer(createAdaptorServer(fileApp), {
|
|
756
|
+
method: 'GET',
|
|
757
|
+
path: '/static/100%25.txt',
|
|
758
|
+
})
|
|
759
|
+
expect(res.status).toBe(202)
|
|
760
|
+
expect(await res.text()).toBe('next handler')
|
|
761
|
+
expect(hookPath).toBe('/static/100%25.txt')
|
|
762
|
+
expect(contextPath).toBe(hookPath)
|
|
763
|
+
})
|
|
764
|
+
|
|
765
|
+
it.each(['/static/%2e%2e%5C100%.txt', '/static//100%.txt', '/static/%5C100%.txt'])(
|
|
766
|
+
'Should retain path validation when opted in: %s',
|
|
767
|
+
async (requestPath) => {
|
|
768
|
+
const fileApp = new App()
|
|
769
|
+
const rewriteRequestPath = vi.fn((requestPath: string) => requestPath)
|
|
770
|
+
const onNotFound = vi.fn()
|
|
771
|
+
fileApp.use(
|
|
772
|
+
'/static/*',
|
|
773
|
+
serveStatic({ root, allowPercentInPath: true, rewriteRequestPath, onNotFound })
|
|
774
|
+
)
|
|
775
|
+
const res = await requestServer(createAdaptorServer(fileApp), {
|
|
776
|
+
method: 'GET',
|
|
777
|
+
path: requestPath,
|
|
778
|
+
})
|
|
779
|
+
expect(res.status).toBe(404)
|
|
780
|
+
expect(rewriteRequestPath).not.toHaveBeenCalled()
|
|
781
|
+
expect(onNotFound).toHaveBeenCalledOnce()
|
|
782
|
+
}
|
|
783
|
+
)
|
|
784
|
+
|
|
785
|
+
it('Should preserve the fixed path option for percent filenames', async () => {
|
|
786
|
+
const fileApp = new App()
|
|
787
|
+
fileApp.use('/static/*', serveStatic({ root, path: 'static/100%.txt' }))
|
|
788
|
+
const res = await requestServer(createAdaptorServer(fileApp), {
|
|
789
|
+
method: 'GET',
|
|
790
|
+
path: '/static/100%25.txt',
|
|
791
|
+
})
|
|
792
|
+
expect(res.status).toBe(200)
|
|
793
|
+
expect(await res.text()).toBe('Hello in static/100%.txt')
|
|
794
|
+
})
|
|
795
|
+
})
|
|
796
|
+
|
|
797
|
+
describe('Stream error handling', () => {
|
|
798
|
+
const testFile = path.join(__dirname, 'assets', 'static', 'plain.txt')
|
|
799
|
+
console.log(testFile)
|
|
800
|
+
let originalMode: number
|
|
801
|
+
|
|
802
|
+
beforeEach(() => {
|
|
803
|
+
const stats = statSync(testFile)
|
|
804
|
+
originalMode = stats.mode
|
|
805
|
+
// Remove read permission to trigger stream error
|
|
806
|
+
chmodSync(testFile, 0o000)
|
|
807
|
+
})
|
|
808
|
+
|
|
809
|
+
afterEach(() => {
|
|
810
|
+
chmodSync(testFile, originalMode)
|
|
811
|
+
})
|
|
812
|
+
|
|
813
|
+
// Skip on Windows as chmod doesn't work for file permissions
|
|
814
|
+
;(process.platform === 'win32' ? it.skip : it)(
|
|
815
|
+
'Should handle read permission errors gracefully',
|
|
816
|
+
async () => {
|
|
817
|
+
const app = new App()
|
|
818
|
+
app.use('/static/*', serveStatic({ root: './tests/adapter/assets' }))
|
|
819
|
+
const server = createAdaptorServer(app)
|
|
820
|
+
await expect(
|
|
821
|
+
requestServer(server, { method: 'GET', path: '/static/plain.txt' })
|
|
822
|
+
).rejects.toThrow()
|
|
823
|
+
}
|
|
824
|
+
)
|
|
825
|
+
})
|
|
826
|
+
})
|
|
827
|
+
|
|
828
|
+
describe('Serve Static Middleware with wrong path', () => {
|
|
829
|
+
it('Should show an error when the path is wrong', async () => {
|
|
830
|
+
const logSpy = vi.spyOn(console, 'error')
|
|
831
|
+
|
|
832
|
+
const app = new App<{
|
|
833
|
+
Variables: {
|
|
834
|
+
path: string
|
|
835
|
+
}
|
|
836
|
+
}>()
|
|
837
|
+
|
|
838
|
+
app.use(
|
|
839
|
+
'*',
|
|
840
|
+
serveStatic({
|
|
841
|
+
root: './public',
|
|
842
|
+
})
|
|
843
|
+
)
|
|
844
|
+
|
|
845
|
+
expect(logSpy).toHaveBeenCalledWith(
|
|
846
|
+
"serveStatic: root path './public' is not found, are you sure it's correct?"
|
|
847
|
+
)
|
|
848
|
+
})
|
|
849
|
+
})
|