Skip to content

Commit

Permalink
Merge pull request #34 from misterzik/development
Browse files Browse the repository at this point in the history
(Enhance)Struct:Infra-v3.2.5
  • Loading branch information
misterzik authored Jun 24, 2023
2 parents 38483ab + 5df1214 commit aff4e2c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
15 changes: 5 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ require("dotenv").config();
const express = require("express");
const app = express();
const cfg = require("./server");
const { readConfigFile } = require("./server/utils/config.utils");
const {
readConfigFile,
setCustomCacheControl,
} = require("./server/utils/config.utils");
const configData = readConfigFile();

const Path = require("path");
Expand All @@ -40,8 +43,7 @@ if (configData.mongo_isEnabled) {
":" +
process.env.MONGO_TOKEN +
"@" +
mongoUri
+
mongoUri +
hasPort +
mongoDb
}`;
Expand All @@ -57,12 +59,6 @@ if (configData.mongo_isEnabled) {
.catch((err) => console.error(err));
}

const setCustomCacheControl = (res, path) => {
if (Static.mime.lookup(path) === "text/html") {
res.setHeader("Cache-Control", "public, max-age=0");
}
};

app.use(Compression());
app.use(Cors());
app.use(express.urlencoded({ extended: false }));
Expand All @@ -76,7 +72,6 @@ app.use(
extensions: "error.html",
})
);

Routes(app);
app.listen(Port, () => {
console.log(`Server is running on port ${Port}`);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@misterzik/espressojs",
"version": "3.2.4",
"version": "3.2.5",
"description": "EspressoJS Introducing Espresso.JS, your ultimate Express configuration starting point and boilerplate. With its simplicity and lack of opinionation, EspressoJS offers plug-and-play configurations built on top of Express.",
"main": "index.js",
"scripts": {
Expand Down
13 changes: 12 additions & 1 deletion server/utils/config.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,15 @@ const vmdLogo = `
'----'/.ZI|<..
`;

module.exports = { readConfigFile, writeConfigFile, vmdLogo };
const setCustomCacheControl = (res, path) => {
if (Static.mime.lookup(path) === "text/html") {
res.setHeader("Cache-Control", "public, max-age=0");
}
};

module.exports = {
readConfigFile,
writeConfigFile,
vmdLogo,
setCustomCacheControl,
};

0 comments on commit aff4e2c

Please sign in to comment.