@imrishmika/cmsx
v1.0.0
Published
Official TypeScript Node module for CMSx Headless CMS Platform (cmsx.imrishmika.dev)
Maintainers
Readme
cmsx
Official TypeScript Node.js module for CMSx Headless CMS Platform (cmsx.imrishmika.dev).
Connect any website, Next.js application, React app, or Node.js server to your CMSx project using environment API keys.
📦 Installation
npm install cmsx
# or
yarn add cmsx
# or
pnpm add cmsx🚀 Quickstart in Node.js / Next.js
1. Set your Environment Variable
Add your CMSx Project API key to your .env.local or environment variables:
CMSX_API_KEY=CMS_acme_prod_8f9a2b2. Initialize in Node.js (CommonJS or ES Modules)
ES Modules / TypeScript:
import { createCMSxClient } from 'cmsx';
const cmsx = createCMSxClient({
apiKey: process.env.CMSX_API_KEY!,
endpoint: 'https://cmsx.imrishmika.dev/api/v1' // optional
});CommonJS (Node.js require):
const { createCMSxClient } = require('cmsx');
const cmsx = createCMSxClient({
apiKey: process.env.CMSX_API_KEY
});3. Verify Connection Status
const connection = await cmsx.verifyKey();
if (connection.valid) {
console.log('✅ Connected to CMSx Project:', connection.project.name);
console.log('Available Collections:', connection.project.collections);
} else {
console.error('❌ Connection Failed:', connection.error);
}4. Fetch Collection Content
// Fetch published blog posts
const posts = await cmsx.getCollection('blog_posts', {
status: 'published',
limit: 10,
});
posts.forEach((entry) => {
console.log(entry.data.title, entry.data.summary);
});📖 API Reference
createCMSxClient(config)
Returns a new CMSxClient instance.
Options:
apiKey(string, required): Public Read-Only key (CMS_...) or Admin Secret key (CMS_SECRET_...).endpoint(string, optional): Custom endpoint URL (defaults tohttps://cmsx.imrishmika.dev/api/v1).
Methods
| Method | Description |
| :--- | :--- |
| cmsx.verifyKey() | Validates API key and returns project metadata. |
| cmsx.getCollection(slug, options?) | Fetches entries from a collection. |
| cmsx.getEntryBySlug(collection, slug) | Fetches a single entry by URL slug. |
| cmsx.getEntryById(id) | Fetches entry by unique ID. |
| cmsx.createEntry(collection, data, status?) | Creates a new entry (requires secret key). |
| cmsx.updateEntry(id, data, status?) | Updates existing entry. |
| cmsx.deleteEntry(id) | Deletes entry. |
| cmsx.getMediaAssets() | Lists uploaded media CDN assets. |
📄 License
MIT © imrishmika
