Skip to content

Commit 5c76d08

Browse files
committed
v0.3.0-beta.15
1 parent 8d9eef6 commit 5c76d08

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

examples/42-wasm/wasm_loader.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import type { Plugin } from 'aleph/types.d.ts'
22

33
export default <Plugin>{
4-
name: 'wasm-loader',
4+
name: 'json-loader',
55
setup: aleph => {
6-
aleph.onLoad(/\.wasm$/i, async ({ specifier }) => {
6+
aleph.onLoad(/\.json$/i, async ({ specifier }) => {
77
const { content } = await aleph.fetchModule(specifier)
88
return {
9-
code: [
10-
`const wasmBytes = new Uint8Array([${content.join(',')}])`,
11-
'const wasmModule = new WebAssembly.Module(wasmBytes)',
12-
'const { exports } = new WebAssembly.Instance(wasmModule)',
13-
'export default exports',
14-
].join('\n')
9+
code: `export default = ` + new TextDecoder().decode(content)
1510
}
1611
})
1712
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
+14-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1-
import type { APIHandler } from 'aleph/types.d.ts'
1+
import type { APIHandler, APIContext } from 'aleph/types.d.ts'
2+
import data from './data.json'
23

3-
export const handler: APIHandler = ({ response }) => {
4+
const create = async (
5+
{ response }: APIContext,
6+
db: string,
7+
) => {
48
const count = parseInt(localStorage.getItem('count') || '0')
5-
response.json({ count })
9+
response.json({ count, db: db, data })
610
}
11+
12+
const requestWithMongo = (handler: typeof create): APIHandler =>
13+
async (context) => {
14+
await handler(context, "mongo")
15+
}
16+
17+
export const handler: APIHandler = requestWithMongo(create)

version.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** `VERSION` managed by https://deno.land/x/publish */
2-
export const VERSION = '0.3.0-beta.14'
2+
export const VERSION = '0.3.0-beta.15'
33

44
/** `prepublish` will be invoked before publish */
55
export async function prepublish(version: string): Promise<boolean> {

0 commit comments

Comments
 (0)