A production Lowdefy server that runs using Node.js is published on npm as @lowdefy/server-node.
Running the server
Step 1 - Create a package.json file
To run the server in a Lowdefy project, first initialise a Node.js project by creating a package.json file in the root of your project. To do this, you can run
npm initStep 2 - Add the @lowdefy/server-node package to your project as a dependency
To add the server as a dependency, run
npm install @lowdefy/server-node --save --save-exactStep 3 - Add the Lowdefy CLI to you project as a dev dependency.
To add the server as a dependency, run:
npm install lowdefy --save-dev --save-exactStep 4 - Add the build and start scripts.
Add the following to the scripts section in your package.json file:
"scripts": {
"init": "lowdefy init",
"build": "lowdefy build",
"start": "lowdefy-server"
},Step 5 - Init a Lowdefy project
Run:
npm run initStep 6 - Add the public files:
Create a folder called public in your project directory and add the Lowdefy public files found here (or add your own logos and files).
Step 7 - Build the Lowdefy project
Build the Lowdefy configuration files in the project by running:
npm run buildStep 8 - Start the server
To start the server, run:
npm run startConfiguration
The Lowdefy server can be configured using command-line arguments or environment variables. The command-line arguments take precedence over the environment variables.
The following command-line arguments can be specified:
--build-directory: The directory of the built Lowdefy configuration (The output oflowdefy build, usually found at./.lowdefy/buildin your project repository). The default is./.lowdefy/build.--port: The port at which to run the server. The default is3000.--public-directory: The directory of the public assets to be served. The default is./public.
The following environment variables can be specified:
LOWDEFY_SERVER_BASE_PATH: Set the base path to serve the Lowdefy application from. This will serve the application underhttps://example.com/<base-path>instead ofhttps://example.com, and all pages underhttps://example.com/<base-path>/<page-id>instead of the defaulthttps://example.com/<page-id>.LOWDEFY_SERVER_BUILD_DIRECTORY: The directory of the built Lowdefy configuration (The output oflowdefy build, usually found at./.lowdefy/buildin your project repository). The default is./.lowdefy/build.LOWDEFY_SERVER_PORT: The port at which to run the server. The default is3000.LOWDEFY_SERVER_PUBLIC_DIRECTORY: The directory of the public assets to be served. The default is./public.
