SlideShare a Scribd company logo
End to end todo list app with
NestJs - Angular - Redux &
Redux Saga
Babacar NIANG
Agenda
Create nest API
Create Angular App
What about Redux ?
Managing angular store
Who I am ?
Console.log(me);
{
fullName: ‘Babacar NIANG’,
nicknames: [‘Basse’, ‘eagledev’],
company: ‘Weego’,
twitter: ‘@Babacar_Basse’,
email: ‘babacar.basse@esp.sn’
}
NestJs
A new framework for building efficient, scalable Node.js
server-side applications.
It uses JavaScript, is built with and fully supports TypeScript.
Also allows developers to code in pure JavaScript
npm install -g @nestjs/cli
nest new dpjs-weego
nest generate module
NestJs
First determine the DTO (Data Transfer Object) schema request
A DTO is an object that defines how the data will be sent over the network.
Define endpoint:
@Post()
async createTodo(@Body() todo: TodoDTO)
Url with parameters
@Get(‘id’)
findOne(@Param('id') id: string)
How to allow request with a specific payload ?
NestJs
npm install --save @nestjs/mongoose mongoose
MongoDB with Nest ?
Import MongooseModule into app.module
MongooseModule.forRoot('mongodb://localhost/nest')
Create Schemas DB
Import Schema model into the module
MongooseModule.forFeature([{ name: 'Todo', schema: TodoSchema }])
Finally inject the Model in the service
constructor(@InjectModel('Todo') private readonly todoModel:
Model<ITodo>) {}
NestJs
https://docs.nestjs.com/techniques/hot-reload
For hot reload
Exception filters
throw new HttpException('todo not found', HttpStatus.NOT_FOUND);
Create
Angular
App
https://angular.io/docs
npm install -g @angular/cli
What
about
Redux ?
State management library for applications
Managing
angular
store
@ngrx
npm install --save @ngrx/core
npm install --save @ngrx/effects
npm install --save @ngrx/entity
npm install --save @ngrx/router-store
npm install --save @ngrx/store
npm install --save @ngrx/store-devtools
Managing
angular
store
Create store
store
actions
effects
reducers
selectors
state
Interface App State
export interface IAppState {
router?: RouterReducerState;
}
App Reducers
export const appReducers: ActionReducerMap<IAppState, any> = {
router: routerReducer,
};
Managing
angular
store
StoreRouterConnectingModule.forRoot({ stateKey: 'router' }),
!environment.production ? StoreDevtoolsModule.instrument() : [],
EffectsModule.forRoot(AllEffects),
Import Store Router, StoreDevTools and Effects modules into app.module
StoreModule.forRoot(appReducers)
Import Store with appReducers forRoot into app.module
Managing
angular
store
Create todo Actions
export class GetTodoList implements Action {
public readonly type = ETodoActions.GetTodoList;
constructor() {}
}
.
….
export type TodoListActions = GetTodoList | GetTodoListSuccess |
GetTodoListError;
Create todo State
export interface ITodoListState {
data: Array<ITodo>;
loaded: boolean;
loading: boolean;
error: any;
}
Managing
angular
store
Create todo reducer
export function todoReducer(state = initialTodoListState,
action: TodoActions): ITodoListState {
switch(action.type) {
…..
default: return state;
}
}
Add todo state to App State
export interface IAppState {
router?: RouterReducerState;
todolist: ITodoListState
}
Add todo reducer into App Reducers
export const appReducers: ActionReducerMap<IAppState, any> = {
router: routerReducer,
todolist: todoReducer
};
Managing
angular
store
Create todo selector
export const selectTodoList = (state: IAppState) => state.todolist;
Create todo effects
@Injectable()
export class TodoEffects {
@Effect()
getTodoList$ = this.action$.pipe(
ofType<GetTodoList>(ETodoActions.GetTodoList),
switchMap(() => this.todoService.getTodoList()),
switchMap(todos => of(new GetTodoListSuccess(todos))),
catchError(err => of(new GetTodoListError(err)))
);
constructor(private action$: Actions, private todoService: TodoService) {}
}
Managing
angular
store
Select todo List state from the store
$todoListState = this.store.pipe(select(selectTodoList));
https://ngrx.io/docs
For more documentation
https://github.com/babacarbasse/todolist-app
Repo Github
Kill -9

More Related Content

What's hot

SOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principlesSOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principles
Sergey Karpushin
 

What's hot (20)

Introduction to JSX
Introduction to JSXIntroduction to JSX
Introduction to JSX
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 
gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!
 
React js t2 - jsx
React js   t2 - jsxReact js   t2 - jsx
React js t2 - jsx
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean Architecture
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
Full Stack Flutter Testing
Full Stack Flutter Testing Full Stack Flutter Testing
Full Stack Flutter Testing
 
Express JS
Express JSExpress JS
Express JS
 
Express node js
Express node jsExpress node js
Express node js
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first steps
 
Java 8 Lambda Built-in Functional Interfaces
Java 8 Lambda Built-in Functional InterfacesJava 8 Lambda Built-in Functional Interfaces
Java 8 Lambda Built-in Functional Interfaces
 
Mock Server Using WireMock
Mock Server Using WireMockMock Server Using WireMock
Mock Server Using WireMock
 
Json Web Token - JWT
Json Web Token - JWTJson Web Token - JWT
Json Web Token - JWT
 
How to go about testing in React?
How to go about testing in React? How to go about testing in React?
How to go about testing in React?
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
SOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principlesSOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principles
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 

Similar to End to end todo list app with NestJs - Angular - Redux & Redux Saga

Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
Yekmer Simsek
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
Igor Bronovskyy
 

Similar to End to end todo list app with NestJs - Angular - Redux & Redux Saga (20)

