This is a standalone sample app showing how to use the @nestjsplus/knex package for integrating Knex.js with Nest. You may also want to read about building dynamic modules in NestJS, and a custom schematic for generating modules based on that pattern.
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.
git clone https://github.com/nestjsplus/knex-cats
Creates a folder called knex-cats
cd knex-cats
This example assumes you have a PostgreSQL installation available. You'll need to add the PostgreSQL database credentials.
The example uses NestJS Configuration Manager 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=<localhost, or IP address of your PostgreSQL server>
port=<port PostgreSQL listens on>
database=<database name>
user=<database user>
password=<database password>
npm install
npm run start:dev
See the docs for more.
See Changelog for more information.
Contributions welcome! See Contributing.
John Biundo (Y Prospect on Discord)
Licensed under the MIT License - see the LICENSE file for details.