Skip to main content

thunder_api 1.1.0 copy "thunder_api: ^1.1.0" to clipboard
thunder_api: ^1.1.0 copied to clipboard

CLI that builds a Postman collection, web API docs and Express routes from simple // @desc, // @route comments in your Node.js controllers.

example/thunder_api_example.dart

import 'dart:convert';

import 'package:thunder_api/thunder_api.dart';

/// Builds a Postman collection from the sample controllers in
/// `example/controllers` without the interactive prompts, and prints it.
///
/// From the command line, the same thing is:
///
/// ```bash
/// thunder_api --build-api-doc   # Postman collection + web docs
/// thunder_api --build-routes    # Express route files
/// ```
Future<void> main() async {
  List<RequestData> requests =
      await ReadRequestFromMethods.getAllRequestsFromDir('example/controllers');

  ApiCollectionModel collection = ApiCollectionModel(
    infoCollection: InfoModel(
      collectionName: "Shop API",
      baseUrl: "http://localhost:3000",
    ),
    variables: [
      VariableModel(key: "base_url", value: "http://localhost:3000"),
      VariableModel(key: "token", value: "paste-a-token-here"),
    ],
    requestCollectionModel: RequestsAdapter.requestsAdapter(requests),
  );

  print(const JsonEncoder.withIndent('  ').convert(collection.toMap()));
}
2
likes
160
points
804
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

CLI that builds a Postman collection, web API docs and Express routes from simple // @desc, // @route comments in your Node.js controllers.

Repository (GitHub)
View/report issues

Topics

#cli #postman #api #express #documentation

License

MIT (license)

Dependencies

args, path

More

Packages that depend on thunder_api