Skip to content

DrEhsan/nestjs-package-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nestjs Package Building example

This repo is an example of how to build a reuasble package/library for NestJS framework

npm i
npm run build

Then you just use the package by installing it through package path

npm i PATH_TO_PACKAGE

Module registering

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { GladiatorModule } from 'gladiator'

@Module({
  imports: [GladiatorModule.register({
    weapon: 'Sword',
    name: 'Nikolaus',
    level: 19
  })],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

Service or Controller

import { Injectable } from '@nestjs/common';
import { GladiatorService } from 'gladiator';

@Injectable()
export class AppService {
  constructor(private readonly gladiatorService: GladiatorService) 
  {}

  async getGladiator(): Promise<boolean> {
    return await this.gladiatorService.IsUsingSword()
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published