Serveronet Client serves static files. You can publish html, js and images as contents of your site.
Client exposes API Backend for every site.
To access Site API documentation browse to this path when on a Site
/sn_client_resources/site_api_docs/
SPA Sites require single_Page_Application in Site Config to be set to true for proper routing.
Index.html will be served for all non-file requests and base path adjusted.
This setting is required for example for Angular and other js frameworks.
Steps to publish a new Site:
[Developed Sites] so the Client can index files and assign a new Site ID[Publish Site] to start publishing processSite Definition consits of following
Site Config is a set of key value pairs. Values can be strings, booleans, arrays. If not defined by the Site Owner they will fallback to the default.
This setting is used when quering peers for database records. When trusted peer responds no quorum will be required. Usually this should list a server which is in control by the Site Owner and has Serveronet Client installed.
Prefered Bittorrent trackers specified by site owner. Clients will use those trackers when announcing or getting peers. If not specified, then algorithm will assign prefered tracker for Site.
Admins/Moderators can edit all records. List their identities in a string. Site Owner is an admin by default so doesn't need to be listed.
For sites like mailbox where data should require logged-in user and would not work without it. Boolean.
Enable SPA behaviour. Index.html is served for all non-file requests and base path is adjusted. Boolean.
Site can allow to upload Visitor's file. Site Owner can set it as false to speed up the replication process. Boolean.
Site optionally can have it's own database. Configure the schema in db_Schema_Versions. Boolean.
DB Schema Versions definition that will result in SQL DDLs. They will bring site database to the most recent version. It will be executed on each client hosting this site. Several systemic fields will be added automatically.
Each version should be indicated by a comparable string value of version_number key. These will work: "0", "v0", "2026-05...".
On upgrade changes to the database will applied on all the peers.
Start with version_number "0", tableCreates and indexCreates. See Tech Demo site and example Site Config on how to manage database versions. With next version you can add columnAlters.
You can define following database schema manipulations:
Following data types are now supported:
They can be nullable or not.
You can define default values.
Site optionally can show Adults Only gate. Age Check compliant. Boolean.
Some sites can provide list of Banned Sites or domains. Such lists can be enabled. See Tech Demo site for an example.
Inject javascript script which adds helper button with usefull links and information. Boolean.
Site API backend reserves certain paths. They are used for Client static paths or API endpoints.
Do not create site folders starting with those paths: sn_client_resources, site_api, visitor_file
When creating schema defintion for a Site do not use follwing column names ane relevant indexes. They will be overwritten.
Site Owner can make Site discoverable by a classic DNS domain name.
Serveronet Client will query DNS TXT field to find a proper Site ID.
Site Owner has to add a DNS TXT entry - snetdnslink
Steps assuming your domain is example.com
snetdnslink.example.com by adding A record snetdnslink pointing to any ip (can be 127.0.0.1)TXT record with snetdnslink as host (snetdnslink.example.com) with value snetdnslink with site ID, for example: snetdnslink=gjdg45...You can check if configuration is correct with dig (Linux)
dig snetdnslink.example.com -t TXT
;; ANSWER SECTION:
snetdnslink.example.com. 3600 IN TXT "snetdnslink=gjdg45..."
OpenNIC servers (OpenNIC ▶) are used to get DNS records pointing to the site address.
When developing a compiled SPA site you might need access Site API Backend from the app.
Edit .env file and set or add those values as below
Change requires config clear: php artisan config:clear
There may be a need to frequently send new records or updates to your Site. You can post your updates in an automated way using token and Site API.
Steps:
Go to the Visitor's Control Panel.
Click on [Enable API Token] to generate a new API Token
With API Token you can make requests as the Visitor
Allow remote access to SN backend, as in section - Allow remote access to SN backend
Make a POST request as in this example
curl 'http://site-id.snet.localhost:15080/site_api/v1/api_upsert_endpoint' \
-X POST -H 'Content-Type: application/json' \
--data-raw '{"api_token":"your_visitor_api_token","_sn_record_json":"{\"title\":\"My title\", \"_sn_table\":\"posts\"}"}'
Please note that HTTPS or running client locally is highly recommeded in such a case.
Generation steps:
using Private KeyLorem ipsum, dolor sit amet consectetur adipisicing elit.