Form.io App Server
The Form.io App Server is a performant run-time application server used to serve single project templates (including forms, resources, roles, etc) at a single deployed endpoint.
It's goals are as follows:
- Provide a single project runtime server where non-submission resources are cached in memory.
- Enable multi-tenant / multi-database deployments.
- Provide extensible server-side functionality, like custom actions.
- Support other databases besides MongoDB compliant databases for submission data.
Installation
To use this library, you must mount it within an Express.js application. As an example, you can create a simple Express.js application with this library by first creating a new Express.js application and then install and use the Server as follows.
npm install --save @formio/appserver
Then within your server.js file, you would add the following.
const express = require('express');
const app = express();
const { Server } = require('@formio/appserver');
(async function bootup() {
// Create the server.
const server = new Server();
// Add the server router.
app.use(await server.router());
// Start server.
app.listen(process.env.PORT, () => {
console.log(`Server running on port ${process.env.PORT}`);
});
})();
License
The Form.io App Server does require a license to run. If you are interested in trying out this technology, please contact us @ https://form.io/contact-us
Running Locally
To run this library locally, you can clone the repository, and then npm install.
yarn install
Then do the following.
cp .env.example .env
Now, within the .env file, modify all of the environment variables to be the correct values. Next, you can run the server using the following.
node index
Environment Variables
This library uses environment variables to configure the configurations required to run the server. These are as follows.
| Variable Name | Required | Description | Example |
|---|---|---|---|
| MONGO | yes | Your MongoDB Connection string to use the default DB. | mongodb://localhost:27017/appserver |
| PROJECT | yes | The endpoint for your deployed Form.io Enterprise project. | https://mydeployment.com/myproject |
| PROJECT_KEY | yes | The API Key for your deployed Form.io Enterprise Project. | abc123 |
| APPSERVER_LICENSE | yes | Your License Key for this App Server deployment. | |
| PORT | no | The port that your server will run on. Default 3005 | 3005 |
| JWT_SECRET | yes | The key used to protect your JWT authentication tokens. | YOUR_SECRET_KEY |
| JWT_EXPIRE_TIME | no | The number of minutes the server's own tokens last. | 60 |
| PORTAL_SECRET | no | Provides the ability to connect to the App Server via the Remote Environment Connection within your Developer Portal. | YOUR_SECRET_KEY |
| PROJECT_CACHE | no | Disables the cache for project resources (such as Project template, Project Settings, and Access Settings). Default "true" | true |
| PROJECT_TTL | no | How often, in seconds, the project's forms, resources and actions are loaded again, which is how changes made in the portal or deployed to the project reach the App Server. 0 disables refreshing. Default 900 | 900 |
| TEMPLATE_SYNC | no | When the forms, resources and actions in a module's template that the project is missing are installed into it: boot once at startup, refresh also on every PROJECT_TTL refresh, or off never. Nothing the project already has is changed. The project remains the source of truth, so use off when forms are managed through stage deployments. Default "boot" | boot |
| MONGO_CONFIG | no | Additional configurations to add to the DB connection string | {} |
Enjoy
- The Form.io Team