mirror of
https://github.com/Nezumi-2711/next-gdrive-index.git
synced 2026-09-22 13:38:38 +00:00
update: rename configuration name, and add preview configuration (break old config)
This commit is contained in:
+31
-12
@@ -20,24 +20,22 @@ const config: z.input<typeof Schema_Config> = {
|
||||
basePath: IS_DEV ? "http://localhost:3000" : new URL(BASE_URL).toString(),
|
||||
|
||||
/**
|
||||
* Allow access to the deploy guide
|
||||
* Will use the `/deploy` route, might be overlap with file / folder name
|
||||
* Show deploy guide dropdown on navbar
|
||||
* that contains the deploy guide and configurator
|
||||
*
|
||||
* Set this to false on final deployment
|
||||
*
|
||||
* I'm using this to show the deploy guide on my own demo deployment
|
||||
* Set this to false on final deployment, except you want to show it
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
showDeployGuide: false,
|
||||
showGuideButton: true,
|
||||
|
||||
/**
|
||||
* How long the cache will be stored in the browser
|
||||
* Used for all pages and api routes
|
||||
*
|
||||
* @default "max-age=0, s-maxage=60, stale-while-revalidate"
|
||||
* @default "public, max-age=60, s-maxage=60, stale-while-revalidate"
|
||||
*/
|
||||
cacheControl: "max-age=0, s-maxage=60, stale-while-revalidate",
|
||||
cacheControl: "public, max-age=60, s-maxage=60, stale-while-revalidate",
|
||||
|
||||
apiConfig: {
|
||||
/**
|
||||
@@ -146,16 +144,16 @@ const config: z.input<typeof Schema_Config> = {
|
||||
* After 30 minutes, and the user still downloading the file, the download will NOT be interrupted
|
||||
* But if the user refresh the page / trying to download again, the download link will be expired
|
||||
*
|
||||
* Default: 6 hours
|
||||
* Default: 1 hour
|
||||
*/
|
||||
temporaryTokenDuration: 6,
|
||||
temporaryTokenDuration: 1,
|
||||
|
||||
/**
|
||||
* Maximum file size that can be downloaded via api routes
|
||||
* If it's larger than this, it will be redirected to the file url
|
||||
*
|
||||
* If you're using Vercel, they have a limit of ~4 - ~4.5MB response size
|
||||
* ref: https://vercel.com/docs/platform/limits#serverless-function-payload-size-limit
|
||||
* ref: https://vercel.com/docs/functions/runtimes#request-body-size
|
||||
* If you're using another platform, you can match the limit with your platform
|
||||
* Or you can set this to 0 to disable the limit
|
||||
*
|
||||
@@ -215,7 +213,10 @@ const config: z.input<typeof Schema_Config> = {
|
||||
* - {{ handle }} will be replaced with the twitter handle from twitterHandle config above
|
||||
* - {{ creator }} will be replaced with mbaharip if you want to credit me
|
||||
*/
|
||||
footer: ["{{ poweredBy }}", "Made with ❤️ by [**{{ author }}**](https://github.com/mbaharip)"],
|
||||
footer: [
|
||||
{ value: "{{ poweredBy }}" },
|
||||
{ value: "Made with ❤️ by [**{{ author }}**](https://github.com/mbaharip)" },
|
||||
],
|
||||
/**
|
||||
* Add page load time on the footer
|
||||
* If you don't want to use it, you can set it to false
|
||||
@@ -303,6 +304,24 @@ const config: z.input<typeof Schema_Config> = {
|
||||
href: "https://saweria.co/mbaharip",
|
||||
},
|
||||
],
|
||||
|
||||
/**
|
||||
* Configuration for file preview
|
||||
*/
|
||||
previewSettings: {
|
||||
manga: {
|
||||
/**
|
||||
* Load first X MB of the file for preview
|
||||
* or load first X items for preview
|
||||
*
|
||||
* @default
|
||||
* maxSize: 15MB
|
||||
* maxItem: 10 items
|
||||
*/
|
||||
maxSize: 15 * 1024 * 1024,
|
||||
maxItem: 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
+49
-17
@@ -93,15 +93,15 @@ export const Schema_Old_Config = z.object({
|
||||
export const Schema_Config_API = z
|
||||
.object({
|
||||
rootFolder: z.string(),
|
||||
isTeamDrive: z.boolean(),
|
||||
isTeamDrive: z.coerce.boolean(),
|
||||
sharedDrive: z.string().optional(),
|
||||
defaultQuery: z.array(z.string()),
|
||||
defaultField: z.string(),
|
||||
defaultOrder: z.string(),
|
||||
itemsPerPage: z.number().positive(),
|
||||
searchResult: z.number().positive(),
|
||||
proxyThumbnail: z.boolean(),
|
||||
streamMaxSize: z.number(),
|
||||
itemsPerPage: z.coerce.number().positive(),
|
||||
searchResult: z.coerce.number().positive(),
|
||||
proxyThumbnail: z.coerce.boolean(),
|
||||
streamMaxSize: z.coerce.number(),
|
||||
|
||||
specialFile: z.object({
|
||||
password: z.string(),
|
||||
@@ -110,9 +110,9 @@ export const Schema_Config_API = z
|
||||
}),
|
||||
hiddenFiles: z.array(z.string()),
|
||||
|
||||
allowDownloadProtectedFile: z.boolean(),
|
||||
temporaryTokenDuration: z.number().positive(),
|
||||
maxFileSize: z.number().positive(),
|
||||
allowDownloadProtectedFile: z.coerce.boolean(),
|
||||
temporaryTokenDuration: z.coerce.number().positive(),
|
||||
maxFileSize: z.coerce.number().positive(),
|
||||
})
|
||||
.refine(
|
||||
(data) => {
|
||||
@@ -130,21 +130,27 @@ export const Schema_Config_Site = z.object({
|
||||
robots: z.string().optional().default("noindex, nofollow"),
|
||||
twitterHandle: z.string().optional().default("@__mbaharip__"),
|
||||
|
||||
showFileExtension: z.boolean().optional().default(false),
|
||||
showFileExtension: z.coerce.boolean().optional().default(false),
|
||||
|
||||
footer: z.string().array().optional(),
|
||||
footer: z
|
||||
.array(
|
||||
z.object({
|
||||
value: z.string(),
|
||||
}),
|
||||
)
|
||||
.default([]),
|
||||
experimental_pageLoadTime: z
|
||||
.literal(false)
|
||||
.or(z.enum(["s", "ms"]))
|
||||
.default("ms"),
|
||||
|
||||
privateIndex: z.boolean().optional().default(false),
|
||||
breadcrumbMax: z.number(),
|
||||
privateIndex: z.coerce.boolean().optional().default(false),
|
||||
breadcrumbMax: z.coerce.number(),
|
||||
|
||||
toaster: z
|
||||
.object({
|
||||
position: z.enum(["top-left", "top-right", "bottom-left", "bottom-right"]),
|
||||
duration: z.number().positive(),
|
||||
duration: z.coerce.number().positive(),
|
||||
})
|
||||
.optional()
|
||||
.default({
|
||||
@@ -157,7 +163,7 @@ export const Schema_Config_Site = z.object({
|
||||
icon: z.enum(Object.keys(icons) as [keyof typeof icons]),
|
||||
name: z.string(),
|
||||
href: z.string(),
|
||||
external: z.boolean().optional().default(false),
|
||||
external: z.coerce.boolean().optional().default(false),
|
||||
}),
|
||||
),
|
||||
supports: z.array(
|
||||
@@ -167,6 +173,13 @@ export const Schema_Config_Site = z.object({
|
||||
href: z.string(),
|
||||
}),
|
||||
),
|
||||
|
||||
previewSettings: z.object({
|
||||
manga: z.object({
|
||||
maxSize: z.coerce.number().positive(),
|
||||
maxItem: z.coerce.number().positive(),
|
||||
}),
|
||||
}),
|
||||
});
|
||||
export const Schema_App_Configuration_Env = z.object({
|
||||
GD_SERVICE_B64: z.string(),
|
||||
@@ -179,7 +192,7 @@ export const Schema_Config = z.object({
|
||||
version: z.string(),
|
||||
basePath: z.string(),
|
||||
cacheControl: z.string(),
|
||||
showDeployGuide: z.boolean(),
|
||||
showGuideButton: z.boolean(),
|
||||
|
||||
apiConfig: Schema_Config_API,
|
||||
|
||||
@@ -202,8 +215,21 @@ export const Schema_ServiceAccount = z.object({
|
||||
|
||||
export const Schema_App_Configuration = z.object({
|
||||
environment: Schema_App_Configuration_Env,
|
||||
api: Schema_Config_API,
|
||||
site: Schema_Config_Site,
|
||||
api: Schema_Config_API.and(
|
||||
z.object({
|
||||
cache: z.object({
|
||||
public: z.coerce.boolean(),
|
||||
maxAge: z.coerce.number().positive(),
|
||||
sMaxAge: z.coerce.number().positive(),
|
||||
staleWhileRevalidate: z.coerce.boolean(),
|
||||
}),
|
||||
}),
|
||||
),
|
||||
site: Schema_Config_Site.and(
|
||||
z.object({
|
||||
guideButton: z.boolean(),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
export type ConfigurationCategory = keyof z.infer<typeof Schema_App_Configuration>;
|
||||
@@ -240,3 +266,9 @@ export const Schema_Theme = z.object({
|
||||
"radius": z.string(),
|
||||
});
|
||||
export type ThemeKeys = keyof z.infer<typeof Schema_Theme>;
|
||||
|
||||
export const Schema_FileToken = z.object({
|
||||
id: z.string(),
|
||||
exp: z.number(),
|
||||
iat: z.number(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user