Skip to content

BigfootDS/pkg-shared-data

Repository files navigation

BigfootDS Shared Data

This package contains data used across multiple services, handled here in an effort to adhere to "D.R.Y" coding principles.

Links

This package is published to these places:

Installation

This is a scoped package, so its install command looks a little longer than normal. But it means you can guarantee that you'll be getting the package from BigfootDS!

npm install @bigfootds/bigfootds-shared-data

TypeScript

This package ships generated TypeScript declarations with its compiled JavaScript output.

import { playerNameProfanityHandler } from "@bigfootds/bigfootds-shared-data";

const result = playerNameProfanityHandler.check("admin");

if (!result.isAllowed) {
	console.log(result.matches);
}

Shared Bigfoot Fetcher metadata is exported here so services can configure headers without importing the fetch wrapper:

import {
	BIGFOOT_FETCHER_HEADER_NAMES,
	type BigfootDSConfig
} from "@bigfootds/bigfootds-shared-data";

const allowedHeaders = [
	"Content-Type",
	"Authorization",
	...BIGFOOT_FETCHER_HEADER_NAMES
];

const serviceMetadata: BigfootDSConfig = {
	productName: "@bigfootds/ms-auth",
	platformType: "api"
};

Basic Usage

Import the package and use the profanity handlers for context-specific checks:

const bdsSharedData = require('@bigfootds/bigfootds-shared-data');

console.log("Top-level items in the package are:")
console.log(Object.keys(bdsSharedData));
console.log("Player name is allowed:")
console.log(bdsSharedData.playerNameProfanityHandler.isAllowed("admin"))

Output:

Top-level items in the package are:
[ 'WordBlacklists', 'WordLists', 'ProfanityHandlers', ... ]
Player name is allowed:
false

Use the chat handler when only profanity should be detected or censored:

const { chatProfanityHandler } = require('@bigfootds/bigfootds-shared-data');

console.log(chatProfanityHandler.exists("I like big butts and I cannot lie"));

Output:

true

Use the player name handler when profanity, reserved words, and developer-only words should all be blocked:

const { playerNameProfanityHandler } = require('@bigfootds/bigfootds-shared-data');

const result = playerNameProfanityHandler.check("bigfootds");

console.log(result.isAllowed);
console.log(result.hasDevWord);

Output:

false
true