0.2.7 • Published 11 months ago

@assetval/user v0.2.7

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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: '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)

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