Skip to main content

dartcore_core 0.1.0 copy "dartcore_core: ^0.1.0" to clipboard
dartcore_core: ^0.1.0 copied to clipboard

Typed exceptions and layered configuration (.env files, environment variables, secret sources) for DartCore backend applications.

dartcore_core #

Typed exceptions and layered configuration (.env files, environment variables, secret directories) for DartCore backend applications.

Part of DartCore, a pure-Dart backend SDK. Most apps import the umbrella package dartcore_framework, which re-exports this one.

Install #

dart pub add dartcore_core

Usage #

import 'package:dartcore_core/dartcore_core.dart';

Future<void> main() async {
  await Config.load();                       // .env, then .env.<APP_ENV>; process env wins
  final port = Config.getInt('APP_PORT', 8080);
  final debug = Config.getBool('APP_DEBUG');
  final secret = Config.require('JWT_SECRET'); // throws ConfigurationException if missing

  print(Config.environment.name);            // development | testing | staging | production
}

External secrets (for example mounted files) can be layered in:

await Config.load(sources: [DirectorySecretSource('/run/secrets')]);

Exceptions carry an HTTP status that dartcore_api turns into a response: ValidationException (422), AuthenticationException (401), AuthorizationException (403), NotFoundException (404), HttpStatusException(status, message), plus ConfigurationException, DatabaseException, ConnectionException and QueryException.

A complete, runnable program is in example/.

Status and limits #

Pre-1.0: the API may change between minor versions. An unknown APP_ENV value is treated as production. See the implementation status and the getting started guide for the list of configuration keys.

0
likes
160
points
--
downloads

Documentation

API reference

Publisher

unverified uploader

Typed exceptions and layered configuration (.env files, environment variables, secret sources) for DartCore backend applications.

Repository (GitHub)
View/report issues
Contributing

Topics

#backend #configuration #env #server

License

MIT (license)

More

Packages that depend on dartcore_core