Denovel Save Abandoned

A Deno Framework For Web Artisan - Inspired by Laravel

Project README

Project is archived during unmaintained, may be continue to maintained soon.

tag License: MIT tag

Denovel is Web Based Framework made by Muhammad Fauzan . Denovel is Inspired by Laravel.

Table of Contents

Installation

  1. Clone Repository
git clone https://github.com/fauzan121002/denovel.git
cd denovel
  1. Open .env then change it by your database information
PORT=3000
BASE_URL=http://localhost:3000

#only support mysql,mongo,sqlite, and postgres
#you may experience some trouble in mariaDB (mysql)
#see the problem here https://github.com/manyuanrong/deno_mysql/issues/29
DB_CONNECTION=postgres
DB_HOST=localhost
DB_NAME=denovel
DB_USER=username
DB_PASS=password
DB_PORT=5432
  1. Run the server
deno run -A --unstable server.ts

or you can use denon (make sure you already install denon in your local computer , see the guide here)

denon run -A --unstable server.ts

Usage

Denomand

Denomand is official command-line interface for Denovel

Help

deno run -A --unstable denomand.ts help

Create a controller

deno run -A --unstable denomand.ts controller --name </YourControllerName>

Create a middleware

deno run -A --unstable denomand.ts middleware --name </YourMiddlewareName>

Create a model

deno run -A --unstable denomand.ts model --name </YourModelName>

Create a provider

deno run -A --unstable denomand.ts provider --name </YourProviderName>

Model

DenoDB is MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno currently used by Denovel

Model Example

class User extends Model {
    static table = "users";
    static timestamps = false;

    static fields = {
        id: {
            primaryKey: true,
            autoIncrement: true
        },
        username: DataTypes.STRING,
        password: DataTypes.STRING
    };
}

Model Field Options

  static fields = {
    email: {
      type: DataTypes.STRING,
      unique: true,
      allowNull: false,
      length: 50,
    },
  };

Field Options :

Option Usage
type Datatypes List
unique boolean
allowNull boolean
length integer

Model Datatypes

Example usage of boolean and integer:

class BlockedUsers extends Model {
    static table = "blocked_users";
    static timestamps = false;

    static fields = {
        id: {
            primaryKey: true,
            autoIncrement: true,
        },
        user_id: {
            type: DataTypes.INTEGER,
        },
        is_verified: {
            type: DataTypes.BOOLEAN,
        }
    };
}
Datatypes List

More datatypes:

Types
BIG_INTEGER
INTEGER
DECIMAL
FLOAT
UUID
BOOLEAN
BINARY
ENUM
STRING
TEXT
DATE
DATETIME
TIME
TIMESTAMP
JSON
JSONP

Model Relationship

One to One :
import {db, DataTypes, Model} from "../../vendor/Denovel/Support/Facades/DB.ts";

import { Relationships } from 'https://deno.land/x/denodb/mod.ts';

class Owner extends Model {
  // ...

  // Fetch a business binded to this owner
  static business() {
    return this.hasOne(Business);
  }
}

class Business extends Model {
  // ...

  // Fetch an owner binded to this business
  static owner() {
    return this.hasOne(Owner);
  }
}

Relationships.oneToOne(Business, Owner);

db.link([Owner, Business]);
One to Many
import {db, DataTypes, Model} from "../../vendor/Denovel/Support/Facades/DB.ts";

import { Relationships } from 'https://deno.land/x/denodb/mod.ts';

class Owner extends Model {
  static table = 'owners';

  static fields = {
    id: {
      type: DataTypes.STRING,
      primaryKey: true,
    },
    name: DataTypes.STRING,
  };

  static businesses() {
    return this.hasMany(Business);
  }
}

class Business extends Model {
  static table = 'businesses';

  static fields = {
    id: {
      type: DataTypes.STRING,
      primaryKey: true,
    },
    name: DataTypes.STRING,
    ownerId: Relationships.belongsTo(Owner),
  };

  static owner() {
    return this.hasOne(Owner);
  }
}

db.link([Owner, Business]);

Many to Many
import {db, DataTypes, Model} from "../../vendor/Denovel/Support/Facades/DB.ts";

import { Relationships } from 'https://deno.land/x/denodb/mod.ts';

class Owner extends Model {
  static table = 'owners';

  static fields = {
    id: {
      type: DataTypes.STRING,
      primaryKey: true,
    },
    name: DataTypes.STRING,
  };

  static businesses() {
    return this.hasMany(Business);
  }
}

class Business extends Model {
  static table = 'businesses';

  static fields = {
    id: {
      type: DataTypes.STRING,
      primaryKey: true,
    },
    name: DataTypes.STRING,
  };

  static owners() {
    return this.hasMany(Owner);
  }
}

const BusinessOwner = Relationships.manyToMany(Business, Owner);

db.link([BusinessOwner, Business, Owner]);

Further informations :

Controller

Using Validation

async post({ request, response, params }: RouterContext) {
  const body = await request.body();
  const [passes,errors] = await super.validate(body.value,{
    todo: 'required|string'
  });

  //then you can do anything with passes , errors and body value
}

? Contributing

Contributions, issues and feature requests are welcome, make sure to read the contribution guideline

? License

This project is licensed under the terms of the MIT license

Open Source Agenda is not affiliated with "Denovel" Project. README Source: fauzan121002/denovel
Stars
129
Open Issues
2
Last Commit
3 years ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating