A Deno Framework For Web Artisan - Inspired by Laravel
Project is archived during unmaintained, may be continue to maintained soon.
Denovel is Web Based Framework made by Muhammad Fauzan . Denovel is Inspired by Laravel.
git clone https://github.com/fauzan121002/denovel.git
cd denovel
.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
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
Denomand is official command-line interface for Denovel
deno run -A --unstable denomand.ts help
deno run -A --unstable denomand.ts controller --name </YourControllerName>
deno run -A --unstable denomand.ts middleware --name </YourMiddlewareName>
deno run -A --unstable denomand.ts model --name </YourModelName>
deno run -A --unstable denomand.ts provider --name </YourProviderName>
DenoDB is MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno currently used by Denovel
class User extends Model {
static table = "users";
static timestamps = false;
static fields = {
id: {
primaryKey: true,
autoIncrement: true
},
username: DataTypes.STRING,
password: DataTypes.STRING
};
}
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 |
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,
}
};
}
More datatypes:
Types |
---|
BIG_INTEGER |
INTEGER |
DECIMAL |
FLOAT |
UUID |
BOOLEAN |
BINARY |
ENUM |
STRING |
TEXT |
DATE |
DATETIME |
TIME |
TIMESTAMP |
JSON |
JSONP |
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]);
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]);
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 :
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
}
Contributions, issues and feature requests are welcome, make sure to read the contribution guideline
This project is licensed under the terms of the MIT license