lingapp-usuario
Version:
Mongoose model for managing users in the LingApp system
86 lines (65 loc) • 1.63 kB
Markdown
# 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
```bash
npm install lingapp-usuario
# or
yarn add lingapp-usuario
```
## Usage
```typescript
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: "john@example.com",
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 interface
- `RoleInterface` - Role interface
- `Permission` - 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