diff options
| author | Abdelaziz Mahdy <[email protected]> | 2024-12-23 03:27:43 -0400 |
|---|---|---|
| committer | Abdelaziz Mahdy <[email protected]> | 2024-12-23 03:27:43 -0400 |
| commit | dfc278be08b64dc9bb3082059648c5f792a79fcb (patch) | |
| tree | 7d79ddcf7abf4ad1eea638b9d9544316ca64e6a3 | |
| parent | f1f5db84f98818af2c047ea375832e5ded5f021a (diff) | |
| download | aniwatch-api-dfc278be08b64dc9bb3082059648c5f792a79fcb.tar.xz aniwatch-api-dfc278be08b64dc9bb3082059648c5f792a79fcb.zip | |
chore: styling changes to be more consistent
| -rw-r--r-- | .env.example | 10 | ||||
| -rw-r--r-- | src/config/cacheControlMiddleware.ts (renamed from src/config/cache_control_middleware.ts) | 4 | ||||
| -rw-r--r-- | src/server.ts | 2 |
3 files changed, 9 insertions, 7 deletions
diff --git a/.env.example b/.env.example index ecbd080..555ad04 100644 --- a/.env.example +++ b/.env.example @@ -24,8 +24,10 @@ ANIWATCH_API_MAX_REQS=70 # env to use optional redis caching functionality ANIWATCH_API_REDIS_CONN_URL=<rediss://default:[email protected]:6379> +# .env.example - Environment configuration file for Aniwatch API + # Cache-Control settings for Vercel Edge Caching -# s-maxage specifies the maximum amount of time a resource is considered fresh when served by a CDN cache -S_MAXAGE=60 -# stale-while-revalidate specifies the amount of time a resource is served stale while a new one is fetched -STALE_WHILE_REVALIDATE=30 +# ANIWATCH_API_S_MAXAGE: Specifies the maximum amount of time (in seconds) a resource is considered fresh when served by a CDN cache. +ANIWATCH_API_S_MAXAGE=60 +# ANIWATCH_API_STALE_WHILE_REVALIDATE: Specifies the amount of time (in seconds) a resource is served stale while a new one is fetched. +ANIWATCH_API_STALE_WHILE_REVALIDATE=30 diff --git a/src/config/cache_control_middleware.ts b/src/config/cacheControlMiddleware.ts index 5543ddc..47035ed 100644 --- a/src/config/cache_control_middleware.ts +++ b/src/config/cacheControlMiddleware.ts @@ -2,8 +2,8 @@ import type { MiddlewareHandler } from "hono"; // Define middleware to add Cache-Control header const cacheControlMiddleware: MiddlewareHandler = async (c, next) => { - const sMaxAge = process.env.S_MAXAGE || "60"; - const staleWhileRevalidate = process.env.STALE_WHILE_REVALIDATE || "30"; + const sMaxAge = process.env.ANIWATCH_API_S_MAXAGE || "60"; + const staleWhileRevalidate = process.env.ANIWATCH_API_STALE_WHILE_REVALIDATE || "30"; c.header( "Cache-Control", `s-maxage=${sMaxAge}, stale-while-revalidate=${staleWhileRevalidate}` diff --git a/src/server.ts b/src/server.ts index 780d25b..85d3fbc 100644 --- a/src/server.ts +++ b/src/server.ts @@ -5,7 +5,7 @@ import corsConfig from "./config/cors.js"; import { ratelimit } from "./config/ratelimit.js"; import { hianimeRouter } from "./routes/hianime.js"; -import cacheControlMiddleware from "./config/cache_control_middleware.js"; +import cacheControlMiddleware from "./config/cacheControlMiddleware.js"; import { Hono } from "hono"; import { logger } from "hono/logger"; |
