-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #264 from radu-matei/chore/cleanup-examples
- Loading branch information
Showing
64 changed files
with
12,803 additions
and
1,002 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,26 @@ | ||
import { ResponseBuilder } from "@fermyon/spin-sdk"; | ||
const { S3Client, ListObjectsV2Command } = require("@aws-sdk/client-s3"); | ||
import { ResponseBuilder } from '@fermyon/spin-sdk'; | ||
import { S3Client, ListObjectsV2Command } from '@aws-sdk/client-s3'; | ||
|
||
const client = new S3Client({ | ||
region: "<>", | ||
credentials: { | ||
accessKeyId: "<>>", | ||
secretAccessKey: "<>", | ||
sessionToken: "<>" | ||
}, | ||
region: '<>', | ||
credentials: { | ||
accessKeyId: '<>>', | ||
secretAccessKey: '<>', | ||
sessionToken: '<>', | ||
}, | ||
}); | ||
|
||
const params = { | ||
Bucket: "<>" | ||
Bucket: '<>', | ||
}; | ||
|
||
const command = new ListObjectsV2Command(params); | ||
|
||
export async function handler(req: Request, res: ResponseBuilder) { | ||
let data | ||
try { | ||
data = await client.send(command); | ||
res.send(JSON.stringify(data.Contents, null, 2)); | ||
} catch (e: any) { | ||
res.status(500) | ||
res.send(`error : ${e.message}`) | ||
} | ||
} | ||
export async function handler(_req: Request, res: ResponseBuilder) { | ||
const command = new ListObjectsV2Command(params); | ||
try { | ||
let data = await client.send(command); | ||
res.send(JSON.stringify(data.Contents, null, 2)); | ||
} catch (e: any) { | ||
res.status(500); | ||
res.send(`error : ${e.message}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
import { ResponseBuilder } from "@fermyon/spin-sdk"; | ||
import { handler } from "."; | ||
import { ResponseBuilder } from '@fermyon/spin-sdk'; | ||
import { handler } from '.'; | ||
|
||
//@ts-ignore | ||
addEventListener('fetch', (event: FetchEvent) => { | ||
handleEvent(event); | ||
handleEvent(event); | ||
}); | ||
|
||
async function handleEvent(event: FetchEvent) { | ||
|
||
let resolve: any, reject: any; | ||
let responsePromise = new Promise(async (res, rej) => { | ||
resolve = res; | ||
reject = rej; | ||
}); | ||
//@ts-ignore | ||
event.respondWith(responsePromise); | ||
|
||
let res = new ResponseBuilder(resolve); | ||
|
||
await handler(event.request, res) | ||
let resolve: any, reject: any; | ||
let responsePromise = new Promise(async (res, rej) => { | ||
resolve = res; | ||
reject = rej; | ||
}); | ||
//@ts-ignore | ||
event.respondWith(responsePromise); | ||
let res = new ResponseBuilder(resolve); | ||
await handler(event.request, res); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,33 @@ | ||
const path = require('path'); | ||
const SpinSdkPlugin = require("@fermyon/spin-sdk/plugins/webpack") | ||
const SpinSdkPlugin = require('@fermyon/spin-sdk/plugins/webpack'); | ||
|
||
module.exports = { | ||
entry: './src/spin.ts', | ||
experiments: { | ||
outputModule: true, | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
use: 'ts-loader', | ||
exclude: /node_modules/, | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: ['.tsx', '.ts', '.js'], | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, './'), | ||
filename: 'dist.js', | ||
module: true, | ||
library: { | ||
type: "module", | ||
} | ||
}, | ||
plugins: [ | ||
new SpinSdkPlugin() | ||
entry: './src/spin.ts', | ||
experiments: { | ||
outputModule: true, | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
use: 'ts-loader', | ||
exclude: /node_modules/, | ||
}, | ||
], | ||
optimization: { | ||
minimize: false | ||
}, | ||
resolve: { | ||
extensions: ['.tsx', '.ts', '.js'], | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, './'), | ||
filename: 'dist.js', | ||
module: true, | ||
library: { | ||
type: 'module', | ||
}, | ||
}; | ||
}, | ||
plugins: [new SpinSdkPlugin()], | ||
optimization: { | ||
minimize: false, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.