# UserModel

This is the Veritas User Schema workspace.

## Installation

```sh
yarn add @assetval/user
```

## Usage

### As a Class (Front End)

```ts
import { User } from '@assetval/user';

const user = new User({
  email: 'example@example.com',
  name: { first: 'John', last: 'Doe' },
  role: 'client',
  profileStatus: 'New',
  emailConfirmed: false,
  email_lower: 'example@example.com'.toLowerCase(),
  password: 'password123'
});
```

### As Schema (Back End)

```ts
import { UserSchema, User } from '@assetval/user';
import { model } from 'mongoose';

export const UserModel = model<User>('users', UserSchema);
```

### As Validation (Back End)

```ts
import { UserValidationSchema } from '@assetval/user';
import { z } from 'zod';
import { MagikRoutes } from '../middleware/RouterManager.js';

const ProfileRoute = MagikRoutes.getRouter('/profile');

ProfileRoute.post('/updateUser', {
  auth: 'ensureAuthenticated',
  validationSchema: z.object({
    body: UserValidationSchema
  }),
  route: async (req, res): Promise<void> => {
    // Do something
  }
});
```

## License

MIT

## Authors

- [Abourass](https://github.com/Abourass)

## Contributing

Download the Schema repository and make sure you have the following installed:

- asdf
- NodeJS (ASDF)
- Yarn (Corepack / Node / ASDF)
- moonrepo
- git-chglog (ASDF)

Then run the following commands:

```sh
yarn install
```
