패키지, 저장소 및 앱 카테고리 검색

GitHub 저장소alalawy/DChisel

DChisel

DChisel은 REST API를 생성하기 위한 간단한 Dart 프레임워크입니다

DChisel 프로젝트 이미지
스타
25
포크
2
최근 푸시(UTC)
2023. 7. 7.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

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.

M Nasrul Alawy GitHub avatar
GitHub 작성자

M Nasrul Alawy ↗

Im a CEO of Alphacsoft. My Basic Prog.Language is C#, But In Job, I Take Python or Golang for Web Backend, React.Js for Web Frontend, Java or Kotlin For Android

AlphacsoftJl. Cipto Mangunkusumo, Majidi - 83619공식 웹사이트 ↗
언어Dart

분류

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 13 개

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