Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
MVCube is a powerful CLI tool designed to streamline the development process in Next.js projects. It allows developers to quickly generate MVC (Model-View-Controller) structures, including Models, Controllers, Views, and reusable UI Components. MVCube sim
MVCube is a CLI tool that simplifies the creation of MVC structures and reusable components in Next.js projects. It helps to quickly set up Models, Controllers, Views, and Components (both global and local).
Install globally with:
npm install -g mvcube
mvcube create <resource-name>
Example:
mvcube create product
This will generate the necessary files for creating a Model, Controller, and Views for a resource.
mvcube componentize <component-name>
Example:
mvcube componentize button
This will extract a section of your code into a reusable component and place it in the appropriate components
folder. You will then choose whether the component is global or local.
The CLI generates the following structure for the create
command:
src/
├── models/
│ └── product.ts
├── controllers/
│ └── productController.ts
└── app/
└── product/
├── page.tsx
└── [id]/
└── page.tsx
For the componentize
command, the CLI creates a component in the components/
folder:
src/
└── components/
└── <component-name>.tsx
product.ts
): Defines the resource's type in TypeScript.productController.ts
): Implements CRUD operations.page.tsx
): Displays a list of resources.[id]/page.tsx
): Displays details of a specific resource.<component-name>.tsx
): A reusable UI component. You can choose whether the component will be global (used throughout the entire application with the alias @/components/{Componente}
) or local (used only within the current page with a relative import ./components/{Componente}
).product
When you run:
mvcube create product
The following files will be created:
src/models/product.ts
)export type Product = {
id: string;
name: string;
description?: string;
price: number;
stock: number;
category: string;
};
src/controllers/productController.ts
)import { Product } from "../models/product";
// List all products
export const getAllProducts = async () => {
return [{ id: "1", name: "Product A", price: 100 }];
};
// Get a product by ID
export const getProductById = async (id) => {
return { id, name: "Product A", price: 100 };
};
// Create a product
export const createProduct = async (data: Product) => {
const newProduct = { id: Date.now().toString(), ...data };
return newProduct;
};
// Update a product
export const updateProduct = async (id, data) => {
const updatedProduct = { id, ...data };
return updatedProduct;
};
// Delete a product
export const deleteProduct = async (id) => {
return { success: true, id };
};
src/app/product/page.tsx
)import { getAllProducts } from "../../controllers/productController";
export default async function ProductPage() {
const products = await getAllProducts();
return (
<div>
<h1>Product List</h1>
<ul>
{products.map((product) => (
<li key={product.id}>
{product.name} - ${product.price}
</li>
))}
</ul>
</div>
);
}
src/app/product/[id]/page.tsx
)import { getProductById } from "../../../controllers/productController";
type Params = {
params: {
id: string;
};
};
export default async function ProductDetailPage({ params }: Params) {
const product = await getProductById(params.id);
return (
<div>
<h1>Product Details</h1>
<p>Name: {product.name}</p>
<p>Price: ${product.price}</p>
</div>
);
}
componentize
When you run:
mvcube componentize button
The CLI will prompt you to choose whether the component should be global or local. Based on your choice, the component will be placed in the components/
folder, and it will either be imported globally or locally.
Global components are stored in the src/components/
directory and can be used throughout the entire application.
The import path for global components will be:
import Button from "@/components/button";
Example structure:
src/
└── components/
└── button.tsx
Local components are also stored in the src/components/
directory but are used only within the page where they are located.
The import path for local components will be:
import Button from "./components/button";
Example structure:
src/
└── components/
└── button.tsx
src/components/button.tsx
)export default function Button({ label }: { label: string }) {
return <button>{label}</button>;
}
src/components/button.tsx
)export default function Button({ label }: { label: string }) {
return <button>{label}</button>;
}
Feel free to contribute! Open an issue or submit a pull request on the GitHub repository.
This project is licensed under the MIT License.
FAQs
MVCube is a powerful CLI tool designed to streamline the development process in Next.js projects. It allows developers to quickly generate MVC (Model-View-Controller) structures, including Models, Controllers, Views, and reusable UI Components. MVCube sim
The npm package mvcube receives a total of 0 weekly downloads. As such, mvcube popularity was classified as not popular.
We found that mvcube demonstrated a healthy version release cadence and project activity because the last version was released less than 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.