Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
admin-bro-typeorm
Advanced tools
This is an inofficial admin-bro adapter which integrates TypeORM into admin-bro.
Installation: npm install admin-bro-typeorm
The plugin can be registered using standard AdminBro.registerAdapter
method.
import { Database, Resource } from "admin-bro-typeorm";
import AdminBro from 'admin-bro'
AdminBro.registerAdapter({ Database, Resource });
// optional: if you use class-validator you have to inject this to resource.
import { validate } from 'class-validator'
Resource.validate = validate;
import {
BaseEntity,
Entity, PrimaryGeneratedColumn, Column,
createConnection,
ManyToOne, OneToMany,
RelationId
} from "typeorm";
import * as express from "express";
import { Database, Resource, UseAsTitle, UseForSearch } from "admin-bro-typeorm";
import { validate } from 'class-validator'
import AdminBro from "admin-bro";
import * as AdminBroExpress from "admin-bro-expressjs"
Resource.validate = validate;
AdminBro.registerAdapter({ Database, Resource });
@Entity({name: "Organizations"})
export class Organization extends BaseEntity
{
@PrimaryGeneratedColumn()
public id: number;
@UseForSearch()
@Column({type: 'varchar', unique: true})
public govRegCode: string;
@Column({type: 'varchar', unique: true})
public name: string;
@OneToMany(type => Person, person => person.organization)
public employees?: Array<Person>;
@UseAsTitle()
public toString(): string
{
return `${this.firstName} ${this.lastName}`;
}
}
@Entity({name: "Persons"})
export class Person extends BaseEntity
{
@PrimaryGeneratedColumn()
public id: number;
@Column({type: 'varchar'})
public firstName: string;
@Column({type: 'varchar'})
public lastName: string;
@ManyToOne(type => Organization, org => org.employees)
@JoinColumn({ name: "organizationId" })
public organization?: Organization;
// in order be able to fetch resources in admin-bro - we have to have id available
@Column("int", { nullable: true })
public organizationId: number | null;
@UseAsTitle()
public toString(): string
{
return `${this.firstName} ${this.lastName}`;
}
}
( async () =>
{
const connection = await createConnection({/* ... */});
// Applying connection to model
Organization.useConnection(connection);
Person.useConnection(connection);
const adminBro = new AdminBro({
// databases: [connection],
resources: [
{ resource: Organization, options: { parent: { name: "foobar" } } },
{ resource: Person, options: { parent: { name: "foobar" } } }
],
rootPath: '/admin',
});
const app = express();
const router = AdminBroExpress.buildRouter(adminBro);
app.use(adminBro.options.rootPath, router);
app.listen(3000);
})();
Admin supports ManyToOne relationship but you also have to define @JoinColumn as stated in the example above.
Typescript developers who want to use admin-bro of version ~1.3.0
- don't do this - use ^1.4.0
instead.
FAQs
TypeORM adapter for AdminBro
The npm package admin-bro-typeorm receives a total of 12 weekly downloads. As such, admin-bro-typeorm popularity was classified as not popular.
We found that admin-bro-typeorm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.