Skip to content

Commit

Permalink
v0.3.0-beta.15
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed Sep 18, 2021
1 parent 8d9eef6 commit 5c76d08
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
11 changes: 3 additions & 8 deletions examples/42-wasm/wasm_loader.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import type { Plugin } from 'aleph/types.d.ts'

export default <Plugin>{
name: 'wasm-loader',
name: 'json-loader',
setup: aleph => {
aleph.onLoad(/\.wasm$/i, async ({ specifier }) => {
aleph.onLoad(/\.json$/i, async ({ specifier }) => {
const { content } = await aleph.fetchModule(specifier)
return {
code: [
`const wasmBytes = new Uint8Array([${content.join(',')}])`,
'const wasmModule = new WebAssembly.Module(wasmBytes)',
'const { exports } = new WebAssembly.Instance(wasmModule)',
'export default exports',
].join('\n')
code: `export default = ` + new TextDecoder().decode(content)
}
})
}
Expand Down
1 change: 1 addition & 0 deletions examples/hello-world/api/counter/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
17 changes: 14 additions & 3 deletions examples/hello-world/api/counter/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import type { APIHandler } from 'aleph/types.d.ts'
import type { APIHandler, APIContext } from 'aleph/types.d.ts'
import data from './data.json'

export const handler: APIHandler = ({ response }) => {
const create = async (
{ response }: APIContext,
db: string,
) => {
const count = parseInt(localStorage.getItem('count') || '0')
response.json({ count })
response.json({ count, db: db, data })
}

const requestWithMongo = (handler: typeof create): APIHandler =>
async (context) => {
await handler(context, "mongo")
}

export const handler: APIHandler = requestWithMongo(create)
2 changes: 1 addition & 1 deletion version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** `VERSION` managed by https://deno.land/x/publish */
export const VERSION = '0.3.0-beta.14'
export const VERSION = '0.3.0-beta.15'

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

0 comments on commit 5c76d08

Please sign in to comment.