npm-trends icon indicating copy to clipboard operation
npm-trends copied to clipboard

instructions for running locally

Open benmccann opened this issue 2 years ago • 4 comments

I tried to run locally, but just get:

TypeError: Failed to fetch

I'm guessing that I must need to setup some environment variables like connecting it to my Github account or something, but can't quite figure out what I'd need to do to get started. Any suggestions?

It's be great to get a CONTRIBUTING.md or similar with some basic setup instructions. Thanks!

benmccann avatar Nov 21 '21 01:11 benmccann

Hey Ben, I haven't run it from scratch in awhile so i'm not sure what's needed to set it up, but i'll do my best to help! Do you get that when starting the server or in the browser when the server is running?

We do have two other services that the platform uses that are in private repos. One is a backend server that i use for logging statistics and the other is a proxy server that handles github authentication and caching. The primary reason they are private was out of pure laziness of not wanting to worry about what was public and what wasn't. You should be able to run it without the backend server, but the proxy server is required because all external API requests go through it. I could probably set it up to make that optional as well, you'd just may hit the github request limit locally.

Anything specific you were interested in improving on the site?

johnmpotter avatar Nov 23 '21 02:11 johnmpotter

I wanted to see a total number of downloads instead of just the weekly / monthly numbers. I ended up building a separate site to do it.

benmccann avatar Nov 23 '21 03:11 benmccann

I know I'm a bit late but here is what I found. I got these endpoints from the npmtrends website and added this config into a .env.local file in the root directory. After that, npm run dev worked like a charm.

NEXT_PUBLIC_FRONTEND_URL="https://npmtrends.com"
NEXT_PUBLIC_BACKEND_URL="https://npm-trends-proxy.uidotdev.workers.dev"
NEXT_PUBLIC_ELASTICSEARCH_URL="https://npm-trends-proxy.uidotdev.workers.dev"
NEXT_PUBLIC_GITHUB_REPOS_API_ENDPOINT="https://npm-trends-proxy.uidotdev.workers.dev/github/repos"
NEXT_PUBLIC_NPM_DOWNLOADS_API_ENDPOINT="https://npm-trends-proxy.uidotdev.workers.dev/npm/downloads"
NEXT_PUBLIC_NPM_REGISTRY_API_ENDPOINT="https://npm-trends-proxy.uidotdev.workers.dev/npm/registry"

abizek avatar Apr 01 '24 05:04 abizek

@benmccann Is your site public? I want to try it!

abizek avatar Apr 01 '24 05:04 abizek