Blame Raw
Cohee · 51ad27fb · · 78 lines (1.9 KB)
1 contributor
1import { EventEmitter } from 'node:events';
2import { CsrfSyncedToken } from 'csrf-sync';
3import { UserDirectoryList, User } from './src/users.js';
4import { CommandLineArguments } from './src/command-line.js';
5import { EVENT_NAMES } from './src/server-events.js';
6
7/**
8 * Event payload for SERVER_STARTED event.
9 */
10export interface ServerStartedEvent {
11 /**
12 * The URL the server is listening on.
13 */
14 url: URL;
15}
16
17/**
18 * Map of all server events to their payload types.
19 */
20export interface ServerEventMap {
21 [EVENT_NAMES.SERVER_STARTED]: [ServerStartedEvent];
22}
23
24declare global {
25 declare namespace NodeJS {
26 export interface Process {
27 /**
28 * A global instance of the server events emitter.
29 */
30 serverEvents: EventEmitter<ServerEventMap>;
31 }
32 }
33
34 declare namespace CookieSessionInterfaces {
35 export interface CookieSessionObject {
36 /**
37 * The CSRF token for the session.
38 */
39 csrfToken: CsrfSyncedToken;
40 /**
41 * Authenticated user handle.
42 */
43 handle: string | null;
44 /**
45 * Account version tag: shake256 derivative of password hash and salt.
46 */
47 version: string | null;
48 /**
49 * Last time the session was extended.
50 */
51 touch: number;
52 }
53 }
54
55 namespace Express {
56 export interface Request {
57 user: {
58 profile: User;
59 directories: UserDirectoryList;
60 };
61 }
62 }
63
64 /**
65 * The root directory for user data.
66 */
67 var DATA_ROOT: string;
68
69 /**
70 * Parsed command line arguments.
71 */
72 var COMMAND_LINE_ARGS: CommandLineArguments;
73
74 /**
75 * Forces a global mode if set to `true` before parsing the CLI arguments.
76 */
77 var FORCE_GLOBAL_MODE: boolean;
78}