Git Product home page Git Product logo

sriracha's Introduction

Sriracha

A super spicy admin backend for Express and Mongoose.

Image of Sriracha

Build Status Coverage Status Dependency Status devDependency Status npm version

Sriracha is an Express app that can be mounted as middleware to any url in your application. The admin site's routes and editing interface are generated dynamically based on your Mongoose Models. Options are available to control the look and feel of the admin site.

Quick Start

  1. Install Sriracha:
npm install --save sriracha
  1. Include Sriracha in your express app and mount it to a url.
var express = require('express');
var admin = require('sriracha');

app = express();
...
app.use('/admin', admin());
  1. Login with username admin and password admin.

Sriracha is running at yourapp/admin!

Image of Sriracha Landing Page

Setting Options Globally

Options can be set globally through the options object passed to the middleware.

var options = {...};
app.use('/admin', admin(options));

username
default: 'admin' User name used to access admin backend.

password
default: 'admin' Password used to access the admin backend.

hideFields:
default: ['_id', '_v'] Fields that are hidden in all documents and collections.

<collection>.searchField:
default: undefined Sriracha implements a simple (for now) autocomplete query against the specified field.

For instance, to search against the email field in the User model, you would supply the following option:

var options = {
...,
User: {
  searchField: 'email'
}
...
}

<collection>.admin
default: undefined A setting of false will hide this field from the admin.

Field Types

Field types are set automatically by Sriracha based on the Mongo schema type. However, they can also be customized. Using the 'adminFieldType' option. See the setting options on a schema for examples of how to set custom field types.

Sriracha currently supports the following field types:

text
default: String and ObjectId schema types. A simple string input field.

text field

textarea
default: none The text area field allows easy inline editing of larger portions of text. The textarea field uses TinyMCE and stores it's results as HTML.

textarea field

date
default: Date schema type. A date picker field using the datepicker jquery plugin.

date field

array
default: Array schema type. An input that accepts a comma separated list of values.

date field

checkbox
default: Boolean schema type. A checkbox that setts a boolean field to true or false.

ref
default: Reference to other documents. An input of tags representing references to other documents.

date field

Setting Options on a Schema

All <collection> level options can be set on an individual schema as well. They will take precedence over the same options if they are also defined globally.

To set schema level options, provide the option, prefixed with admin.

For example, the following schema would set the lastName to the search field for users, and would hide the email and onboarding.signupDate fields.

...
var Schema = mongoose.Schema;

var UserSchema = new Schema({
  lastName: {
    type: String,
    default: '',
    adminSearchField: true
  },
  ...,
  email: {
    type: String,
    admin: false
  }
  onboarding: {
    signupDate: {
      type: Date,
      admin: false
    },
    hasLoggedIn: {
      type: Boolean,
      default: false
    }
  },
});
...

Examples

Examples can be found in the ./examples directory. To run them:

git clone <this-repo-or-your-fork>
cd <this-repo-or-your-fork>
npm install
# run the app with simple setup
gulp simple
# run the app with advanced setup
gulp advanced

Contributing

Contributing is anything from filing bugs, to requesting new features, to building features and their tests. Read the Contributing doc to find out more.

Acknowledgments

Thanks Iron Summit Media Strategies for the awesome Start Bootstrap Themes.

Siracha started with SB Admin and I used Jade Converter to turn it into Jade.

sriracha's People

Contributors

hdngr avatar

Watchers

James Cloos avatar Aaron Purtill 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.