Skip to content

Commit fe38042

Browse files
committed
Merge remote-tracking branch 'origin/feat/rebrand'
2 parents 577debe + aad49b9 commit fe38042

19 files changed

+332
-9285
lines changed

.env-example

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
POSTGRES_USER="adminbro"
2-
POSTGRES_PASSWORD="adminbro"
3-
POSTGRES_DATABASE="adminbro-typeorm-app"
1+
POSTGRES_USER="adminjs"
2+
POSTGRES_PASSWORD="adminjs"
3+
POSTGRES_DATABASE="adminjs-typeorm-app"
44
POSTGRES_PORT=5432
55
POSTGRES_HOST="localhost"

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,6 @@ dist
159159
types
160160
build
161161
lib
162-
.adminbro
162+
.adminjs
163163

164164
example-app/cypress/videos

README.md

+58-58
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
## admin-bro-typeorm
1+
## adminjs-typeorm
22

3-
This is an official [admin-bro](https://github.com/SoftwareBrothers/admin-bro) adapter which integrates [TypeORM](https://typeorm.io/) into admin-bro. (originally forked from [Arteha/admin-bro-typeorm](https://github.com/Arteha/admin-bro-typeorm))
3+
This is an official [AdminJS](https://github.com/SoftwareBrothers/adminjs) adapter which integrates [TypeORM](https://typeorm.io/) into AdminJS. (originally forked from [Arteha/admin-bro-typeorm](https://github.com/Arteha/admin-bro-typeorm))
44

5-
Installation: `yarn add @admin-bro/typeorm`
5+
Installation: `yarn add @adminjs/typeorm`
66

77
## Usage
88

9-
The plugin can be registered using standard `AdminBro.registerAdapter` method.
10-
o
9+
The plugin can be registered using standard `AdminJS.registerAdapter` method.
10+
1111
```typescript
12-
import { Database, Resource } from '@admin-bro/typeorm'
13-
import AdminBro from 'admin-bro'
12+
import { Database, Resource } from '@adminjs/typeorm'
13+
import AdminJS from 'adminjs'
1414

15-
AdminBro.registerAdapter({ Database, Resource });
15+
AdminJS.registerAdapter({ Database, Resource });
1616

1717
// optional: if you use class-validator you have to inject this to resource.
1818
import { validate } from 'class-validator'
@@ -23,67 +23,67 @@ Resource.validate = validate
2323

2424
```typescript
2525
import {
26-
BaseEntity,
27-
Entity, PrimaryGeneratedColumn, Column,
28-
createConnection,
29-
ManyToOne,
30-
RelationId
26+
BaseEntity,
27+
Entity, PrimaryGeneratedColumn, Column,
28+
createConnection,
29+
ManyToOne,
30+
RelationId
3131
} from 'typeorm'
3232
import * as express from 'express'
33-
import { Database, Resource } from '@admin-bro/typeorm'
33+
import { Database, Resource } from '@adminjs/typeorm'
3434
import { validate } from 'class-validator'
3535

36-
import AdminBro from 'admin-bro'
37-
import * as AdminBroExpress from '@admin-bro/express'
36+
import AdminJS from 'adminjs'
37+
import * as AdminJSExpress from '@adminjs/express'
3838

3939
Resource.validate = validate
40-
AdminBro.registerAdapter({ Database, Resource })
40+
AdminJS.registerAdapter({ Database, Resource })
4141

4242
@Entity()
4343
export class Person extends BaseEntity
4444
{
45-
@PrimaryGeneratedColumn()
46-
public id: number;
47-
48-
@Column({type: 'varchar'})
49-
public firstName: string;
50-
51-
@Column({type: 'varchar'})
52-
public lastName: string;
53-
54-
@ManyToOne(type => CarDealer, carDealer => carDealer.cars)
55-
organization: Organization;
56-
57-
// in order be able to fetch resources in admin-bro - we have to have id available
58-
@RelationId((person: Person) => person.organization)
59-
organizationId: number;
60-
61-
// For fancy clickable relation links:
62-
public toString(): string
63-
{
64-
return `${firstName} ${lastName}`;
65-
}
45+
@PrimaryGeneratedColumn()
46+
public id: number;
47+
48+
@Column({type: 'varchar'})
49+
public firstName: string;
50+
51+
@Column({type: 'varchar'})
52+
public lastName: string;
53+
54+
@ManyToOne(type => CarDealer, carDealer => carDealer.cars)
55+
organization: Organization;
56+
57+
// in order be able to fetch resources in adminjs - we have to have id available
58+
@RelationId((person: Person) => person.organization)
59+
organizationId: number;
60+
61+
// For fancy clickable relation links:
62+
public toString(): string
63+
{
64+
return `${firstName} ${lastName}`;
65+
}
6666
}
6767

6868
( async () =>
6969
{
70-
const connection = await createConnection({/* ... */})
71-
72-
// Applying connection to model
73-
Person.useConnection(connection)
74-
75-
const adminBro = new AdminBro({
76-
// databases: [connection],
77-
resources: [
78-
{ resource: Person, options: { parent: { name: 'foobar' } } }
79-
],
80-
rootPath: '/admin',
81-
})
82-
83-
const app = express()
84-
const router = AdminBroExpress.buildRouter(adminBro)
85-
app.use(adminBro.options.rootPath, router)
86-
app.listen(3000)
70+
const connection = await createConnection({/* ... */})
71+
72+
// Applying connection to model
73+
Person.useConnection(connection)
74+
75+
const adminJs = new AdminJS({
76+
// databases: [connection],
77+
resources: [
78+
{ resource: Person, options: { parent: { name: 'foobar' } } }
79+
],
80+
rootPath: '/admin',
81+
})
82+
83+
const app = express()
84+
const router = AdminJSExpress.buildRouter(adminJs)
85+
app.use(adminJs.options.rootPath, router)
86+
app.listen(3000)
8787
})()
8888
```
8989

@@ -112,15 +112,15 @@ yarn link
112112

113113
4. Setup example app
114114

115-
Install all dependencies and use previously linked version of `@admin-bro/typeorm`.
115+
Install all dependencies and use previously linked version of `@adminjs/typeorm`.
116116

117117
```
118118
cd example-app
119119
yarn install
120-
yarn link @admin-bro/typeorm
120+
yarn link @adminjs/typeorm
121121
```
122122

123-
Optionally you might want to link your local version of `admin-bro` package
123+
Optionally you might want to link your local version of `adminjs` package
124124

125125
5. Make sure you have all the envs set (which are defined in `example-app/ormconfig.js`)
126126

example-app/.env-example

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
POSTGRES_USER="adminbro"
2-
POSTGRES_PASSWORD="adminbro"
3-
POSTGRES_DATABASE="adminbro-typeorm-app"
1+
POSTGRES_USER="adminjs"
2+
POSTGRES_PASSWORD="adminjs"
3+
POSTGRES_DATABASE="adminjs-typeorm-app"
44
POSTGRES_PORT=5432
55
POSTGRES_HOST="localhost"

example-app/package.json

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
{
2-
"name": "example-app",
3-
"version": "1.0.0",
4-
"main": "index.js",
5-
"license": "MIT",
6-
"scripts": {
7-
"build": "tsc",
8-
"start": "node build/src/index.js",
9-
"dev": "yarn build && concurrently \"yarn build --watch\" \"nodemon --ext '.js' --watch ../lib --watch ./build --ignore 'cypress/**/*.js' node build/src/index.js\"",
10-
"cypress:open": "cypress open",
11-
"cypress:run": "cypress run"
12-
},
13-
"devDependencies": {
14-
"@types/express": "^4.17.7",
15-
"@types/node": "^8.0.29",
16-
"concurrently": "^5.2.0",
17-
"cypress": "^4.11.0",
18-
"nodemon": "^2.0.4",
19-
"ts-node": "3.3.0",
20-
"typescript": "3.9.7"
21-
},
22-
"dependencies": {
23-
"admin-bro": "^3.3.1",
24-
"@admin-bro/express": "^3.0.0",
25-
"@admin-bro/typeorm": "^1.0.1",
26-
"express": "^4.17.1",
27-
"express-formidable": "^1.2.0",
28-
"express-session": "^1.17.1",
29-
"pg": "^8.3.0",
30-
"reflect-metadata": "^0.1.10",
31-
"typeorm": "0.2.28"
32-
}
2+
"name": "example-app",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"scripts": {
7+
"build": "tsc",
8+
"start": "node build/src/index.js",
9+
"dev": "yarn build && concurrently \"yarn build --watch\" \"nodemon --ext '.js' --watch ../lib --watch ./build --ignore 'cypress/**/*.js' node build/src/index.js\"",
10+
"cypress:open": "cypress open",
11+
"cypress:run": "cypress run"
12+
},
13+
"devDependencies": {
14+
"@types/express": "^4.17.7",
15+
"@types/node": "^8.0.29",
16+
"concurrently": "^5.2.0",
17+
"cypress": "^4.11.0",
18+
"nodemon": "^2.0.4",
19+
"ts-node": "3.3.0",
20+
"typescript": "3.9.7"
21+
},
22+
"dependencies": {
23+
"adminjs": "^3.3.1",
24+
"@adminjs/express": "^3.0.0",
25+
"@adminjs/typeorm": "^1.0.1",
26+
"express": "^4.17.1",
27+
"express-formidable": "^1.2.0",
28+
"express-session": "^1.17.1",
29+
"pg": "^8.3.0",
30+
"reflect-metadata": "^0.1.10",
31+
"typeorm": "0.2.28"
32+
}
3333
}

example-app/src/entity/Car.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class Car extends BaseEntity {
2222
@ManyToOne((type) => Seller, (seller) => seller.cars)
2323
seller: User;
2424

25-
// in order be able to fetch resources in admin-bro - we have to have id available
25+
// in order be able to fetch resources in adminjs - we have to have id available
2626
@RelationId((car: Car) => car.owner)
2727
ownerId: number;
2828

example-app/src/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import 'reflect-metadata'
22
import { createConnection } from 'typeorm'
33
import express from 'express'
4-
import AdminBro from 'admin-bro'
5-
import { buildRouter } from '@admin-bro/express'
6-
import * as TypeormAdapter from '@admin-bro/typeorm'
4+
import AdminJS from 'adminjs'
5+
import { buildRouter } from '@adminjs/express'
6+
import * as TypeormAdapter from '@adminjs/typeorm'
77
import { User } from './entity/User'
88
import { Car } from './entity/Car'
99
import { Seller } from './entity/Seller'
1010

11-
AdminBro.registerAdapter(TypeormAdapter)
11+
AdminJS.registerAdapter(TypeormAdapter)
1212

1313
const PORT = 3000
1414

1515
const run = async () => {
1616
await createConnection()
1717
const app = express()
18-
const admin = new AdminBro({
18+
const admin = new AdminJS({
1919
resources: [{
2020
resource: User,
2121
options: {

example-app/tsconfig.json

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{
22
"compilerOptions": {
3-
"baseUrl": ".",
4-
"outDir": "./build",
5-
"target": "es6",
6-
"esModuleInterop": true,
7-
"jsx": "react",
8-
"strictNullChecks": true,
9-
"strictFunctionTypes": true,
10-
"strictBindCallApply": true,
11-
"noImplicitThis": true,
12-
"moduleResolution": "node",
13-
"module": "commonjs",
14-
"types": ["cypress"],
15-
"emitDecoratorMetadata": true,
16-
"experimentalDecorators": true,
17-
"strictPropertyInitialization": false,
18-
"sourceMap": true,
19-
"paths": {
20-
"react": ["node_modules/@types/react"],
21-
"admin-bro": ["node_modules/admin-bro"],
22-
}
3+
"baseUrl": ".",
4+
"outDir": "./build",
5+
"target": "es6",
6+
"esModuleInterop": true,
7+
"jsx": "react",
8+
"strictNullChecks": true,
9+
"strictFunctionTypes": true,
10+
"strictBindCallApply": true,
11+
"noImplicitThis": true,
12+
"moduleResolution": "node",
13+
"module": "commonjs",
14+
"types": ["cypress"],
15+
"emitDecoratorMetadata": true,
16+
"experimentalDecorators": true,
17+
"strictPropertyInitialization": false,
18+
"sourceMap": true,
19+
"paths": {
20+
"react": ["node_modules/@types/react"],
21+
"adminjs": ["node_modules/adminjs"]
22+
}
2323
},
2424
"include": [
25-
"./src/**/*",
26-
"./cypress/**/*"
25+
"./src/**/*",
26+
"./cypress/**/*"
2727
],
2828
}

0 commit comments

Comments
 (0)