Node.js Backend with Express and TypeScript

VerifiedSafe

Node.js 20 LTS runtime for building Express and TypeScript backend services. Handles async operations, database connections with PostgreSQL, image processing with Sharp, and environment configuration. Use when working on server-side JavaScript with modern module system and TypeScript.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude Code
#nodejs#typescript#express#postgresql#backend

Recommended for

Automated summary

Provides Node.js 20 LTS patterns for building Express + TypeScript backend services with ESM, PostgreSQL, and image processing.

Strengths

  • Covers ESM module system with extension requirements
  • Includes environment config validation with defaults
  • Provides database connection pool setup with error handling
  • Shows async/await and transaction patterns

Limitations

  • Assumes specific project structure (backend/src/)
  • Does not cover deployment or production optimizations
  • Limited to Node.js 20 LTS, not newer versions
When to use it

When developing a Node.js backend with Express, TypeScript, and PostgreSQL in a monorepo context.

When not to use it

When using CommonJS modules, alternative databases, or frontend-only JavaScript.

Security analysis

Safe
Quality score90/100

The skill provides Node.js backend patterns and code snippets. It does not instruct the agent to execute destructive commands, exfiltrate data, or bypass safety. Allowed tools like Bash are standard for development but not exploited here.

No concerns found

How this analysis is made

Examples

Create a new database pool
Set up a PostgreSQL connection pool with max 20 connections and 30s idle timeout, using the pg library and ESM.
Implement a transaction with rollback
Show me how to implement a database transaction with rollback in Node.js using the pg pool in ESM.
Validate environment variables
Write a validated environment configuration module with required and optional variables, using dotenv.

name: node description: | Node.js LTS runtime and server-side JavaScript patterns for INVOOPAY backend. Use when: working with backend services, async operations, crypto, Buffer handling, or Node.js APIs. allowed-tools: Read, Edit, Write, Glob, Grep, Bash

Node Skill

Node.js 20 LTS runtime powering Express + TypeScript backend. Uses ES modules ("type": "module") with tsx for development. PostgreSQL via pg with connection pooling. Sharp for image processing.

Quick Start

Module System (ESM)

// backend/src/server.ts - Entry point
import app from './app.js';           // .js extension required for ESM
import { env } from './config/env.js';

app.listen(env.port, () => {
  console.log(`Backend listening on port ${env.port}`);
});

Environment Configuration

// backend/src/config/env.ts - Validated env with defaults
import dotenv from 'dotenv';
dotenv.config();

const required = (value: string | undefined, fallback?: string) => {
  if (value) return value;
  if (fallback !== undefined) return fallback;
  throw new Error('Missing required environment variable');
};

export const env = {
  port: Number(process.env.PORT ?? 4000),
  dbHost: process.env.DB_HOST ?? 'localhost',
  jwtSecret: required(process.env.JWT_SECRET, 'dev-only-secret'),
  nodeEnv: process.env.NODE_ENV ?? 'development',
};

Database Connection Pool

// backend/src/db/client.ts
import pg from 'pg';
const { Pool } = pg;

export const pool = new Pool({
  host: env.dbHost,
  max: 20,                    // Max connections
  idleTimeoutMillis: 30000,   // Close idle after 30s
  connectionTimeoutMillis: 2000,
});

pool.on('error', (err) => {
  console.error('Unexpected error on idle client', err);
  process.exit(-1);           // Crash on pool errors
});

Key Concepts

| Concept | Usage | Example | |---------|-------|---------| | ESM imports | Always use .js extension | import { x } from './mod.js' | | __dirname | Use import.meta.url | path.dirname(fileURLToPath(import.meta.url)) | | Async/await | All I/O operations | await pool.query(...) | | Buffer | Binary data handling | Buffer.from(data, 'hex') | | crypto | Encryption/hashing | crypto.randomBytes(32) |

Common Patterns

Async Service Method

export const productService = {
  async get(id: number, language: string = 'en') {
    const result = await pool.query(
      'SELECT * FROM products WHERE id = $1', [id]
    );
    if (!result.rows[0]) return null;
    return mapProduct(result.rows[0]);
  }
};

Transaction with Rollback

const client = await pool.connect();
try {
  await client.query('BEGIN');
  await client.query('INSERT ...', [...]);
  await client.query('UPDATE ...', [...]);
  await client.query('COMMIT');
} catch (error) {
  await client.query('ROLLBACK');
  throw error;
} finally {
  client.release();  // Always release!
}

See Also

  • patterns - Async patterns, error handling
  • types - TypeScript integration
  • modules - Project structure, imports
  • errors - Error handling patterns

Related Skills

For Express routes and middleware, see the express skill. For database queries, see the postgresql skill. For TypeScript patterns, see the typescript skill.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/node-js-backend-with-express-and-typescript-mm78nned/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/node-js-backend-with-express-and-typescript-mm78nned' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/node-js-backend-with-express-and-typescript-mm78nned/download' --output '.skill-downloads/node-js-backend-with-express-and-typescript-mm78nned/SKILL.md.part' && mv '.skill-downloads/node-js-backend-with-express-and-typescript-mm78nned/SKILL.md.part' '.skill-downloads/node-js-backend-with-express-and-typescript-mm78nned/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Edit, Write, Glob, Grep, Bash

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/node-js-backend-with-express-and-typescript-mm78nned/SKILL.md' && test -s '.skill-downloads/node-js-backend-with-express-and-typescript-mm78nned/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/node' && cp -R '.skill-downloads/node-js-backend-with-express-and-typescript-mm78nned' '.claude/skills/node'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/node-js-backend-with-express-and-typescript-mm78nned'

openskills read 'node-js-backend-with-express-and-typescript-mm78nned'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/node-js-backend-with-express-and-typescript-mm78nned/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills