identity-admin v1.26.3
Identity Admin Dashboard
How to install
npm i identity-admin
Features
- Creating Dashboard with minimal Ui for mongoose models.
- Provide DashboardController for custom routing and middlewares.
- Provide multiple dashboard instances with diffrent routes.
Create new unAuthenticated
Dashboard:
- Create new instance from Dashboard.
- Provide Resources array of resources file.
- Build the instance after mongoose setup by passing app instance to the build function.
const dashboard: Dashboard = new Dashboard({ resources:[ <Resource: IResourceFile> ]);
dashboard.build(app);
To create new Authenticated
Dashboard:
- Create new instance from Dashboard.
- Provide Resources array of resources file.
- Provide authenticate function which take AdminCredentials as parameter and return a promise of boolean or user data.
- Provide cookiesConfiguration (cookie name and cookie secret).
- Build the instance after mongoose setup by passing app instance to the build function.
const dashboard = new Dashboard({
resources: [ UserResource ],
cookiesConfiguration: {
cookiesSecret: "cokieieSecret",
cookieName: "connect.sid"
},
authenticate: async (credentials: AdminCredentials) => {
const user = await Admin.findOne({ email: credentials.email });
if (user) {
const matched = await bcrypt.compare(credentials.password, user.encryptedPassword);
if (matched) {
return user;
}
}
return false;
}
})
dashboard.build(app);
To create new CustomRoutes
Dashboard:
This method require to implement your own view and new react app
- Create new controller class with invirsify-express-utils notaitions and extend ActionController.
- Create new controller class with invirsify-express-utils notaitions and extend ResourceController.
- Create new controller class with invirsify-express-utils notaitions and extend DashboardController.
- Provide resource file and repository in super constructor.
Following class will create new route /v1/contries ***Now you can pass any auth middlewares you want
@controller('/v1/actions', defaultHeaders)
export default class ActionsController extends ActionController{
constructor(
@inject(TYPES.IResources) private resources: IResourceFile[]) {
super(resources);
}
}
@controller('/v1/resources', defaultHeaders)
export default class ResourcesController extends ResourceController{
constructor(
@inject(TYPES.IResources) private resources: IResourceFile[]) {
super(resources);
}
}
@controller('/v1/contries', defaultHeaders)
export default class CountryController extends DashboardController{
constructor(
@inject(TYPES.ICountryRepository) private countryRepository: CountryRepository,
@inject(TYPES.ICountryResource) private countryResource: IResourceFile ) {
super(CountryResource, countryRepository);
}
}
Documentaion:
Dashboard(dashBoardConfig: DashboardConfig);
build(app: Application): void;
Dashboard:
Dashboard constructor to create new instance from idntity-admin.
- dashBoardConfig:
{ resources: IResourceFile[]; // Array of resources files. rootPath?: string; // optional root path default to /dashboard localesOptions?: i18n.ConfigurationOptions; // locales options for custom dashboard cookiesConfiguration: CookieConfiguration; // cookies configuration in case of authenticated dashboard authenticate?: AuthenticateMiddleWare; // authenticate function used to login the admin. }
IResourceFile
For resource file example check
IResourceFileCookieConfiguration
{
cookiesSecret: string; // cookie secret to handle sessions
cookieName: string; // cookie name as appeared in browser
}
11 days ago
11 days ago
23 days ago
2 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
6 months ago
6 months ago
6 months ago
8 months ago
8 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
7 months ago
8 months ago
8 months ago
7 months ago
7 months ago
7 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
11 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago