Giter Club home page Giter Club logo

sequelize-admin's Introduction

sequelize-admin

A connect module for managing database entries of registered sequelize models.

Look & Feel

The initial view will show you all the available models + it's instances:

Build Status

Getting started

The idea behind sequelize-admin is to have a drop-in, easy-to-use CMS-like admin panel, which allows the creation, deletion and modification of database entries. The application needs to be based on connect or express and should use sequelize. To add the module to your existing application, you just have to add the following line:

app.use(admin(sequelize))

This will make the admin area available under http://your.app/admin. sequelize-admin is depending on the module sequelize-restful, which transforms a sequelize instance into a RESTful interface. If your are already using sequelize-restful, you need to tell sequelize-admin where it can find the REST API. If you don't define that option, the admin panel will create it's own instance of the REST interface.

// default of restful: true
app.use(admin(sequelize, { restful: '/my/path/to/the/rest/api' }))

In addition to that, you might need to protect your API against external request. This is where sequelize-authentication comes into play. The module will take parameters of a request to authenticate against your database. If you want to use that, you have to give sequelize-admin a small hint:

// default of authentication: false

// passing true will assume, that no param options is used 
// and that the credentials are passed via params mode.
app.use(admin(sequelize, { authentication: true }))

// define the relevant options of authentication
app.use(admin(sequelize, { 
	authentication: {
		param: 'credentials',
		via:   'headers'
	}
}))

In total, you will end up with something like this:

var app            = express()
  , authentication = require('sequelize-authentication')
  , restful        = require('sequelize-restful)
  , admin          = require('sequelize-admin')
  , Sequelize      = require('sequelize')
  , sequelize      = new Sequelize('database', 'user', 'password')

app.configure(function() {
	app.use(authenticate(sequelize, { 
		via: 'headers', 
		scope: '/admin/api', 
		param: 'credentials' 
	}))
  
	app.use(restful(sequelize, { endpoint: '/admin/api' }))

	app.use(admin(sequelize, {
		endpoint: '/admin',
		restful:  '/admin/api',
		authentication: {
			via: 'headers', 
			param: 'credentials' 
		}
	}))
})

If you just skip all the options and only use admin(sequelize), you will get an admin panel which is located under http://your.app/admin, with a RESTful API under http://your.app/admin/api and without any protection of that API.

Develompent notes

Updating dependencies

Dependencies are managed with bower. Check the documentation to get details about updating components. The respective component.json is located under app/js/component.json. In order to update a new component, you have to do this:

cd app/js
bower install <component>

After updating bootstrap you need to run the following command:

npm run amdify-bootstrap

sequelize-admin's People

Contributors

sdepold avatar

Watchers

James Cloos avatar Andrew Sherstobitov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.