Socket
Book a DemoInstallSign in
Socket

create-xianfires

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-xianfires

Simple JS Framework for Events Driven Programming

latest
npmnpm
Version
1.0.75
Version published
Weekly downloads
2.5K
-35.88%
Maintainers
1
Weekly downloads
ย 
Created
Source

XianFire Framework Documentation

Engineered by Christian I. Cabrera โ€” Instructor I, College of Computer Studies
Lightweight JS Framework for Events-Driven & Integrative Programming 2

๐Ÿ”ฅ Overview

XianFire is a minimal, Lightweight JS Framework for rapidly scaffolding full-stack web applications with built-in authentication, database integration (MySQL or MongoDB), Electron desktop app support, and dynamic code generation.

Designed for fast prototyping, student projects, desktop applications, and small-to-medium applications โ€” especially for Events-Driven Programming and Integrative Programming 2 at Mindoro State University.

โœจ Key Features

โœ… Express.js server with session-based auth
โœ… MySQL (Sequelize) or MongoDB (Mongoose) support
โœ… Electron desktop app integration
โœ… Auto-generated CRUD templates
โœ… CLI generator for models & controllers (create:model, create:controller)
โœ… Built-in migration system
โœ… .xian custom template engine
โœ… Tailwind CSS ready
โœ… Zero-config setup
โœ… Cross-platform desktop builds

๐Ÿ“ฆ Installation & Setup

1. Generate a new project

npm create xianfires@latest myApp

You'll be prompted to choose:

  • Template Type: Default Template or With CRUD Functions
  • Database: MongoDB or MySQL
  • Electron: Include Electron for desktop app support (optional)

๐Ÿ’ก If you don't specify a name, it defaults to xianfire-app.

2. Install dependencies

cd myApp
npm install

3. Run database migration

npm run migrate

โœ… Creates database (MySQL) or collections (MongoDB) + syncs models.

4. Start development server

npm run xian

๐ŸŒ Web app runs at โ†’ http://localhost:3000

5. (If Electron chosen) Run desktop app

# Development mode (server + Electron)
npm run xian-dev

# Production build
npm run xianca

๐Ÿ—‚๏ธ Project Structure

myApp/
โ”œโ”€ controllers/
โ”‚  โ”œโ”€ authController.js      # Login/Register/Dashboard logic (if CRUD)
โ”‚  โ”œโ”€ homeController.js      # Home page handler
โ”‚  โ””โ”€ *.js                   # Your generated controllers
โ”œโ”€ models/
โ”‚  โ”œโ”€ db.js                  # Sequelize connection (MySQL only)
โ”‚  โ”œโ”€ userModel.js           # Default User model
โ”‚  โ””โ”€ *.js                   # Your generated models
โ”œโ”€ routes/
โ”‚  โ””โ”€ index.js               # Main route definitions
โ”œโ”€ views/
โ”‚  โ”œโ”€ home.xian
โ”‚  โ”œโ”€ login.xian             # If CRUD template chosen
โ”‚  โ”œโ”€ register.xian
โ”‚  โ”œโ”€ dashboard.xian
โ”‚  โ””โ”€ *.xian                 # Your custom views
โ”œโ”€ public/
โ”‚  โ””โ”€ tailwind.css           # Pre-configured Tailwind
โ”œโ”€ electron/                 ๐Ÿ†• Electron desktop app files
โ”‚  โ””โ”€ main.js                # Electron main process
โ”œโ”€ create.js                 # CLI generator for models & controllers
โ”œโ”€ migrate.js                # Database initializer
โ”œโ”€ index.js                  # Server entry point
โ”œโ”€ package.json
โ””โ”€ node_modules/

โšก Core Features

1. .xian Template Engine

Render views with res.render("filename") โ€” no complex templating needed.

Example: views/home.xian

<!DOCTYPE html>
<html>
<head>
  <title>Home</title>
  <link href="/tailwind.css" rel="stylesheet">
</head>
<body class="bg-gray-50">
  <h1 class="text-3xl font-bold text-center mt-10">Welcome to XianFire ๐Ÿ”ฅ</h1>
  <p class="text-center mt-4">Home Page</p>
