- Install NodeJs: https://nodejs.org/
- Install Postman: https://www.postman.com/
- Install XAMPP: https://www.apachefriends.org/
- Install NestJs CLI:
npm i -g @nestjs/cli
- Run
nest new project-name
to create a new NestJs project
- Change the directory to the new project and run
npm run start:dev
to start the NestJs server
Session 1: Creating GET endpoints
- Create an endpoint that returns a string "Hello World!".
- Create an endpoint that subtracts two numbers.
- Create an endpoint that sums two numbers.
- Create an endpoint that multiplies two numbers.
- Create an endpoint that divides two numbers.
- Create an endpoint that given an operation and a string of numbers separated by
,
, returns the result of the operation applied to the numbers.
- Create an endpoint that returns a list of available movies (title and id).
- Add query params to the endpoint from point 1 to sort the movies by title ascending or descending.
- Create an endpoint that returns movie details given the movie id.
- Create an endpoint that returns a random quote.
- Create an endpoint that returns a random dog photo.
Session 2: Creating CRUD endpoints connected to a database
- Create a new NestJs application using
nest new session2
- Run
npm install --save @nestjs/typeorm typeorm mysql2
- Create a
ormconfig.ts
file at ./src
level with the following content:
import { DataSourceOptions } from 'typeorm';
const config: DataSourceOptions = {
type: 'mysql',
host: 'localhost',
port: 3306,
username: 'root',
password: '',
database: '<<NAME OF THE DATABASE>>',
entities: [__dirname + '/**/*.entity.{ts,js}'],
synchronize: true,
};
export = config;
- In
app.module.ts
, add TypeOrmModule.forRoot(ormconfig)
to the imports
array, with import * as ormconfig from './ormconfig'
a an import.
- Create an endpoint that (c)reates a new user.
- Create an endpoint that (r)eads and returns a user given the user id.
- Create an endpoint that (u)pdates a user given the user id.
- Create an endpoint that (d)eletes a user given the user id.
- Create an endpoint that creates a song (title, artist, length ...).
- Create an endpoint that creates a playlist (playlist name, songs).
- Create an endpoint that updates a playlist with a given song.
- Create an endpoint that removes a song from a playlist.
- Create an endpoint that returns a list of available playlists.
- Create an endpoint that returns a list of songs in a playlist.