All blogs / JavaScript / TypeScript
Marcin Wanago Blog
JavaScript blog focused on covering practical issues and explaining how the language works under the hood.
- Posts
- 372 from 1 Feb 2018 to 10 Mar 2025
- Posting
- now and then
- Kind
- personal blog
- Feed
- https://wanago.io/feed/
2025 10
- Big O notation: Avoiding common performance pitfalls
- API with NestJS #187. Rate limiting using Throttler
- Web Scraping with Playwright
- Beginner’s guide to Web Scraping with Cheerio
- API with NestJS #186. What’s new in Express 5?
- Machine Learning with TypeScript and TensorFlow: Training your first model
- API with NestJS #185. Operations with PostGIS Polygons in PostgreSQL and Drizzle
- API with NestJS #184. Storing PostGIS Polygons in PostgreSQL with Drizzle ORM
- API with NestJS #183. Distance and radius in PostgreSQL with Drizzle ORM
- API with NestJS #182. Storing coordinates in PostgreSQL with Drizzle ORM
2024 53
- API with NestJS #181. Prepared statements in PostgreSQL with Drizzle ORM
- API with NestJS #180. Organizing Drizzle ORM schema with PostgreSQL
- API with NestJS #179. Pattern matching search with Drizzle ORM and PostgreSQL
- API with NestJS #178. Storing files inside of a PostgreSQL database with Drizzle
- API with NestJS #177. Response serialization with the Drizzle ORM
- API with NestJS #176. Database migrations with the Drizzle ORM
- API with NestJS #175. PUT and PATCH requests with PostgreSQL and Drizzle ORM
- API with NestJS #174. Multiple PostgreSQL schemas with Drizzle ORM
- API with NestJS #173. Storing money with Drizzle ORM and PostgreSQL
- API with NestJS #172. Database normalization with Drizzle ORM and PostgreSQL
- API with NestJS #171. Recursive relationships with Drizzle ORM and PostgreSQL
- API with NestJS #170. Polymorphic associations with PostgreSQL and Drizzle ORM
- API with NestJS #169. Unique IDs with UUIDs using Drizzle ORM and PostgreSQL
- API with NestJS #168. Integration tests with the Drizzle ORM
- API with NestJS #167. Unit tests with the Drizzle ORM
- API with NestJS #166. Logging with the Drizzle ORM
- API with NestJS #165. Time intervals with the Drizzle ORM and PostgreSQL
- API with NestJS #164. Improving the performance with indexes using Drizzle ORM
- API with NestJS #163. Full-text search with the Drizzle ORM and PostgreSQL
- API with NestJS #162. Identity columns with the Drizzle ORM and PostgreSQL
- API with NestJS #161. Generated columns with the Drizzle ORM and PostgreSQL
- API with NestJS #160. Using views with the Drizzle ORM and PostgreSQL
- API with NestJS #159. Date and time with PostgreSQL and the Drizzle ORM
- API with NestJS #158. Soft deletes with the Drizzle ORM
- API with NestJS #157. Handling JSON data with PostgreSQL and the Drizzle ORM
- API with NestJS #156. Arrays with PostgreSQL and the Drizzle ORM
- API with NestJS #155. Offset and keyset pagination with the Drizzle ORM
- API with NestJS #154. Many-to-many relationships with Drizzle ORM and PostgreSQL
- API with NestJS #153. SQL transactions with the Drizzle ORM
- API with NestJS #152. SQL constraints with the Drizzle ORM
- API with NestJS #151. Implementing many-to-one relationships with Drizzle ORM
- API with NestJS #150. One-to-one relationships with the Drizzle ORM
- API with NestJS #149. Introduction to the Drizzle ORM with PostgreSQL
- Translating React apps with i18next and testing them End-to-End with Playwright
- Drag and Drop with React. Writing E2E tests using Playwright
- Implementing infinite scrolling with React. Writing E2E tests with Playwright
- JavaScript testing #18. E2E Playwright tests for uploading and downloading files
- JavaScript testing #17. Introduction to End-to-End testing with Playwright
- JavaScript testing #16. Snapshot testing with React, Jest, and Vitest
- API with NestJS #148. Understanding the injection scopes
- JavaScript testing #15. Interpreting the code coverage metric
- Comparing ECMAScript Modules and CommonJS
- Monorepos with Yarn Workspaces
- API with NestJS #147. The data types to store money with PostgreSQL and Prisma
- Understanding native JavaScript modules
- API with NestJS #146. Polymorphic associations with PostgreSQL and Prisma
- API with NestJS #145. Securing applications with Helmet
- API with NestJS #144. Creating CLI applications with the Nest Commander
- API with NestJS #143. Optimizing queries with views using PostgreSQL and Kysely
- API with NestJS #142. A video chat with WebRTC and React
- API with NestJS #141. Getting distinct records with Prisma and PostgreSQL
- API with NestJS #140. Using multiple PostgreSQL schemas with Prisma
- API with NestJS #139. Using UUID as primary keys with Prisma and PostgreSQL
2023 52
- React with Vite and TypeScript and its common challenges
- API with NestJS #138. Filtering records with Prisma
- API with NestJS #137. Recursive relationships with Prisma and PostgreSQL
- API with NestJS #136. Raw SQL queries with Prisma and PostgreSQL range types
- API with NestJS #135. Referential actions and foreign keys in PostgreSQL with Prisma
- API with NestJS #134. Aggregating statistics with PostgreSQL and Prisma
- API with NestJS #133. Introducing database normalization with PostgreSQL and Prisma
- API with NestJS #132. Handling date and time in PostgreSQL with Kysely
- API with NestJS #131. Unit tests with PostgreSQL and Kysely
- API with NestJS #130. Avoiding storing sensitive information in API logs
- API with NestJS #129. Implementing soft deletes with SQL and Kysely
- API with NestJS #128. Managing JSON data with PostgreSQL and Kysely
- API with NestJS #127. Arrays with PostgreSQL and Kysely
- API with NestJS #126. Improving the database performance with indexes and Kysely
- API with NestJS #125. Offset and keyset pagination with Kysely
- API with NestJS #124. Handling SQL constraints with Kysely
- API with NestJS #123. SQL transactions with Kysely
- API with NestJS #122. Many-to-many relationships with Kysely and PostgreSQL
- API with NestJS #121. Many-to-one relationships with PostgreSQL and Kysely
- API with NestJS #120. One-to-one relationships with the Kysely query builder
- API with NestJS #119. Type-safe SQL queries with Kysely and PostgreSQL
- API with NestJS #118. Uploading and streaming videos
- Introduction to managing a private NPM registry with Verdaccio
- API with NestJS #117. CORS – Cross-Origin Resource Sharing
- API with NestJS #116. REST API versioning
- API with NestJS #115. Database migrations with Prisma
- API with NestJS #114. Modifying data using PUT and PATCH methods with Prisma
- API with NestJS #113. Logging with Prisma
- API with NestJS #112. Serializing the response with Prisma
- API with NestJS #111. Constraints with PostgreSQL and Prisma
- API with NestJS #110. Managing JSON data with PostgreSQL and Prisma
- API with NestJS #109. Arrays with PostgreSQL and Prisma
- API with NestJS #108. Date and time with Prisma and PostgreSQL
- API with NestJS #107. Offset and keyset pagination with Prisma
- API with NestJS #106. Improving performance through indexes with Prisma
- API with NestJS #105. Implementing soft deletes with Prisma and middleware
- API with NestJS #104. Writing transactions with Prisma
- API with NestJS #103. Integration tests with Prisma
- API with NestJS #102. Writing unit tests with Prisma
- API with NestJS #101. Managing sensitive data using the AWS Secrets Manager
- API with NestJS #100. The HTTPS protocol with Route 53 and AWS Certificate Manager
- API with NestJS #99. Scaling the number of application instances with Amazon ECS
- API with NestJS #98. Health checks with Terminus and Amazon ECS
- API with NestJS #97. Introduction to managing logs with Amazon CloudWatch
- API with NestJS #96. Running unit tests with CI/CD and GitHub Actions
- API with NestJS #95. CI/CD with Amazon ECS and GitHub Actions
- API with NestJS #94. Deploying multiple instances on AWS with a load balancer
- API with NestJS #93. Deploying a NestJS app with Amazon ECS and RDS
- API with NestJS #92. Increasing the developer experience with Docker Compose
- API with NestJS #91. Dockerizing a NestJS API with Docker Compose
- API with NestJS #90. Using various types of SQL joins
- API with NestJS #89. Replacing Express with Fastify
2022 52
- API with NestJS #88. Testing a project with raw SQL using integration tests
- API with NestJS #87. Writing unit tests in a project with raw SQL
- API with NestJS #86. Logging with the built-in logger when using raw SQL
- API with NestJS #85. Defining constraints with raw SQL
- Introduction to Gatsby with TypeScript and GitHub Pages
- API with NestJS #84. Implementing filtering using subqueries with raw SQL
- API with NestJS #83. Text search with tsvector and raw SQL
- API with NestJS #82. Introduction to indexes with raw SQL queries
- API with NestJS #81. Soft deletes with raw SQL queries
- API with NestJS #80. Updating entities with PUT and PATCH using raw SQL queries
- API with NestJS #79. Implementing searching with pattern matching and raw SQL
- API with NestJS #78. Generating statistics using aggregate functions in raw SQL
- API with NestJS #77. Offset and keyset pagination with raw SQL queries
- API with NestJS #76. Working with transactions using raw SQL queries
- API with NestJS #75. Many-to-many relationships using raw SQL queries
- API with NestJS #74. Designing many-to-one relationships using raw SQL queries
- API with NestJS #73. One-to-one relationships with raw SQL queries
- API with NestJS #72. Working with PostgreSQL using raw SQL queries
- API with NestJS #71. Introduction to feature flags
- API with NestJS #70. Defining dynamic modules
- JavaScript testing #14. Mocking WebSockets using the mock-socket library
- JavaScript testing #13. Mocking a REST API with the Mock Service Worker
- API with NestJS #69. Database migrations with TypeORM
- API with NestJS #68. Interacting with the application through REPL
- API with NestJS #67. Migrating to TypeORM 0.3
- Introduction to performance testing with k6
- Rendering long lists using virtualization with React
- API with NestJS #66. Improving PostgreSQL performance with indexes using MikroORM
- API with NestJS #65. Implementing soft deletes using MikroORM and filters
- API with NestJS #64. Transactions with PostgreSQL and MikroORM
- API with NestJS #63. Relationships with PostgreSQL and MikroORM
- API with NestJS #62. Introduction to MikroORM with PostgreSQL
- Creating recursive and dynamic forms with React Hook Form and TypeScript
- Dynamic and recursive forms with Formik and TypeScript
- JavaScript testing #12. Testing downloaded files and file inputs with Cypress
- JavaScript testing #11. Spying on functions. Pitfalls of not resetting Jest mocks
- JavaScript testing #10. Advanced mocking with Jest and React Testing Library
- Using AbortController to deal with race conditions in React
- JavaScript testing #9. Replacing Enzyme with React Testing Library
- The Referer header and the importance of the Referrer-Policy
- The danger of iframe clickjacking and how to deal with it
- Countering MIME sniffing with X-Content-Type-Options and Content-Type headers
- Fighting cross-site-scripting (XSS) with content security policy
- API with NestJS #61. Dealing with circular dependencies
- Serial type versus identity columns in PostgreSQL and TypeORM
- API with NestJS #60. The OpenAPI specification and Swagger
- Measuring performance with Web Vitals and React
- API with NestJS #59. Introduction to a monorepo with Lerna and Yarn workspaces
- Managing objects with unknown structures in TypeScript using index signatures
- API with NestJS #58. Using ETag to implement cache and save bandwidth
- Preventing man-in-the-middle attacks with Strict Transport Security
- Managing WebSockets with Redux Toolkit Query and TypeScript
2021 52
- Introduction to Redux Toolkit Query with TypeScript
- Redux middleware and how to use it with WebSockets
- API with NestJS #57. Composing classes with the mixin pattern
- Creating views with PostgreSQL and TypeORM
- Defining generated columns with PostgreSQL and TypeORM
- The basics of database normalization with TypeORM and PostgreSQL
- API with NestJS #56. Authorization with roles and claims
- API with NestJS #55. Uploading files to the server
- API with NestJS #54. Storing files inside a PostgreSQL database
- API with NestJS #53. Implementing soft deletes with PostgreSQL and TypeORM
- API with NestJS #52. Generating documentation with Compodoc and JSDoc
- API with NestJS #51. Health checks with Terminus and Datadog
- API with NestJS #50. Introduction to logging with the built-in logger and TypeORM
- API with NestJS #49. Updating with PUT and PATCH with MongoDB and Mongoose
- API with NestJS #48. Definining indexes with MongoDB and Mongoose
- API with NestJS #47. Implementing pagination with MongoDB and Mongoose
- API with NestJS #46. Managing transactions with MongoDB and Mongoose
- API with NestJS #45. Virtual properties with MongoDB and Mongoose
- API with NestJS #44. Implementing relationships with MongoDB
- API with NestJS #43. Introduction to MongoDB
- Defining constraints with PostgreSQL and TypeORM
- Getting geeky with Git #11. Keeping our Git history clean with fixup commits
- API with NestJS #42. Authenticating users with Google
- API with NestJS #41. Verifying phone numbers and sending SMS messages with Twilio
- API with NestJS #40. Confirming the email address
- API with NestJS #39. Reacting to Stripe events with webhooks
- API with NestJS #38. Setting up recurring payments via subscriptions with Stripe
- API with NestJS #37. Using Stripe to save credit cards for future use
- API with NestJS #36. Introduction to Stripe with React
- API with NestJS #35. Using server-side sessions instead of JSON Web Tokens
- Getting geeky with Git #10. The overview of Git hooks with Husky
- Getting geeky with Git #9. Understanding the revert feature
- Range types in PostgreSQL and TypeORM
- Uncaught errors in Node.js and the browser
- API with NestJS #34. Handling CPU-intensive tasks with queues
- A generic confirmation modal with Redux, Redux Toolkit, and TypeScript
- Comparing the HashRouter and the BrowserRouter in React applications
- Using React components written in JavaScript within TypeScript code
- API with NestJS #33. Managing PostgreSQL relationships with Prisma
- API with NestJS #32. Introduction to Prisma with PostgreSQL
- Time intervals with PostgreSQL and TypeORM
- Managing date and time with PostgreSQL and TypeORM
- API with NestJS #31. Two-factor authentication
- GraphQL on the client side with Apollo, React, and TypeScript
- API with NestJS #30. Scalar types in GraphQL
- API with NestJS #29. Real-time updates with GraphQL subscriptions
- API with NestJS #28. Dealing in the N + 1 problem in GraphQL
- API with NestJS #27. Introduction to GraphQL. Queries, mutations, and authentication
- API with NestJS #26. Real-time chat with WebSockets
- API with NestJS #25. Sending scheduled emails with cron and Nodemailer
- API with NestJS #24. Cache with Redis. Running the app in a Node.js cluster
- API with NestJS #23. Implementing in-memory cache to increase the performance
2020 52
- API with NestJS #22. Storing JSON with PostgreSQL and TypeORM
- Dealing with some CSRF attacks using the SameSite cookies
- Increasing security of Express applications with the Helmet middleware
- API with NestJS #21. An introduction to CQRS
- API with NestJS #20. Communicating with microservices using the gRPC framework
- API with NestJS #19. Using RabbitMQ to communicate with microservices
- API with NestJS #18. Exploring the idea of microservices
- API with NestJS #17. Offset and keyset pagination with PostgreSQL and TypeORM
- API with NestJS #16. Using the array data type with PostgreSQL and TypeORM
- API with NestJS #15. Defining transactions with PostgreSQL and TypeORM
- API with NestJS #14. Improving performance of our Postgres database with indexes
- Getting geeky with Git #8. Improving our debugging flow with Bisect and Worktree
- Building forms with React Hook Form and TypeScript
- React Context API with hooks and TypeScript
- API with NestJS #13. Implementing refresh tokens using JWT
- Getting geeky with Git #7. Cherry Pick with Reflog
- API with NestJS #12. Introduction to Elasticsearch
- Introduction to AWS Lambda. Managing a contact form with Simple Email Service
- Getting geeky with Git #6. Interactive Rebase
- Generating changelog automatically with Standard Version
- API with NestJS #11. Managing private files with Amazon S3
- API with NestJS #10. Uploading public files to Amazon S3
- Getting geeky with Git #5. Improving merge workflow with rebase
- Getting geeky with Git #4. Fast-forward merge and merge strategies
- API with NestJS #9. Testing services and controllers with integration tests
- API with NestJS #8. Writing unit tests
- Structural type system and polymorphism in TypeScript. Type guards with predicates
- API with NestJS #7. Creating relationships with Postgres and TypeORM
- API with NestJS #6. Looking into dependency injection and modules
- API with NestJS #5. Serializing the response with interceptors
- API with NestJS #4. Error handling and data validation
- API with NestJS #3. Authenticating users with bcrypt, Passport, JWT, and cookies
- API with NestJS #2. Setting up a PostgreSQL database with TypeORM
- API with NestJS #1. Controllers, routing and the module structure
- Getting geeky with Git #3. The branch is a reference
- TypeScript Express tutorial #15. Using PUT vs PATCH in MongoDB with Mongoose
- TypeScript Express tutorial #14. Code optimization with Mongoose Lean Queries
- Getting geeky with Git #2. Building blocks of a commit
- Getting geeky with Git #1. Remotes and upstream branches
- Building forms using Formik with the React Hooks API and TypeScript
- What’s the deal with immutability in JavaScript?
- TypeScript type inference with const assertions and the infer keyword
- Functional React components with generic props in TypeScript
- Race conditions in React and beyond. A race condition guard with TypeScript
- More advanced types with TypeScript generics
- TypeScript Generics. Discussing naming conventions
- TypeScript Express tutorial #13. Using Mongoose virtuals to populate documents
- Applying SOLID principles to your TypeScript code
- Understanding any and unknown in TypeScript. Difference between never and void
- JavaScript design patterns #5. The Observer pattern with TypeScript
- JavaScript testing #8. Integrating Cypress with Cucumber and Gherkin
- JavaScript testing #7. Diving deeper into commands and selectors in Cypress
2019 52
- JavaScript testing #6. Introduction to End-to-End testing with Cypress
- JavaScript design patterns #4. Decorators and their implementation in TypeScript
- JavaScript testing #5. Testing hooks with react-hooks-testing-library and Redux
- JavaScript design patterns #3. The Facade pattern and applying it to React Hooks
- JavaScript design patterns #2. Factories and their implementation in TypeScript
- Exploring the caching in the browser. Clarifying the cache-control header
- Understanding the useEffect hook in React. Designing custom hooks
- JavaScript design patterns #1. Singleton and the Module
- Current state of the Concurrent Mode in React
- Writing React forms with Formik. Validating data using Yup
- Understanding JavaScript Proxy. Preserving backward compatibility in a library
- TypeScript Express tutorial #12. Creating a CI/CD pipeline with Travis and Heroku
- Measuring the quality of the User Experience with the User Timing API
- Improving our code with pure functions
- Regex course – part four. Avoiding catastrophic backtracking using lookahead
- Bug-proofing our application with Error Boundaries and the Strict Mode
- Installing a Progressive Web App. Writing a Web App Manifest
- Internationalization API built into your browser
- Introduction to Data-Driven Documents. The basics of D3.js
- Making the job of garbage collector easier by replacing the Map with the WeakMap
- The process of rendering a page. Increasing the performance by reducing browser reflow
- Improving our performance, accessibility, and SEO with Lighthouse audits
- Creating a Material Design slider with Web Components. The Shadow DOM concept
- TypeScript Express tutorial #11. Node.js Two-Factor Authentication
- Node.js TypeScript #15. Benefits of the HTTP/2 protocol
- Algorithm React uses to update the view. Increasing the performance of a component
- What are symbols and how they can be useful to you
- Creating a simple drawing app using canvas. Saving and loading images
- Using Push Notifications with Service Workers and Node.js
- The basics of Service Workers: how should our application behave when offline?
- React SSR with Next.js #2. Prefetching the data with getInitialProps
- React SSR with Next.js #1. Concept of Server Side Rendering & basics of routing
- Node.js TypeScript #14. Measuring processes & worker threads with Performance Hooks
- Node.js TypeScript #13. Sending data between Worker Threads
- Node.js TypeScript #12. Introduction to Worker Threads with TypeScript
- Node.js TypeScript #11. Harnessing the power of many processes using a cluster
- Node.js TypeScript #10. Is Node.js single-threaded? Creating child processes
- Creating malicious packages and dealing with them using npm audit
- Node.js TypeScript #9. The Event Loop in Node.js
- Node.js TypeScript #8. Implementing HTTPS with our own OpenSSL certificate
- Node.js TypeScript #7. Creating a server and receiving requests
- Node.js TypeScript #6. Sending HTTP requests, understanding multipart/form-data
- Node.js TypeScript #5. Writable streams, pipes, and the process streams
- Node.js TypeScript #4. Paused and flowing modes of a readable stream
- Node.js TypeScript #3. Explaining the Buffer
- Node.js TypeScript #2. The synchronous nature of the EventEmitter
- Node.js TypeScript #1. Modules, process arguments, basics of the File System
- TypeScript Express tutorial #10. Testing Express applications
- TypeScript Express tutorial #9. The basics of migrations using TypeORM and Postgres
- TypeScript Express tutorial #8. Types of relationships with Postgres and TypeORM
- TypeScript Express tutorial #7. Relational databases with Postgres and TypeORM
- TypeScript Express tutorial #6. Basic data processing with MongoDB aggregation
2018 49
- TypeScript Express tutorial #5. MongoDB relationships between documents
- TypeScript Express tutorial #4. Registering users and authenticating with JWT
- TypeScript Express tutorial #3. Error handling and validating incoming data
- TypeScript Express tutorial #2. MongoDB, models and environment variables
- TypeScript Express tutorial #1. Middleware, routing, and controllers
- Using recursion to traverse data structures. Execution context and the call stack
- Is eval evil? Just In Time (JIT) compiling
- Handling errors in JavaScript with try…catch and finally
- Cross-Origin Resource Sharing. Avoiding Access-Control-Allow-Origin CORS error
- Comparing working with JSON using the XHR and the Fetch API
- Concatenating strings with template literals. Tagged templates
- Explaining the JavaScript array. Sparse and dense arrays.
- Fundamentals of storing data in the browser with IndexedDB
- Object property descriptors. Getters and setters
- Introduction to WebSockets. Creating a Node.js server and using WebSocket API in the browser
- JavaScript testing #4. Mocking API calls and simulating React components interactions
- JavaScript testing #3. Testing props, the mount function and snapshot tests.
- JavaScript testing #2. Introducing Enzyme and testing React components
- JavaScript testing #1. Explaining types of tests. Basics of unit testing with Jest
- Webpack 4 course – part eight. Dynamic imports with prefetch and preload
- Webpack 4 course – part seven. Decreasing the bundle size with tree shaking
- Webpack 4 course – part six. Increasing development experience
- Webpack 4 course – part five. Built-in optimization for production
- Webpack 4 course – part three. Working with plugins
- Webpack 4 course – part two. Using loaders to handle scss, image files and transpile JS
- Webpack 4 course – part one. Entry, output and ES6 modules
- Diving deeper into the Event object. Creating and using custom events
- Understanding events. Bubbling and capturing
- Understanding memory management and the garbage collector.
- Cookies: explaining document.cookie and the Set-Cookie header.
- Web Storage API: localStorage and sessionStorage
- Webpack 4 course – part four. Code splitting with SplitChunksPlugin
- Diving into functions. Passing by reference is a lie!
- Keeping your dependencies in order when using NPM.
- Regex course – part three. Grouping and using ES6 features.
- Regex course – part two. Writing more elegant and precise patterns.
- Regex course – part one. Basic concepts.
- Demystifying generators. Implementing async/await.
- Explaining async/await. Creating dummy promises.
- Explaining promises and callbacks while implementing a sorting algorithm.
- [1] + [2] – [3] === 9!? Looking into assembly code of coercion.
- Scopes in JavaScript. Different types of variable declarations.
- Prototype. The big bro behind ES6 class.
- Defining the undefined. A try/catch trick.
- Priority of CSS declarations. A smart way to avoid !important
- What is “this”? Arrow functions.
- Current state of compiling TypeScript to WebAssembly
- Cloning objects in JavaScript. Looking under the hood of reference and primitive types.
- When async is just not enough. An introduction to multithreading in the browser