</body>
</html>

2. Authentication (CRUD Template Only)

RouteMethodDescription
/GETHome page
/loginGETRender login form
/loginPOSTAuthenticate user
/registerGETRender registration form
/registerPOSTCreate new user
/dashboardGETProtected dashboard (session)
/logoutGETDestroy session & redirect
/forgot-passwordGETForgot password page (stub)

3. Database Support

๐Ÿ˜ MySQL (Sequelize)

  • Connection defined in models/db.js
  • Models use sequelize.define()
  • Migration creates DB + tables

๐Ÿƒ MongoDB (Mongoose)

  • Connection handled in migrate.js
  • Models use mongoose.Schema
  • Migration ensures collections exist

4. ๐Ÿ–ฅ๏ธ Electron Desktop App (Optional)

XianFire includes seamless Electron integration:

  • Single codebase: Same app runs as web and desktop
  • Automatic server management: Express server runs inside Electron
  • Native menus: File and View menus with standard shortcuts
  • Cross-platform: Build for Windows, macOS, and Linux

Electron Features:

  • Native window with proper dimensions (1200x800)
  • Development tools integration
  • Standard application menu
  • Secure context isolation
  • Build system ready for distribution

๐Ÿงฐ CLI Code Generator

After project setup, generate models and controllers dynamically:

โž• Generate a Model

npm run create:model Product

โ†’ Creates models/Product.js:

import { DataTypes } from "sequelize";
import { sequelize } from "./db.js";

export const Product = sequelize.define("Product", {
  name: { type: DataTypes.STRING, allowNull: false },
  email: { type: DataTypes.STRING, allowNull: false },
  password: { type: DataTypes.STRING, allowNull: false }
});

export { sequelize };

โœ… Fields are customizable โ€” edit after generation.

โž• Generate a Controller

npm run create:controller productController

โ†’ Creates controllers/productController.js with full CRUD:

import { Product } from "../models/Product.js";

export const getAllProducts = async (req, res) => { ... };
export const createProduct = async (req, res) => { ... };
export const getProductById = async (req, res) => { ... };
export const updateProduct = async (req, res) => { ... };
export const deleteProduct = async (req, res) => { ... };

โœ… Auto-imports matching model. Uses PascalCase โ†” camelCase conversion.

๐Ÿš€ Usage Examples

1. Create a User (MySQL)

import { User } from './models/userModel.js';
import bcrypt from 'bcrypt';

const hashed = await bcrypt.hash('mypassword', 10);
await User.create({
  name: "Jane Doe",
  email: "jane@example.com",
  password: hashed
});

2. Find and Authenticate User

import bcrypt from "bcrypt";
import { User } from "./models/userModel.js";

const user = await User.findOne({ where: { email: "jane@example.com" } });
if (user && await bcrypt.compare("mypassword", user.password)) {
  console.log("โœ… Login successful!");
} else {
  console.log("โŒ Invalid credentials");
}

3. Add a New Route

In routes/index.js:

import { getAllProducts } from "../controllers/productController.js";

// Add after existing routes
router.get("/api/products", getAllProducts);

Then visit โ†’ http://localhost:3000/api/products

4. Run as Desktop App

If you chose Electron during setup:

# Development mode (auto-reload)
npm run xian-dev

# Production mode
npm run xianca

# Build distributable packages
npm run dist

โ†’ Creates executable files in dist/ folder for all platforms

๐Ÿ’พ Migration System

Run anytime to ensure DB structure is synced:

npm run migrate
  • MySQL: Creates DB (if missing) + drops & recreates tables (sync({ force: true }))
  • MongoDB: Connects + ensures collections exist by inserting/deleting dummy doc

โš ๏ธ Warning: MySQL migration wipes existing data. Use sync() without force in production.

๐Ÿ› ๏ธ Configuration

MySQL Connection (models/db.js)

import { Sequelize } from "sequelize";

export const sequelize = new Sequelize("myApp", "root", "your_password_here", {
  host: "localhost",
  dialect: "mysql",
});

