Better Typing and Optimizations
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
import { createCheckers } from 'ts-interface-checker';
|
||||
import User from './user.model-ti';
|
||||
import Token from '../token/token.model-ti';
|
||||
|
||||
const UserChecker = createCheckers(User, Token)['User'];
|
||||
export default UserChecker;
|
||||
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* This module was automatically generated by `ts-interface-builder`
|
||||
*/
|
||||
import * as t from 'ts-interface-checker';
|
||||
// tslint:disable:object-literal-key-quotes
|
||||
|
||||
export const User = t.iface([], {
|
||||
id: t.opt('number'),
|
||||
name: t.opt('string'),
|
||||
email: t.opt('string'),
|
||||
username: 'string',
|
||||
password: t.opt('string'),
|
||||
profilePictureUrl: t.opt('string'),
|
||||
accessToken: t.opt('Token'),
|
||||
refreshToken: t.opt('Token'),
|
||||
roles: t.opt(t.array('string')),
|
||||
});
|
||||
|
||||
const exportedTypeSuite: t.ITypeSuite = {
|
||||
User,
|
||||
};
|
||||
export default exportedTypeSuite;
|
||||
@@ -1,14 +1,20 @@
|
||||
import { Type, type Static } from '@sinclair/typebox'
|
||||
|
||||
import { Token } from '../token/token.model';
|
||||
|
||||
export interface User {
|
||||
id?: number;
|
||||
name?: string;
|
||||
email?: string;
|
||||
username: string;
|
||||
password?: string;
|
||||
profilePictureUrl?: string;
|
||||
accessToken?: Token;
|
||||
refreshToken?: Token;
|
||||
roles?: Array<string>;
|
||||
validateAccessToken?: () => Token | undefined;
|
||||
}
|
||||
|
||||
export const User = Type.Object({
|
||||
id: Type.Optional(Type.Number()),
|
||||
name: Type.Optional(Type.String()),
|
||||
email: Type.Optional(Type.String()),
|
||||
username: Type.String(),
|
||||
password: Type.Optional(Type.String()),
|
||||
profilePictureUrl: Type.Optional(Type.String()),
|
||||
accessToken: Type.Optional(Token),
|
||||
refreshToken: Type.Optional(Token),
|
||||
roles: Type.Optional(Type.Array(Type.String())),
|
||||
validateAccessToken: Type.Optional(Type.Function([],Type.Optional(Token)))
|
||||
});
|
||||
|
||||
|
||||
export type User = Static<typeof User>;
|
||||
|
||||
Reference in New Issue
Block a user