Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
ezzy-express-mvc
Advanced tools
A complete mvc infrastructure to render pages from a specific directory based.
A complete mvc infrastructure to render pages from a specific directory.
You can use this class to recurse through a directory that contains Controllers, Models and Views to prepare an application with multiple routes mapped accordingly. This utility maps all controllers to their respective views and provides the necessary models to generate the response.
When the application initializes, an instance to the controller is
registered in the express application. Then, at the time of the request,
an instance of the respective model gets injected into the view of the
application. While the model is injected, the code checks for any JS and CSS
assets that exist in the respective assets directory. During production,
this directory is only checked once, but in development, the directory
is checked on every request. Additionally, sass and compass have been
implemented to allow dynamic CSS generation to the corresponding /css
folder.
For example, you can structure your directory in this manner:
And now in your localhost.js file, you can simply invoke it like this:
const ExpressMvc = require('ezzy-express-mvc');
new ExpressMvc(__dirname + '/src')
.promise // we have to wait for file detection.
.then(app => app.listen(9000));
If you'd like to bind other applications to the same port, simply use:
const ExpressMvc = require('ezzy-express-mvc');
new ExpressMvc(__dirname + '/src')
.promise
.then(app => app.bindExpressMvc(__dirname + '/anotherDirectory'))
.then(app => app.listen(9000));
/**
* @param {string} directory The directory of the mvc sources.
* @param {Function|Function[]} middleware Any middleware that's required.
* @param {function({HttpBasics}):boolean} requestFilter The filter function that decides if this instance of the MVC application will handle the request.
* @param {RegExp} domainReg The regular expression for the domain or the function that will check if the route will be resolved.
* @param {string[]|string} statics The static routes to assign before anything. Note: These routes are directories matching the context of the folders within the application.
* @param {boolean} bind404 If we should bind a 404 route after all the controllers are bound to avoid continuing to any other applications.
* @param {string} customErrorDir The custom error directory where the application can find [error-status].html files.
* @param {Function|Function[]} globalMiddleware The global middleware to use on this and all other bound MVC applications.
* @param {express} expressDependency The express instance to be used if a certain version is required.
* @param {string} partials The name of the partials directories.
* @param {string} layouts The name of the layouts directories.
* @param {string} helpersFile The file containing handlebars helpers.
* @param {string[]} partialsDirectories Any additional directories to look for partials.
* @param {string[]} layoutsDirectories Any additional directories to look for layouts.
* @param {string[]} otherStatics Any additional directories to use as static files.
*/
const defaultConfig = {
directory: undefined,
middleware: undefined,
domainReg: /.*/,
statics: undefined,
bind404: false,
requestFilter: undefined,
customErrorDir: 'errors',
globalMiddleware: undefined,
expressDependency: undefined,
partials: undefined,
layouts: undefined,
helpersFile: undefined,
partialsDirectories: [],
layoutsDirectories: [],
otherStatics: []
};
FAQs
A complete mvc infrastructure to render pages from a specific directory based.
The npm package ezzy-express-mvc receives a total of 0 weekly downloads. As such, ezzy-express-mvc popularity was classified as not popular.
We found that ezzy-express-mvc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.