Skip to content

Louifine/nest-api-books

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description

Nest framework TypeScript starter repository.

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Step to init the project

Première installation

npm i -g @nest/cli

Pour avoir de l'aide

nest --help

0 - Création du workspace Nest avec la commande

nest new nestjs-api-book

1 - Création du CRUD pour la ressource Book

nest generate ressource books

# OU de son abréviation
nest g res books

1.1 - Installation de dotenv

npm i dotenv

et importation dans le app.module.ts

import * as dotenv from 'dotenv';

2 - Installation de TypeOrm

npm i @nestjs/typeorm typeorm pg

2.1 - Changement du port et ajout d'un préfixe global (modification de la fonction bootstrap)

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.setGlobalPrefix('api');
  await app.listen(8080);
}

2.2 - Injection du du repository Book à l'aide de TypeOrm dans le module Book

@Module({
  imports: [TypeOrmModule.forFeature([Book])],
  controllers: [BooksController],
  providers: [BooksService],
})
export class BooksModule {}

3 - Injection du repository et complétion du book service

4 - Création de la collection Thunderclient

installation de l'extention Thunderclient

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors