Modular Headless CMS built with GraphQL, TypeScript and Express.
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)[],
}
# npm
$ npm install shattercms
# yarn
$ yarn add shattercms
typeorm
does not list thepg
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: '*'
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": []
}
// 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'],
};
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
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)
};
This project is licensed under the MIT License.
See LICENSE for more information.