First Committ

This commit is contained in:
Paolo Arena
2021-08-31 18:09:59 +02:00
commit 1d6c55807c
299 changed files with 55382 additions and 0 deletions

15
src/utils/auth.ts Executable file
View File

@@ -0,0 +1,15 @@
import Cookies from 'js-cookie'
const TokenKey = 'Admin-Token'
export function getCookie() {
return Cookies.get(TokenKey)
}
export function setCookie(token: string) {
return Cookies.set(TokenKey, token)
}
export function removeCookie() {
return Cookies.remove(TokenKey)
}

21
src/utils/config.ts Executable file
View File

@@ -0,0 +1,21 @@
import dotenv from 'dotenv'
dotenv.config()
let path
switch (process.env.NODE_ENV) {
case 'test':
path = `${__dirname}/../../.env.test`
break
case 'development':
path = `${__dirname}/../../.env.development`
break
default:
path = `${__dirname}/../../.env.production`
}
dotenv.config({ path })
console.log('path', path)
console.log('process.env.APP_ID', process.env.APP_ID)
export const { APP_ID } = process.env
export const { LOG_LEVEL } = process.env

11
src/utils/methods.ts Executable file
View File

@@ -0,0 +1,11 @@
export function timeout(duration: number): Promise<{}> {
return new Promise((resolve, reject) => {
setTimeout(() => { // @ts-ignore
resolve()
}, duration);
})
}
export function randomNumber(min: number, max: number) : number {
return Math.floor((Math.random() * max) + min);
}

8
src/utils/validators.ts Executable file
View File

@@ -0,0 +1,8 @@
export namespace Validators {
const Regs = {
link: /(https?|ftp):\/\/(-\.)?([^\s/?#-]+\.?)+(\/[^\s]*)?@iS/,
}
// @ts-ignore
export const LinkValidator = (value, component) => Regs.link.test(value)
}