42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import fp from "fastify-plugin"
|
|
import dayjs from "dayjs"
|
|
|
|
// 🧩 Plugins
|
|
import customParseFormat from "dayjs/plugin/customParseFormat.js";
|
|
import isBetween from "dayjs/plugin/isBetween.js";
|
|
import duration from "dayjs/plugin/duration.js";
|
|
import utc from "dayjs/plugin/utc"
|
|
import timezone from "dayjs/plugin/timezone"
|
|
import isSameOrAfter from "dayjs/plugin/isSameOrAfter"
|
|
import isSameOrBefore from "dayjs/plugin/isSameOrBefore"
|
|
import isoWeek from "dayjs/plugin/isoWeek"
|
|
import localizedFormat from "dayjs/plugin/localizedFormat"
|
|
|
|
// 🔧 Erweiterungen aktivieren
|
|
dayjs.extend(utc)
|
|
dayjs.extend(timezone)
|
|
dayjs.extend(isSameOrAfter)
|
|
dayjs.extend(isSameOrBefore)
|
|
dayjs.extend(isBetween)
|
|
dayjs.extend(isoWeek)
|
|
dayjs.extend(localizedFormat)
|
|
dayjs.extend(customParseFormat)
|
|
dayjs.extend(isBetween)
|
|
dayjs.extend(duration)
|
|
|
|
/**
|
|
* Fastify Plugin: hängt dayjs an den Server an
|
|
*/
|
|
export default fp(async (server) => {
|
|
server.decorate("dayjs", dayjs)
|
|
})
|
|
|
|
/**
|
|
* Typ-Erweiterung für TypeScript
|
|
*/
|
|
declare module "fastify" {
|
|
interface FastifyInstance {
|
|
dayjs: typeof dayjs
|
|
}
|
|
}
|