Skip to content

Latest commit

 

History

History

counter

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Counter Example

A minimal in-memory counter API built with the Vania framework. No database — just a shared Counter object behind four routes.

Endpoints

Method Path Description
GET /api/counter Current value
POST /api/counter/increment Add one, return value
POST /api/counter/decrement Subtract one, return value
POST /api/counter/reset Reset to zero

Layout

lib/
  app/counter.dart                          # the counter logic (no HTTP)
  app/http/controllers/counter_controller.dart
  route/api_route.dart
  app/providers/route_service_provider.dart
  config/app.dart
bin/server.dart
test/counter_test.dart                       # unit tests for the counter

Running

dart pub get
dart run bin/server.dart

Tests

The counter logic lives in a plain Counter class, so it is tested directly without a server:

dart test