koa 0.0.1

  • Readme
  • Changelog
  • Installing
  • 47

dart koa #

  • 基于Dart语言实现的后端框架
  • 借鉴了Node.js koa框架的api设计
  • 实现了中间件和context,可自由开发中间件

安装 #

在pubspec.yaml文件中的dependencies添加 #

  koa: any

执行安装依赖 #

  pub get

来写一个 Hello World #

运行需要Dart环境, 可以点击 Dart环境搭建查看和下载SDK

创建一个文件夹, 并且创建一个 pubspec.yaml 文件 #

  mkdir dart-koa
  touch ./dart-koa/pubspec.yaml

编辑pubspec.yaml内容 #

  name: 项目名称
  version: 0.0.1
    sdk: '>=2.3.0 <3.0.0'
    koa: any

进入项目目录 #

  cd ./dart-koa

在项目目录中执行安装依赖 #

  pub get

代码编写 #

  mkdir lib
  touch lib/main.dart

编辑内容 #

import 'package:koa/koa.dart';

main() {
  final Koa app = Koa();

  app.use((ctx, next) {
    ctx.response.string = 'hello world';

  app.listen(3030, callback: () {

启动服务 #

dart lib/main.dart

现在打开浏览器访问 http://localhost:3030 就能看到内容啦!

0.0.1 #

  • 第一个版本发布

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  koa: ^0.0.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:koa/koa.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health issues and suggestions

Document public APIs. (-1 points)

61 out of 61 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/request.dart. (-0.50 points)

Analysis of lib/request.dart reported 1 hint:

line 110 col 11: Use isNotEmpty instead of length

Format lib/context.dart.

Run dartfmt to format lib/context.dart.

Format lib/koa.dart.

Run dartfmt to format lib/koa.dart.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/response.dart (Run dartfmt to format lib/response.dart.)
  • lib/utils/compose.dart (Run dartfmt to format lib/utils/compose.dart.)
  • lib/utils/send-file.dart (Run dartfmt to format lib/utils/send-file.dart.)

Maintenance issues and suggestions

The description contains too many non-ASCII characters. (-20 points)

The site uses English as its primary language. The value of the description field in your package's pubspec.yaml field should primarily contain characters used in English.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and koa.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
http_server ^0.9.8+3 0.9.8+3
mime ^0.9.6+3 0.9.6+3
Transitive dependencies
path 1.6.4