@kauabunga/trust-blue-fish

0.9.9 • Public • Published

Bluefish

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

Content API Library

bluefish-01

Getting Started

Define your content

require('bluefish')({ 
  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('bluefish')({ /* ... */ })
  .then(function(bluefish){
    bluefish.getModel('homePage').index();
  });

Or

<script src="api/v1/content.js"></script>
<script>
  console.log(window._bluefish_content);
</script>

Installation

npm install bluefish --save

Demo

See an example running on Heroku https://bluefish.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('bluefish')({
  // ...
  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/bluefish');

require('bluefish')({
  // ...
  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, bluefish will remove all users at startup
  clean: boolean,
  data: [
    {
      name: 'Test User',
      email: 'test@test.com',
      password: 'test'
    },
    {
      name: 'Admin',
      role: 'admin',
      email: 'admin@admin.com',
      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 bluefish = require('bluefish')(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/solnetdigital/bluefish.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. Ensure you are on the master branch
  4. npm version <patch|minor|major>
  5. git push && git push --tags
  6. Wait for travis to deploy the new tag

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.9.90latest

Version History

VersionDownloads (Last 7 Days)Published
0.9.90

Package Sidebar

Install

npm i @kauabunga/trust-blue-fish

Weekly Downloads

0

Version

0.9.9

License

none

Unpacked Size

23.4 MB

Total Files

1352

Last publish

Collaborators

  • kauabunga