Logo di Express Jwt Postgres Api

Express Jwt Postgres Api

Community
andersonamaral2
express-jwt-postgres-api

Builds a production-style Express.js REST API with JWT authentication, PostgreSQL, layered middleware, and Docker Compose for local development. Use when the user asks to scaffold a secure Node.js/Express API with login, protected routes, and a relational database.

Panoramica

Pubblicato daandersonamaral2
RepositoryClaude-Code-to-Deep-Agents-Skills-Converter
Nome della skillexpress-jwt-postgres-api
Stelle
58
Fork
8
File inclusi
Solo istruzioni
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da andersonamaral2 su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Express Jwt Postgres Api in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/andersonamaral2/Claude-Code-to-Deep-Agents-Skills-Converter/tree/main/examples/deep-agents-output-3
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/andersonamaral2/Claude-Code-to-Deep-Agents-Skills-Converter.git /tmp/Claude-Code-to-Deep-Agents-Skills-Converter
mkdir -p .claude/skills
cp -r /tmp/Claude-Code-to-Deep-Agents-Skills-Converter/examples/deep-agents-output-3 .claude/skills/express-jwt-postgres-api
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Express Jwt Postgres Api in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Express Jwt Postgres Api non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Express Jwt Postgres Api non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Skill: Express.js JWT API with PostgreSQL and Docker

Builds a production-style Express.js REST API with JWT authentication, a PostgreSQL database, layered middleware, and Docker Compose for local development.

Execution Context

This skill runs inside Deep Agents CLI (v0.0.34+). Available tools:

ToolUsage in this skill
write_todosPlan the build steps
executeRun npm, docker, curl, and inline tests
write_fileCreate source files, SQL, compose, and .env
edit_fileAdjust files if a test reveals an issue

Critical execution rules:

  1. Always start by creating the plan via write_todos.
  2. Create files one by one via write_file — never generate everything at once.
  3. Test each module via execute immediately after creating it.
  4. Verify required environment variables before starting the server.

Execution Plan (use with write_todos)

  • 1. Check prerequisites (Node.js 18+, npm, Docker, Docker Compose)
  • 2. Verify environment variables (JWT_SECRET, DATABASE_URL, PORT)
  • 3. Initialize project and install dependencies
  • 4. Create src/db.js (PostgreSQL pool)
  • 5. Create middleware (auth.js, logger.js)
  • 6. Create routes (auth.js, notes.js)
  • 7. Create src/index.js entry point
  • 8. Create db/init.sql and docker-compose.yml
  • 9. Create .env, start the database, run the API
  • 10. Test the full register → login → create-note flow

Prerequisites Check

Use execute to verify the toolchain:

bash
node --version    # requires 18+
npm --version
docker --version
docker compose version

Environment Setup

Verify required environment variables via execute:

bash
for var in JWT_SECRET DATABASE_URL; do
  if [ -z "${!var}" ]; then
    echo "WARNING: $var not set — will fall back to .env defaults"
  fi
done
echo "Environment check done"

Security note: Never hardcode production secrets. The .env below uses placeholders; keep it out of version control via .gitignore.

Implementation

Initialize the project via execute:

bash
npm init -y

Install dependencies via execute:

bash
npm install express jsonwebtoken bcrypt pg dotenv
npm install --save-dev nodemon

Use write_file to create src/db.js:

javascript
const { Pool } = require('pg');

const pool = new Pool({ connectionString: process.env.DATABASE_URL });

module.exports = { pool };

Test via execute:

bash
node -e "require('./src/db.js'); console.log('OK: db module loads')"

Use write_file to create src/middleware/auth.js:

javascript
const jwt = require('jsonwebtoken');

function authRequired(req, res, next) {
  const header = req.headers.authorization || '';
  const token = header.startsWith('Bearer ') ? header.slice(7) : null;
  if (!token) return res.status(401).json({ error: 'missing token' });
  try {
    req.user = jwt.verify(token, process.env.JWT_SECRET);
    next();
  } catch {
    return res.status(401).json({ error: 'invalid token' });
  }
}

module.exports = { authRequired };

Use write_file to create src/middleware/logger.js:

javascript
module.exports = function logger(req, res, next) {
  console.log(`${new Date().toISOString()} ${req.method} ${req.path}`);
  next();
};

Test the middleware via execute:

bash
node -e "require('./src/middleware/auth.js'); require('./src/middleware/logger.js'); console.log('OK: middleware loads')"

