Skip to content

Commit 932e389

Browse files
committed
today
1 parent bc9cb16 commit 932e389

File tree

4 files changed

+75
-5
lines changed

4 files changed

+75
-5
lines changed

app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"scripts": {
33
"build:index": "node src/build-index.mjs",
4-
"build": "npm run build:index"
4+
"build": "npm run build:index",
5+
"serve": "node src/serve.mjs"
56
}
67
}

app/src/build-index.mjs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import fs from "node:fs/promises";
22
import path from "node:path";
3+
import { fileURLToPath } from 'url';
4+
import { dirname } from 'path';
5+
6+
const CURRENT_DIR = dirname(fileURLToPath(import.meta.url));
7+
const BASE_DIR = path.resolve( CURRENT_DIR, "../../");
8+
const TIL_DIR = path.resolve(BASE_DIR, "content");
9+
console.log(`BASE_DIR: ${BASE_DIR}`);
10+
console.log(`CURRENT_DIR: ${CURRENT_DIR}`);
11+
console.log(`TIL_DIR: ${TIL_DIR}`);
312

4-
const TIL_DIR = path.resolve("content");
513
const files = [];
614

715
async function readDir(dir) {
@@ -75,6 +83,6 @@ for (const file of files) {
7583

7684
items.sort((a, b) => String(b.date).localeCompare(String(a.date)));
7785

78-
await fs.copyFile("app/src/index.html", "dist/index.html");
79-
await fs.writeFile("dist/index.json", JSON.stringify(items, null, 2));
80-
console.log(`Wrote dist/index.json with ${items.length} items`);
86+
await fs.copyFile( `${BASE_DIR}/app/src/index.html`, `${BASE_DIR}/dist/index.html`);
87+
await fs.writeFile(`${BASE_DIR}/dist/index.json`, JSON.stringify(items, null, 2));
88+
console.log(`Wrote ${BASE_DIR}/dist/index.json with ${items.length} items`);

app/src/serve.mjs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import http from "http";
2+
import path from "node:path";
3+
import { createReadStream, statSync } from "fs";
4+
import { extname, join, dirname } from "path";
5+
import { fileURLToPath } from "url";
6+
7+
8+
const CURRENT_DIR = dirname(fileURLToPath(import.meta.url));
9+
const BASE_DIR = path.resolve( CURRENT_DIR, "../../");
10+
const DIST_PATH = join(BASE_DIR, "dist");
11+
12+
const mimeTypes = {
13+
".html": "text/html",
14+
".js": "application/javascript",
15+
".css": "text/css",
16+
".json": "application/json",
17+
".png": "image/png",
18+
".jpg": "image/jpeg",
19+
".gif": "image/gif",
20+
".svg": "image/svg+xml",
21+
};
22+
23+
const server = http.createServer((req, res) => {
24+
let filePath = req.url === "/" ? "/index.html" : req.url;
25+
filePath = join(DIST_PATH, filePath);
26+
27+
try {
28+
statSync(filePath);
29+
const ext = extname(filePath).toLowerCase();
30+
const contentType = mimeTypes[ext] || "application/octet-stream";
31+
32+
res.writeHead(200, { "Content-Type": contentType });
33+
createReadStream(filePath).pipe(res);
34+
} catch (err) {
35+
res.writeHead(404, { "Content-Type": "text/plain" });
36+
res.end("404 Not Found");
37+
}
38+
});
39+
40+
const PORT = 3000;
41+
server.listen(PORT, () => {
42+
console.log(`Serving /dist at http://localhost:${PORT}`);
43+
});
44+
console.log(`Serving files from ${DIST_PATH}`);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: List AWS Resources from Command Line
3+
description: Useful AWS CLI commands to list resources.
4+
author: rfranr
5+
date: 2025-09-26
6+
tags: [#aws, #cli, #resources]
7+
---
8+
9+
## List enabled scheduled EventBridge rules
10+
11+
```
12+
aws events list-rules \
13+
--query "Rules[?ScheduleExpression!=null && State=='ENABLED'].[Name,ScheduleExpression]" \
14+
--output table
15+
```
16+
17+
This command lists all enabled EventBridge rules with a schedule expression in a table format.

0 commit comments

Comments
 (0)