๐Ÿ” Update username/password as needed.

MongoDB URI (migrate.js)

const DB_URI = `mongodb://127.0.0.1:27017/myApp`;

๐ŸŒ Change host/port if MongoDB runs elsewhere.

Electron Configuration (package.json)

The Electron build is pre-configured with:

  • App ID: com.xianfire.app
  • Output directory: dist/
  • Proper file inclusion/exclusion patterns
  • Multi-platform support

โš™๏ธ Available Scripts

CommandDescription
npm run xianStart server with auto-reload (nodemon)
npm startStart server (production)
npm run migrateInitialize/sync database
npm run create:model <Name>Generate Sequelize model
npm run create:controller <nameController>Generate Express controller
npm run xian-dev๐Ÿ†• Run Electron app in development
npm run xianca๐Ÿ†• Run Electron app (production)
npm run dist๐Ÿ†• Build distributable packages

๐Ÿงฉ Extending XianFire

You can easily extend the framework:

  • โœ… Add Models โ†’ models/YourModel.js
  • โœ… Add Controllers โ†’ controllers/yourController.js
  • โœ… Add Routes โ†’ Import in routes/index.js
  • โœ… Add Views โ†’ views/yourpage.xian
  • โœ… Add CSS/JS โ†’ public/ folder
  • โœ… Integrate Frontend โ†’ Vue, React, Svelte via CDN or build tools
  • โœ… Customize Electron โ†’ Modify electron/main.js for native features

๐Ÿ“Œ Important Notes

  • ๐Ÿ” Always ensure MySQL or MongoDB service is running before npm run migrate.
  • ๐Ÿช Authentication relies on express-session โ€” configure secret in index.js for production.
  • ๐Ÿงช Generated controllers assume RESTful conventions โ€” adjust routes as needed.
  • ๐Ÿ–ฅ๏ธ Electron: The same app runs identically in browser and desktop environments
  • ๐Ÿ“ฆ Distribution: Use npm run dist to create installers for Windows, macOS, and Linux
  • ๐Ÿง‘โ€๐Ÿ’ป For student projects: Great for demos, capstones, and rapid MVP development

๐ŸŽ“ Learning Path for Students

  • Generate project โ†’ npm create xianfires@latest myProject
  • Choose CRUD + MySQL + Electron for full-stack + desktop experience
  • Run npm run migrate โ†’ npm run xian
  • Visit http://localhost:3000 โ†’ Register a user
  • Use npm run create:model Book โ†’ npm run create:controller bookController
  • Add routes โ†’ Test API endpoints
  • Customize views โ†’ Add Tailwind styling
  • Test desktop version โ†’ npm run xian-dev
  • Build distributable โ†’ npm run dist
  • Deploy web version to Render/Vercel/Heroku

โœ… You're now ready to build blazing-fast web AND desktop apps with XianFire!

๐Ÿ”ง Editor Setup (VS Code)

To enable HTML syntax highlighting for .xian template files in Visual Studio Code, add this configuration to your VS Code settings.json:

โœ… Step-by-Step

  • Open VS Code
  • Press Ctrl + , (Windows/Linux) or Cmd + , (Mac) to open Settings
  • Click the "Open Settings (JSON)" icon in the top right (looks like a file with curly braces {})
  • Add or merge this snippet into your settings.json:
{
  "files.associations": {
    "*.xian": "html"
  }
}
  • Save the file.

โœ… Now all .xian files will be highlighted as HTML โ€” including autocomplete, formatting, and error detection!

๐Ÿ–ผ๏ธ Example Before & After

Before (No association)After (HTML highlighting)
Plain text, no colorsโœ… Syntax-highlighted HTML
No tag autocompleteโœ… <div>, class=, etc. work
Hard to readโœ… Easy to develop templates

"Simplicity is the ultimate sophistication." โ€” Designed for Mindoro State University students to learn, build, and ship without boilerplate headaches.

Now with desktop app superpowers! ๐Ÿš€

Happy coding!

Keywords

Christian I Cabrera

FAQs

Package last updated on 08 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.