nodejs

Typescript and Jest

May 15, 2020
babel, javascript, jest, nodejs, typescript

A short kata to configure a nodejs project, using TypeScript instead of javascript, and to create a unit test using the Jest testing framework. Requirements Create a new nodejs project and install dependencies: $ npm init -y $ npm i -D typescript nodemon \ jest \ babel-jest \ @types/jest \ @babel/preset-typescript \ @babel/preset-env \ @babel/core Initialise jest $ jest --init The following questions will help Jest to create a suitable configuration for your project √ Would you like to use Jest when running "test" script in "package. ...

Lerna

May 4, 2020
nodejs, docker, expressjs, lerna, monorepo

Monorepo (all projects are stored in a single repository) is a relatively new concept (to me) and so I’ve provided more than usual hits/sample code in the kata. This is primarily to help me cement the core commands. The BACKGROUND to why I’ve created this is kata is this. I’ve recently needed to create several RabbitMQ consumers through a devised pattern, including additional common functionality. As there is common code, I did not want to violate the DRY principle so set about researching a way to do this, easily, with a nodejs repo. ...

React Express Socketio

April 27, 2020
nodejs, expressjs, react, socket.io, websockets

Requirements: Create a React application and run it to get default page Remove all extant files Create a new App.js starter file Add socket-io to server.js Add socket-io-client to App component Send ‘Welcome!’ message on client connect Render ‘Welcome!’ message from the server Tech: nodejs npm npx react (create-react-app) socket.io (socker-io) socket.io-client (https://www.npmjs.com/package/socket.io-client) References ...

React Function Components

April 27, 2020
nodejs, react, function component, react hooks

Requirements: Create a React application and run it to get default page Remove all extant files Create a new App.js starter file Add a new function component that renders an input field and a button - call this Input Add a new function component that renders a table - call this Table Import and add both new function components as child components to the App ...