Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nestjsplus/knex-cats

Sample app using @nestjsplus/knex
https://github.com/nestjsplus/knex-cats

Last synced: about 2 months ago
JSON representation

Sample app using @nestjsplus/knex

Awesome Lists containing this project

README

        



Nest Logo

Sample App for @nestjsplus/knex



License
npm version Built with NestJS

### What?

This is a standalone sample app showing how to use the [@nestjsplus/knex](https://github.com/nestjsplus/knex) package for integrating [Knex.js](http://knexjs.org) with [Nest](https://nestjs.com). You may also want to read about [building dynamic modules in NestJS](https://dev.to/nestjs/advanced-nestjs-how-to-build-completely-dynamic-nestjs-modules-1370), and a [custom schematic for generating modules based on that pattern](https://dev.to/nestjs/build-a-nestjs-module-for-knex-js-or-other-resource-based-libraries-in-5-minutes-12an).

You can clone and install it, and examine the source code to learn how to use the package.

The `src/app.controller.ts` file and `src/app.service.ts` files also demonstrate how to use a few basic Knex.js features.

### Installation

> git clone https://github.com/nestjsplus/knex-cats

Creates a folder called `knex-cats`

> cd knex-cats

#### Supply credentials

This example assumes you have a PostgreSQL installation available. You'll need to add the PostgreSQL database credentials.

The example uses [NestJS Configuration Manager](https://github.com/nestjsplus/config) to supply environment variables to the app. It's set up to expect a `development.env` file in a folder called `config` at the root level (a sibling to `src`). (You can change any of these settings, or use more features of *NestJS Configuration Manager* by reading the docs, or hard code your credentials, or use another config manager, etc.).

The `development.env` file should look like this:

```
host=
port=
database=
user=
password=
```

#### Install dependencies and run

> npm install

> npm run start:dev

See [the docs](https://github.com/nestjsplus/knex) for more.

### Change Log

See [Changelog](CHANGELOG.md) for more information.

### Contributing

Contributions welcome! See [Contributing](CONTRIBUTING.md).

### Author

**John Biundo (Y Prospect on [Discord](https://discord.gg/G7Qnnhy))**

### License

Licensed under the MIT License - see the [LICENSE](LICENSE) file for details.