cmeasy
v0.7.0
Published
Content API Library
Downloads
20
Readme
cmeasy beta
Content API Library
Getting Started
Define your content
require('cmeasy')({
models: [
{
name: 'Home Page',
singleton: true,
definition: {
title: {
type: 'String',
label: 'Home Page Title',
default: 'Default Home Page Title'
}
}
}
]
});
Access your content
require('http').get({
host: '127.0.0.1',
path: '/api/v1/content/homePage'
});
Or
require('cmeasy')({ /* ... */ })
.then(function(cmeasy){
cmeasy.getModel('homePage').index();
});
Or
<script src="api/v1/content.js"></script>
<script>
console.log(window._cmeasy_content);
</script>
Installation
npm install cmeasy --save
Demo
See an example running on Heroku https://cmeasy.herokuapp.com/
Or
Deploy your own demo to Heroku
Or
See an example React app using the content on jsfiddle.net
See server/options.js for the complete demo configuration
Options
Connect your Express App
var express = require('express');
var app = express();
require('cmeasy')({
// ...
express: app
// ...
});
var server = require('http').createServer(app);
server.listen(9000, '127.0.0.1');
Connect your Database
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/cmeasy');
require('cmeasy')({
// ...
mongoose: mongoose
// ...
});
Config documentation
// null values indicate that the given property is optional
// By default no models are defined. The following is an example
const models = [
{
name: string,
// If true, more than one instance of this model may exist. If false, only one instance
// can be created
singleton: null | boolean,
disableDelete: null | boolean,
disableCreate: null | boolean,
definition: {
title: {
type: 'String',
label: null | string,
displayColumn: null | boolean,
},
category: {
type: 'Select',
label: null | string,
enum: string[]
},
},
initialData: {
clean: boolean, // Clear all existing models at startup
data: [
{
title: 'A title',
category: 'Category'
}
]
}
}
];
// The following shows the default value for options.initalUsers
const initialUsers = {
// If true, cmeasy will remove all users at startup
clean: boolean,
data: [
{
name: 'Test User',
email: '[email protected]',
password: 'test'
},
{
name: 'Admin',
role: 'admin',
email: '[email protected]',
password: 'admin'
}
]
};
// Every parameter is optional
const options = {
name: null | string,
mongoose: null | mongoose.Connection,
express: null | express.Application,
rootRoute: null | string,
models: models,
initialUsers: null | initalUsers
}
const cmeasy = require('cmeasy')(options);
API documentation
TODO
Controller documentation
TODO
See website for complete API (TODO)
Roadmap
- Demo site showing the decouple presentation app using this library - Home Page + Blog.
- Default to using in memory database and remove Mongo requirement. Mongo support via dao plugin.
- Api-check options + Integration tests
- Refactor angular into separate project. Pure ES5/6 data layer library wrapped in angular module.
- Basic User Management / Integrations
- Basic Author/Publisher workflow
- Draft content versions / API
- Self documenting Content API
- More field types + field type plugin api
- Order property for fields presentation order in form
- JSON export / import
- Improve protractor automation coverage
- Performance test mongo
- Performance test API
Build & Development
Prerequisites
- Git
- Node.js and npm Node ^4.2.3, npm ^2.14.7
- Bower (
npm install --global bower
) - Grunt (
npm install --global grunt-cli
) - MongoDB - Keep a running daemon with
mongod
Developing
- Run
git clone https://github.com/Kauabunga/cmeasy.git
to clone the repository - Run
npm install
to install server dependencies. - Run
bower install
to install front-end dependencies. - Run
mongod
in a separate shell to keep an instance of the MongoDB Daemon running - Run
grunt serve
to start the development server. It should automatically open the client in your browser when ready.
Contributing
Contributing is awesome!
Please ensure your contributions come with tests.
Release
- Ensure all tests pass
- Ensure linting passes
npm version <patch|minor|major>
git push && git push --tags
npm publish
Build
Run grunt build
to build the project
Testing
Running npm test
will run the unit tests with karma.
- Server:
grunt test:server
- Client:
grunt test:client
TODO
- Project Structure
- Integrate
nsp
checks with CI - Migrate to Pug
Features
- Define content models via config or web client
- Content and content model CRUD API
- User management - with + without email service