Files
corerender/readme.md
T

176 lines
6.5 KiB
Markdown
Raw Normal View History

2026-05-07 20:22:12 +00:00
# corerender
2026-05-07 20:22:12 +00:00
`corerender` is a serve.zone prerendering service that fetches requested URLs, passes HTML pages through `@push.rocks/smartssr`, caches rendered output in Smartdata, and serves non-HTML assets through unchanged.
2026-05-07 20:22:12 +00:00
## Issue Reporting and Security
2026-05-07 20:22:12 +00:00
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
2026-05-07 20:22:12 +00:00
## What It Does
2025-01-01 07:33:33 +01:00
2026-05-07 20:22:12 +00:00
`corerender` is a small service wrapper around a prerender pipeline. It is useful when crawlers, link previews, or static cache warmers need HTML after web components have rendered, while regular assets should be streamed from origin without SSR overhead.
2025-01-01 07:33:33 +01:00
2026-05-07 20:22:12 +00:00
Runtime flow:
2026-05-07 20:22:12 +00:00
```text
GET /render/https://example.com/page?x=1
-> fetch origin URL
-> if content-type is HTML, render through SmartSSR
-> cache PrerenderResult in Smartdata
-> return rendered HTML with origin status and headers
```
2026-05-07 20:22:12 +00:00
## Highlights
2026-05-07 20:22:12 +00:00
- 🧩 SmartSSR-based rendering for web-component applications
- 🗃️ Smartdata-backed `PrerenderResult` cache
- 🕒 cached render reuse for fresh results and automatic stale-result refresh
- 🗺️ sitemap and robots.txt aware prerender helpers
- 🧹 scheduled cleanup for old prerender results
- 🖥️ UtilityServiceServer with a `/render/*` route
- 🧰 exported `Rendertron`, `runCli()`, and `stop()` entry points
2026-05-07 20:22:12 +00:00
## Install
2026-05-07 20:22:12 +00:00
In this workspace, install dependencies with pnpm and run the package scripts from the repo root.
```bash
pnpm install
```
2026-05-07 20:22:12 +00:00
For internal registry consumption:
2026-05-07 20:22:12 +00:00
```bash
pnpm add corerender
```
2026-05-07 20:22:12 +00:00
## Quick Start
2026-05-07 20:22:12 +00:00
```typescript
import { Rendertron } from 'corerender';
2026-05-07 20:22:12 +00:00
const rendertron = new Rendertron();
2026-05-07 20:22:12 +00:00
await rendertron.start();
2026-05-07 20:22:12 +00:00
process.once('SIGTERM', async () => {
await rendertron.stop();
process.exit(0);
});
```
2026-05-07 20:22:12 +00:00
The package-level CLI runner does the same bootstrapping:
```typescript
2026-05-07 20:22:12 +00:00
import { runCli, stop } from 'corerender';
2026-05-07 20:22:12 +00:00
await runCli();
await stop();
```
## Service Route
2026-05-07 20:22:12 +00:00
The service registers one custom route on its `UtilityServiceServer`:
2026-05-07 20:22:12 +00:00
```text
GET /render/*
```
2026-05-07 20:22:12 +00:00
The remainder of the path is interpreted as the origin URL. Query strings are preserved.
2026-05-07 20:22:12 +00:00
Examples:
2026-05-07 20:22:12 +00:00
```text
/render/https://example.com/
/render/https://example.com/products?id=123
```
2026-05-07 20:22:12 +00:00
Behavior:
2026-05-07 20:22:12 +00:00
- origin fetch errors return `502`
- malformed relative protocol artifacts such as `https://url(...)` return `500`
- HTML origin responses are rendered with SmartSSR and cached
- non-HTML origin responses are returned directly as binary data
2026-05-07 20:22:12 +00:00
## Cache and Prerendering
2026-05-07 20:22:12 +00:00
`PrerenderManager` coordinates SmartSSR, Smartrobots, and SmartSitemap.
2026-05-07 20:22:12 +00:00
The current cache behavior in `PrerenderResult` is:
2026-05-07 20:22:12 +00:00
- render results younger than 12 hours are reused
- older render results are marked for rerendering
- cleanup deletes results older than 24 hours
2026-05-07 20:22:12 +00:00
Sitemap helpers are available through the service instance after startup:
```typescript
2026-05-07 20:22:12 +00:00
await rendertron.prerenderManager.prerenderDomain('example.com');
await rendertron.prerenderManager.prerenderSitemap('https://example.com/sitemap.xml');
```
2026-05-07 20:22:12 +00:00
The scheduled `prerenderLocalDomains` task currently has the domain source stubbed out in this repo. The cleanup task is scheduled daily.
2026-05-07 20:22:12 +00:00
## Operational Notes
2026-05-07 20:22:12 +00:00
| Concern | Current implementation |
| --- | --- |
| Persistence | `rendertron.db.ts` initializes a Smartdata MongoDB connection for `PrerenderResult` documents. |
| HTTP server | `Rendertron.start()` creates a `UtilityServiceServer` named `rendertron`. |
| Rendering | `PrerenderManager` creates `SmartSSR`, `Smartrobots`, and `SmartSitemap` instances. |
| Task scheduling | `TaskManager` starts scheduled prerender and cleanup tasks through `@push.rocks/taskbuffer`. |
| Shutdown | `Rendertron.stop()` stops the server, prerender manager, task manager, and database connection. |
2026-05-07 20:22:12 +00:00
## API Surface
2026-05-07 20:22:12 +00:00
| Export | Purpose |
| --- | --- |
| `Rendertron` | Main service class with `start()` and `stop()`. |
| `runCli()` | Starts a singleton `Rendertron` instance. |
| `stop()` | Stops the singleton instance started by `runCli()`. |
2026-05-07 20:22:12 +00:00
Important public instance properties after startup:
| Property | Purpose |
| --- | --- |
| `serviceServerInstance` | Underlying UtilityServiceServer. |
| `prerenderManager` | Rendering, robots.txt, sitemap, and cache helper manager. |
| `taskManager` | Scheduled prerender/cleanup task manager. |
## Development
```bash
pnpm run build
pnpm test
pnpm start
```
2026-05-07 20:22:12 +00:00
Useful source entry points:
2026-05-07 20:22:12 +00:00
- `ts/index.ts` exports `Rendertron`, `runCli()`, and `stop()`.
- `ts/rendertron.classes.rendertron.ts` owns service startup and `/render/*` routing.
- `ts/rendertron.classes.prerendermanager.ts` owns SmartSSR, robots.txt, and sitemap rendering helpers.
- `ts/rendertron.classes.prerenderresult.ts` owns cached render document behavior.
- `ts/rendertron.taskmanager.ts` owns scheduled prerender and cleanup tasks.
2026-05-07 20:22:12 +00:00
## License and Legal Information
2026-05-07 20:22:12 +00:00
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [license](./license) file.
2026-05-07 20:22:12 +00:00
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
2026-05-07 20:22:12 +00:00
### Trademarks
2026-05-07 20:22:12 +00:00
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
2026-05-07 20:22:12 +00:00
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
### Company Information
2026-05-07 20:22:12 +00:00
Task Venture Capital GmbH
Registered at District Court Bremen HRB 35230 HB, Germany
2026-05-07 20:22:12 +00:00
For any legal inquiries or further information, please contact us via email at hello@task.vc.
2025-01-01 07:33:33 +01:00
2026-05-07 20:22:12 +00:00
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.