Skip to content

Commit

Permalink
Add short (5min public cache).
Browse files Browse the repository at this point in the history
Expose the docker container port by default.
  • Loading branch information
Maczuga committed Sep 3, 2024
1 parent 7d6fea3 commit c64a517
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ services:
restart: always
ports:
- "${SERVER_PORT:-9876}:${SERVER_PORT:-9876}"
expose:
- "${SERVER_PORT:-9876}"
env_file:
- .env.local
7 changes: 2 additions & 5 deletions src/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ export const initServer = () => {

const app = express();
app.set("etag", false);
app.use(
express.static("public", {
maxAge: 300,
})
);
app.disable("x-powered-by");

app.use(express.json());
const PORT = Number(process.env.SERVER_PORT);

Expand Down
7 changes: 1 addition & 6 deletions src/routes/getTSMAppData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ export const getTSMAppData = async (req: Request, res: Response, next: NextFunct

const lua = await generateTSMAppData(realms);

const cacheTime = 5;

const now = new Date();
const expires = new Date();
expires.setMinutes(now.getMinutes() + cacheTime);

res.set({
"Content-Type": "text/plain",
"Cache-Control": `public, max-age=${300}, must-revalidate`,
});

res.status(200).send(lua);
Expand Down

0 comments on commit c64a517

Please sign in to comment.