myselfhimself / deepgram-node-proxy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example Node Proxy for Deepgram

Discord Contributor Covenant

Despite our SDK working in the browser, our API is restricted by CORS. Our SDK has an option to utilise a REST proxy, so you can still benefit from the SDK's functionality in the browser.

It is your responsibility to secure this application behind your own authentication, or risk others using your Deepgram credit for their own purpose.

This is an example proxy, built using http-proxy. Please consider securing it behind your own client authentication before making it available generally.

Setup

Clone this repository from GitHub.

Initial installation

Install the dependencies to be able to run this application.

npm i

Configuring your SSL Identity

Run the following to generate an PKCS12 file, to act as your SSL indentity when making a secure request to the Deepgram API. This does not affect your ability to run this proxy behind it's own SSL.

Generate 2048-bit RSA private key:

openssl genrsa -out key.pem 2048

Generate a Certificate Signing Request:

openssl req -new -sha256 -key key.pem -out csr.csr

Generate a self-signed x509 certificate suitable for use on web servers.

openssl req -x509 -sha256 -days 365 -key key.pem -in csr.csr -out certificate.pem

Create SSL identity file in PKCS12 as mentioned here

openssl pkcs12 -export -out certificate.p12 -inkey key.pem -in certificate.pem

Setting up your environment variables

Copy the sample.env to .env and fill out the variables.

ALLOWED_ORIGIN=http://localhost:3000 # the origin of the application making the REST requests to Deepgram
PORT=4433 # the port you intend to run your proxy on
DEEPGRAM_API_KEY=5364knj5hgbnipjgp9h490g84h245h524h # your Deepgram API with atleast the usage:write scope

Running locally

npm run dev

Development and Contributing

Interested in contributing? We ❤️ pull requests!

To make sure our community is safe for all, be sure to review and agree to our Code of Conduct. Then see the Contribution guidelines for more information.

Getting Help

We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:

About

License:MIT License


Languages

Language:JavaScript 100.0%