https://github.com/hdngr/sriracha
A super spicy admin backend for Express and Mongoose.
https://github.com/hdngr/sriracha
Last synced: 5 months ago
JSON representation
A super spicy admin backend for Express and Mongoose.
- Host: GitHub
- URL: https://github.com/hdngr/sriracha
- Owner: hdngr
- License: mit
- Created: 2015-10-20T06:12:26.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-24T04:36:39.000Z (almost 10 years ago)
- Last Synced: 2026-01-24T04:21:35.031Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 1.12 MB
- Stars: 150
- Watchers: 6
- Forks: 20
- Open Issues: 13
-
Metadata Files:
- Readme: Readme.md
- Contributing: Contributing.md
- License: LICENSE
Awesome Lists containing this project
- awesome-express - sriracha-admin - Express 中间件模块,为 Mongoose 动态生成管理站点。 (中间件)
- awesome-github-projects - sriracha - A super spicy admin backend for Express and Mongoose. ⭐150 `JavaScript` (📦 Legacy & Inactive Projects)
README
# Sriracha
A super spicy admin backend for Express and Mongoose.

[](https://travis-ci.org/hdngr/sriracha)
[](https://coveralls.io/github/hdngr/sriracha?branch=master)
[](https://david-dm.org/hdngr/sriracha)
[](https://david-dm.org/hdngr/sriracha#info=devDependencies)
[](https://badge.fury.io/js/sriracha)
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
```
2. 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());
```
3. Login with username `admin` and password `admin`.
Sriracha is running at `yourapp/admin`!

## 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.
**\.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'
}
...
}
```
**\.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](#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.

**textarea**
*default*: none
The text area field allows easy inline editing of larger portions of text. The textarea field uses [TinyMCE](https://www.tinymce.com/) and stores it's results as HTML.

**date**
*default*: Date schema type.
A date picker field using the [datepicker jquery plugin](https://eonasdan.github.io/bootstrap-datetimepicker).

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

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

## 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](./Contributing.md) doc to find out more.
## Acknowledgments
Thanks [Iron Summit Media Strategies](http://www.ironsummitmedia.com/) for the awesome [Start Bootstrap Themes](http://startbootstrap.com/).
Siracha started with [SB Admin](http://startbootstrap.com/template-overviews/sb-admin/) and I used [Jade Converter](http://html2jade.org/) to turn it into Jade.