CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/postgresql-node-best-practices

PostgreSQL patterns for Node.js with pg — connection pooling, parameterized

99

1.75x
Quality

99%

Does it follow best practices?

Impact

100%

1.75x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-4/

Product Catalog Service

Problem/Feature Description

An e-commerce company needs a product catalog backend built with Node.js, TypeScript, and Express. The service reads from and writes to PostgreSQL using the pg package. The database is accessible via a DATABASE_URL environment variable.

The catalog service needs to support:

  • Adding a single product (name, description, price in cents, category, tags as an array of strings)
  • Importing a batch of products from a supplier feed (receives an array of 100-2000 products at once and needs to write them all efficiently)
  • Looking up a product by ID
  • Filtering products by category
  • Finding products that match any of a given set of tags
  • Finding products within a set of categories (e.g. show me all products in "electronics", "books", or "toys")

Products have: id (serial), name, description, price_cents (integer), category, tags (text array), created_at.

Output Specification

Produce:

  • db.ts -- Database connection module
  • products.ts -- Functions for all six operations listed above
  • package.json -- With required dependencies

The code should be complete TypeScript with no placeholders or TODO comments.

evals

tile.json