-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathstaticData.ts
More file actions
93 lines (87 loc) · 2.26 KB
/
Copy pathstaticData.ts
File metadata and controls
93 lines (87 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import path from 'path'
import { readFile } from 'fs/promises'
import { safeLoad } from 'js-yaml'
import logger from '../lib/logger'
export async function loadStaticData (file: string) {
const filePath = path.resolve('./data/static/' + file + '.yml')
return await readFile(filePath, 'utf8')
.then(safeLoad)
.catch(() => logger.error('Could not open file: "' + filePath + '"'))
}
export interface StaticUser {
email: string
password: string
key: string
role: 'admin' | 'customer' | 'deluxe' | 'accounting'
username?: string
profileImage?: string
walletBalance?: number
lastLoginIp?: string
deletedFlag?: boolean
totpSecret?: string
customDomain?: boolean
securityQuestion?: StaticUserSecurityQuestion
feedback?: StaticUserFeedback
address?: StaticUserAddress[]
card?: StaticUserCard[]
}
export interface StaticUserSecurityQuestion {
id: number
answer: string
}
export interface StaticUserFeedback {
comment: string
rating: 1 | 2 | 3 | 4 | 5
}
export interface StaticUserAddress {
fullName: string
mobileNum: number
zipCode: string
streetAddress: string
city: string
state: string
country: string
}
export interface StaticUserCard {
fullName: string
cardNum: number
expMonth: number
expYear: number
}
export async function loadStaticUserData (): Promise<StaticUser[]> {
return await loadStaticData('users') as StaticUser[]
}
export interface StaticChallenge {
name: string
category: string
tags?: string[]
description: string
difficulty: number
hint: string
hintUrl: string
mitigationUrl: string
key: string
disabledEnv?: string[]
tutorial?: {
order: number
}
}
export async function loadStaticChallengeData (): Promise<StaticChallenge[]> {
return await loadStaticData('challenges') as StaticChallenge[]
}
export interface StaticDelivery {
name: string
price: number
deluxePrice: number
eta: number
icon: string
}
export async function loadStaticDeliveryData (): Promise<StaticDelivery[]> {
return await loadStaticData('deliveries') as StaticDelivery[]
}
export interface StaticSecurityQuestions {
question: string
}
export async function loadStaticSecurityQuestionsData (): Promise<StaticSecurityQuestions[]> {
return await loadStaticData('securityQuestions') as StaticSecurityQuestions[]
}