Skip to main content
Module

x/cors/test/run.sh

Deno.js CORS middleware
Extremely Popular
Latest
File
#!/bin/bashstart=`date +%s`
file=$1listening_phrase="CORS-enabled web server listening on port 8000"
# Run simple-usage-enable-all-cors-requests example server and execute associated test file to request against itprintf "Runnnig $file simple-usage-enable-all-cors-requests example server and test it\n"timeout 30s grep -q "$listening_phrase" <(deno run --allow-net --allow-read --allow-env --unstable ./examples/$file/simple-usage-enable-all-cors-requests.ts &) || exit 1 deno test --allow-net ./test/simple-usage-enable-all-cors-requests.test.tswaitkill -9 $(lsof -t -i:8000)
# Run enable-cors-for-a-single-route example server and execute associated test file to request against itprintf "Running $file enable-cors-for-a-single-route example server and test it\n"timeout 10s grep -q "$listening_phrase" <(deno run --allow-net --allow-read --allow-env --unstable ./examples/$file/enable-cors-for-a-single-route.ts &) || exit 1 deno test --allow-net ./test/enable-cors-for-a-single-route.test.tswaitkill -9 $(lsof -t -i:8000)
# Run configuring-cors example server and execute associated test file to request against itprintf "Running $file configuring-cors example server and test it\n"timeout 10s grep -q "$listening_phrase" <(deno run --allow-net --allow-read --allow-env --unstable ./examples/$file/configuring-cors.ts &) || exit 1 deno test --allow-net ./test/configuring-cors.test.tswaitkill -9 $(lsof -t -i:8000)
# Run configuring-cors-w-dynamic-origin example server and execute associated test file to request against itprintf "Running $file configuring-cors-w-dynamic-origin example server and test it\n"timeout 10s grep -q "$listening_phrase" <(deno run --allow-net --allow-read --allow-env --unstable ./examples/$file/configuring-cors-w-dynamic-origin.ts &) || exit 1 deno test --allow-net ./test/configuring-cors-w-dynamic-origin.test.tswaitkill -9 $(lsof -t -i:8000)
# Run enabling-cors-pre-flight example server and execute associated test file to request against itprintf "Running $file enabling-cors-pre-flight example server and test it\n"timeout 10s grep -q "$listening_phrase" <(deno run --allow-net --allow-read --allow-env --unstable ./examples/$file/enabling-cors-pre-flight.ts &) || exit 1 deno test --allow-net ./test/enabling-cors-pre-flight.test.tswaitkill -9 $(lsof -t -i:8000)
# Run configuring-cors-asynchronously example server and execute associated test file to request against itprintf "Running $file configuring-cors-asynchronously example server and test it\n"timeout 10s grep -q "$listening_phrase" <(deno run --allow-net --allow-read --allow-env --unstable ./examples/$file/configuring-cors-asynchronously.ts &) || exit 1 deno test --allow-net ./test/configuring-cors-asynchronously.test.tswaitkill -9 $(lsof -t -i:8000)
# Logging Statsend=`date +%s`runtime=$((end-start))printf "\n"echo "Script ran in $runtime seconds"