dartapi 0.2.2
dartapi: ^0.2.2 copied to clipboard
DartAPI is a CLI-driven project generator and toolset for building typed REST APIs in Dart.
0.2.2 #
Refresh-token reuse now actually terminates the session.
- Generated projects depend on
dartapi_core ^0.6.0. - The generated
onRefreshTokenReusehandler previously only printed a warning (the comment said "revoke the whole session", but the framework had no API for it). It now calls the newjwtService.revokeAllForUser(sub)— every outstanding access and refresh token for the affected user, including any an attacker just minted, becomes invalid and a fresh login is required. Applies to both the--fulland--with=authscaffolds. - Scaffold comments now spell out the multi-process caveat: behind
--isolates=Nor multiple instances,InMemoryTokenStoremust be replaced with a shared backend overridingrevokeIfActiveandrevokeSubject/subjectRevocationCutoff.
0.2.1 #
- Generated projects depend on
dartapi_core ^0.5.0(OpenAPI overhaul). - Generated controllers use the new
requestFields:pattern — the sameFieldSetthat validates the request now also produces its OpenAPI schema, and422/400error responses are documented automatically. Swagger UI/ReDoc assets are version-pinned,enableDocsordering no longer matters, and every operation gets anoperationIdfor clean client code generation.
0.2.0 #
Generated projects are production-deployable out of the box.
- Generated projects now depend on
dartapi_core ^0.4.0anddartapi_db ^0.1.0:- Graceful shutdown is built in — SIGTERM drains in-flight requests instead
of aborting them (correct behaviour under Kubernetes/Cloud Run rolling
deploys), with
onShutdownhooks running after the drain. - Rate limiting keys by the real socket IP; the full template documents the
trustProxy: trueswitch for deployments behind a proxy/load balancer.
- Graceful shutdown is built in — SIGTERM drains in-flight requests instead
of aborting them (correct behaviour under Kubernetes/Cloud Run rolling
deploys), with
GET /healthnow checks the database: when a DB is configured, generated apps wiredb.ping()intoenableHealthCheck(checks: [...])and report"degraded"when the database stops answering (both full and--with=dbscaffolds).- Every generated project ships a GitHub Actions CI workflow
(
.github/workflows/ci.yaml): format check,dart analyze --fatal-infos, anddart teston every push/PR.
0.1.52 #
- Update generated projects to
dartapi_core ^0.3.0(secure token revocation and refresh rotation):auth_service.dart.tmpl: login and refresh now issue tokens viaJwtService.generateTokenPair— the deprecatedgenerateRefreshToken(accessToken: ...)(removal planned fordartapi_core0.4.0) is no longer used.- Refresh endpoint returns a full new token pair: refresh tokens are single-use when a
TokenStoreis configured (verifyRefreshTokenconsumes them atomically), so the old token can no longer be re-issued unchanged. - Logout revokes both the access token and (when sent in the request body as
{"refreshToken": "..."}) the refresh token;revokeTokennow verifies the token signature and returnsFuture<bool>. - Wire the new
JwtService.onRefreshTokenReusecallback inbootstrap.dart.tmpland the generatedmain.dartwith a comment explaining it fires when an already-consumed refresh token is presented again (token-theft signal). TokenStoreis now a base class: comments in generated code explain to extend it (not implement), thatrevoke()gained a{Duration? ttl}parameter, and that distributed backends should overriderevokeIfActivewith an atomic operation (e.g. RedisSET NX EX).- Generated auth tests:
JwtServiceis constructed with anInMemoryTokenStore(required for revocation and rotation), refresh tests assert a rotated (different) refresh token and that reuse of a consumed token throws 401, and logout tests cover revoking both tokens.
- Use new
dartapi_coreAPIs in generated projects:app.configureLogging(format: LogFormat.json, excludePaths: [...])— structured JSON request logs with health/metrics probes excluded.app.start(address: '0.0.0.0', ...)— bind address is now explicit/configurable, with a comment pointing atawait app.stop()for graceful programmatic shutdown.
- Generated README documents the rotated refresh response, single-use semantics, and that invalid/missing tokens receive
401with aWWW-Authenticate: Bearerheader (was403beforedartapi_core0.2.0).
0.1.51 #
- Fix
--fullgenerated projects: addimport 'package:shelf/shelf.dart'toauth_controller.dart,files_controller.dart,notifications_controller.dart,product_controller.dart,stats_controller.dart, anduser_controller.darttemplates —RequestandResponseare not re-exported bydartapi_core, causing undefined-class errors. - Fix
ws_controller.dart.tmpl: change barecatch (_)toon Object catch (_)to satisfy theavoid_catches_without_on_clauseslint. - Fix
bootstrap.dart.tmpl: remove redundantimport 'package:<project>/src/core/dartapi.dart'—DartAPIis already provided by thedartapi_coreimport, making it an unnecessary import warning.
0.1.50 #
- Bump generated
dartapi_coredependency to^0.1.9anddartapi_dbto^0.0.15. - Add
Dockerfileto every generated project (both--minimaland--full) — multi-stage build producing a slim Debian runtime image. - Run
dart analyzeafterdart pub getduring project scaffolding — analyzer warnings are printed so issues are surfaced immediately afterdartapi create.
0.1.49 #
- Bump generated
dartapi_coredependency to^0.1.8anddartapi_dbto^0.0.14. - Bump generated project SDK constraint from
^3.7.0to^3.7.2. - Fix
_buildMainContent:dart:iois now imported whenever any feature flag is active (was only imported for--with=db), fixing a compile error in projects generated with--with=auth,--with=files, or--with=wsbut without--with=db(_loadEnvusesPlatform.environment). - Fix
auth_service_test.dart.tmpl: remove duplicateimport 'package:dartapi_core/dartapi_core.dart'. - Fix
stats_controller.dart.tmpl: replaceDateTime.now()uptime withStopwatch.elapsed— immune to system clock adjustments. - Fix
user_service_test.dart.tmpl: addconsttoUserDTO(...)constructor calls. - Bump
dartapiSDK constraint to^3.7.2,shelfto^1.4.2,testto^1.24.0. - Dependency upgrades:
test1.31.0 → 1.31.1 and related transitive dev bumps.
0.1.48 #
- Update DTO templates to use
FieldSetfromdartapi_core ^0.1.4:user_dto.dart.tmpl,login_dto.dart.tmpl,product_dto.dart.tmpl,resource_dto.dart.tmpl- Replaced manual
static const schema = {...}withstatic Map<String, dynamic> get schema => fields.toJsonSchema(). - Replaced individual
verifyKeycalls infromJsonwithfields.validate(json).
- Bump minimum
dartapi_coredependency to^0.1.4.
0.1.47 #
- Fix generated
hello_controller.dart: replace non-existentApiRoute.get()factory withApiRoute(method: ApiMethod.get, typedHandler:) - Fix
bootstrap.dartambiguousAppConfigimport: hideAppConfigfromdartapi_coreso the project's own subclass takes precedence - Remove duplicate
dartapi_coreimports inauth_controller,notifications_controller,stats_controller,auth_service,auth_service_testtemplates - Fix
UploadedFile.readBytes()call infiles_controller: use.bytesproperty instead - Remove unnecessary
!null-assertion on_jwtServiceinside guardedif (_jwtService != null)checks acrossfiles_controller,user_controller,product_controller,ws_controller - Remove stray
package:shelf/shelf.dartimports from controller templates; addshelf: ^1.4.2as a direct dependency in the generatedpubspec.yaml - Add
dart pub getafter project scaffold indartapi create
0.1.46 #
- Bump generated
dartapi_coredep to^0.1.2(addsServiceRegistryDI container) - Update
bootstrap.dart.tmplto use the registry pattern:app.register<T>(),app.registerSingleton<T>(),app.get<T>()replace manual constructor threading
0.1.45 #
- Add
--minimal(default),--full, and--with=<features>flags todartapi createdartapi create my_app— minimal scaffold: hello controller + bare server, one dep (dartapi_core)dartapi create my_app --full— full kitchen-sink scaffold (current default behaviour)dartapi create my_app --with=auth— minimal + JWT auth wiringdartapi create my_app --with=db— minimal + database CRUD (user/product repositories, migrations)dartapi create my_app --with=auth,db— minimal + both; JwtService wired into user/product controllersdartapi create my_app --with=files— minimal + file upload controllerdartapi create my_app --with=ws— minimal + WebSocket echo controller--with=features are composable:--with=auth,db,files,wsequals--fullwithout stats/notifications
- Add
Featureenum (auth,db,files,ws) andkAllFeaturesconstant - Refactor
CreateCommandConstants.directories()and.files()to accept{Set<Feature> features, bool full} - Add
hello_controller.dart.tmpl— singleGET /helloendpoint used by the minimal scaffold - Add
readme_minimal.md.tmpl— short README for minimal projects - Make
JwtServiceoptional (JwtService?) inUserController,ProductController,FilesController, andWsControllertemplates — auth middleware only applied when aJwtServiceis provided pubspec.yamlfor generated projects is now built programmatically based on features (no template duplication)- 119 tests passing (30 new tests across all
--with=combinations and cross-mode invariants)
0.1.44 #
- Replace
dartapi_authwithdartapi_core ^0.1.1in generatedpubspec.yaml— auth is now part ofdartapi_core - Update all generated template imports from
package:dartapi_auth/dartapi_auth.darttopackage:dartapi_core/dartapi_core.dart
0.1.43 #
- Update templates to import
DartAPI,RouterManager,AppConfig,loadEnvFile, andmergeEnvfromdartapi_core ^0.1.0instead of generating them as project files - Remove
router.dartgeneration —RouterManageris now indartapi_core - Generated
AppConfigextendscore.AppConfig(only overridesdbNamewith the project name) - Generated
env_loader.dartre-exportsloadEnvFile/mergeEnvfromdartapi_core - Remove
shelf_cors_headersandshelf_routerfrom generatedpubspec.yaml(now transitive viadartapi_core)
0.1.42 #
- Upgrade
lintsfrom^5.1.1to^6.1.0 - Bump generated deps to latest:
dartapi_auth ^0.0.10,dartapi_core ^0.0.27,dartapi_db ^0.0.12,shelf ^1.4.2,shelf_router ^1.1.4,test ^1.24.0,lints ^6.1.0 - Add
shelf_web_socket ^3.0.0andweb_socket_channel ^3.0.3to generatedpubspec.yaml(required by WebSocket controller) - Tighten generated SDK constraint to
^3.7.0
0.1.41 #
- Bump generated
dartapi_coredep to^0.0.26(fix:/docsand other small responses crash with "read method can only be called once" when compression middleware is active)
0.1.40 #
- Add
NotificationsController—GET /notifications/streamstreams Server-Sent Events (SSE) viasseResponse() - Add
FilesController—POST /files/upload(multipart) andGET /fileswith background post-upload task - Add
WsController— WebSocket echo-chat at/ws/chatwith JWT auth viawebSocketRoutes - Add
StatsController—GET /admin/statsandGET /admin/infoprotected byapiKeyMiddleware(X-Admin-Keyheader) - Add
bootstrap.dart—createApp(AppConfig, {DartApiDB? db})consolidates all wiring (JWT, token store, repos, services, middleware, controllers, built-in endpoints); generatedmain.dartis now ~60 lines - Simplify generated
main.dart: only env loading, port/isolates parsing, optional DB connection,createApp()call, shutdown hook, andapp.start() - Bump generated
dartapi_coredep to^0.0.25
0.1.39 #
- Generated project no longer crashes on
dartapi runwhen no database is configured - Add
DB_ENABLEDenv var (defaultfalsein dev,truein staging/production); when false the app starts with in-memory repositories — no PostgreSQL needed - Generated
main.dartconditionally creates DB connection and runs migrations only whenDB_ENABLED=true; falls back toInMemoryUserRepository/InMemoryProductRepositoryotherwise app.onShutdownusesdb?.close()(db is now nullable)AppConfig.dbEnabledgetter readsDB_ENABLED
0.1.38 #
- Fix generated
bin/main.dart:MigrationRunner(db).run()→.migrate()(correct method name) - Fix generated
bin/main.dart: add// ignore: avoid_printon all startup debugprintcalls - Fix generated
lib/src/dto/user_dto.dart:validateAllnow uses the correctMap<String, void Function()>signature;EmailValidatornow receives its required message argument - Fix generated
test/services/user_service_test.dart:UserDTO(...)constructors are nowconst - Fix generated
lib/src/config/app_config.dart: wrap.env.<APP_ENV>in backticks in doc comment to suppress HTML angle-bracket warning
0.1.37 #
- Generated project upgraded to production-grade scaffold:
- Full CRUD for Users and Products (GET list, GET by id, POST, PUT, DELETE) with 404 guards
- Controller → Service → Repository enterprise architecture;
InMemoryXxxRepositoryfor dev/tests,DbXxxRepositoryfor production - Multi-field validation in
UserDTO.fromJsonviavalidateAll(collects all errors before throwing 422) - Per-route 5-minute cache on
GET /productswithX-Cache: HIT/MISSheader - Background task demo on
POST /products(fires after 201 response is delivered) POST /auth/logoutendpoint that revokes the access token viaInMemoryTokenStore- SQL migration files
0001_create_users_table.sqland0002_create_products_table.sqlgenerated inmigrations/ - Comprehensive
README.mdcovering all features, full project structure, all running modes, complete API reference with request/response examples, middleware pipeline diagram, Prometheus metrics, production checklist, and extending guide - Full
UserServicetest suite —getUsers(pagination, empty page),getUser(404),createUser,updateUser(success + reflect + 404),deleteUser(success + list + 404) - Auth test suite updated with
logoutgroup — verifies revoked token fails verification and logout completes without throw
0.1.36 #
- Add
dartapi build [--output=<name>] [--docker]— AOT-compiles the project to a self-contained native binary viadart compile exe;--dockerwrites a multi-stageDockerfilethat produces a minimaldebian:bookworm-slimruntime image - Add
dartapi run --isolates=N— spawns N Dart isolates all bound to the same port (HttpServer.bind shared: true), using every CPU core - Generated
DartAPI.start()gains ashared: boolparameter for multi-isolate mode - Generated
DartAPI.enableMetrics()— registersGET /metrics(Prometheus text format) and addsmetricsMiddlewareto the pipeline - Generated
main.dartreadsISOLATESenv var, spawns N−1 extra isolates, and passesshared: truetoapp.start() - Bump generated
dartapi_coredep to^0.0.24
0.1.35 #
- Bump generated
dartapi_coredep to^0.0.22(multi-field validation) - Bump generated
dartapi_authdep to^0.0.9(refresh token rotation)
0.1.34 #
- Add
dartapi generate resource <Name>— scaffolds a full CRUD resource: controller (GET list, GET by id, POST, PUT, DELETE), DTO withfromJson/toMap, and model withSerializable - Generated controller uses
pathParam<int>,queryParam<int>,PaginatedResponse, and returnsnullon DELETE for automatic 204 response - Prints wiring instructions and next steps after generation
0.1.33 #
- Add
dartapi run --env=<environment>— injectsAPP_ENVinto the server process (dartapi run --env=staging) - Combine with
--watch:dartapi run --env=dev --watch - Bump generated
dartapi_coredep to^0.0.21
0.1.32 #
- Move generated env files from project root into
env/subdirectory —env/.env.dev,env/.env.staging,env/.env.uat,env/.env.production,env/.env.example - Update generated
main.dartto load fromenv/.envandenv/.env.<APP_ENV> - Update generated
.gitignoreto excludeenv/.env*(keepsenv/.env.examplecommitted) - Add
dartapi run --watch— watcheslib/andbin/for.dartfile changes and auto-restarts the server (500 ms debounce)
0.1.31 #
dartapi generate controllernow prints wiring instructions — shows the import andapp.addControllers([...])call to add tobin/main.dart- Bump generated
dartapi_coredep to^0.0.20(fixes bool/num response serialization)
0.1.30 #
- Add generated
README.mdto scaffolded projects — covers project structure, per-environment run commands, environment variable reference, API endpoint table, migration and test commands - Fix CORS: generated
DartAPIclass now acceptscorsOriginand usesconfig.corsOrigininstead of hardcoded'*' - Add
AppConfig.validateForProduction()— warns at startup when production runs with development JWT secrets
0.1.29 #
- Fix: replace
dotenvexternal dependency with a built-inenv_loader.dart(no version-resolution issues, zero extra deps) - Generated
lib/src/config/env_loader.dartprovidesloadEnvFile(path)andmergeEnv(sources)— handles comments, inline comments, and quoted values
0.1.28 #
- Fix:
dartapi createnow runsdart pub getautomatically after scaffolding — packages are resolved immediately and IDEs show no missing-import errors
0.1.27 #
- Fix: generated
AuthControllertest usedusername: 'admin'but controller checksadmin@mail.com— corrected to match - Add multi-environment support to generated projects:
.env.dev,.env.staging,.env.uat,.env.productioneach scaffolded with appropriate defaults - Add
.env.example(committed) documenting all available environment variables - Add
dotenv: ^4.2.1to generatedpubspec.yaml—.envand.env.<APP_ENV>are loaded at startup - Generated
main.dartnow loadsDotEnvbeforeAppConfig, prints startup info in debug mode, and supports--port=Nalongside--port N - Generated
AppConfignow hasAppEnvironmentenum,isDev/isStaging/isUat/isProductionhelpers, per-env smart defaults fordebug,logLevel,jwtAccessExpiry,dbPoolSize, andcorsOrigin - Add
.gitignoreto generated projects (excludes.env.*files, keeps.env.example)
0.1.26 #
- Bump generated
dartapi_coredep to^0.0.19,dartapi_authto^0.0.8,dartapi_dbto^0.0.10
0.1.25 #
- Add
test/suite:utils_test.dart,create_command_constants_test.dart,generate_controller_test.dart,generate_migration_test.dart - Add
dart_test.yamlwithconcurrency: 1to prevent CWD conflicts across test files - Tests cover:
StringCasingExtension, template placeholder substitution, scaffolded file tree, controller generation, and migration numbering
0.1.24 #
- Add
AppConfig(lib/src/config/app_config.dart) to generated projects — typed env var config viaEnvConfig - Generated
main.dartreads DB and JWT credentials fromAppConfiginstead of hardcoded strings - Generated
DartAPIclass now exposesenableHealthCheck()which registersGET /health - Bump generated
dartapi_coredep to^0.0.18
0.1.23 #
- Fix: generated
AuthController.refreshTokennow parses request body as JSON instead of URL-encoded form data
0.1.22 #
- Fix: remove stale
bin/<name>.dartandlib/<name>.dartgenerated bydart create(causedavoid_printwarning) - Fix:
pageandlimitin generatedUserController.getAllUsersare now commented out to avoidunused_local_variablewarning - Fix: add
consttoApiExceptionthrows in generatedAuthControllerandProductController(prefer_const_constructors)
0.1.21 #
- Add
onStartup/onShutdownlifecycle hooks to generatedDartAPIclass - Shutdown hooks run on SIGINT and SIGTERM (SIGTERM skipped on Windows)
- Bump generated
dartapi_coredep to^0.0.16
0.1.20 #
- Extract all scaffolded file contents into
.tmplfiles underlib/templates/ - Add
TemplateEngineforIsolate.resolvePackageUri-based template loading and{{placeholder}}substitution CreateCommandConstants.files()is now async;createProjectandgenerateControllerare now asyncdartapi generate controllerusescontroller.dart.tmplinstead of an inline string
0.1.19 #
- Bump generated
dartapi_coredep to^0.0.14 - Generated
RouterManagernow registerscontroller.webSocketRoutesviashelf_router
0.1.18 #
- Bump generated
dartapi_coredep to^0.0.13
0.1.17 #
- Improve README: remove emojis, fix broken content, add MySQL example
0.1.16 #
- Fix generated
AuthController: invalid credentials now returns 401 (was 500); missing/invalid refresh token now returns 400/401 - Bump generated
dartapi_coredep to^0.0.11
0.1.15 #
- Bump generated
dartapi_coredep to^0.0.10
0.1.14 #
- Bump generated
dartapi_authdep to^0.0.6 - Bump generated
dartapi_dbdep to^0.0.8 - Generated
AuthController.refreshTokennow correctlyawaitsjwtService.verifyRefreshToken()
0.1.13 #
- Add
dartapi generate migration <name>— creates a numbered.sqlfile inmigrations/ - Add
dartapi db migrate [--dry-run]— runsbin/migrate.dartinside the project to apply pending migrations
0.1.12 #
- Bump generated
dartapi_coredep to^0.0.9 - Generated
RouterManagernow tracks all collected routes viacollectedRoutes - Generated
DartAPIclass now hasenableDocs({title, version})— call afteraddControllers()to serve/docs,/redoc,/openapi.json - Generated
main.dartnow callsapp.enableDocs(title: projectName, version: '1.0.0') - Add
dartapi docs [--port=<port>] [--out=<file>]CLI command to export OpenAPI spec from a running server
0.1.11 #
- Bump generated
dartapi_coredep to^0.0.7 - Generated
UserControllernow demonstrates query params (page,limit) andstatusCode: 201on POST - Generated
ProductControllernow demonstrates path params (GET /products/<id>) andstatusCode: 201on POST
0.1.10 #
- Add step-by-step running instructions to README
- Add Postman testing guide for all generated endpoints (auth, users, products)
0.1.9 #
- Update generated project templates to use latest package versions (
dartapi_db: ^0.0.7,dartapi_core: ^0.0.6,dartapi_auth: ^0.0.5) - Generated
main.dartnow includesPoolConfiginDbConfigto enable connection pooling by default
0.1.8 #
- Fix
dartapi run --port 8080(space-separated) now works alongside--port=8080
0.1.7 #
- Add Documentation for Postgress for Generated Project
- Fixed issues related to Postgres parsing.
0.1.6 #
- upgrade Dartapi core
0.1.4 #
- Update Readme
- Fix Controller Generator
0.1.3 #
- Repo License Changes
- Fix Code Issues
- Add DartApi Core, Dartpi Db
- Improve Project scaffolding and structure.
0.1.1 #
- Add Stop and Reload Server Support.
- Add Demo test for controllers.
0.0.9 #
- Separate CORE logic to separeate DartApi_core package
- Add some linting rules
0.0.8 #
- Improve type safety for Api Request Response
- Implemented Common Serailization Validation
- Changed HTTP Methods.
- Add Meta Data for OpenAPi Implementation
- Add More logs
0.0.7 #
- CORS support
0.0.6 #
- dart format
0.0.5 #
✅ Auth Middleware Support - Add Auth Middleware support for each route. ✅ Auth Middleware Template - Add Auth Middleware template. ✅ Fix Middleware loggin - Fix a Middle ware logging issue which prevented logs on dartapi run ✅ Add Default to CLI
0.0.4 #
✅ Custom Middleware Support - Add Custom Middleware support for each route.
0.0.3 #
✅ Request Validation Middleware - Request Validation using MiddleWare support Added and template generated
0.0.2 #
✅ CLI Tool - Generate projects, controllers, and models using the dartapi CLI.
0.0.1 #
✅ Fast and lightweight - Minimal dependencies, optimized for speed.
✅ Easy to use - Simple setup and minimal boilerplate.
✅ Configurable port - Start the server with a custom port (--port=<number>).
✅ Dynamic routing - Automatically registers controllers and their routes.
✅ Middleware support - Includes logging and future authentication middleware.
✅ CLI Tool - Generate projects, controllers, and models using the dartapi CLI.