@koma-app/core
v0.1.6
Published
Client typé, types et formateurs du storefront Koma — sans React.
Maintainers
Readme
@koma-app/core
Client typé, types, formateurs et helpers du storefront Koma, sans React. Base de
@koma-app/react, utilisable seul par n'importe quel framework.
import { createKomaClient, formatPrice, groupByDay } from "@koma-app/core";
const koma = createKomaClient(); // /api/v1 en même origine (site proxifié) ; sinon { baseUrl, studioKey: "pk_…" }
const studio = await koma.studio();
const courses = await koma.courses();
for (const day of groupByDay(courses, { timeZone: studio.timezone, locale: studio.locale })) {
console.log(day.heading, day.courses.map((c) => `${c.title} ${formatPrice(c.priceCents, studio.currency)}`));
}createKomaClient({ baseUrl?, studioKey?, fetch?, credentials? }):studio,courses,course,cardProducts,otpRequest,otpVerify,me,logout,account,trialEligibility,payIntent,cardIntent,payWithCredit,requestCancellation,contact. Les échecs rejettent uneKomaApiError { status, code, message }.- Formateurs :
formatPrice,formatTime,formatDuration,formatDayHeading,formatFullDate,groupByDay(fuseau et locale du studio, jamais en dur). - Stockage local tolérant (
koma.*) : identité mémorisée, réservation locale par cours, verrou post-achat, contexte essai. - Calendrier :
googleCalendarUrl,buildIcs,eventWindow. SEO :courseJsonLd.
Contrat de l'API : docs/api.md du dépôt Koma.
