Skip to content

shamimhaque-mpi/devlien

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

91 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Devlien Framework

Devlien is a minimal and flexible Node.js backend framework designed to work seamlessly with:

  • βœ… Nuxt.js
  • βœ… Next.js
  • βœ… NestJS
  • βœ… Or run independently as a standalone server

It gives you a Laravel-like development experience while staying simple and unopinionated.


⚑ Quick Start (Standalone Server)

npm create devlien@latest devlienApp

πŸš€ Quick Start with Nuxt.js or Nextjs

This guide will walk you through installing and using Devlien in a Nuxt.js, Nextjs project.


1️⃣ Install the Framework (If you install Devlien into any other framework)

In your Nuxtjs or Nextjs project root, install Devlien:

npm install devlien

2️⃣ Run the Setup Command (If you install Devlien into any other framework)

Initialize the server environment using:

npx devlien setup

This will automatically create the following structure inside your project:

server
β”œβ”€β”€ app
β”‚   β”œβ”€β”€ Http
|   |   β”œβ”€β”€Controllers
|   |   β”œβ”€β”€Middleware
|   |   └──Resources
β”‚   β”œβ”€β”€ Models
β”‚   └── Providers
β”œβ”€β”€ config
β”‚   β”œβ”€β”€ app
β”‚   └── database
β”œβ”€β”€ database
β”‚   β”œβ”€β”€ migrations
β”‚   └── seeds
β”œβ”€β”€ routes
β”‚   β”œβ”€β”€ web
β”‚   └── api
β”œβ”€β”€ resources
β”‚   └── views
β”œβ”€β”€ .env

3️⃣ Configure .env File

Edit the generated .env file and set your database configuration:

APP_NAME="Devlien"

DB_CONNECTION="mysql"
DB_HOST="localhost"
DB_PORT="3306"
DB_USERNAME=root
DB_PASSWORD=secret
DB_NAME=devlien

βœ… You must have a running MySQL/MariaDB database before proceeding.


✨ Generate Core Components

Devlien includes several command-line tools to help you build faster:


πŸ“‚ Create a Controller

npx devlien make:controller HomeController

This will generate:
server/app/Controllers/HomeController.js


πŸ“¦ Create a Model

npx devlien make:model User

This will generate:
server/app/Models/User.js


🧱 Create a Migration

npx devlien make:migration users

This will generate:
server/database/migrations/2025_06_23_XXXXXX_users.js

Edit the file to define your table structure.


πŸ”„ Run Migrations

npx devlien migrate
npx devlien migrate:rollback --all

This will execute all pending migrations and create tables in your database.


πŸš€ Create a HTTP Resource

npx devlien make:resource

You’ll be prompted to enter the resource name (e.g., Product) and Devlien will generate resource for you.


πŸ“š Migration Usage Example

In your migraion: /database/migrations/...users.js

import Migration from "devlien/migration";

export default class extends Migration {
    up(schema){
        schema.create('users', (table)=>{
           table.increments('id');
           table.string('name');
           table.string('email').unique();
           table.string('password');
           table.set('status', ['active', 'inactive']).default('active');
        });
    }
    down(schema){
        schema.drop('users');
    }
}

πŸ“š Route Usage Example

In your routes/api.js:

import route from "devlien/route";
import Auth from "../app/Http/Middleware/Auth.js";

export default route.serve(route => {
    route.group({'prefix':'api', 'middleware':[Auth]}, (route)=>{
        route.get('index', 'UserController@index');
        route.put('create', 'UserController@create'); 
        route.put('update/:id', 'UserController@update');
    })
});

πŸ“„ Template Usage Example

In you controller

import view from "devlien/view";

export default class DevlienController extends Controller {
    constructor() {
        super();
        // Any setup or initialization can go here.
    }
    async wellcome(request) {
        return await view('wellcome', {title:'Wellcome to Devlien'});
    }
}

In you template (root/resources/views/wellcome.dl)

<template>
    <h1>{{ title }}</h1>
    <p>{{ version }}</p>
</template>

@script
    const version = "1.0.3";
@endscript

πŸ“š Model Usage Example

In your controller:

import User from "../../Models/User.js";

// Fetch users
let users = await User.get();


// or
let user = new User();
let users = await user.get();
await User.limit(10).get();
await User.skip(5).limit(10).get();
await User.where({id:1}).where([{id:1}, {id:1}]).where(['id', '=', 1]).get();
await User.where({id:1}).first();
await User.create({
    "name" : "Shamim Haque",
    "username" : "shmimhaque",
    "email" : "shamim.haque.dev@gmail.com"
});
await User.where({id:1}).update({
    "name" : "Shamim Haque",
    "email" : "shamim.haque.dev@gmail.com"
});

More query methods coming soon...


🧾 Roadmap (Coming Soon)

  • Authentication scaffolding
  • RESTful API boilerplate
  • Collection map
  • Queue process

πŸ‘¨β€πŸ’» Author

Shamim Haque
GitHub: @shamimhaque-mpi
πŸ“§ Email: shamim.haque.dev@gmail.com


πŸ“„ License

This project is open-source and available under the MIT License.

About

Lightweight Node.js framework that works seamlessly with Next.js, Nuxt.js, Angular or as a standalone backend server.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors