Modular Headless CMS built with GraphQL, TypeScript and Express.
This repository has been archived on 2026-06-11. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • TypeScript 89.1%
  • JavaScript 10.9%
Find a file
2021-06-15 15:13:54 +02:00
.github chore: update readme 2021-06-15 01:03:19 +02:00
.vscode refactor: switch to yarn2 pnp, overhaul codebase 2021-06-14 19:43:03 +02:00
.yarn chore: cleanup, add release script 2021-06-15 15:11:37 +02:00
packages chore(release): 0.7.0 2021-06-15 15:13:54 +02:00
.editorconfig chore: initial commit 2021-01-19 16:51:21 +01:00
.gitignore refactor: switch to yarn2 pnp, overhaul codebase 2021-06-14 19:43:03 +02:00
.pnp.js chore(deps): install interactive-tools plugin, upgrade dependencies 2021-06-15 14:33:55 +02:00
.prettierrc chore: initial commit 2021-01-19 16:51:21 +01:00
.versionrc chore: fix release script 2021-06-15 15:13:47 +02:00
.yarnrc.yml chore: cleanup, add release script 2021-06-15 15:11:37 +02:00
CHANGELOG.md chore(release): 0.7.0 2021-06-15 15:13:54 +02:00
jest.config.ts chore: add cli unit tests 2021-06-14 23:48:10 +02:00
LICENSE chore: initial commit 2021-01-19 16:51:21 +01:00
package.json chore(release): 0.7.0 2021-06-15 15:13:54 +02:00
README.md chore: add license, prerequisites and yarn2 notice to readme 2021-06-15 13:59:02 +02:00
tsconfig.json chore: add cli unit tests 2021-06-14 23:48:10 +02:00
yarn.lock chore(deps): install interactive-tools plugin, upgrade dependencies 2021-06-15 14:33:55 +02:00

ShatterCMS

ShatterCMS Icon

Test Status Downloads Version Types License

Modular Headless CMS built with GraphQL, TypeScript and Express.

Getting Started

Prerequisites

ShatterCMS Gateway uses a PostgreSQL database under the hood. Follow the guides for your platform to get a database running. If your connection options vary from the default, you can set your own in the config file.

shatter.config.ts

postgres: {
  url?: string,
  database: 'shattercms',
  username: 'postgres',
  password: 'postgres',
  logging: boolean,
  synchronize: boolean,
  migrations?: (string | Function)[],
}

Installation

# npm
$ npm install shattercms

# yarn
$ yarn add shattercms

typeorm does not list the pg package as dependency, causing issues on startup when using yarn 2. Just add the snippet below to your .yarnrc.yml to fix this issue.

.yarnrc.yml

packageExtensions:
  'typeorm@*':
    dependencies:
      pg: '*'

Usage

Configuration

shatter.config.ts

import { UserConfig } from 'shattercms';

const config: UserConfig = {
  modules: [],
};
export default config;

shatter.config.js

/** @type {import('shattercms').UserConfig} */
const config = {
  modules: [],
};
module.exports = config;

shatter.config.json

{
  "modules": []
}

Adding modules

// Without passing options
export default {
  modules: ['@shattercms/shards'],
};

// With passing options
export default {
  modules: [
    ['@shattercms/shards', { foo: 'bar' }],
    // or
    {
      path: '@shattercms/shards',
      options: { foo: 'bar' },
    },
  ],
};

// Local modules
export default {
  modules: ['./local/module'],
};

Start the Server

package.json

"scripts": {
  "start": "shattercms"
}
# use a script
$ npm run start
$ yarn start

# or call directly
$ yarn shattercms

# view the help for all commands and options
$ yarn shattercms --help

Development

Create your own modules

yourModule.ts

import type { Module } from '@shattercms/types';

interface ModuleOptions {
  foo: string;
}

const exampleModule: Module<ModuleOptions> = (context, moduleOptions) => {
  // context.resolvers.push(YourCustomResolver);
  // context.entities.push(YourCustomEntities);
  // ...
  // console.log(moduleOptions)
};
export default exampleModule;

TypeScript modules need to be compiled to JavaScript before they can be used with ShatterCMS.

yourModule.js

module.exports = (context, moduleOptions) => {
  // context.resolvers.push(YourCustomResolver);
  // context.entities.push(YourCustomEntities);
  // ...
  // console.log(moduleOptions)
};

License

This project is licensed under the MIT License.

See LICENSE for more information.