typesense / typesense/typesense-js

typesense module for Deno

Open
#95 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
569
Forks
99
Avg merge
5h 6m
Merged PRs (30d)
2

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 of import ApiCall from './ApiCall' use import ApiCall from './ApiCall.ts'
    Also Errors, instead of import { ObjectNotFound } from './Errors' use import { ObjectNotFound } from './Errors/ObjectNotFound.ts'

  • Keys.ts needs modified to use the hmac and base64 modules from Deno:
    Change: import { createHmac } from 'crypto' to

import {hmac} from "https://deno.land/x/hmac@v2.0.1/mod.ts";
import {encode as base64Encode} from "https://deno.land/std@0.118.0/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 ReadStream Deno equilivant

  • All of axios needs replaced in ApiCall.ts Maybe you could use the Deno version https://github.com/roonie007/axiod but much more ideally you could use the built in Deno fetch support

  • Lastly, there may be other 'nodejs' specific APIs being used in the code that I didn't look for

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by auditing the imports and runtime APIs in src/Typesense.ts, Keys.ts, Configuration.js, Documents.ts, and ApiCall.ts for Deno incompatibilities. Review the listed extension, crypto, logging, stream, and HTTP concerns, then verify that the client can run under Deno without the remaining Node.js-specific APIs.

Written by the indexing model from the issue text.

Assessment

Tech stack
deno, typescript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.