lingapp-usuario
v1.0.1
Published
Mongoose model for managing users in the LingApp system
Maintainers
Readme
lingapp-usuario
A Mongoose model for managing users and roles in the LingApp system. This package provides a structured way to handle user management with role-based permissions.
Features
- Full TypeScript support
- Mongoose model with proper typing
- Role-based permissions system
- User management with optional fields
- Password handling support
- Timestamps for user creation and updates
Installation
npm install lingapp-usuario
# or
yarn add lingapp-usuarioUsage
import { Usuario, Role, UsuarioInterface, RoleInterface } from 'lingapp-usuario';
// Create a new role
const role = new Role({
name: "Admin",
permissions: [
{
type: "read",
route: "/users",
description: "View users",
icon: "users"
}
]
});
// Create a new user
const user = new Usuario({
firstName: "John",
lastName: "Doe",
email: "[email protected]",
role: "Admin",
permissoes: [role._id],
password: "hashedPassword",
isHashed: true
});
// Save the user
await user.save();Types
The package exports the following types:
UsuarioInterface- Main user interfaceRoleInterface- Role interfacePermission- Permission interface- And other related interfaces
Schema Structure
The models include:
Usuario Model
- Basic user information (name, email, etc.)
- Optional fields (birth date, phone, CPF)
- Role and permissions references
- Password handling
- Timestamps
Role Model
- Role name
- Permissions array
- Timestamps
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT
