Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Latest commit

 

History

History
177 lines (133 loc) · 3.48 KB

README.md

File metadata and controls

177 lines (133 loc) · 3.48 KB

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.