docs: refresh readme and legal info

This commit is contained in:
2026-05-07 20:22:12 +00:00
parent 86dafd6c5b
commit af1d20dbbc
3 changed files with 157 additions and 156 deletions
+3 -1
View File
@@ -1,4 +1,6 @@
Copyright (c) 2016 Task Venture Capital GmbH (hello@task.vc)
MIT License
Copyright (c) 2026 Task Venture Capital GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+2 -2
View File
@@ -4,8 +4,8 @@
"description": "A rendering service designed for serve.zone that efficiently preserves styles while rendering web components.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH",
"license": "UNLICENSED",
"author": "Task Venture Capital GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"start": "(node --max_old_space_size=200 ./cli.js)",
+151 -152
View File
@@ -1,176 +1,175 @@
# Corerender
A rendering service for serve.zone that preserves styles for web components.
# corerender
`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.
## Issue Reporting and Security
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.
## What It Does
`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.
Runtime flow:
```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
```
## Highlights
- 🧩 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
## Install
To install Corerender in your project, you can use npm. Make sure you have Node.js installed and then run the following command in your terminal:
In this workspace, install dependencies with pnpm and run the package scripts from the repo root.
```shell
npm install corerender
```bash
pnpm install
```
This will add `corerender` as a dependency to your project, allowing you to use its rendering services to preserve styles for web components efficiently.
For internal registry consumption:
## Usage
```bash
pnpm add corerender
```
Welcome to the comprehensive usage guide for `corerender`, a powerful rendering service designed to integrate seamlessly within your web applications, ensuring that styles for web components are preserved properly. The guide is structured to provide a thorough understanding of `corerender`'s capabilities, demonstrating its flexibility and efficiency through realistic scenarios.
### Setting Up Your Environment
First things first, lets get `corerender` up and running in your project. Ensure you've installed the package as detailed in the [Install](#install) section. Since `corerender` is a TypeScript-friendly library, it is recommended to use TypeScript for development to leverage the full power of type safety and IntelliSense.
### Basic Render Service Setup
## Quick Start
```typescript
import { Rendertron } from 'corerender';
const rendertronInstance = new Rendertron();
const rendertron = new Rendertron();
(async () => {
console.log('Starting rendertron...');
await rendertronInstance.start();
console.log('Rendertron started successfully!');
})();
await rendertron.start();
```
The code initializes an instance of `Rendertron` and starts the service asynchronously. `Rendertron` is the core class responsible for managing the rendering processes, including task scheduling and storing rendering results persistently in a database.
### Understanding the Rendertron Architecture
The architecture of `Rendertron` is designed to support web component rendering through several integral components:
1. **Prerender Manager**: Manages the creation and retrieval of prerender results.
2. **Task Manager**: Handles scheduling tasks for prerendering operations and cleanup routines.
3. **Utility Service Server**: Provides the server interface that accepts/render requests and serves prerendered content efficiently.
### Using the Prerender Manager
The `PrerenderManager` is responsible for generating and caching the rendering results of webpages. Heres how you can use the `PrerenderManager` to prerender a webpage:
```typescript
import { PrerenderManager } from 'corerender/dist_ts/rendertron.classes.prerendermanager';
(async () => {
const prerenderManager = new PrerenderManager();
await prerenderManager.start();
const urlToPrerender = 'https://example.com';
const prerenderResult = await prerenderManager.getPrerenderResultForUrl(urlToPrerender);
console.log(`Prerendered content for ${urlToPrerender}:`);
console.log(prerenderResult);
await prerenderManager.stop();
})();
```
The above script demonstrates accessing a webpage's prerendered content. It initializes the `PrerenderManager`, specifies a URL, and requests the rendering result, which is stored or retrieved from the database.
### Scheduling Prerendering Tasks
The `TaskManager` class allows for efficiently scheduling tasks, such as regular prerendering of local domains and cleanup of outdated render results:
```typescript
import { TaskManager } from 'corerender/dist_ts/rendertron.taskmanager';
const taskManager = new TaskManager(rendertronInstance);
taskManager.start();
// Example: Manual trigger of a specific task
taskManager.triggerTaskByName('prerenderLocalDomains');
taskManager.stop();
```
`TaskManager` works closely with the `Rendertron` service to ensure tasks are executed as per defined schedules (e.g., every 30 minutes or daily). It allows manual triggering for immediate execution outside the schedule.
### Managing Render Results
The pre-rendered results are stored using `smartdata`s `SmartDataDbDoc`. You may need advanced control over whether these are retrieved, created anew, or updated:
```typescript
import { PrerenderResult } from 'corerender/dist_ts/rendertron.classes.prerenderresult';
(async () => {
const url = 'https://example.com';
let prerenderResult = await PrerenderResult.getPrerenderResultForUrl(prerenderManager, url);
// Check if an updated result is necessary
if (prerenderResultNeedsUpdate(prerenderResult)) {
prerenderResult = await PrerenderResult.createPrerenderResultForUrl(prerenderManager, url);
}
console.log(`Final Prerendered content for ${url}:`, prerenderResult.renderResultString);
})();
```
### Integrating with External Systems
`Corerender` can be integrated into broader systems that programmatically manage URLs and rendering frequencies. For instance, parsing and prerendering sitemaps:
```typescript
class IntegrationExample {
private prerenderManager: PrerenderManager;
constructor() {
this.prerenderManager = new PrerenderManager();
}
async prerenderFromSitemap(sitemapUrl: string) {
await this.prerenderManager.prerenderSitemap(sitemapUrl);
console.log('Finished prerendering sitemap:', sitemapUrl);
}
}
(async () => {
const integrationExample = new IntegrationExample();
await integrationExample.prerenderFromSitemap('https://example.com/sitemap.xml');
})();
```
### Server-Side Rendering Directly with SmartSSR
`Rendertron` uses the highly efficient `smartssr` for SSR requests. You can easily direct incoming server requests to utilize this rendering pipeline:
```typescript
import { typedserver } from 'corerender/dist_ts/rendertron.plugins';
const serviceServerInstance = new typedserver.utilityservers.UtilityServiceServer({
serviceDomain: 'rendertron.example.com',
serviceName: 'RendertronService',
serviceVersion: '2.0.61', // Replace with dynamic version retrieval if needed
addCustomRoutes: async (serverArg) => {
serverArg.addRoute(
'/render/*',
new typedserver.servertools.Handler('GET', async (req, res) => {
const requestedUrl = req.url.replace('/render/', '');
const prerenderedContent = await prerenderManager.getPrerenderResultForUrl(requestedUrl);
res.write(prerenderedContent);
res.end();
})
);
},
process.once('SIGTERM', async () => {
await rendertron.stop();
process.exit(0);
});
(async () => {
await serviceServerInstance.start();
console.log('SSR Server Started');
})();
```
### Customizing the Logger
`Rendertron` employs the `smartlog` package for logging activities across the service. To customize logging, instantiate a logger with custom configurations:
The package-level CLI runner does the same bootstrapping:
```typescript
import { smartlog } from 'corerender/dist_ts/rendertron.plugins';
import { runCli, stop } from 'corerender';
const customLogger = smartlog.Smartlog.create({ /* custom options */ });
customLogger.log('info', 'Custom logger integrated successfully.');
await runCli();
await stop();
```
### Closing Remarks
## Service Route
With these examples, you should have a robust understanding of how to implement `corerender` in your web application. Its a powerful service that takes care of rendering optimizations, allowing developers to focus on building components and architecture, with clear workflows to handle tasks and results efficiently.
The service registers one custom route on its `UtilityServiceServer`:
undefined
```text
GET /render/*
```
The remainder of the path is interpreted as the origin URL. Query strings are preserved.
Examples:
```text
/render/https://example.com/
/render/https://example.com/products?id=123
```
Behavior:
- 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
## Cache and Prerendering
`PrerenderManager` coordinates SmartSSR, Smartrobots, and SmartSitemap.
The current cache behavior in `PrerenderResult` is:
- render results younger than 12 hours are reused
- older render results are marked for rerendering
- cleanup deletes results older than 24 hours
Sitemap helpers are available through the service instance after startup:
```typescript
await rendertron.prerenderManager.prerenderDomain('example.com');
await rendertron.prerenderManager.prerenderSitemap('https://example.com/sitemap.xml');
```
The scheduled `prerenderLocalDomains` task currently has the domain source stubbed out in this repo. The cleanup task is scheduled daily.
## Operational Notes
| 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. |
## API Surface
| Export | Purpose |
| --- | --- |
| `Rendertron` | Main service class with `start()` and `stop()`. |
| `runCli()` | Starts a singleton `Rendertron` instance. |
| `stop()` | Stops the singleton instance started by `runCli()`. |
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
```
Useful source entry points:
- `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.
## License and Legal Information
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [license](./license) file.
**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.
### Trademarks
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.
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
Task Venture Capital GmbH
Registered at District Court Bremen HRB 35230 HB, Germany
For any legal inquiries or further information, please contact us via email at hello@task.vc.
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.