Skip to content

meragix/axon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Axon

HTTP request logging middleware for the Dart server ecosystem.
Inspired by Morgan and built for Dart 3.


Packages

Package Description Version
axon_core Zero-dependency token engine, format compiler, serializers pub
axon_shelf Shelf middleware adapter pub
axon_dart_frog Dart Frog middleware adapter pub

Planned: axon_dio


Quick start

dart pub add axon_shelf
import 'package:axon_shelf/axon_shelf.dart';
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as io;

void main() async {
  final handler = Pipeline()
      .addMiddleware(axonShelf())
      .addHandler((req) => Response.ok('hello'));

  await io.serve(handler, 'localhost', 8080);
}

Output:

GET / 200 3 ms
POST /api/users 201 12 ms
GET /api/users/42 404 1 ms

Why Axon over Morgan?

Feature Morgan (Node.js) Axon (Dart)
Format strings
Predefined formats
Custom tokens
JSON output ❌ (manual workaround) ✅ Native
Numeric types in JSON int/double preserved
Header masking MaskingRules
Type safety ❌ (JavaScript) ✅ Dart 3 sealed classes
Fail-fast on bad format FormatCompilationError
Auth-agnostic :remote-user UserExtractor
TTY color auto-detect dart:io detection

Monorepo

This repository is managed with Melos.

dart pub global activate melos
melos bootstrap    # install all dependencies
melos test         # run all tests
melos analyze      # dart analyze across packages
melos format       # dart format across packages
melos publish:dry  # dry-run publish check

Contributing

Contributions are welcome. Please open an issue before submitting a PR for non-trivial changes.

  • Follow Conventional Commits: Melos uses them for versioning.
  • Run melos analyze and melos format:check before pushing.
  • Add tests for any new token or serializer.
  • Open an issue before submitting a PR for non-trivial changes

License

MIT — see LICENSE.

About

The Morgan-inspired HTTP logger for Dart - fast, type-safe, server & client.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors