create basic http-ts app
This commit is contained in:
4
hi/.gitignore
vendored
Normal file
4
hi/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
node_modules
|
||||
dist
|
||||
target
|
||||
.spin/
|
3
hi/README.md
Normal file
3
hi/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
## HTTP-TS template
|
||||
|
||||
This is a simple template to get started with spin-js-sdk using typescript.
|
22
hi/package.json
Normal file
22
hi/package.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "hi",
|
||||
"version": "1.0.0",
|
||||
"description": "says hi",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "npx webpack --mode=production && mkdir -p target && spin js2wasm -o target/hi.wasm dist/spin.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"ts-loader": "^9.4.1",
|
||||
"typescript": "^4.8.4",
|
||||
"webpack": "^5.74.0",
|
||||
"webpack-cli": "^4.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fermyon/spin-sdk": "0.6.0"
|
||||
}
|
||||
}
|
17
hi/spin.toml
Normal file
17
hi/spin.toml
Normal file
@ -0,0 +1,17 @@
|
||||
spin_manifest_version = 2
|
||||
|
||||
[application]
|
||||
authors = ["haqadosch"]
|
||||
description = "says hi"
|
||||
name = "hi"
|
||||
version = "0.1.0"
|
||||
|
||||
[[trigger.http]]
|
||||
route = "/hi"
|
||||
component = "hi"
|
||||
|
||||
[component.hi]
|
||||
source = "target/hi.wasm"
|
||||
exclude_files = ["**/node_modules"]
|
||||
[component.hi.build]
|
||||
command = "npm run build"
|
9
hi/src/index.ts
Normal file
9
hi/src/index.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { HandleRequest, HttpRequest, HttpResponse } from "@fermyon/spin-sdk"
|
||||
|
||||
export const handleRequest: HandleRequest = async function (request: HttpRequest): Promise<HttpResponse> {
|
||||
return {
|
||||
status: 200,
|
||||
headers: { "content-type": "text/plain" },
|
||||
body: "Hello from TS-SDK"
|
||||
}
|
||||
}
|
15
hi/tsconfig.json
Normal file
15
hi/tsconfig.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist/",
|
||||
"noImplicitAny": true,
|
||||
"module": "es6",
|
||||
"target": "es5",
|
||||
"jsx": "react",
|
||||
"skipLibCheck": true,
|
||||
"lib": ["ES2015"],
|
||||
"allowJs": true,
|
||||
"strict": true,
|
||||
"noImplicitReturns": true,
|
||||
"moduleResolution": "node"
|
||||
}
|
||||
}
|
25
hi/webpack.config.js
Normal file
25
hi/webpack.config.js
Normal file
@ -0,0 +1,25 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
entry: './src/index.ts',
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: 'ts-loader',
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.tsx', '.ts', '.js'],
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: 'spin.js',
|
||||
library: 'spin'
|
||||
},
|
||||
optimization: {
|
||||
minimize: false
|
||||
},
|
||||
};
|
Reference in New Issue
Block a user