-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhooks.ts
31 lines (27 loc) · 806 Bytes
/
hooks.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import 'dotenv/config';
import '$services/redis/client';
import boxen from 'boxen';
import { DateTime } from 'luxon';
import type { Handle, GetSession } from '@sveltejs/kit';
import { sequence } from '@sveltejs/kit/hooks';
import { useCachePage, useSession, useErrors } from '$services/middlewares';
if (!process.env.REDIS_HOST) {
console.error(
boxen('You must specify Redis connection info in the .env file', {
padding: 1,
margin: 1,
borderStyle: 'double'
})
);
process.exit(1);
}
export const handle: Handle = sequence(useErrors, useCachePage, useSession);
export const getSession: GetSession = (event) => {
return event.locals.session;
};
DateTime.prototype.toString = function () {
return this.toMillis();
};
DateTime.prototype.toJSON = function () {
return this.toMillis();
};