File tree Expand file tree Collapse file tree 7 files changed +138
-0
lines changed Expand file tree Collapse file tree 7 files changed +138
-0
lines changed Original file line number Diff line number Diff line change 1+ node_modules
2+ dist
3+ target
4+ .spin /
5+ build /
Original file line number Diff line number Diff line change 1+ # ` http-js ` Template
2+
3+ A starter template for building JavaScript HTTP applications with Spin.
4+
5+ ## Getting Started
6+
7+ Build the App
8+
9+ ``` bash
10+ spin build
11+ ```
12+
13+ ## Run the App
14+
15+ ``` bash
16+ spin up
17+ ```
18+
19+ ## Using Spin Interfaces
20+
21+ To use additional Spin interfaces, install the corresponding packages:
22+
23+ | Interface | Package |
24+ | ---------------| ---------------------------------|
25+ | Key-Value | ` @spinframework/spin-kv ` |
26+ | LLM | ` @spinframework/spin-llm ` |
27+ | MQTT | ` @spinframework/spin-mqtt ` |
28+ | MySQL | ` @spinframework/spin-mysql ` |
29+ | PostgreSQL | ` @spinframework/spin-postgres ` |
30+ | Redis | ` @spinframework/spin-redis ` |
31+ | SQLite | ` @spinframework/spin-sqlite ` |
32+ | Variables | ` @spinframework/spin-variables ` |
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " test-empty-precompile" ,
3+ "version" : " 1.0.0" ,
4+ "description" : " " ,
5+ "main" : " index.js" ,
6+ "scripts" : {
7+ "build" : " npx webpack && mkdirp dist && j2w -i build/bundle.js --initLocation http://test-empty-precompile.localhost -o dist/test-empty-precompile.wasm" ,
8+ "test" : " echo \" Error: no test specified\" && exit 1"
9+ },
10+ "keywords" : [],
11+ "author" : " " ,
12+ "license" : " ISC" ,
13+ "devDependencies" : {
14+ "mkdirp" : " ^3.0.1" ,
15+ "webpack" : " ^5.74.0" ,
16+ "webpack-cli" : " ^4.10.0"
17+ },
18+ "dependencies" : {
19+ "@spinframework/build-tools" : " file:../../packages/build-tools" ,
20+ "@spinframework/wasi-http-proxy" : " file:../../packages/http-trigger"
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ spin_manifest_version = 2
2+
3+ [application ]
4+ authors = [
" Karthik Ganeshram <[email protected] >" ]
5+ description = " "
6+ name = " test-empty-precompile"
7+ version = " 0.1.0"
8+
9+ [[trigger .http ]]
10+ route = " /..."
11+ component = " test-empty-precompile"
12+
13+ [component .test-empty-precompile ]
14+ source = " dist/test-empty-precompile.wasm"
15+ exclude_files = [" **/node_modules" ]
16+ [component .test-empty-precompile .build ]
17+ command = [" npm install" , " npm run build" ]
18+ watch = [" src/**/*.js" ]
Original file line number Diff line number Diff line change 1+
2+ function handle ( _request ) {
3+ return new Response ( 'Hello, Spin!' , {
4+ status : 200 ,
5+ headers : {
6+ 'content-type' : 'text/plain'
7+ }
8+ } ) ;
9+ }
10+
11+ addEventListener ( 'fetch' , ( event ) => {
12+ event . respondWith ( handle ( event . request ) ) ;
13+ } ) ;
Original file line number Diff line number Diff line change 1+ import path from 'path' ;
2+ import SpinSdkPlugin from "@spinframework/build-tools/plugins/webpack/index.js" ;
3+
4+ const config = async ( ) => {
5+ let SpinPlugin = await SpinSdkPlugin . init ( )
6+ return {
7+ mode : 'production' ,
8+ stats : 'errors-only' ,
9+ entry : './src/index.js' ,
10+ experiments : {
11+ outputModule : true ,
12+ } ,
13+ resolve : {
14+ extensions : [ '.js' ] ,
15+ } ,
16+ output : {
17+ path : path . resolve ( process . cwd ( ) , './build' ) ,
18+ filename : 'bundle.js' ,
19+ module : true ,
20+ library : {
21+ type : "module" ,
22+ }
23+ } ,
24+ plugins : [
25+ SpinPlugin
26+ ] ,
27+ optimization : {
28+ minimize : false
29+ } ,
30+ } ;
31+ }
32+ export default config
Original file line number Diff line number Diff line change @@ -42,3 +42,19 @@ if [ "$isFailed" = true ] ; then
4242 echo " Some tests failed"
4343 exit 1
4444fi
45+
46+ # Test the no regex precompile
47+
48+ cd test-empty-precompile
49+ spin up &
50+ echo " Teting app with no regex to precompile"
51+
52+ if ! timeout 60s bash -c '
53+ until status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/health) && [ "$status" -eq 200 ]; do
54+ echo "Current status: $status, waiting..."
55+ sleep 2
56+ done
57+ ' ; then
58+ echo " Spin app did not return HTTP 200 in 60 seconds"
59+ exit 1
60+ fi
You can’t perform that action at this time.
0 commit comments