Appearance
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
Clone the nestkit-starter repository or download the source code
bashgit clone https://github.com/deeepvision/nestkit-starter.git
Navigate to the project directory
bashcd nestkit-starter
Install dependencies using your preferred package manager (npm or yarn)
bashnpm install # or yarn install
Configuration
Start the local database with
npm run docker:up
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.Update the AppModule
In the
src/app.module.ts
file, import and register any additional NestKit modules that you need for your project. Update theimports
array accordingly.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.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:bashnpm 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.
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:
bashnpm 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.
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:bashnpm i -g @deeepvision/nestkit-cli
Once you have the
nestkit-cli
installed, you need to create system roles such assuperadmin
,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:
bashnestkit 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:
bashnestkit 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:bashnestkit 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 theSERVICE_ACCOUNT_APP_ID
environment variable with this ID before starting your application.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.