Skip to content

Commit

Permalink
chore: styling changes to be more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
abdelaziz-mahdy committed Dec 23, 2024
1 parent f1f5db8 commit dfc278b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ ANIWATCH_API_MAX_REQS=70
# env to use optional redis caching functionality
ANIWATCH_API_REDIS_CONN_URL=<rediss://default:your-secure-password@your-redis-instance-name.provider.com: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
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
2 changes: 1 addition & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit dfc278b

Please sign in to comment.