@seastartech/dream-shared
v2.1.0
Published
Shared utilities for Dream Machine projects
Keywords
Readme
@seastartech/dream-shared
Shared utilities used by every other @seastartech/dream-* package and by the API/frontend consumers.
Installation
npm install @seastartech/dream-sharedWhat's exported
export * from "./models" // MetaField
export * from "./services" // axios, setApiURL, setAuthToken, dayjsServices
AxiosInstance— a singletonaxiosinstance.setApiURL(baseURL: string)— sets the base URL on the singleton.setAuthToken(token: string)— setsAuthorization(pass the full"Bearer <jwt>").axios— the configured instance, used by all@seastartech/dream-*API functions.
DayJsInstance— a pre-configureddayjsexport, so consumers don't each import dayjs and pick different plugin sets.
Models
MetaField— the standard audit shape (createdAt,modifiedAt,createdBy,modifiedBy, etc.) shared across all entity models.
Usage
In a Next.js handler or server action:
import { setApiURL, setAuthToken } from "@seastartech/dream-shared"
setApiURL(process.env.NEXT_PUBLIC_API_BASE_URL!)
setAuthToken(`Bearer ${accessToken}`)In next-dream-machine this is wrapped by lib/withAuth.ts — always go through that wrapper.
Build
npm run build # tsc → dist/index.js + dist/index.d.ts
npm run watch # tsc --watch
npm run clean # rm -rf distLicense
MIT