Use write_file to create src/routes/auth.js with POST /auth/register (bcrypt-hash the password and insert the user) and POST /auth/login (verify the password and return a signed JWT).

Use write_file to create src/routes/notes.js with CRUD endpoints (GET/POST/PUT/DELETE /notes) guarded by the authRequired middleware and scoped to req.user.id.

Test the routers via execute:

bash
node -e "require('./src/routes/auth.js'); require('./src/routes/notes.js'); console.log('OK: routers load')"

Use write_file to create src/index.js:

javascript
require('dotenv').config();
const express = require('express');
const logger = require('./middleware/logger');
const authRouter = require('./routes/auth');
const notesRouter = require('./routes/notes');

const app = express();
app.use(express.json());
app.use(logger);
app.use('/auth', authRouter);
app.use('/notes', notesRouter);

const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`API listening on ${port}`));

Use write_file to create db/init.sql:

sql
CREATE TABLE IF NOT EXISTS users (
  id SERIAL PRIMARY KEY,
  email TEXT UNIQUE NOT NULL,
  password_hash TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS notes (
  id SERIAL PRIMARY KEY,
  user_id INTEGER REFERENCES users(id),
  body TEXT NOT NULL
);

Use write_file to create docker-compose.yml:

yaml
version: "3.8"
services:
  db:
    image: postgres:16
    environment:
      POSTGRES_USER: api
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: api
    ports:
      - "5432:5432"
    volumes:
      - ./db/init.sql:/docker-entrypoint-initdb.d/init.sql
      - pgdata:/var/lib/postgresql/data

volumes:
  pgdata:

Use write_file to create .env:

PORT=3000
JWT_SECRET=change-me-in-production
DATABASE_URL=postgresql://api:change-me@localhost:5432/api
POSTGRES_PASSWORD=change-me

Security note: These are placeholder secrets. Replace them with real values from your secret manager before deploying, and add .env to .gitignore.

Start the database via execute:

bash
docker compose up -d

Add a dev script and run the API via execute:

bash
npm pkg set scripts.dev="nodemon src/index.js"
npm run dev &
sleep 3

Test the full flow via execute:

bash
curl -s -X POST http://localhost:3000/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"a@b.com","password":"secret123"}'

TOKEN=$(curl -s -X POST http://localhost:3000/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"a@b.com","password":"secret123"}' \
  | python3 -c "import sys,json;print(json.load(sys.stdin)['token'])")

curl -s -X POST http://localhost:3000/notes \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"body":"hello"}'

Document the project architecture and conventions in AGENTS.md at the root (the Deep Agents equivalent of a project memory file).

Usage with Deep Agents CLI

Mode 1 — Build (one-shot)

bash
deepagents -y "Scaffold an Express JWT API with PostgreSQL following the express-jwt-postgres-api skill"

Mode 2 — Interactive

bash
deepagents
> Build me a secure Express REST API with JWT auth and a Postgres database

Mode 3 — Non-interactive (CI/CD)

bash
deepagents -n -y -S "npm,node,docker" "Generate the Express JWT API scaffold in ./api"

Troubleshooting

Node.js not found

bash
node --version
# Install via nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 18

Database connection refused

bash
# Is the container up and healthy?
docker compose ps
docker compose logs db | tail -20
# Confirm DATABASE_URL host/port match docker-compose.yml (localhost:5432)

JWT verify fails on protected routes

bash
# JWT_SECRET must be identical at sign time (login) and verify time (auth middleware).
echo "JWT_SECRET is ${JWT_SECRET:+set}"
# Re-issue a token after confirming the secret is exported, then retry the request.

Port 3000 already in use

bash
lsof -i :3000
# Kill the process or change PORT in .env

Context window overflow

Use /compact before continuing, or split route generation into `task` sub-agents.

Domande frequenti

Cosa fa la skill IA Express Jwt Postgres Api?

Builds a production-style Express.js REST API with JWT authentication, PostgreSQL, layered middleware, and Docker Compose for local development. Use when the user asks to scaffold a secure Node.js/Express API with login, protected routes, and a relational database.

Perché usare Express Jwt Postgres Api su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Express Jwt Postgres Api è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Express Jwt Postgres Api in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/andersonamaral2/Claude-Code-to-Deep-Agents-Skills-Converter/tree/main/examples/deep-agents-output-3. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Express Jwt Postgres Api?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Express Jwt Postgres Api?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Express Jwt Postgres Api: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Express Jwt Postgres Api è gratuita?

Sì. È pubblicata su GitHub da andersonamaral2 con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