npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cmeasy

v0.7.0

Published

Content API Library

Downloads

59

Readme

cmeasy beta

Npm Version Build Status Dependency Status Heroku Code Climate Test Coverage Sauce Test Status

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 Deploy

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

Developing

  1. Run git clone https://github.com/Kauabunga/cmeasy.git to clone the repository
  2. Run npm install to install server dependencies.
  3. Run bower install to install front-end dependencies.
  4. Run mongod in a separate shell to keep an instance of the MongoDB Daemon running
  5. 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

  1. Ensure all tests pass
  2. Ensure linting passes
  3. npm version <patch|minor|major>
  4. git push && git push --tags
  5. 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