Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Santuy is a nextjs framework and SQL for auto generate data from model
You are viewing docs for the v1 of santuy
Features:
//model (models/models.ts)
import { ProductModel } from "./product-model";
import { UserModel } from "./user-model";
import { CategoryModel } from "./category-model";
//define all models
const models: any = {
'categories': CategoryModel,
'products': ProductModel,
'users': UserModel,
}
export { models }
//model users (file: models/user-model.ts)
const UserModel = {
name: 'users',
icon: 'AiOutlineUser',
columns: [
{
name: 'id',
title: 'ID',
dataType: 'INT AUTO_INCREMENT PRIMARY KEY',
inputType: 'number',
},
{
name: 'username',
title: 'Username',
dataType: 'VARCHAR(100) NULL',
inputType: 'text',
},
{
name: 'password',
title: 'Password',
dataType: 'VARCHAR(255) NULL',
inputType: 'password',
},
{
name: 'name',
title: 'Name',
dataType: 'VARCHAR(30) NULL',
inputType: 'text',
},
{
name: 'avatar',
title: 'Avatar',
dataType: 'VARCHAR(100) NULL',
inputType: 'image',
},
{
name: 'address',
title: 'Address',
dataType: 'VARCHAR(100) NULL',
inputType: 'textarea',
},
],
};
export { UserModel }
//model categories (file: models/category-model.ts)
const CategoryModel = {
name: 'categories',
icon: 'AiOutlineFileAdd',
columns: [
{
name: 'id',
title: 'ID',
dataType: 'INT AUTO_INCREMENT PRIMARY KEY',
inputType: 'number',
},
{
name: 'name',
title: 'Category Name',
dataType: 'VARCHAR(100) NULL',
inputType: 'text',
},
],
};
export { CategoryModel }
//model categories (file: models/product-model.ts)
const ProductModel = {
name: 'products',
icon: 'AiOutlineFileAdd',
columns: [
{
name: 'id',
title: 'ID',
dataType: 'INT AUTO_INCREMENT PRIMARY KEY',
inputType: 'number',
},
{
name: 'categoryId',
title: 'Category',
dataType: 'INT NULL',
inputType: 'select',
selectData: "categories",
relation: 'categories.id'
},
{
name: 'name',
title: 'Item Name',
dataType: 'VARCHAR(100) NULL',
inputType: 'text',
},
{
name: 'plu',
title: 'PLU',
dataType: 'VARCHAR(50) NULL',
inputType: 'text',
},
{
name: 'unit',
title: 'Unit',
dataType: 'VARCHAR(30) NULL',
inputType: 'text',
},
{
name: 'cost',
title: 'Cost',
dataType: 'INT NULL',
inputType: 'number',
},
{
name: 'price',
title: 'Price',
dataType: 'INT NULL',
inputType: 'number',
},
{
name: 'qty',
title: 'Qty',
dataType: 'INT NULL',
inputType: 'number',
},
],
includes: [
{
model: 'categories',
relation: 'categoryId'
}
]
};
export { ProductModel }
//file: api/migrate/route.ts
//url: http://localhost:3000/api/migrate
import { models } from '@/models/models'
import { NextResponse } from 'next/server'
import { NextRequest } from "next/server"
import { DatabaseType, migrate, MigrateType } from 'santuy'
export async function GET(request: NextRequest) {
let dev = process.env.ENV == "development" || false;
if(!dev){
return NextResponse.json("Migration not allowed!", { status: 400 })
}
let database: DatabaseType = {
host: "localhost",
user: "root",
password: "",
port: 3306,
database: "santuy",
}
let mig: MigrateType = {
models,
database
}
let response: any = await migrate(mig);
if (!response) {
return NextResponse.json("Migration error!", { status: 400 })
}
return NextResponse.json(response, { status: 200 })
}
//file: api/seed/route.ts
//url: http://localhost:3000/api/seed?model=users
//url: http://localhost:3000/api/seed?model=categories
//url: http://localhost:3000/api/seed?model=products
import { NextResponse } from 'next/server';
import { NextRequest } from "next/server";
import { DatabaseType, seed, SeedType } from 'santuy';
import path from 'path';
export async function GET(request: NextRequest) {
let dev = process.env.ENV == "development" || false;
if(!dev){
return NextResponse.json("Seed not allowed!", { status: 400 })
}
const database: DatabaseType = {
host: "localhost",
user: "root",
password: "",
port: 3306,
database: "santuy",
}
const model = request.nextUrl.searchParams.get("model") || "";
const jsonPath = path.join(process.cwd(), 'src/seeds');
const seeder: SeedType = {
model,
path: jsonPath,
database
}
const response: any = await seed(seeder);
if (!response) {
return NextResponse.json("Seeding error!", { status: 400 })
}
return NextResponse.json(response, { status: 200 })
}
FAQs
Santuy is a nodejs framework and database generator from model schema.
The npm package santuy receives a total of 6 weekly downloads. As such, santuy popularity was classified as not popular.
We found that santuy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.