@server/next 0.34.1 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +45 -17
- package/index.js +663 -272
- package/package.json +2 -1
package/index.d.ts
CHANGED
|
@@ -8,12 +8,12 @@ type LimitOptions = {
|
|
|
8
8
|
declare class UploadPipeline {
|
|
9
9
|
private _bucket;
|
|
10
10
|
private _limits;
|
|
11
|
-
constructor(bucket?: Bucket | null);
|
|
11
|
+
constructor(bucket?: Bucket | string | null);
|
|
12
12
|
limit(options: LimitOptions): this;
|
|
13
|
-
store(bucket: Bucket): this;
|
|
13
|
+
store(bucket: Bucket | string): this;
|
|
14
14
|
processFile(originalName: string, data: Buffer, contentType: string): Promise<UploadedFile>;
|
|
15
15
|
}
|
|
16
|
-
declare function upload(bucket?: Bucket | null): UploadPipeline;
|
|
16
|
+
declare function upload(bucket?: Bucket | string | null): UploadPipeline;
|
|
17
17
|
|
|
18
18
|
type Method = "get" | "post" | "put" | "patch" | "delete" | "head" | "options" | "socket";
|
|
19
19
|
type ServerConfig<Session = {}, User = {}> = {
|
|
@@ -30,11 +30,15 @@ declare namespace JSX {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
type BodyMode = "parse" | "raw" | "stream";
|
|
33
|
+
type BodyOption = BodyMode | {
|
|
34
|
+
mode?: BodyMode;
|
|
35
|
+
max?: number | string | false;
|
|
36
|
+
};
|
|
33
37
|
type RouteOptions = {
|
|
34
38
|
tags?: string | string[];
|
|
35
39
|
title?: string;
|
|
36
40
|
description?: string;
|
|
37
|
-
body?:
|
|
41
|
+
body?: BodyOption;
|
|
38
42
|
};
|
|
39
43
|
type Route = {
|
|
40
44
|
path: string;
|
|
@@ -51,12 +55,29 @@ type Cookie = {
|
|
|
51
55
|
sameSite?: "Strict" | "Lax" | "None";
|
|
52
56
|
};
|
|
53
57
|
type RouterMethod = "*" | Method;
|
|
58
|
+
type FileInfo = {
|
|
59
|
+
exists: boolean;
|
|
60
|
+
size: number;
|
|
61
|
+
date: Date | null;
|
|
62
|
+
type?: string | null;
|
|
63
|
+
};
|
|
64
|
+
type BucketFile = {
|
|
65
|
+
readonly path: string;
|
|
66
|
+
readonly id: string;
|
|
67
|
+
readonly name: string;
|
|
68
|
+
exists(): Promise<boolean>;
|
|
69
|
+
info?(): Promise<FileInfo>;
|
|
70
|
+
write(content: string | Buffer | ReadableStream, options?: {
|
|
71
|
+
type?: string;
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
stream(): ReadableStream;
|
|
74
|
+
slice?(start: number, end?: number): BucketFile;
|
|
75
|
+
bytes(): Promise<Uint8Array>;
|
|
76
|
+
remove(): Promise<void>;
|
|
77
|
+
};
|
|
54
78
|
type Bucket = {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
write: (path: string, data: string | Buffer | ReadableStream) => Promise<void | string>;
|
|
58
|
-
delete: (path: string) => Promise<boolean>;
|
|
59
|
-
folder?: (prefix: string) => Bucket;
|
|
79
|
+
file(name: string): BucketFile;
|
|
80
|
+
folder?(prefix: string): Bucket;
|
|
60
81
|
};
|
|
61
82
|
type UploadedFile = {
|
|
62
83
|
name: string;
|
|
@@ -93,7 +114,7 @@ type KVStore = {
|
|
|
93
114
|
keys: () => Promise<string[]>;
|
|
94
115
|
};
|
|
95
116
|
type Provider = "email" | "github" | "google" | "microsoft" | "discord" | "facebook" | "apple";
|
|
96
|
-
type Strategy = "cookie" | "jwt" | "token";
|
|
117
|
+
type Strategy = "cookie" | "jwt" | "token" | "key";
|
|
97
118
|
type AuthSession = {
|
|
98
119
|
id: string;
|
|
99
120
|
provider: Provider;
|
|
@@ -106,9 +127,10 @@ type AuthUser<T = Record<string, any>> = T & {
|
|
|
106
127
|
strategy: Strategy;
|
|
107
128
|
email: string;
|
|
108
129
|
};
|
|
109
|
-
type AuthOption = `${Strategy}:${Provider}` | {
|
|
130
|
+
type AuthOption = `${Strategy}:${Provider}` | "key" | {
|
|
110
131
|
strategy: Strategy;
|
|
111
|
-
providers
|
|
132
|
+
providers?: Provider | Provider[];
|
|
133
|
+
key?: string;
|
|
112
134
|
session?: KVStore;
|
|
113
135
|
store?: KVStore;
|
|
114
136
|
redirect?: string;
|
|
@@ -119,6 +141,7 @@ type AuthSettings = {
|
|
|
119
141
|
strategy: Strategy;
|
|
120
142
|
store: KVStore;
|
|
121
143
|
session: KVStore;
|
|
144
|
+
key?: string;
|
|
122
145
|
cleanUser: <T = AuthUser>(user: T) => T | Promise<T>;
|
|
123
146
|
redirect: string;
|
|
124
147
|
};
|
|
@@ -162,9 +185,9 @@ type Options = {
|
|
|
162
185
|
openapi?: any;
|
|
163
186
|
onError?: OnError;
|
|
164
187
|
log?: LogLevel | boolean;
|
|
165
|
-
favicon?: string |
|
|
188
|
+
favicon?: string | BucketFile;
|
|
166
189
|
security?: boolean | SecurityOptions;
|
|
167
|
-
body?:
|
|
190
|
+
body?: BodyOption;
|
|
168
191
|
};
|
|
169
192
|
type Settings = {
|
|
170
193
|
port: number;
|
|
@@ -181,9 +204,9 @@ type Settings = {
|
|
|
181
204
|
openapi?: any;
|
|
182
205
|
onError?: OnError;
|
|
183
206
|
log: Logger;
|
|
184
|
-
favicon?: string |
|
|
207
|
+
favicon?: string | BucketFile;
|
|
185
208
|
security: SecuritySettings;
|
|
186
|
-
body:
|
|
209
|
+
body: BodyOption;
|
|
187
210
|
};
|
|
188
211
|
type Time = {
|
|
189
212
|
(name: string): void;
|
|
@@ -342,6 +365,11 @@ declare class Server<O extends ServerConfig = {}> extends Router<O> {
|
|
|
342
365
|
platform: Platform;
|
|
343
366
|
sockets: any[];
|
|
344
367
|
websocket: any;
|
|
368
|
+
faviconCache?: {
|
|
369
|
+
bytes: Buffer;
|
|
370
|
+
type: string;
|
|
371
|
+
etag: string;
|
|
372
|
+
} | null;
|
|
345
373
|
port?: number;
|
|
346
374
|
constructor(options?: Options);
|
|
347
375
|
self(): this;
|
|
@@ -464,4 +492,4 @@ declare class Server<O extends ServerConfig = {}> extends Router<O> {
|
|
|
464
492
|
}
|
|
465
493
|
declare function server<Session extends Record<string, any> = {}, User extends Record<string, any> = {}>(options?: Options): Server<ServerConfig<Session, User>>;
|
|
466
494
|
|
|
467
|
-
export { type AuthOption, type AuthSession, type AuthSettings, type AuthUser, type BasicValue, type Body, type BodyMode, type Bucket, type BunEnv, type Context, type Cookie, type CorsSettings, type ExtractPathParams, type InferParamType, type InlineReply, type KVStore, type LimitOptions, type LogLevel, type Logger, type Method, type Middleware, type Options, type ParamTypeMap, type ParamsToObject, type PathToParams, type Platform, type Provider, type Route, type RouteOptions, type RouterMethod, type SecurityOptions, type SecuritySettings, type SerializableValue, Server, type ServerConfig, TypedServerError as ServerError, type Settings, type Strategy, type Time, UploadPipeline, type UploadedFile, cookies, server as default, download, file, headers, json, redirect, router, send, status, type, upload };
|
|
495
|
+
export { type AuthOption, type AuthSession, type AuthSettings, type AuthUser, type BasicValue, type Body, type BodyMode, type BodyOption, type Bucket, type BucketFile, type BunEnv, type Context, type Cookie, type CorsSettings, type ExtractPathParams, type FileInfo, type InferParamType, type InlineReply, type KVStore, type LimitOptions, type LogLevel, type Logger, type Method, type Middleware, type Options, type ParamTypeMap, type ParamsToObject, type PathToParams, type Platform, type Provider, type Route, type RouteOptions, type RouterMethod, type SecurityOptions, type SecuritySettings, type SerializableValue, Server, type ServerConfig, TypedServerError as ServerError, type Settings, type Strategy, type Time, UploadPipeline, type UploadedFile, cookies, server as default, download, file, headers, json, redirect, router, send, status, type, upload };
|