搜索插件、代码仓与 APP 分类

插件详情v1.1.0+13

dchisel

一个用于创建REST API的简单Dart Web框架。DChisel支持自定义中间件以及MySQL和PostgreSQL ORM。

近 30 天下载
11
喜欢数
46
Pub 分数
80

安装插件

flutter pub add dchisel

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

DChisel 是一个轻量级的 Dart Web 框架,专为构建 REST API 而设计。它提供对 MySQL 和 PostgreSQL ORM 的内置支持,实现无缝的数据库交互。该框架允许开发者实现自定义中间件以处理请求和路由逻辑。专注于简洁性和性能,DChisel 非常适合需要结构化 API 开发与数据库集成的后端服务。它运行在 Dart 上,适用于面向 Web 环境的服务器端应用程序。

适合场景

  • 构建 RESTful API
  • 基于数据库的后端服务
  • 基于中间件的请求处理
  • 服务器端 Dart 应用程序
  • 与 MySQL/PostgreSQL 集成的 API

主要特点

  • 自定义中间件支持
  • MySQL 和 PostgreSQL ORM
  • 轻量且快速
  • 简单的 REST API 结构
  • Dart 原生的服务器端执行

适合对象

  • 使用 Dart 的后端开发人员
  • 构建以 API 为先的应用程序的团队
  • 需要数据库 ORM 的项目
  • Web 服务器,开销极小
  • 寻求简单服务器框架的开发者

使用建议

  • 有限的平台支持(不支持移动设备或桌面端)
  • 无内置认证
  • 复杂设置需要手动配置
  • 不适合用于用户界面密集型应用
  • 依赖社区维护

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Dchisel Logo

DChisel Dart Framework

DChisel is simple Dart Framework for creating REST API

pub package

English Documentation Indonesia Documentation

Features

  • Custom host server and port
  • GET, POST, PUT, DELETE, PATCH Routes
  • ORM CRUD to PostgreSQL
  • ORM CRUD to MySQL
  • Global Middleware
  • Specific Route Middleware
  • Auth
  • Base Response Ok & Forbidden
  • Header CORS
  • Base64 decode to File
  • Hotreload

Usage

To add the dchisel to your Dart application read the install instructions.

Host Server

Default host is "localhost" and port 8000

import 'package:dchisel/dchisel.dart';

Future<void> main(List<String> arguments) async {
  DRoute route() {
    var droute = DRoute();
    droute.get('/', (Request req) async => resOk("Hello, DChisel"));
    return droute;
  }
  DChisel().serve(getroutes: route());
}

If you want to change the host to 0.0.0.0 and port to 5555 you can use :

 DChisel().serve(getroutes: route(), serverHost: '0.0.0.0', serverPort: 5555);
GET Route
droute.get('/hello', (Request request) {
    return 'Hello, World';
});

GET with param you can use :

droute.get('/getparam/<name>', (Request request, String name) {
    return 'Hello, $name';
});
POST Route
droute.post('/hello', (Request request) async {
    return 'Hello, World';
});

If you want to get Body value from your POST request, use :

var body = await request.body.asJson;

If you want to get Header value from your POST request, use :

var headers = await request.headers;
PUT Route
droute.put('/hello/<name>', (Request request, String name) async {
  return 'Hello, $name';
});

PUT also can get Header and Body request

var headers = await request.headers;
var body = await request.body.asJson;
DELETE Route
droute.delete('/hello/<name>', (Request request, String name) async {
  return 'Hello, $name';
});

Dchisel ORM

For now, DChisel only support PostgreSQL and MySQL

DB Config
DChiselDB().configDB('dialect', // DIALECT DATABASE, IF YOU USE POSTGRESQL CHANGE 'dialect' to 'postgre', IF YOU USE MYSQL CHANGE 'dialect' to 'mysql'
    host: 'your_host',
    db: 'your_db_name',
    port: your_port, //integer
    username: 'your_db_username',
    password: 'your_db_password');
Get All Data
DChiselDB().getAll('your_table_name');
Get Data With Custom Column and Filter
DChiselDB().getOption('your_table_name', 
    column: 'your_column1,your_column2', 
    where: ['your_column_name', 'your_filter_value']);

If you want filter contains, just add % into your filter value, example :

'%your_filter_value%'
Create Data
DChiselDB().create('users', data: {
    'your_column_name': 'your_value'
});
Update Data
DChiselDB().update('users', data: {
    'your_column_name': 'your_value'
}, where: ['your_filter_column_name', 'your_filter_value']);
Delete Data
DChiselDB().deleteAll('your_table_name');
Delete Data Custom Filter
DChiselDB().deleteOption('your_table_name', where: ['your_filter_column_name', 'your_filter_value']);

Issues

Please file any issues, bugs or feature requests as an issue on our GitHub page. Commercial support is available, you can contact us at <alphacsoft@gmail.com>.

Want to contribute

If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our contribution guide and send us your pull request.

Author

This dchisel framework for Dart is developed by Alphacsoft.

所属分类

依赖

依赖清单 14 项

源码仓库

使用此插件的项目

暂无相关数据。