Skip to content

Commit 5d0dd3c

Browse files
committed
chore: rebrand AdminBro to AdminJS
This commit is a part of AdminBro to AdminJS process. BREAKING CHANGE: AdminBro has been rebranded to AdminJS. All package and repository names had been updated. 1. Update your dependencies to use new `adminjs` packages. - `admin-bro` -> `adminjs` for the core package - `@admin-bro/<package name>` -> `@adminjs/<package name>` for other modules 2. Update your custom CSS classes: - `.admin-bro_<component name>` -> `.adminjs_<component name>` (example: `.adminjs_Box`) 3. Search your project for `admin-bro` occurrences - most likely they will have to be updated to `adminjs`
1 parent 9beb192 commit 5d0dd3c

File tree

13 files changed

+88
-88
lines changed

13 files changed

+88
-88
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
# Expressjs plugin for AdminBro
1+
# Expressjs plugin for AdminJS
22

3-
This is an official [AdminBro](https://github.com/SoftwareBrothers/admin-bro) plugin which integrates it to [expressjs](https://expressjs.com/) framework.
3+
This is an official [AdminJS](https://github.com/SoftwareBrothers/adminjs) plugin which integrates it to [expressjs](https://expressjs.com/) framework.
44

5-
## AdminBro
5+
## AdminJS
66

7-
AdminBro is an automatic admin interface which can be plugged into your application. You, as a developer, provide database models (like posts, comments, stores, products or whatever else your application uses), and AdminBro generates UI which allows you (or other trusted users) to manage content.
7+
AdminJS is an automatic admin interface which can be plugged into your application. You, as a developer, provide database models (like posts, comments, stores, products or whatever else your application uses), and AdminJS generates UI which allows you (or other trusted users) to manage content.
88

9-
Check out the example application with mongo and postgres models here: https://admin-bro-example-app-staging.herokuapp.com/admin
9+
Check out the example application with mongo and postgres models here: https://adminjs-example-app-staging.herokuapp.com/admin
1010

11-
Or visit [AdminBro](https://github.com/SoftwareBrothers/admin-bro) github page.
11+
Or visit [AdminJS](https://github.com/SoftwareBrothers/adminjs) github page.
1212

1313
## Usage
1414

15-
To see example usage visit the [Express section under AdminBro project page](https://softwarebrothers.github.io/admin-bro-dev/module-admin-bro-expressjs.html)
15+
To see example usage visit the [Express section under AdminJS project page](https://softwarebrothers.github.io/adminjs-dev/module-adminjs-expressjs.html)
1616

1717
## Debugging
18-
Set `process.env.ADMIN_BRO_EXPRESS_DEBUG` env variable to see debug logs from the library
18+
Set `process.env.ADMINJS_EXPRESS_DEBUG` env variable to see debug logs from the library
1919

2020
## License
2121

22-
AdminBro is Copyright © 2018 SoftwareBrothers.co. It is free software and may be redistributed under the terms specified in the [LICENSE](LICENSE) file.
22+
AdminJS is Copyright © 2021 SoftwareBrothers.co. It is free software and may be redistributed under the terms specified in the [LICENSE](LICENSE) file.
2323

2424
## About SoftwareBrothers.co
2525

examples/auth.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import AdminBro from "admin-bro";
1+
import AdminJS from "adminjs";
22
import express from "express";
33
import mongoose from "mongoose";
4-
import MongooseAdapter from "@admin-bro/mongoose";
5-
import AdminBroExpress from "../src";
4+
import MongooseAdapter from "@adminjs/mongoose";
5+
import AdminJSExpress from "../src";
66

77
import "./mongoose/article-model";
88
import "./mongoose/admin-model";
99

10-
AdminBro.registerAdapter(MongooseAdapter);
10+
AdminJS.registerAdapter(MongooseAdapter);
1111

1212
const ADMIN = {
1313
@@ -20,12 +20,12 @@ const start = async () => {
2020
);
2121
const app = express();
2222

23-
const adminBro = new AdminBro({
23+
const adminJs = new AdminJS({
2424
databases: [connection],
2525
rootPath: "/admin",
2626
});
2727

28-
const router = AdminBroExpress.buildAuthenticatedRouter(adminBro, {
28+
const router = AdminJSExpress.buildAuthenticatedRouter(adminJs, {
2929
authenticate: async (email, password) => {
3030
if (ADMIN.password === password && ADMIN.email === email) {
3131
return ADMIN;
@@ -35,10 +35,10 @@ const start = async () => {
3535
cookiePassword: "somasd1nda0asssjsdhb21uy3g",
3636
});
3737

38-
app.use(adminBro.options.rootPath, router);
38+
app.use(adminJs.options.rootPath, router);
3939

4040
app.listen(process.env.PORT || 8080, () =>
41-
console.log("AdminBro is under localhost:8080/admin")
41+
console.log("AdminJS is running under localhost:8080/admin")
4242
);
4343
};
4444

examples/simple.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import AdminBro from "admin-bro";
1+
import AdminJS from "adminjs";
22
import express from "express";
33
import mongoose from "mongoose";
4-
import MongooseAdapter from "@admin-bro/mongoose";
4+
import MongooseAdapter from "@adminjs/mongoose";
55

6-
import AdminBroExpress from "../src";
6+
import AdminJSExpress from "../src";
77
import "./mongoose/article-model";
88
import "./mongoose/admin-model";
99

10-
AdminBro.registerAdapter(MongooseAdapter);
10+
AdminJS.registerAdapter(MongooseAdapter);
1111

1212
const start = async () => {
1313
const connection = await mongoose.connect(
@@ -16,16 +16,16 @@ const start = async () => {
1616
);
1717
const app = express();
1818

19-
const adminBro = new AdminBro({
19+
const adminJs = new AdminJS({
2020
databases: [connection],
2121
rootPath: "/admin",
2222
});
23-
const router = AdminBroExpress.buildRouter(adminBro);
23+
const router = AdminJSExpress.buildRouter(adminJs);
2424

25-
app.use(adminBro.options.rootPath, router);
25+
app.use(adminJs.options.rootPath, router);
2626

2727
app.listen(process.env.PORT || 8080, () =>
28-
console.log("AdminBro is under localhost:8080/admin")
28+
console.log("AdminJS is running under localhost:8080/admin")
2929
);
3030
};
3131

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "@admin-bro/express",
2+
"name": "@adminjs/express",
33
"version": "3.1.0",
4-
"description": "This is an official AdminBro plugin which integrates it to expressjs framework",
4+
"description": "This is an official AdminJS plugin which integrates it with Express.js framework",
55
"main": "lib/index.js",
66
"scripts": {
77
"dev": "rm -rf lib && tsc --watch",
@@ -15,22 +15,22 @@
1515
},
1616
"repository": {
1717
"type": "git",
18-
"url": "git+https://github.com/SoftwareBrothers/admin-bro-expressjs.git"
18+
"url": "git+https://github.com/SoftwareBrothers/adminjs-expressjs.git"
1919
},
2020
"keywords": [
2121
"expressjs",
2222
"admin",
23-
"adminbro",
23+
"adminjs",
2424
"admin-panel"
2525
],
2626
"author": "Michał Laskowski",
2727
"license": "SEE LICENSE IN LICENSE",
2828
"bugs": {
29-
"url": "https://github.com/SoftwareBrothers/admin-bro-expressjs/issues"
29+
"url": "https://github.com/SoftwareBrothers/adminjs-expressjs/issues"
3030
},
31-
"homepage": "https://github.com/SoftwareBrothers/admin-bro-expressjs#readme",
31+
"homepage": "https://github.com/SoftwareBrothers/adminjs-expressjs#readme",
3232
"peerDependencies": {
33-
"admin-bro": ">=3.0.0",
33+
"adminjs": ">=3.0.0",
3434
"express": ">=4.16.4",
3535
"express-formidable": "^1.2.0",
3636
"express-session": ">=1.15.6"
@@ -41,7 +41,7 @@
4141
}
4242
},
4343
"devDependencies": {
44-
"@admin-bro/mongoose": "^1.1.0",
44+
"@adminjs/mongoose": "^1.1.0",
4545
"@commitlint/config-conventional": "^11.0.0",
4646
"@semantic-release/git": "^9.0.0",
4747
"@types/express": "^4.17.9",
@@ -52,7 +52,7 @@
5252
"@types/mongoose": "^5.10.1",
5353
"@typescript-eslint/eslint-plugin": "^4.8.1",
5454
"@typescript-eslint/parser": "^4.8.1",
55-
"admin-bro": "^3.3.1",
55+
"adminjs": "^3.3.1",
5656
"chai": "^4.2.0",
5757
"commitlint": "^11.0.0",
5858
"eslint": "^7.13.0",

src/authentication/login.handler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import AdminBro from "admin-bro";
1+
import AdminJS from "adminjs";
22
import { Router } from "express";
33
import { AuthenticationOptions } from "../types";
44

5-
const getLoginPath = (admin: AdminBro): string => {
5+
const getLoginPath = (admin: AdminJS): string => {
66
const { loginPath, rootPath } = admin.options;
77
// since we are inside already namespaced router we have to replace login and logout routes that
88
// they don't have rootUrl inside. So changing /admin/login to just /login.
@@ -17,7 +17,7 @@ const getLoginPath = (admin: AdminBro): string => {
1717

1818
export const withLogin = (
1919
router: Router,
20-
admin: AdminBro,
20+
admin: AdminJS,
2121
auth: AuthenticationOptions
2222
): void => {
2323
const { rootPath } = admin.options;

src/authentication/logout.handler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import AdminBro from "admin-bro";
1+
import AdminJS from "adminjs";
22
import { Router } from "express";
33

4-
const getLogoutPath = (admin: AdminBro) => {
4+
const getLogoutPath = (admin: AdminJS) => {
55
const { logoutPath, rootPath } = admin.options;
66
const normalizedLogoutPath = logoutPath.replace(rootPath, "");
77

@@ -10,7 +10,7 @@ const getLogoutPath = (admin: AdminBro) => {
1010
: `/${normalizedLogoutPath}`;
1111
};
1212

13-
export const withLogout = (router: Router, admin: AdminBro): void => {
13+
export const withLogout = (router: Router, admin: AdminJS): void => {
1414
const logoutPath = getLogoutPath(admin);
1515

1616
router.get(logoutPath, async (request, response) => {

src/authentication/protected-routes.handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import AdminBro, { Router as AdminRouter } from "admin-bro";
1+
import AdminJS, { Router as AdminRouter } from "adminjs";
22
import { Router } from "express";
33

44
export const withProtectedRoutesHandler = (
55
router: Router,
6-
admin: AdminBro
6+
admin: AdminJS
77
): void => {
88
const { rootPath } = admin.options;
99

src/buildAuthenticatedRouter.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import AdminBro from "admin-bro";
1+
import AdminJS from "adminjs";
22
import express, { Router } from "express";
33
import session from "express-session";
44
import { withLogout } from "./authentication/logout.handler";
@@ -11,7 +11,7 @@ import formidableMiddleware from "express-formidable";
1111

1212
/**
1313
* @typedef {Function} Authenticate
14-
* @memberof module:@admin-bro/express
14+
* @memberof module:@adminjs/express
1515
* @description
1616
* function taking 2 arguments email and password
1717
* @param {string} [email] email given in the form
@@ -27,26 +27,26 @@ import formidableMiddleware from "express-formidable";
2727
* not optimized for production usage and, in development, it causes
2828
* logging out after every page refresh (if you use nodemon).
2929
* @static
30-
* @memberof module:@admin-bro/express
30+
* @memberof module:@adminjs/express
3131
* @example
3232
* const ADMIN = {
3333
* email: 'test@example.com',
3434
* password: 'password',
3535
* }
3636
*
37-
* AdminBroExpress.buildAuthenticatedRouter(adminBro, {
37+
* AdminJSExpress.buildAuthenticatedRouter(adminJs, {
3838
* authenticate: async (email, password) => {
3939
* if (ADMIN.password === password && ADMIN.email === email) {
4040
* return ADMIN
4141
* }
4242
* return null
4343
* },
44-
* cookieName: 'adminbro',
44+
* cookieName: 'adminjs',
4545
* cookiePassword: 'somePassword',
4646
* }, [router])
4747
*/
4848
export const buildAuthenticatedRouter = (
49-
admin: AdminBro,
49+
admin: AdminJS,
5050
auth: AuthenticationOptions,
5151
predefinedRouter?: express.Router | null,
5252
sessionOptions?: session.SessionOptions,
@@ -65,7 +65,7 @@ export const buildAuthenticatedRouter = (
6565
session({
6666
...sessionOptions,
6767
secret: auth.cookiePassword,
68-
name: auth.cookieName || "adminbro",
68+
name: auth.cookieName || "adminjs",
6969
})
7070
);
7171
router.use(formidableMiddleware(formidableOptions));

src/buildRouter.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
import AdminBro, { Router as AdminRouter } from "admin-bro";
1+
import AdminJS, { Router as AdminRouter } from "adminjs";
22
import { RequestHandler, Router } from "express";
33
import formidableMiddleware from "express-formidable";
44
import path from "path";
55
import { WrongArgumentError } from "./errors";
66
import { log } from "./logger";
77
import { FormidableOptions } from "./types";
88

9-
const INVALID_ADMIN_BRO_INSTANCE =
10-
"You have to pass an instance of AdminBro to the buildRouter() function";
9+
const INVALID_ADMINJS_INSTANCE =
10+
"You have to pass an instance of AdminJS to the buildRouter() function";
1111

1212
export const buildRouter = (
13-
admin: AdminBro,
13+
admin: AdminJS,
1414
predefinedRouter?: Router | null,
1515
formidableOptions?: FormidableOptions
1616
): Router => {
17-
if (admin?.constructor?.name !== "AdminBro") {
18-
throw new WrongArgumentError(INVALID_ADMIN_BRO_INSTANCE);
17+
if (admin?.constructor?.name !== "AdminJS") {
18+
throw new WrongArgumentError(INVALID_ADMINJS_INSTANCE);
1919
}
2020

2121
admin.initialize().then(() => {
22-
log.debug("AdminBro: bundle ready");
22+
log.debug("AdminJS: bundle ready");
2323
});
2424

2525
const { routes, assets } = AdminRouter;
2626
const router = predefinedRouter ?? Router();
2727
router.use(formidableMiddleware(formidableOptions));
2828

2929
routes.forEach((route) => {
30-
// we have to change routes defined in AdminBro from {recordId} to :recordId
30+
// we have to change routes defined in AdminJS from {recordId} to :recordId
3131
const expressPath = route.path.replace(/{/g, ":").replace(/}/g, "");
3232

3333
const handler: RequestHandler = async (req, res, next) => {

src/errors.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ export class OldBodyParserUsedError extends Error {
99
constructor(
1010
message = `
1111
You probably used old \`body-parser\` middleware, which is not compatible
12-
with @admin-bro/express. In order to make it work you will have to
13-
1. move body-parser invocation after the admin bro setup like this:
12+
with @adminjs/express. In order to make it work you will have to
13+
1. move body-parser invocation after the AdminJS setup like this:
1414
15-
const adminBro = new AdminBro()
16-
const router = new buildRouter(adminBro)
17-
app.use(adminBro.options.rootPath, router)
15+
const adminJs = new AdminJS()
16+
const router = new buildRouter(adminJs)
17+
app.use(adminJs.options.rootPath, router)
1818
19-
// body parser goes after the AdminBro router
19+
// body parser goes after the AdminJS router
2020
app.use(bodyParser())
2121
2222
2. Upgrade body-parser to the latest version and use it like this:

0 commit comments

Comments
 (0)