Menu

Database — Fastify with TypeScript (part 13/18)
📰

Database — Fastify with TypeScript (part 13/18)

DEV Community: fastify·Antonio Tripodi·9 days ago
#CTp1cOGV
#devtofastify#devto#dev#users#fastify
Long article (2838 words) — no AI summary yet.
Reading 0:00
15s threshold

Database

Thirteenth chapter of the "Fastify with TypeScript" series. Our users have lived in memory since chapter 5 and vanish at every restart. Time to give them a real home in PostgreSQL, and to organize the code around it with a repository and a service.

A PostgreSQL to work with

The quickest way to get a database is Docker:

docker run --name fastify-pg -e POSTGRES_PASSWORD = postgres -e POSTGRES_DB = app -p 5432:5432 -d postgres:16

Enter fullscreen mode

Exit fullscreen mode

That matches the DATABASE_URL we put in .env back in chapter 4 ( postgres://postgres:postgres@localhost:5432/app ).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.