2024-10-01 02:44:39 +03:00
|
|
|
import type { Cookies } from '@sveltejs/kit'
|
2024-10-01 04:59:41 +03:00
|
|
|
import { env } from '$env/dynamic/private'
|
2024-11-19 01:12:33 +03:00
|
|
|
import { get, writable } from 'svelte/store'
|
2024-10-29 11:45:20 +03:00
|
|
|
import { existsSync, readFileSync } from 'fs'
|
2024-10-01 02:44:39 +03:00
|
|
|
|
|
|
|
export const scopeCookies = (cookies: Cookies, path: string) => {
|
|
|
|
return {
|
|
|
|
get: (key: string) => {
|
|
|
|
return cookies.get(key)
|
|
|
|
},
|
|
|
|
set: (key: string, value: string, props: import('cookie').CookieSerializeOptions = {}) => {
|
|
|
|
cookies.set(key, value, { ...props, path })
|
|
|
|
},
|
|
|
|
delete: (key: string, props: import('cookie').CookieSerializeOptions = {}) => {
|
|
|
|
cookies.delete(key, { ...props, path })
|
|
|
|
}
|
|
|
|
}
|
2024-10-01 04:34:07 +03:00
|
|
|
}
|
|
|
|
|
2024-10-01 04:59:41 +03:00
|
|
|
export const visitCountFile = `${env.WEBSITE_DATA_DIR}/visitcount`
|
2024-11-23 02:46:42 +03:00
|
|
|
export const visitCount = writable(parseInt(existsSync(visitCountFile) ? readFileSync(visitCountFile).toString() : '0'));
|