A progressive Node.js framework for building efficient and scalable server-side applications.
Nest framework TypeScript starter repository.
$ npm install# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prodPremière installation
npm i -g @nest/cliPour avoir de l'aide
nest --help0 - Création du workspace Nest avec la commande
nest new nestjs-api-book1 - Création du CRUD pour la ressource Book
nest generate ressource books
# OU de son abréviation
nest g res books1.1 - Installation de dotenv
npm i dotenvet importation dans le app.module.ts
import * as dotenv from 'dotenv';2 - Installation de TypeOrm
npm i @nestjs/typeorm typeorm pg2.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