AdminBroOptions
This is the heart of entire AdminBro - all options resides here.
Usage with regular javascript
const AdminBro = require('admin-bro')
//...
const adminBro = new AdminBro({
rootPath: '/xyz-admin',
logoutPath: '/xyz-admin/exit',
loginPath: '/xyz-admin/sign-in',
databases: [mongooseConnection],
resources: [{ resource: ArticleModel, options: {...}}],
branding: {
companyName: 'XYZ c.o.',
},
})
TypeScript
import { AdminBroOptions } from 'admin-bro
const options: AdminBroOptions = {
rootPath: '/xyz-admin',
logoutPath: '/xyz-admin/exit',
loginPath: '/xyz-admin/sign-in',
databases: [mongooseConnection],
resources: [{ resource: ArticleModel, options: {...}}],
branding: {
companyName: 'XYZ c.o.',
},
}
const adminBro = new AdminBro(options)
Members
# assets Optional
Custom assets you want to pass to AdminBro
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
styles |
Array.<string> |
<optional> |
List to urls of custom stylesheets. You can pass your font - icons here (as an example) |
scripts |
Array.<string> |
<optional> |
List of urls to custom scripts. If you use some particular js, library - you can pass its url here. |
globalsFromCDN |
boolean |
<optional> |
Flag indicates if all default styles and scripts should be fetched from CDN or from local, bundle. Default to CDN. You may change this if your internet connection is slow and you are, developing AdminBro on local machine. |
# dashboard Optional
Option to modify the dashboard
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
handler |
PageHandler |
<optional> |
Handler function which is triggered in the api when user launches the dashboard. |
component |
string |
<optional> |
Bundled component name which should be rendered when user opens the dashboard |
# databases Optional
Array of all Databases which are supported by AdminBro via adapters
# env Optional
Environmental variables passed to the frontend.
So let say you want to pass some GOOGLE_MAP_API_TOKEN to the frontend. You can do this by adding it here:
new AdminBro({env: {
GOOGLE_MAP_API_TOKEN: 'my-token',
}})
and this token will be available on the frontend by using:
AdminBro.envs.GOOGLE_MAP_API_TOKEN
# pages Optional
List of custom pages which will be visible below all resources
Example
pages: {
customPage: {
label: "Custom page",
handler: async (request, response, context) => {
return {
text: 'I am fetched from the backend',
}
},
component: AdminBro.bundle('./components/some-stats'),
},
anotherPage: {
label: "TypeScript page",
component: AdminBro.bundle('./components/test-component'),
},
}
# resources Optional
Array of all Resources which are supported by AdminBro via adapters. You can pass either resource or resource with an options and thus modify it.
Properties:
Name | Type | Description |
---|---|---|
resources[].resource |
any | |
resources[].options |
ResourceOptions |
# version Optional
Flag which indicates if version number should be visible on the UI
Type Definitions
# AdminPage
Object describing regular page in AdminBro
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
handler |
PageHandler |
<optional> |
|
component |
string | ||
label |
string |
<optional> |
# BrandingOptions
Branding Options
You can use them to change how AdminBro looks. For instance to change name and colors (dark theme) run:
const theme = require('admin-bro-theme-dark')
new AdminBro({
branding: {
companyName: 'John Doe Family Business',
theme,
}
})
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
logo |
string | false |
<optional> |
URL to a logo, or |
companyName |
string |
<optional> |
Name of your company, which will replace "AdminBro". |
theme |
CSSTheme |
<optional> |
CSS theme. |
softwareBrothers |
boolean |
<optional> |
Flag indicates if |
favicon |
string |
<optional> |
URL to a favicon |
# PageContext
Context object passed to a PageHandler
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
_admin |
AdminBro | current instance of AdminBro. You may use it to fetch other Resources by their names: |
|
currentAdmin |
CurrentAdmin |
<optional> |
Currently logged in admin |
h |
ViewHelpers | view helpers |
# PageHandler(request, response, context)
Function which is invoked when user enters given AdminPage
Parameters:
Name | Type | Description |
---|---|---|
request |
any | |
response |
any | |
context |
PageContext |
# ResourceWithOptions
Defaut way of passing Options with a Resource
Properties:
Name | Type | Description |
---|---|---|
resource |
any | |
options |
ResourceOptions |
# VersionSettings
Version Props
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
admin |
boolean |
<optional> |
if set to true - current admin version will be visible |
app |
string |
<optional> |
Here you can pass any arbitrary version text which will be seen in the US., You can pass here your current API version. |