DX with Node Js

How to improve your developing experience with Node Js

Danilo Assis

Danilo Assis

daniloab_daniloab
Woovi Logo

Tech Lead

Overview

  • Introduction
  • Learn in Public
  • Draw and Architect
  • Documentation
  • Concepts
  • APIs
  • Test
  • Observability
  • References
  • Conclusion

Introduction

  • Problem
  • Why
  • How to Improve

Problem

  • High Costs
  • Heavy Developer Cycle
  • Lacks: Documentation, Process
  • Poor Communication

Learn in Public

Learn in Public

    • Write/talk about everything that you're learning
    • Try to teach at least three different people
    • Cone of Learning

Learn in Public - Read List

  • Learn in Public - by Danilo Assis
  • How to put the Learning in Public in practice - by Danilo Assis
  • How to avoid frustration while learning something new - by Danilo Assis

Draw and Architect

    • Clear path of the problem
    • Enhanced communication
    • Process
    • Tools: excalidraw, figma, mermaid

Documentation

Documentation - Team

    • Improved Efficiency
    • Consistency
    • Onboarding and Training
    • Knowledge Transfer
    • Scalability
    • Continuity
    • Team Playbook

Documentation - Yourself

    • Problem Pattern Matching
    • Consistency
    • Personal Growth
    • Retention and Recall
    • Remember Things
    • Own Playbook

Strategies

  • Second Brain
  • Digital Garden
  • Zettelkasten
  • Blog post
  • Just take notes

Second Brain

Second Brain

Practice

Environment

    • Easier to move and contribute
    • Ship Faster
    • Routine
    • Playground

CodeSandbox

StackBlitz

Woovi Scripts

    • Collocation
    • Scalability
    • Reusable
    • Maintainable

Scripts Calling API

import open from 'open';
import { v4 as uuidv4 } from 'uuid';
import { apiWithLog,jsonOrText } from '@woovi/apiWithLog';
import { getApiBaseUrl, isMainScript } from '@woovi/shared';
import { appID } from '../apiID';
const run = async () => {
const url = `${getApiBaseUrl()}/api/v1/charge`;
const payload = {
correlationID: uuidv4().toString(),
value: 1500,
comment: 'from-script-api',
};
const options = {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: appID,
},
body: JSON.stringify(payload),
};
const response = await apiWithLog(url, options);
const data = await jsonOrText(response);
if (data.error) {
return;
}
// await open(data.charge.paymentLinkUrl);
await open(`http://localhost:8103/home/charge/${data.charge.globalID}`)
return data;
};
(async () => {
if (!isMainScript(require, module, __filename)) {
return;
}
try {
await run();
} catch (err) {
// eslint-disable-next-line
console.log('err: ', err);
process.exit(1);
}
process.exit(0);
})();

Code

Request Result - Error

Request Result - Success

Typing API

Tests

  • CI/CD
  • Prevents Bugs and Regression
  • Cost-Efficiency
  • Integration Test
  • Failing Tests
  • Dev must to know what is doing it
  • Test Driven Development

API Test

const url = '/api/openpix/v1/charge';
it('should not accept invalid payload', async () => {
const application = await createApplication();
const authorization = base64(
`${application.clientId}:${application.clientSecret}`,
);
const payload = {
correlationID: 'correlationID',
value: 'value',
comment: 'good',
};
const response = await request(app.callback())
.post(url)
.set({
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: authorization,
})
.send(JSON.stringify(payload));
expect(response.status).toBe(400);
expect(response.body).toEqual({
error:
'value must be a `number` type, but the final value was: `NaN` (cast from the value `"value"`).',
});
});
  • Building Rest APIs with koa-js
  • See on Youtube Video
  • KoaJs CRUD - Backend implementation of REST api with Node.js, Koa.js, MongoDB and Jest Tests
  • CI/CD - Practical Benefits

Observability

  • Automation
  • Logs
  • Slack
  • Botina
  • Instrumentation: Kibana, APM

BOTina

BOTina - Help Commands

BOTina - Diff Command

BOTina - Release

BOTina - CircleCI Release Workflow

  • Improving Operational Work with a Slack Bot
  • Botina Slack Talk Repo
  • Botina Slack Bot Repo

Woovi Logging

  • console.log()
  • debugConsole()
  • debugAggregate()

Debug Console

Debug Console

  • Debugging Nested Objects

Send to Slack

Dependabot

Dependabot

Woovi Engineer Blog

  • Woovi Engineer Blog

References

  • 7 Principles and 10 Tactics to Make You a 10x Developer
  • How to check if a node file is running as a script?
  • apiWithLog
  • Test Plan Driven Development
  • Failing Tests, Write to Fail and Fix
  • Testing a REST API
  • Shipping to Production - Series

Website

https://daniloassis.dev

Thanks

We are hiring!

woovi.com/jobs