https://github.com/bigfootds/bigfoot-fetcher

JavaScript fetch override for cohesive, consistent usage across various BigfootDS projects.

https://github.com/bigfootds/bigfoot-fetcher

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.6%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

JavaScript fetch override for cohesive, consistent usage across various BigfootDS projects.

Basic Info
Statistics
  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 1
Created over 1 year ago · Last pushed about 1 year ago
Metadata Files
Readme License

README.md

@bigfootds/Bigfoot-Fetcher

JavaScript fetch override for cohesive, consistent usage across various BigfootDS projects.

Note that this package, while publicly available and MIT-licensed, is not intended for public contribution/collaboration. We just need an easy way to consolidate some functionality that will be reused across multiple projects, and an NPM package is a nice, easy way to do that.

Installation

npm install @bigfootds/bigfoot-fetcher

Usage

Import the package as:

js const {fetcher} = require("@bigfootds/bigfoot-fetcher");

Or:

js import {fetcher} from "@bigfootds/bigfoot-fetcher";

Then, use fetcher in place of any fetch function calls. It's a wrapper around fetch!

NodeJS Usage

```js app.get("/headers", (request, response) => { response.json({result: JSON.stringify(request.headers)}); })

fetcher("http://localhost:3030/headers") .then(async (response) => {return await response.json()}) .then((data) => { console.log("Returned headers:"); console.log(data); }); ```

Returned headers: { result: '{"host":"localhost:3030","connection":"keep-alive","osname":"Linux","osversion":"5.15.0-125-generic","platformname":"API","platformtype":"api","productname":"@bigfootds/ms-auth","accept":"*/*","accept-language":"*","sec-fetch-mode":"cors","user-agent":"node","accept-encoding":"gzip, deflate"}' }

ReactJS Usage

Vite has special config steps that must be done because of the strange way that they handle environment variables.

```js // vite.config.js

import { defineConfig, loadEnv } from 'vite' import react from '@vitejs/plugin-react' import packageJson from "./package.json";

// https://vitejs.dev/config/ export default defineConfig(({mode}) => {

const env = loadEnv(mode, process.cwd(), ""); let combined = {...env, ...packageJson.bigfootds}; console.log(combined);

return { plugins: [react()], define: { 'process.env':combined } } }) ```

```jsx import './App.css' import {fetcher} from "@bigfootds/bigfoot-fetcher";

function App() { const makeBigfootDSFetch = async () => { let result = await fetcher("http://localhost:3030/headers"); let data = await result.json(); console.log(data); }

return ( <>

</> ) }

export default App

```

The above returns this to the console:

{ "result": { "host": "localhost:3030", "connection": "keep-alive", "browserengineversion": "131.0.0.0", "browserversion": "131.0.0.0", "osname": "Windows", "browsername": "Chrome", "osversion": "10", "sec-ch-ua": "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"", "sec-ch-ua-mobile": "?0", "browserenginename": "Blink", "platformname": "web client", "osversionname": "10", "platformtype": "desktop", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", "dnt": "1", "productname": "Super Cool Frontend Website", "sec-ch-ua-platform": "\"Windows\"", "accept": "*/*", "origin": "http://localhost:5173", "sec-fetch-site": "same-site", "sec-fetch-mode": "cors", "sec-fetch-dest": "empty", "referer": "http://localhost:5173/", "accept-encoding": "gzip, deflate, br, zstd", "accept-language": "en-AU,en-GB;q=0.9,en-US;q=0.8,en;q=0.7", "if-none-match": "W/\"363-kym2xWPe6ASfGk36ZZ0u32/cuvA\"" } }

Yes, Windows 11 shows up as Windows 10 - more work can maybe be done in this area but it requires some more-secure browser context configuration.

Note that the headers above are populated by some default request headers as well as the "Bigfoot Fetcher" headers, which come from a package.json contents like this:

json { "name": "@bigfootds/ms-auth", "version": "1.0.1", "description": "Core authentication & IAM services for BigfootDS & its various games and products.", "config":{ "bigfootds":{ "platformType":"api", "platformName":"API", "productName":"@bigfootds/ms-auth" } }, // ...rest of package.json for a NodeJS back-end project }

json { "name": "vite-testo", "private": true, "version": "0.0.0", "bigfootds": { "productName": "Super Cool Frontend Website", "platformName":"web client" }, // ...rest of package.json for a front-end project }

These headers are added to all fetch requests that use this package's fetcher function:

typescript interface BigfootDSConfig { productName?: string, productVersion?: string, browserName?: string, browserVersion?: string, browserEngineName?: string, browserEngineVersion?: string, osName?: string, osVersion?: string, osVersionName?: string, platformType?: string, platformName?: string }

Whether or not they are actually added depends on if they have value, and they don't all have value on all platforms. e.g. no browser properties in the NodeJS environment!

Owner

  • Name: BigfootDS
  • Login: BigfootDS
  • Kind: organization
  • Email: contact@bigfootds.com
  • Location: Sydney, AUS

Game development group.

GitHub Events

Total
  • Release event: 6
  • Public event: 1
  • Push event: 9
  • Create event: 6
Last Year
  • Release event: 6
  • Public event: 1
  • Push event: 9
  • Create event: 6

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 6
  • Total maintainers: 1
npmjs.org: @bigfootds/bigfoot-fetcher

JavaScript fetch override for cohesive, consistent usage across various BigfootDS projects.

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 0 Last month
Rankings
Dependent repos count: 25.5%
Average: 31.2%
Dependent packages count: 36.9%
Maintainers (1)
Last synced: 10 months ago

Dependencies

.github/workflows/cd_npm.yml actions
  • JS-DevTools/npm-publish v3 composite
  • actions/checkout v4 composite
  • actions/create-release v1 composite
  • actions/setup-node v4 composite
  • eregon/publish-release v1.0.6 composite
  • mathieudutour/github-tag-action v6.2 composite
  • reedyuk/npm-version master composite
  • stefanzweifel/git-auto-commit-action v5 composite
package-lock.json npm
  • @types/node 22.10.1 development
  • typescript 5.7.2 development
  • undici-types 6.20.0 development
  • bowser 2.11.0
  • dotenv 16.4.5
  • my-ua-parser 2.0.4
package.json npm
  • @types/node ^22.10.1 development
  • typescript ^5.7.2 development
  • bowser ^2.11.0
  • dotenv ^16.4.5
  • my-ua-parser ^2.0.4