Git Product home page Git Product logo

dchisel's Introduction

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 [email protected].

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.

dchisel's People

Contributors

shakannn avatar alalawy avatar

Stargazers

 avatar Farhan Fadhilah Djabari avatar Gabriel H. S. Gava avatar  avatar Elriz Wiraswara avatar Fajar Susilo avatar Verdi Pratama avatar  avatar Ramdani avatar Fairuz Fitrananda avatar Patricio Bonilla avatar Kab Agouda avatar AYMEN TOUMI avatar Alireza Easazade avatar 菘菘 avatar Kevin Wilfried avatar Dhari avatar Andres Garcia avatar  avatar Alvin Ferdian avatar Muhammad Dafi avatar Adam Santiaji avatar andikadeveloper avatar Pahrurozi avatar Ahmad Muhardian avatar

Watchers

James Cloos avatar  avatar  avatar Fajar Susilo avatar  avatar

Forkers

shakannn zateros

dchisel's Issues

RangeError when there are more than one routes of the same type (except GET)

Edit: Tested using the latest version available on pub.dev

Unhandled exception:
RangeError (index): Invalid value: Only valid value is 0: 1
#0      List.[] (dart:core-patch/growable_array.dart:264:36)
#1      DChisel.serve.routerData
package:dchisel/src/dchiselServer.dart:120
#2      DChisel.serve.createServer
package:dchisel/src/dchiselServer.dart:140
#3      DChisel.serve
package:dchisel/src/dchiselServer.dart:146
#4      main
bin/server.dart:65
#5      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:32)
#6      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)


===== CRASH =====
si_signo=Segmentation fault(11), si_code=1, si_addr=0x10
Exited (sigsegv)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.