Skip to content

Getting Started with NestKit

To get started with NestKit, you can use the nestkit-starter project as a solid foundation for your application. The nestkit-starter project is a pre-configured NestJS template that includes various NestKit modules to help you build your application more efficiently. Follow these steps to install NestKit using the nestkit-starter project and modify it according to your needs.

Prerequisites

Before you can start using NestKit, make sure that you have the following prerequisites installed and set up:

  • Node.js (version 18 or higher)
  • npm or yarn (package managers)

Installation

  1. Clone the nestkit-starter repository or download the source code

    bash
    git clone https://github.com/deeepvision/nestkit-starter.git
  2. Navigate to the project directory

    bash
    cd nestkit-starter
  3. Install dependencies using your preferred package manager (npm or yarn)

    bash
    npm install
    # or
    yarn install

Configuration

  1. Start the local database with npm run docker:up

  2. Configure the necessary modules in the src/config directory

    Modify the configuration files in the src/config directory according to your project requirements. For example, update the database connection settings, authentication settings, and other module configurations as needed.

  3. Update the AppModule

    In the src/app.module.ts file, import and register any additional NestKit modules that you need for your project. Update the imports array accordingly.

  4. Remove any unnecessary components

    If there are any components, services, or other parts of the nestkit-starter project that you do not need for your application, remove them to keep your project lean and maintainable.

  5. Build migration files

    Before you can run migrations, you need to build the project. Building the project will create a dist directory containing the compiled migrations files from your TypeScript source code. To build the application, run the following command:

    bash
    npm run build

    This command will compile your TypeScript files and create a dist folder with the generated JavaScript files. Make sure there are no errors during the build process.

  6. Run Migrations

    After building the application, you need to run the database migrations to create the necessary tables and structures in your database. To run the migrations, execute the following command:

    bash
    npm run migration:run

    This command will run the migration scripts found in your project and update the database schema accordingly. Ensure that the migrations are executed successfully and there are no errors.

  7. Seed the Database

    To seed your database with initial data, you can use the nestkit-cli package provided by DeepVision. This CLI tool will help you to seed your database with the necessary data for your application.

    First, install the @deeepvision/nestkit-cli package globally on your system by running the following command:

    bash
    npm i -g @deeepvision/nestkit-cli

    Once you have the nestkit-cli installed, you need to create system roles such as superadmin, orgadmin, user, etc. These roles are essential for managing the different levels of access and permissions within your application.

    To seed the database with these system roles, run the following command:

    bash
    nestkit db seed system-roles

    All roles, except for superadmin, will be created with a minimal set of permissions. As you develop your application and add new modules or implement specific business logic, you will need to update and manage the permissions list for each role accordingly.

    To create a superadmin user in your NestKit application, use the following command:

    bash
    nestkit db seed superadmin

    This command will seed your database with a superadmin user, who will have the highest level of permissions and access to all features and modules within your application. Make sure to handle this user role carefully, as it grants complete control over your system.

    Before starting your NestKit application, you need to create an app service account and set its ID in the SERVICE_ACCOUNT_APP_ID environment variable. To do this, run the following command:

    bash
    nestkit db seed app-sa

    This command will seed your database with an app service account and provide you with its ID. Make sure to set the SERVICE_ACCOUNT_APP_ID environment variable with this ID before starting your application.

  8. Start the NestJS application with npm run start:dev

    This command will start your application in development mode with live-reloading enabled.

Now, you have a NestJS application powered by NestKit and configured to your needs. You can begin building your application features using the NestKit modules and their associated utilities. Remember to consult the NestKit documentation for guidance on using each module effectively.

Created by DeepVision Software.