denwa-web-shared
shared-constants
core60 linesSource
Use shared library constants like TIME and THEME. Load when hardcoding time durations, milliseconds, breakpoints, or offsets.
denwa-web-shared — Use library constants
Setup
tsx
import { TIME, THEME } from 'denwa-web-shared/server';
const timeout = TIME.milliseconds.seconds5;
const offset = THEME.OFFSET[4];Core Patterns
Using TIME constants for durations
tsx
import { TIME } from 'denwa-web-shared/server';
export const fetchWithTimeout = async (url: string) => {
const controller = new AbortController();
setTimeout(() => controller.abort(), TIME.milliseconds.seconds5);
return fetch(url, { signal: controller.signal });
};Common Mistakes
MEDIUM Hardcoding time values
Wrong:
tsx
setTimeout(fn, 1000);Correct:
tsx
import { TIME } from 'denwa-web-shared/server';
setTimeout(fn, TIME.milliseconds.seconds1);Agents hardcode milliseconds values instead of using the TIME constant.
Source: maintainer interview