![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
@marxlnfcs/nest-lokijs
Advanced tools
Warning This library is for experimentation and may contain some bugs that I will remove from time to time. With this library I'm learning how dependency injection works and how to build such libraries according to "best practice".
So please use this library with caution.
npm i @marxlnfcs/nest-lokijs
@Module({
imports: [
LokiJSModule.forRoot({
...
}),
LokiJSModule.forRootAsync({
useFactory: (configService: ConfigService) => ({
...
}),
inject: [ConfigService]
})
]
})
export class AppModule {}
The entity is a model definition, that will be stored in the database.
// ------------------------------
// entities/test.entity.ts
import {LokiEntity} from '@marxlnfcs/nest-lokijs';
import {LokiColumnBoolean, LokiColumnCreated, LokiColumnId, LokiColumnText, LokiColumnUpdated} from "../src/lib/decorators/column.decorator";
@LokiEntity('<collection-name>')
export class TestEntity {
@LokiColumnId()
id: string;
@LokiColumnText()
name: string;
@LokiColumnText({ nullable: true })
source: string|null;
@LokiColumnBoolean({ default: false })
enabled: boolean;
@LokiColumnUpdated()
updated: Date;
@LokiColumnCreated()
created: Date;
}
// ------------------------------
// app.module.ts
import {LokiJSModule} from '@marxlnfcs/nest-lokijs';
@Module({
imports: [
LokiJSModule.forFeature(TestEntity)
]
})
export class AppModule {}
The repository helps you to fetch the data from the database. This class works like a service and you can use the dependency injection.
// ------------------------------
// repositories/test.repository.ts
import {LokiRepository, LokiJSRepository} from '@marxlnfcs/nest-lokijs';
import {TestEntity} from '../entities/test.entity.ts';
@LokiRepository(TestEntity)
export class TestRepository extends LokiJSRepository<TestEntity> {}
// ------------------------------
// app.module.ts
import {LokiJSModule} from '@marxlnfcs/nest-lokijs';
@Module({
imports: [
LokiJSModule.forFeature(TestRepository)
]
})
export class AppModule {}
The subscriber can be assigned to any entity. The subscriber's function is to manipulate the entities before they are returned from the repository or written to the database.
// ------------------------------
// subscribers/test.subscriber.ts
import {LokiSubscriber, ILokiJSSubscriber} from '@marxlnfcs/nest-lokijs';
import {TestEntity} from '../entities/test.entity.ts';
@LokiSubscriber(TestEntity)
export class TestSubscriber extends ILokiJSSubscriber<TestEntity> {
afterLoad(entity: TestEntity): Promise<TestEntity> | Promise<void> | void | TestEntity {}
beforeInsert(entity: TestEntity): Promise<TestEntity> | Promise<void> | void | TestEntity {}
afterInsert(entity: TestEntity): Promise<TestEntity> | Promise<void> | void | TestEntity {}
beforeUpdate(entity: TestEntity, databaseEntity: TestEntity): Promise<TestEntity> | Promise<void> | void | TestEntity {}
afterUpdate(entity: TestEntity): Promise<TestEntity> | Promise<void> | void | TestEntity {}
afterDelete(entity: TestEntity): Promise<TestEntity> | Promise<void> | void | TestEntity {}
}
// ------------------------------
// app.module.ts
import {LokiJSModule} from '@marxlnfcs/nest-lokijs';
@Module({
imports: [
LokiJSModule.forFeature(TestSubscriber)
]
})
export class AppModule {}
FAQs
A LokiJS Module for NestJS
The npm package @marxlnfcs/nest-lokijs receives a total of 0 weekly downloads. As such, @marxlnfcs/nest-lokijs popularity was classified as not popular.
We found that @marxlnfcs/nest-lokijs 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.