Skip to content

Commit

Permalink
Fix: Getting "Entity too large" error while rendering multi layer cha…
Browse files Browse the repository at this point in the history
…rt #1
  • Loading branch information
tobiashochguertel committed Jun 24, 2023
1 parent 188ffa4 commit 99a7740
Show file tree
Hide file tree
Showing 5 changed files with 517 additions and 428 deletions.
7 changes: 6 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
podman build --format docker --tag th-helm-playground-template .
#!/bin/bash
# podman build --format docker --tag th-helm-playground-template .

docker build --tag th-helm-playground-template:1.0.1 .
docker tag th-helm-playground-template:1.0.1 th-helm-playground-template:latest

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "helm-template-service",
"version": "1.0.0",
"version": "1.0.1",
"author": "",
"description": "",
"license": "ISC",
Expand Down Expand Up @@ -43,7 +43,8 @@
"scripts": {
"build": "npx tsc",
"start": "node dist/index.js",
"dev": "concurrently \"npx tsc --watch\" \"nodemon -q dist/index.js\"",
"lint": "eslint . --fix"
"lint": "eslint . --fix",
"compile": "tsc && yarn run start",
"dev": "npx nodemon -e ts --exec \"yarn run compile\""
}
}
34 changes: 28 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ type Content = {
}

const app: Express = express()
app.use(bodyParser.text());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.text({ limit: '50mb' }));
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ extended: false, limit: '50mb' }));
app.use(express.static('public'));

app.post('/template', async (req, res) => {
Expand All @@ -37,8 +37,31 @@ app.post('/template', async (req, res) => {
}
const directories = Array.from(chart.values()).filter((item: Content) => item.type === "directory");
const files = Array.from(chart.values()).filter((item: Content) => item.type === "file");
directories.forEach((directory: Content) => { fs.mkdirSync(`./public/chart/${directory.filename}`, { recursive: true }); });
files.forEach((file: Content) => { fs.writeFileSync(`./public/chart/${file.filename}`, file.content || ""); });
directories.forEach((directory: Content) => {
try {
fs.mkdirSync(`./public/chart/${directory.filename}`, { recursive: true });
} catch (err: unknown) {
if (err instanceof Error) {
console.log(`Error: ${directory.filename}: ${err.message}`)
}
if (!(err instanceof Error)) {
console.log(err);
}
}
});
files.forEach((file: Content) => {

try {
fs.writeFileSync(`./public/chart/${file.filename}`, file.content ?? "");
} catch (err: unknown) {
if (err instanceof Error) {
console.log(`Error: ${file.filename}: ${err.message}`)
}
if (!(err instanceof Error)) {
console.log(err);
}
}
});

const selection: Content = req.body.selection as Content;
fs.writeFileSync("./public/chart/" + selection.filename, selection.content || "");
Expand Down Expand Up @@ -80,7 +103,6 @@ app.post('/template', async (req, res) => {
});
res.send(result);
// fs.rmSync("./public/chart/", { recursive: true, force: true });
return;
});
// res.json({ "result": "ok" });
});
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,5 @@
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": ["src"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "public", "dist"]
}
Loading

0 comments on commit 99a7740

Please sign in to comment.