fixed SSE Connection error and Rust error when compiling (last brace in /src/markdown.rs)
Some checks failed
Deploy / build-and-deploy (push) Failing after 2s
Some checks failed
Deploy / build-and-deploy (push) Failing after 2s
also updated the markdown post that you see upon entering.
This commit is contained in:
@@ -673,8 +673,4 @@ pub fn checkhealth() -> HealthReport {
|
|||||||
cache_stats_count,
|
cache_stats_count,
|
||||||
errors,
|
errors,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
cache_stats_count,
|
|
||||||
errors,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -434,7 +434,6 @@ Key API endpoints include:
|
|||||||
All API routes are implemented using Next.js API routes and are available out of the box. For more details, check the code in the `src/app/api/posts/` directory.
|
All API routes are implemented using Next.js API routes and are available out of the box. For more details, check the code in the `src/app/api/posts/` directory.
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
|
|
||||||
## Train of Thought for this Project and Todo
|
## Train of Thought for this Project and Todo
|
||||||
|
|
||||||
@@ -446,29 +445,24 @@ If you have seen this is not very mindfull of browser resources tho.
|
|||||||
|-------|----|
|
|-------|----|
|
||||||
|<span style="color:green;">Done</span>|**Rust Parser for Markdown**|
|
|<span style="color:green;">Done</span>|**Rust Parser for Markdown**|
|
||||||
|<span style="color:lightblue;">LTS</span>|_Long Term Support and upkeep_|
|
|<span style="color:lightblue;">LTS</span>|_Long Term Support and upkeep_|
|
||||||
|<span style="color:red;">Not Done</span>|Full Inline _CSS_ Support for **HTML**|
|
|<span style="color:lime;">Partially Done</span>|**Caching with Rust**|
|
||||||
|
|<span style="color:green;">Done</span>|Full Inline _CSS_ Support for **HTML**|
|
||||||
---
|
---
|
||||||
|
|
||||||
## <font color="red">R</font><font color="orange">e</font><font color="yellow">c</font><font color="green">e</font><font color="blue">n</font><font color="purple">t</font> <font color="red">C</font><font color="orange">h</font><font color="yellow">a</font><font color="green">n</font><font color="blue">g</font><font color="purple">e</font><font color="red">s</font>
|
## Recent Changes
|
||||||
|
|
||||||
<img src="https://upload.wikimedia.org/wikipedia/commons/0/0f/Original_Ferris.svg" style="height:50px;width:90px;display:block;margin:0 auto;" alt="cute lil guy">
|
<img src="https://upload.wikimedia.org/wikipedia/commons/0/0f/Original_Ferris.svg" style="height:50px;width:90px;display:block;margin:0 auto;" alt="cute lil guy">
|
||||||
|
<p style="display:block;margin:0 auto;text-align:center;font-style:italic;font-weight:bold;">Ferris the Cutie</p>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
If you have noticed the Project has switched to a more reliable and _faster_ **Rust** Markdown-Parser!
|
### Caching:
|
||||||
If you are wondering:
|
Recently the _Rust Parser recived a update_ which introduced **Caching using RAM**. This is not yet _fully implemented_, but it is in the works.
|
||||||
|
|
||||||
#### <u>Why?</u>
|
### Recursive Folder-Scanning via Rust:
|
||||||
|
The Rust Parser was **not implemented fully** _(28.JUN.2025)_. **BUT**, I can proudly state that since _29.JUN.25_ **The Rust Parser is parsing** with ease and with _BLAZING SPEEDS_
|
||||||
- To make **loading times** / _compile times_ (For the **HTML of the Pages** || _slugification_) of posts quicker.
|
|
||||||
|
|
||||||
#### <u>What changed?</u>
|
|
||||||
|
|
||||||
- The **RustMarkdownParser** (_RMP_) only really changed the **Architecture** of the _Parsing for Markdown Files_. If you are wondering how _fast_ the Parser is then have a look at the **Admin-Panel**, which also _changed quite a lot_.
|
|
||||||
|
|
||||||
#### <u>Do I need to do anything?</u>
|
|
||||||
|
|
||||||
- If you havent already, then **Update** the Blog! Blogging stays the same. No difference. Just _🗲 faster 🗲_.
|
|
||||||
|
|
||||||
|
### Fixed SSE CORS Connection:
|
||||||
|
Since Ages the **SSE Streaming _was_ broken**, now its fixed (see _@src/app/api/posts/stream/route.ts_). This works fine, needs some work still.
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
|||||||
@@ -8,29 +8,65 @@ export const runtime = 'nodejs';
|
|||||||
// Store connected clients
|
// Store connected clients
|
||||||
const clients = new Set<ReadableStreamDefaultController>();
|
const clients = new Set<ReadableStreamDefaultController>();
|
||||||
|
|
||||||
|
// Handle CORS preflight requests
|
||||||
|
export async function OPTIONS(request: NextRequest) {
|
||||||
|
return new NextResponse(null, {
|
||||||
|
status: 200,
|
||||||
|
headers: {
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
'Access-Control-Allow-Methods': 'GET, OPTIONS',
|
||||||
|
'Access-Control-Allow-Headers': 'Cache-Control, Content-Type',
|
||||||
|
'Access-Control-Max-Age': '86400',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export async function GET(request: NextRequest) {
|
export async function GET(request: NextRequest) {
|
||||||
|
try {
|
||||||
const stream = new ReadableStream({
|
const stream = new ReadableStream({
|
||||||
start(controller) {
|
start(controller) {
|
||||||
// Add this client to the set
|
// Add this client to the set
|
||||||
clients.add(controller);
|
clients.add(controller);
|
||||||
|
|
||||||
// Send initial connection message
|
// Send initial connection message
|
||||||
|
try {
|
||||||
controller.enqueue(`data: ${JSON.stringify({ type: 'connected', message: 'SSE connection established' })}\n\n`);
|
controller.enqueue(`data: ${JSON.stringify({ type: 'connected', message: 'SSE connection established' })}\n\n`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error sending initial message:', error);
|
||||||
|
clients.delete(controller);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Set up file watcher if not already set up
|
// Set up file watcher if not already set up
|
||||||
if (clients.size === 1) {
|
if (clients.size === 1) {
|
||||||
|
try {
|
||||||
watchPosts(() => {
|
watchPosts(() => {
|
||||||
// Notify all connected clients about the update
|
// Notify all connected clients about the update
|
||||||
const message = JSON.stringify({ type: 'update', timestamp: new Date().toISOString() });
|
const message = JSON.stringify({ type: 'update', timestamp: new Date().toISOString() });
|
||||||
|
const clientsToRemove: ReadableStreamDefaultController[] = [];
|
||||||
|
|
||||||
clients.forEach(client => {
|
clients.forEach(client => {
|
||||||
try {
|
try {
|
||||||
client.enqueue(`data: ${message}\n\n`);
|
client.enqueue(`data: ${message}\n\n`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Remove disconnected clients
|
// Mark client for removal
|
||||||
clients.delete(client);
|
clientsToRemove.push(client);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Remove disconnected clients
|
||||||
|
clientsToRemove.forEach(client => {
|
||||||
|
clients.delete(client);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Stop watching if no clients are connected
|
||||||
|
if (clients.size === 0) {
|
||||||
|
stopWatching();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error setting up file watcher:', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up when client disconnects
|
// Clean up when client disconnects
|
||||||
@@ -42,16 +78,37 @@ export async function GET(request: NextRequest) {
|
|||||||
stopWatching();
|
stopWatching();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
cancel() {
|
||||||
|
// Handle stream cancellation - we can't access the specific controller here
|
||||||
|
// The abort event handler will handle cleanup for the specific controller
|
||||||
|
if (clients.size === 0) {
|
||||||
|
stopWatching();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return new NextResponse(stream, {
|
return new NextResponse(stream, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'text/event-stream',
|
'Content-Type': 'text/event-stream',
|
||||||
'Cache-Control': 'no-cache',
|
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
||||||
'Connection': 'keep-alive',
|
'Connection': 'keep-alive',
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
'Access-Control-Allow-Headers': 'Cache-Control'
|
'Access-Control-Allow-Headers': 'Cache-Control, Content-Type',
|
||||||
}
|
'X-Accel-Buffering': 'no', // Disable nginx buffering
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('SSE route error:', error);
|
||||||
|
return new NextResponse(
|
||||||
|
JSON.stringify({ error: 'Internal server error' }),
|
||||||
|
{
|
||||||
|
status: 500,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user