sriracha

by hdngr

hdngr / sriracha

A super spicy admin backend for Express and Mongoose.

132 Stars 17 Forks Last release: Not found MIT License 48 Commits 3 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

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

 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 
cd 
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.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.