Modular Headless CMS built with GraphQL, TypeScript and Express.
- TypeScript 89.1%
- JavaScript 10.9%
| .github | ||
| .vscode | ||
| .yarn | ||
| packages | ||
| .editorconfig | ||
| .gitignore | ||
| .pnp.js | ||
| .prettierrc | ||
| .versionrc | ||
| .yarnrc.yml | ||
| CHANGELOG.md | ||
| jest.config.ts | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| yarn.lock | ||
ShatterCMS
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
typeormdoes not list thepgpackage as dependency, causing issues on startup when using yarn 2. Just add the snippet below to your.yarnrc.ymlto 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.