Pythe1337N / garmin-connect

Makes it simple to interface with Garmin Connect to get or set any data point.
MIT License
144 stars 58 forks source link

Deprecated request and cloudscraper notices #49

Open wscourge opened 1 year ago

wscourge commented 1 year ago

When running npm install or yarn:

warning cloudscraper > request-promise@4.2.6: request-promise has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
warning request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning request > uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
warning request > har-validator@5.1.5: this library is no longer supported
warning " > cloudscraper@4.6.0" has unmet peer dependency "brotli@^1.3.2".

Then, when using the package in Next.js, the simplest usage such as calling this function on any api route:

import { GarminConnect } from "garmin-connect"

const URL =
  "https://connect.garmin.com/modern/proxy/badge-service/badge/detail/v2"

export default async (garminId: number) => {
  const credentials = { ... }

  const Garmin = new GarminConnect(credentials)
  await Garmin.login(credentials.username, credentials.password)
  return await Garmin.get(`${URL}/${garminId}`)
}

results in the following server logs for cloudscrapper dependency:

Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Import trace for requested module:
./node_modules/cloudscraper/lib/brotli.js
./node_modules/cloudscraper/index.js
./lib/garmin-connect/common/CFClient.ts
./lib/garmin-connect/garmin/GarminConnect.ts
./lib/garmin-connect/index.ts
./api/garmin/get-badge.ts
./app/api/jbadges/route.ts

and the following for app-root-path dependency:

Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/app-root-path/lib/app-root-path.js
./node_modules/app-root-path/index.js
./node_modules/garmin-connect/dist/garmin/GarminConnect.js
./node_modules/garmin-connect/dist/index.js
./api/garmin/get-badge.ts
./app/api/badges/route.ts

How to fix this?