typesense/typesense-js

Add support for mulltiple API keys per cluster

elieobeid7 opened this issue · 2 comments

I reported this issue typesense/firestore-typesense-search#60 and I thought, it's a Firebase plugin issue, turns out the javascript library accepts only one key for all nodes which makes no sense, is this by design?

All Typesense libraries support one key per cluster, why?

Is it because you only set up a cluster using private IPs and you never thought that someone like me would want to set up servers in multiple data centers? So if a cluster is accessible privately only it's secure by design, this is the main reason, right?

To use multiple API keys, you'd simply instantiate multiple instances of the client each with a separate API key... and use the appropriate client instance to call the methods needed.

Eg:

const typesense1 = new Typesense.Client({
  nodes: [
    {
      host: "hostname",
      port: "443",
      protocol: "https",
    },
  ],
  apiKey: 'APIKEY-ABC',
});


const typesense2 = new Typesense.Client({
  nodes: [
    {
      host: "hostname",
      port: "443",
      protocol: "https",
    },
  ],
  apiKey: 'APIKEY-XYZ,
});

you only set up a cluster using private IPs... a cluster is accessible privately only it's secure by design

No, Typesense can indeed be exposed to the internet using public IPs.

you never thought that someone like me would want to set up servers in multiple data centers

No, Typesense is indeed designed to be run across multiple data centers. We run thousands of nodes this way across 80 data centers in Typesense Cloud.

We both know this isn't ideal, closing this ticket as it seems to me, this won't be fixed. I added one key for all servers and called it a day since I refuse to write such code.