
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@nest-excalibur/data-base
Advanced tools
With the database module you can insert massively data for testing or production.
npm i --save-dev @nest-excalibur/common-api
npm install @nest-excalibur/data-base
Just import the DataBaseModule
import { TypeOrmModule } from '@nestjs/typeorm';
import {DataBaseModule} from '@nest-excalibur/data-base/lib';
@Module({
imports: [
DataBaseModule.forRoot({productionFlag: false}),
TypeOrmModule.forRoot({
// Your database connection config
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {
}
If you want use an asynchronous configuration, for example, the following code shows how to use the forRootAsync
through by using ConfigService
:
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigModule, ConfigService } from '@nestjs/config';
import {DataBaseModule} from '@nest-excalibur/data-base/lib';
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
}),
DataBaseModule.forRootAsync({
useFactory: (configService: ConfigService) => {
const production = configService.get<boolean>('production');
return {
productionFlag: production,
};
},
inject: [ConfigService],
}),
TypeOrmModule.forRoot({
// Your database connection config
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {
}
To insert bulk data either for development or production, the module can be used to set the way the data will be created.
import {Module} from '@nestjs/common';
import {DataBaseModule} from '@nest-excalibur/data-base/lib';
@Module({
imports: [
DataBaseModule
.forBulkData(
{
dtoClassValidation: UserCreateDTO,
pathDev: '/src/modules/users/bulks/development/users.json',
pathProd: '/dist/modules/users/bulks/production/users.json',
aliasName: 'users',
creationOrder: 1,
entity: UserEntity,
},
),
TypeOrmModule.forFeature([UserEntity]),
],
})
export class UsersModule {
}
You can use
js
files insteadjson
files.
It is a fact that json files are not taken into account when building the project with the typescript transpiler. However, you can use multiple npm packages to handle this like cpy.
To create start massive insertion just use the DataBaseService
on the AppModule
In this example, the massive insertion is handle on onModuleInit
method:
import { DataBaseService } from '@nest-excalibur/data-base/lib';
export class AppModule implements OnModuleInit {
constructor(
private readonly dataBaseService: DataBaseService,
) {
}
onModuleInit() {
this.dataBaseService
.insertData()
.then(
_ => this.dataBaseService.showSummary(),
);
}
}
MongoDB Object ids are unique and It will be an issue handle the refs toward other documents at the creating the test data.
To handle this is necesary add the documents on the following way:
Lets suppose we have two documents users
and posts
where posts
has a reference with users
.
users.json
[
{
"$metaID": 1,
"name": "Mara"
},
{
"$metaID": 2,
"name": "Deleon"
}
]
add
$metaID
key for the index
On posts.json
just add the reference according with the $metaID
of users.json
:
[
{
"user": 1,
"title": "POST 1"
},
{
"user": 2,
"title": "POST 2"
}
]
Especify on the module the referenced attribute with its respective entity class
post.module.ts
@Module({
imports: [
TypeOrmModule.forFeature([PostEntity], 'mongo_conn'),
DataBaseModule.forBulkData(
{
pathDev: '/src/post/bulks/development/posts.json',
creationOrder: 2,
entity: PostEntity,
connection: 'mongo_conn',
dtoClassValidation: PostCreateDTO,
refs: {
user: UserEntity,
}
},
),
],
})
export class PostModule { }
### Logs
```text
CONNECTION: default
Order Entity Created Status File Size Refs
1 Product Categories 9 OK 0.54 Kb --
2 ProductEntity 15 OK 1.52 Kb --
CONNECTION: mongo_conn
Order Entity Created Status File Size Refs
1 UserEntity 96 OK 4.97 Kb --
2 PostEntity 19 OK 0.5 Kb user
FAQs
Module for handle database and mocks
The npm package @nest-excalibur/data-base receives a total of 7 weekly downloads. As such, @nest-excalibur/data-base popularity was classified as not popular.
We found that @nest-excalibur/data-base 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.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.