@assetval/user
v0.2.7
Published
AssetVal's internal user model
Downloads
18
Readme
UserModel
This is the Veritas User Schema workspace.
Installation
yarn add @assetval/user
Usage
As a Class (Front End)
import { User } from '@assetval/user';
const user = new User({
email: '[email protected]',
name: { first: 'John', last: 'Doe' },
role: 'client',
profileStatus: 'New',
emailConfirmed: false,
email_lower: '[email protected]'.toLowerCase(),
password: 'password123'
});
As Schema (Back End)
import { UserSchema, User } from '@assetval/user';
import { model } from 'mongoose';
export const UserModel = model<User>('users', UserSchema);
As Validation (Back End)
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
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:
yarn install