DEV Community

Cover image for S — Slice to Essentials (build the thin slice)
Manuel S. Martone
Manuel S. Martone

Posted on

S — Slice to Essentials (build the thin slice)

Definition of the slice

  • 1 screen (+ success state)
  • 2 endpoints (POST /action, GET /status)
  • 3 tests (happy, bad input, mocked failure)
  • 1 metric instrumented (per attempt)

Minimal folder skeleton

/app
  /api        # endpoints
  /ui         # one screen + success
  /tests      # 3 tests
  /metrics    # logger/tracker
Enter fullscreen mode Exit fullscreen mode

Fastify stubs (copy‑paste)

app.post('/action', async (req, reply) => {
  const { input } = req.body || {};
  if (!input) {
      reply.statusCode = 400:
      return { error: 'missing input' };
  }
  const id = Date.now().toString();
  // TODO: enqueue or mock work
  return { id };
});

app.get('/status', async (req, reply) => {
  const { id } = req.query || {};
  // TODO: return mocked result for demo
  return { id, state: 'done', result: { ok: true } };
});
Enter fullscreen mode Exit fullscreen mode

Tests (Given/When/Then)

Given valid input → When POST /action → Then receive id
Given missing input → When POST /action → Then 400
Given id → When GET /status → Then state in {'queued','done'} and result?
Enter fullscreen mode Exit fullscreen mode

Instrumentation (pseudo)

log('attempt', { id, ts });
log('success', { id, ts, useful: rating });
Enter fullscreen mode Exit fullscreen mode

Ship boring. Learn fast. The goal isn’t elegance; it’s evidence.

Full checklist + copy blocks → https://shipwithai.substack.com/p/pasta-al-dente-ship-a-one-feature?utm_source=devto&utm_medium=social&utm_campaign=issue_pasta_al_dente_week

Top comments (0)