Better Typing and Optimizations
This commit is contained in:
@@ -1,18 +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 HttpError = t.iface([], {
|
||||
title: 'string',
|
||||
status: 'number',
|
||||
details: 'string',
|
||||
developerMessage: 'string',
|
||||
timestamp: 'string',
|
||||
});
|
||||
|
||||
const exportedTypeSuite: t.ITypeSuite = {
|
||||
HttpError,
|
||||
};
|
||||
export default exportedTypeSuite;
|
||||
@@ -1,7 +1,12 @@
|
||||
export interface HttpError {
|
||||
title: string;
|
||||
status: number;
|
||||
details: string;
|
||||
developerMessage: string;
|
||||
timestamp: string;
|
||||
}
|
||||
import { Type, type Static } from '@sinclair/typebox'
|
||||
|
||||
|
||||
export const HttpError = Type.Object({
|
||||
title: Type.String(),
|
||||
status: Type.Number(),
|
||||
details: Type.String(),
|
||||
developerMessage: Type.String(),
|
||||
timestamp: Type.String()
|
||||
});
|
||||
|
||||
export type HttpError = Static<typeof HttpError>;
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import { createCheckers } from 'ts-interface-checker';
|
||||
import HttpError from './httpError.model-ti';
|
||||
|
||||
const HttpErrorChecker = createCheckers(HttpError)['HttpError'];
|
||||
export default HttpErrorChecker;
|
||||
@@ -1,18 +1,25 @@
|
||||
export type Language = {
|
||||
name: string;
|
||||
color: string;
|
||||
percentage: number;
|
||||
}
|
||||
import { Type, type Static } from '@sinclair/typebox'
|
||||
|
||||
export type Project = {
|
||||
name: string;
|
||||
description: string;
|
||||
link: string;
|
||||
|
||||
license?: string;
|
||||
languages?: Language[];
|
||||
export const Language = Type.Object({
|
||||
name: Type.String(),
|
||||
color: Type.String(),
|
||||
percentage: Type.Number(),
|
||||
})
|
||||
|
||||
stars: number;
|
||||
forks: number;
|
||||
watchers: number;
|
||||
}
|
||||
export const Project = Type.Object({
|
||||
name: Type.String(),
|
||||
description: Type.String(),
|
||||
link: Type.String(),
|
||||
|
||||
license: Type.Optional(Type.String()),
|
||||
languages: Type.Optional(Type.Array(Language)),
|
||||
|
||||
stars: Type.Number(),
|
||||
forks: Type.Number(),
|
||||
watchers: Type.Number(),
|
||||
});
|
||||
|
||||
|
||||
export type Language = Static<typeof Language>;
|
||||
export type Project = Static<typeof Project>;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
export interface Stack {
|
||||
name: string;
|
||||
image: string;
|
||||
description: string;
|
||||
}
|
||||
import { Type, type Static } from '@sinclair/typebox'
|
||||
|
||||
|
||||
export const Stack = Type.Object({
|
||||
name: Type.String(),
|
||||
image: Type.String(),
|
||||
description: Type.String()
|
||||
});
|
||||
|
||||
|
||||
export type Stack = Static<typeof Stack>;
|
||||
|
||||
@@ -1,15 +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 Token = t.iface([], {
|
||||
token: 'string',
|
||||
expirationDate: t.union('string', 'number'),
|
||||
});
|
||||
|
||||
const exportedTypeSuite: t.ITypeSuite = {
|
||||
Token,
|
||||
};
|
||||
export default exportedTypeSuite;
|
||||
@@ -1,4 +1,9 @@
|
||||
export interface Token {
|
||||
token: string;
|
||||
expirationDate: string | number;
|
||||
}
|
||||
import { Type, type Static } from '@sinclair/typebox'
|
||||
|
||||
|
||||
export const Token = Type.Object({
|
||||
token: Type.String(),
|
||||
expirationDate: Type.Union([Type.String(), Type.Number()])
|
||||
});
|
||||
|
||||
export type Token = Static<typeof Token>;
|
||||
|
||||
@@ -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