Closed rlee1990 closed 2 years ago
Update: as of now using
import * as _ from "https://deno.land/x/websocket@v0.1.4/mod.ts";
import { StreamChat } from "https://esm.sh/stream-chat@7.2.0"
both as of now seems to work. There is an issue using just the stream-chat option in Deno due to the WS package. Will keep testing to see if everything else works
Well this does not work I get the below error:
Error: Error bundling function: exit status 1
error: Import 'https://esm.sh/v96/isomorphic-ws@4.0.1/deno/isomorphic-ws.js' failed: 500 Internal Server Error
at https://esm.sh/v96/stream-chat@7.2.0/deno/stream-chat.js:2:1120
Hi, @rlee1990. We don't currently plan to support Deno. I don't know if the compatability mode would work, but this repo at the moment only supports node.
Hey @madsroskar, just asking if anything changed recently as you published a blog post about deno some time ago?
@fkoch-tgm that wasn't me that made this but I managed to get it all working on deno.
@fkoch-tgm that wasn't me that made this but I managed to get it all working on deno.
oh sorry😅 How did you get it to work? I always have an issue with the crypto implementation...
Sorry for the late replay. This is my function in Deno for this. I use supabase as a backend.
import { serve } from "https://deno.land/std@0.131.0/http/server.ts"
import { create, Header, Payload, } from "https://deno.land/x/djwt@v2.7/mod.ts"
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2.0.0-rc.12'
const STREAM_SECRET = Deno.env.get("stream_secret")
const encoder = new TextEncoder()
const keyBuf = encoder.encode(STREAM_SECRET)
const key = await crypto.subtle.importKey(
'raw',
keyBuf,
{ name: 'HMAC', hash: 'SHA-256' },
true,
['sign', 'verify']
)
const header: Header = {
alg: 'HS256',
typ: 'JWT',
}
const supabase = createClient(
Deno.env.get("SUPABASE_URL")!,
Deno.env.get("SUPABAS_ROLE_KEY")!
);
serve(async (req) => {
const body = await req.json()
const {record} = body;
const payload: Payload = {
user_id: record.id,
}
const token = await create(header, payload, key)
//Save the token
return new Response(
null,
{status: 200, headers: { "Content-Type": "application/json" } },
)
})
Wanted to know if this already supports Deno? If not is it possible to add support?