Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nestely

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestely

Nestedly is a NestJS Provider for the Kysely query builder

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

build-deploy License: MIT Coverage Status npm type definitions current-version Nest Logo

Table of Contents

Table of contents generated with markdown-toc

Nestely

About

Nestely is a NestJs module that integrates Kysely into your NestJs application.

What else does this module do?

Nothing else really. It just provides a way to inject the Kysely instance into your services/controllers/repositories. I created this module just to avoid the same boilerplate code in every NestJs project I create.

This project has been tested with

  • Kysely 0.24
  • SQLite3

Installation

Install the latest version of Nestely using npm:

npm install nestely

NestJs Configuration Nest Logo

In order to configure the module with your NestJs application, you need to import the NestelyModule into your AppModule (or any other module).

import { Module } from '@nestjs/common';
import { NestelyModule } from 'nestely';

@Module({
  imports: [
    NestelyModule.register({
      plugins: [new CamelCasePlugin()],
      dialect: new SqliteDialect({
        database: new SQLite(':memory:'),
      }),
      isGlobal: true,
    }),
    // Asynchronous configuration
    NestelyModule.registerAsync({
      useFactory: () => ({
        dialect: new SqliteDialect({
          database: new SQLite(':memory:'),
        }),
        plugins: [new CamelCasePlugin()],
      }),
      isGlobal: false, // default is true
    }),
  ],
})
export class AppModule {}
Using the Kysely instance

Once the module is configured, you can inject the Kysely instance into your services/controllers/repositories using the @InjectKysely() decorator.

import { Injectable } from '@nestjs/common';
import { InjectKysely, Kysely } from 'nestely';
import { DB } from './db.interface';

@Injectable()
export class AppService {
  // provide the DB interface
  constructor(@InjectKysely() private readonly kysely: Kysely<DB>) {}

  async findAll(): Promise<void> {
    const result = await sql`select 1+1 as result`.execute(this.kysely);
    console.log(result); // { rows: [ { result: 2 } ] }
  }
}

Keywords

FAQs

Package last updated on 18 Jul 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc