
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@bubojs/sequelize
Advanced tools
The @SequelizeAttributes decorator allows 3 things:
The decorator takes 3 parameters:
example:
import { Controller, DefaultActions, Post, Body } from '@bubojs/api'
import { SequelizeAttributes } from '../../utils/middlewares/SequelizeAttributes.middleware'
import { AuthMiddleware, RoleMiddleware } from '@bubojs/catalog'
import { userAcl } from './UserAcl'
@Acl(userAcl)
@Controller({ repository: userRepository })
export class UsersController {
constructor() {
applyUserAccessControlList()
}
@AuthMiddleware()
@CheckAcl()
@SequelizeAttributes(
User,
() => ['password'],
(req: any) => {
const attr = req.permission.attributes
return attr === ['*'] ? undefined : attr
}
)
[DefaultActions.GET_ONE]() {}
In this example on the getOne route of the users we have the following configuration:
The populate option allows the client to aggregate other models related to the first one in the database and return these additional data in a single query without having to make another query
the decorator takes two parameters:
example:
Model User
import { Column, Default, Model, Table, HasOne } from 'sequelize-typescript'
import { DataTypes } from 'sequelize'
import { CircularHelper } from '@bubojs/sequelize'
import { Basket } from '../basket/Basket'
@Table({
paranoid: true,
tableName: 'user',
underscored: true,
timestamps: true
})
export class User extends Model {
@Column({ type: DataTypes.STRING })
declare username: string
@Default(USERS_ROLES.PLAYER)
@Column({ type: DataTypes.STRING })
declare role: USERS_ROLES
@Column({ type: DataTypes.STRING })
declare password: string
@HasOne(() => Basket)
declare avatar: CircularHelper<Avatar>
Model Basket
import { Model, Column, DataType, HasMany, HasOne, ForeignKey, Table, BelongsTo } from 'sequelize-typescript'
import { CircularHelper } from '@bubojs/sequelize'
import { Product } from '../product/Product'
import { User } from '../user/User'
@Table({
paranoid: true,
timestamps: true,
tableName: 'basket',
underscored: true
})
export class Basket extends Model {
@Column({type: DataTypes.JSON})
declare content: Object
@ForeignKey(() => User)
@Column
declare userId: number
@BelongsTo(() => User)
declare user: CircularHelper<User>
@HasMany(()=> Product)
declare products: Array<CircularHelper<Product>>
}
Model Product
import { Model, Column, DataType, HasMany, HasOne, ForeignKey, Table, BelongsTo } from 'sequelize-typescript'
import { CircularHelper } from '@bubojs/sequelize'
import { Basket } from '../basket/Basket'
@Table({
paranoid: true,
timestamps: true,
tableName: 'product',
underscored: true
})
export class Product extends Model {
@Column({type: DataTypes.JSON})
declare content: Object
@ForeignKey(() => User)
@Column
declare userId: number
@BelongsTo(() => User)
declare user: CircularHelper<User>
@HasMany(()=> Product)
declare products: Array<CircularHelper<Product>>
}
Controleur User
import { AfterMiddleware, BeforeMiddleware, Controller, DefaultActions, Post, Body } from '@bubojs/api'
import { ValidationMiddleware, CurrentUser, AuthMiddleware, RoleMiddleware } from '@bubojs/catalog'
import { applyUserAccessControlList } from './UsersAccess'
import { User } from './User'
import { userAcl } from './UserAcl'
import { SequelizePopulate } from '../../bubo.middlewares/Sequelize/Populate.middleware'
@Acl(userAcl)
@Controller({ repository: userRepository })
export class UsersController {
@AuthMiddleware()
@CheckAcl()
@SequelizePopulate(User, ['basket.product'])
[DefaultActions.GET_ONE]() {}
}
FAQs
Unknown package
We found that @bubojs/sequelize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.