Cloud CMS Application Server
The `cloudcms-server` package provides a robust Node.js application server framework specifically designed to integrate with Cloud CMS deployments. It offers core server-side functionalities, including request routing, error handling, view engine support (e.g., Handlebars), and a flexible storage mechanism. This storage mechanism can utilize local file systems, Amazon S3, or S3FS for managing application content, configuration, and temporary data. The current stable version is 3.2.353, indicating a mature and actively maintained project. It serves as the foundational backbone for the application server tier of Cloud CMS, typically hosted at cloudcms.net, enabling developers to build and deploy applications that deeply leverage Cloud CMS's Web Content Management (WCM) capabilities. Key differentiators include its deep, purpose-built integration with the Cloud CMS platform, highly extensible configuration options for various storage backends, and a pluggable architecture that allows for custom functions at different stages of the request lifecycle.
Common errors
-
Error: Configuration for store 'oneteam' not found
cause The `storeConfigurations` block refers to a `storeEngine` name (e.g., 'oneteam') that is not defined in the `storeEngines` block, or a typo exists.fixEnsure all store names referenced within `storeConfigurations` exactly match a defined `type` within the `storeEngines` object. Double-check for typos. -
Failed to start Cloud CMS Application Server: Error: Missing accessKeyId in config
cause An S3 or S3FS `storeEngine` is enabled and configured, but the required AWS credentials (`accessKey` or `secretKey`) are missing or empty in its configuration.fixProvide valid `accessKey` and `secretKey` within the `config` object for any S3 or S3FS store engines. It is recommended to use environment variables (e.g., `process.env.AWS_ACCESS_KEY_ID`) for these sensitive credentials. -
TypeError: Cannot read properties of undefined (reading 'start')
cause The `cloudcms-server` module was imported incorrectly, resulting in `cloudcmsServer` being `undefined` or not having a `start` method.fixFor CommonJS, use `const cloudcmsServer = require('cloudcms-server');`. For ESM, use `import cloudcmsServer from 'cloudcms-server';`. Avoid named imports for the main server object.
Warnings
- gotcha The configuration object, especially `storeEngines` and `storeConfigurations`, is complex and critical for correct server operation. Misconfigurations in paths, types, or credentials for storage can lead to startup failures or runtime errors.
- gotcha When enabling S3 or S3FS store engines, the underlying AWS SDK (or similar) library is a runtime dependency. While `cloudcms-server` might not explicitly list `aws-sdk` in its `package.json`'s dependencies, you may need to install it manually in your project (`npm install aws-sdk`) to ensure S3 functionality works correctly.
- gotcha Many advanced features like `wcm`, `virtualHost`, `insight`, and `serverTags` are disabled by default in the provided configuration snippet. If you intend to use these features, you must explicitly enable them in your `serverConfig` object.
Install
-
npm install cloudcms-server -
yarn add cloudcms-server -
pnpm add cloudcms-server
Imports
- cloudcmsServer
import { cloudcmsServer } from 'cloudcms-server';import cloudcmsServer from 'cloudcms-server';
- start
import { start } from 'cloudcms-server';const cloudcmsServer = require('cloudcms-server'); cloudcmsServer.start(config); - Server Configuration
const config = require('./config.json');const config = { /* ... */ };
Quickstart
import cloudcmsServer from 'cloudcms-server';
const serverConfig = {
"setup": "single",
"name": "My Cloud CMS Application",
"socketFunctions": [],
"routeFunctions": [
async function(req, res, next) {
if (req.url === '/') {
return res.send('Welcome to your Cloud CMS powered application!');
}
next();
}
],
"errorFunctions": [],
"configureFunctions": {},
"viewEngine": "handlebars",
"wcm": {
"enabled": true, // Enable WCM features
"cache": false
},
"auth": {
"enabled": true,
"providers": {}
},
"port": process.env.PORT ?? 3000,
"host": process.env.HOST ?? '0.0.0.0'
};
async function startServer() {
try {
const server = await cloudcmsServer.start(serverConfig);
console.log(`Cloud CMS Application Server started successfully on port ${server.port}`);
console.log('Access it at http://localhost:' + server.port);
} catch (err) {
console.error('Failed to start Cloud CMS Application Server:', err);
process.exit(1);
}
}
startServer();