veko
Version:
Ultra-lightweight Node.js framework with ZERO dependencies - VSV components, Tailwind CSS, asset imports, SSR
112 lines (95 loc) • 2.65 kB
JavaScript
/**
* VekoJS - Zero Dependencies Framework
* @module veko
* @version 1.2.25
*/
const App = require('./lib/app');
// Import VSV support
let VSVSupport = null;
let VekoPHP = null;
let VekoTailwind = null;
try {
VSVSupport = require('./lib/vsv');
VekoPHP = require('./lib/vsv/php');
VekoTailwind = require('./lib/vsv').VekoTailwind;
} catch (error) {
// VSV support error
}
// Import Core modules
let Core = null;
try {
Core = require('./lib/core');
} catch (error) {
// Core module error
}
// Export principal
module.exports = {
App,
// Create a new app
createApp: (options = {}) => new App(options),
// Start in development mode
startDev: (options = {}) => {
const app = new App({
...options,
isDev: true
});
return app.listen(options.port || 3000);
},
// Start in production mode
start: (options = {}) => {
const app = new App({
...options,
isDev: false
});
return app.listen(options.port || 3000);
},
// VSV Support
VSV: VSVSupport,
VekoPHP: VekoPHP,
VekoTailwind: VekoTailwind,
// Core modules
Core: Core,
PageTypes: Core?.PageTypes,
PageSymbols: Core?.PageSymbols,
ModuleManager: Core?.ModuleManager,
PageBuilder: Core?.PageBuilder,
PageRouter: Core?.PageRouter,
defineConfig: Core?.defineConfig,
getConfig: Core?.getConfig,
// Create a VSV app
createVSVApp: async (options = {}) => {
const app = new App(options);
await app.enableVSV(options.vsv || options);
return app;
},
// Start a VSV app in development mode
startVSVDev: async (options = {}) => {
const app = new App({
...options,
isDev: true
});
await app.enableVSV(options.vsv || options);
return app.listen(options.port || 3000);
},
// Create a full-featured app with modules/themes
createModularApp: async (options = {}) => {
const app = new App(options);
await app.enableVSV(options.vsv || options);
// Initialize module system if Core is available
if (Core?.ModuleManager && app.vsv) {
app.modules = new Core.ModuleManager(app.vsv, options);
await app.modules.init();
// Apply default theme if specified
if (options.defaultTheme) {
await app.modules.setTheme(options.defaultTheme);
}
// Auto-load modules
if (options.autoLoadModules) {
for (const moduleName of options.autoLoadModules) {
await app.modules.enableModule(moduleName);
}
}
}
return app;
}
};