-
-
Notifications
You must be signed in to change notification settings - Fork 89
Description
It would be awesome if there was a Deno compatible typesense module.
You can almost directly import * as Typsense from src/Typesense.ts but there are some issue:
-
Deno requires all local imports to have explict .ts extensions
So instead ofimport ApiCall from './ApiCall'useimport ApiCall from './ApiCall.ts'
Also Errors, instead ofimport { ObjectNotFound } from './Errors'useimport { ObjectNotFound } from './Errors/ObjectNotFound.ts' -
Keys.ts needs modified to use the
hmacandbase64modules from Deno:
Change:import { createHmac } from 'crypto'to
import {hmac} from "https://deno.land/x/[email protected]/mod.ts";
import {encode as base64Encode} from "https://deno.land/[email protected]/encoding/base64.ts"
And change lines
const digest = Buffer.from(createHmac('sha256', searchKey).update(paramsJSON).digest('base64'))
return Buffer.from(rawScopedKey).toString('base64')to
const digest = hmac("sha256", searchKey, paramsJSON, "utf8", "base64")
return base64Encode(rawScopedKey);- Configuration.js needs a loglevel replacement. I just used a stub:
this.logger =
{
trace : v => console.log(v),
debug : v => console.log(v),
info : v => console.info(v),
warn : v => console.warn(v),
error : v => console.error(v),
log : v => console.log(v),
setLevel : () => {}
}
This is where I gave up because there are at least 3 remaining issues:
-
Documents.ts needs a
ReadStreamDeno equilivant -
All of
axiosneeds replaced in ApiCall.ts Maybe you could use the Deno versionhttps://github.com/roonie007/axiodbut much more ideally you could use the built in Denofetchsupport -
Lastly, there may be other 'nodejs' specific APIs being used in the code that I didn't look for