File tree 4 files changed +19
-12
lines changed
4 files changed +19
-12
lines changed Original file line number Diff line number Diff line change 1
1
import type { Plugin } from 'aleph/types.d.ts'
2
2
3
3
export default < Plugin > {
4
- name : 'wasm -loader' ,
4
+ name : 'json -loader' ,
5
5
setup : aleph => {
6
- aleph . onLoad ( / \. w a s m $ / i, async ( { specifier } ) => {
6
+ aleph . onLoad ( / \. j s o n $ / i, async ( { specifier } ) => {
7
7
const { content } = await aleph . fetchModule ( specifier )
8
8
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 )
15
10
}
16
11
} )
17
12
}
Original file line number Diff line number Diff line change
1
+ {}
Original file line number Diff line number Diff line change 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'
2
3
3
- export const handler : APIHandler = ( { response } ) => {
4
+ const create = async (
5
+ { response } : APIContext ,
6
+ db : string ,
7
+ ) => {
4
8
const count = parseInt ( localStorage . getItem ( 'count' ) || '0' )
5
- response . json ( { count } )
9
+ response . json ( { count, db : db , data } )
6
10
}
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 )
Original file line number Diff line number Diff line change 1
1
/** `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 '
3
3
4
4
/** `prepublish` will be invoked before publish */
5
5
export async function prepublish ( version : string ) : Promise < boolean > {
You can’t perform that action at this time.
0 commit comments