1
- import type { D1Database , KVNamespace , R2Bucket } from '@cloudflare/workers-types' ;
1
+ type D1Database = import ( '@cloudflare/workers-types' ) . D1Database ;
2
+ type KVNamespace = import ( '@cloudflare/workers-types' ) . KVNamespace ;
3
+ type R2Bucket = import ( '@cloudflare/workers-types' ) . R2Bucket ;
2
4
3
5
interface Config {
4
6
title : string ;
@@ -56,6 +58,24 @@ type MenuItem = NavbarItem & {
56
58
action ?: ( ) => void ;
57
59
} ;
58
60
61
+ interface User {
62
+ name ?: string | null ;
63
+ email ?: string | null ;
64
+ image ?: string | null ;
65
+ id ?: string | null ; // Optional user ID (can be from OAuth provider or internal)
66
+ role ?: string | null ; // Optional role for authorization
67
+ [ key : string ] : any ; // Allow other properties as needed for flexibility
68
+ }
69
+
70
+ // Define the session type to include user and session-specific properties
71
+ interface Session {
72
+ user ?: User | null ; // User information associated with the session
73
+ expires : string ; // Expiration date as an ISO string
74
+ accessToken ?: string ; // Optional access token for OAuth/JWT providers
75
+ refreshToken ?: string ; // Optional refresh token for OAuth/JWT providers
76
+ [ key : string ] : any ; // Allow extensions for future changes or addons
77
+ }
78
+
59
79
declare namespace App {
60
80
interface Locals {
61
81
db ?: D1Database ;
@@ -69,7 +89,8 @@ declare namespace App {
69
89
}
70
90
71
91
interface PageData {
72
- config : Config ;
92
+ session : Session | null ;
93
+ config ?: Config ;
73
94
}
74
95
75
96
interface Platform {
@@ -80,17 +101,7 @@ declare namespace App {
80
101
env ?: Env ;
81
102
// Cloudflare-specific properties
82
103
cf ?: {
83
- asn ?: string ; // Autonomous System Number
84
- asOrganization ?: string ; // Organization name of ASN
85
- city ?: string ; // City of the request origin
86
- continent ?: string ; // Continent of the request origin
87
- country ?: string ; // Country code (ISO 3166-1 Alpha 2)
88
- latitude ?: string ; // Latitude of the request origin
89
- longitude ?: string ; // Longitude of the request origin
90
- postalCode ?: string ; // Postal code of the request origin
91
- region ?: string ; // Region name
92
- regionCode ?: string ; // Region code
93
- timezone ?: string ; // Timezone of the request origin
104
+ [ key : string ] : string | undefined ;
94
105
} ;
95
106
}
96
107
}
0 commit comments