React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
 
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
 
Simple React Todo List
Simple React Todo ListSimple React Todo List
Simple React Todo List
 
Heroku pop-behind-the-sense
Heroku pop-behind-the-senseHeroku pop-behind-the-sense
Heroku pop-behind-the-sense
 
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
How To Integrate Native Android App With React Native.
How To Integrate Native Android App With React Native.How To Integrate Native Android App With React Native.
How To Integrate Native Android App With React Native.
 
Building a dashboard using AngularJS
Building a dashboard using AngularJSBuilding a dashboard using AngularJS
Building a dashboard using AngularJS
 
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
 
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
Angular Js Basics
Angular Js BasicsAngular Js Basics
Angular Js Basics
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 
React django
React djangoReact django
React django
 
Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6
 
Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Building and deploying React applications
Building and deploying React applicationsBuilding and deploying React applications
Building and deploying React applications
 

Recently uploaded

RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
Atif Razi
 
Digital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfDigital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdf
AbrahamGadissa
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
Kamal Acharya
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 

Recently uploaded (20)

Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
 
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docxThe Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge
 
Digital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfDigital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdf
 
fluid mechanics gate notes . gate all pyqs answer
fluid mechanics gate notes . gate all pyqs answerfluid mechanics gate notes . gate all pyqs answer
fluid mechanics gate notes . gate all pyqs answer
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
Explosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdfExplosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdf
 
Pharmacy management system project report..pdf
Pharmacy management system project report..pdfPharmacy management system project report..pdf
Pharmacy management system project report..pdf
 
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationKIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
 
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
Natalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in KrakówNatalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in Kraków
 

End to end todo list app with NestJs - Angular - Redux & Redux Saga

  • 1. End to end todo list app with NestJs - Angular - Redux & Redux Saga Babacar NIANG
  • 2. Agenda Create nest API Create Angular App What about Redux ? Managing angular store Who I am ?
  • 3. Console.log(me); { fullName: ‘Babacar NIANG’, nicknames: [‘Basse’, ‘eagledev’], company: ‘Weego’, twitter: ‘@Babacar_Basse’, email: ‘babacar.basse@esp.sn’ }
  • 4. NestJs A new framework for building efficient, scalable Node.js server-side applications. It uses JavaScript, is built with and fully supports TypeScript. Also allows developers to code in pure JavaScript npm install -g @nestjs/cli nest new dpjs-weego nest generate module
  • 5. NestJs First determine the DTO (Data Transfer Object) schema request A DTO is an object that defines how the data will be sent over the network. Define endpoint: @Post() async createTodo(@Body() todo: TodoDTO) Url with parameters @Get(‘id’) findOne(@Param('id') id: string) How to allow request with a specific payload ?
  • 6. NestJs npm install --save @nestjs/mongoose mongoose MongoDB with Nest ? Import MongooseModule into app.module MongooseModule.forRoot('mongodb://localhost/nest') Create Schemas DB Import Schema model into the module MongooseModule.forFeature([{ name: 'Todo', schema: TodoSchema }]) Finally inject the Model in the service constructor(@InjectModel('Todo') private readonly todoModel: Model<ITodo>) {}
  • 7. NestJs https://docs.nestjs.com/techniques/hot-reload For hot reload Exception filters throw new HttpException('todo not found', HttpStatus.NOT_FOUND);
  • 9. What about Redux ? State management library for applications
  • 10. Managing angular store @ngrx npm install --save @ngrx/core npm install --save @ngrx/effects npm install --save @ngrx/entity npm install --save @ngrx/router-store npm install --save @ngrx/store npm install --save @ngrx/store-devtools
  • 11. Managing angular store Create store store actions effects reducers selectors state Interface App State export interface IAppState { router?: RouterReducerState; } App Reducers export const appReducers: ActionReducerMap<IAppState, any> = { router: routerReducer, };
  • 12. Managing angular store StoreRouterConnectingModule.forRoot({ stateKey: 'router' }), !environment.production ? StoreDevtoolsModule.instrument() : [], EffectsModule.forRoot(AllEffects), Import Store Router, StoreDevTools and Effects modules into app.module StoreModule.forRoot(appReducers) Import Store with appReducers forRoot into app.module
  • 13. Managing angular store Create todo Actions export class GetTodoList implements Action { public readonly type = ETodoActions.GetTodoList; constructor() {} } . …. export type TodoListActions = GetTodoList | GetTodoListSuccess | GetTodoListError; Create todo State export interface ITodoListState { data: Array<ITodo>; loaded: boolean; loading: boolean; error: any; }
  • 14. Managing angular store Create todo reducer export function todoReducer(state = initialTodoListState, action: TodoActions): ITodoListState { switch(action.type) { ….. default: return state; } } Add todo state to App State export interface IAppState { router?: RouterReducerState; todolist: ITodoListState } Add todo reducer into App Reducers export const appReducers: ActionReducerMap<IAppState, any> = { router: routerReducer, todolist: todoReducer };
  • 15. Managing angular store Create todo selector export const selectTodoList = (state: IAppState) => state.todolist; Create todo effects @Injectable() export class TodoEffects { @Effect() getTodoList$ = this.action$.pipe( ofType<GetTodoList>(ETodoActions.GetTodoList), switchMap(() => this.todoService.getTodoList()), switchMap(todos => of(new GetTodoListSuccess(todos))), catchError(err => of(new GetTodoListError(err))) ); constructor(private action$: Actions, private todoService: TodoService) {} }
  • 16. Managing angular store Select todo List state from the store $todoListState = this.store.pipe(select(selectTodoList)); https://ngrx.io/docs For more documentation https://github.com/babacarbasse/todolist-app Repo Github