Files
mrfrys-node-server/src/types/basicTypes.ts
T

152 lines
3.1 KiB
TypeScript

/* ----------------------------------------------------------------------------
Question Server
GitLab: <https://gitlab.com/MrFry/mrfrys-node-server>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
------------------------------------------------------------------------- */
import express from 'express'
import { SearchResultQuestion } from '../utils/classes'
import type { Database } from 'better-sqlite3'
import type { Socket as SocketIoSocket } from 'socket.io'
import http from 'http'
import https from 'https'
export interface QuestionData {
type: string
date?: Date | number
images?: Array<string>
hashedImages?: Array<string>
possibleAnswers?: Array<{
text: string
selectedByUser: boolean
}>
}
export interface Question {
Q: string
A: string
data: QuestionData
cache?: {
Q: Array<string>
A: Array<string>
}
}
export interface Subject {
Name: string
Questions: Array<Question>
}
export interface DataFile {
path: string
name: string
locked?: Boolean
shouldSearch:
| string
| {
location?: {
val: string
}
}
shouldSave: {
location?: {
val: string
}
version?: {
compare: string
val: string
}
}
}
export interface QuestionDb extends DataFile {
data: Array<Subject>
index: number
}
export interface User {
id: number
pw: string
created: Date
}
export interface User {
id: number
pw: string
pwRequestCount: number
avaiblePWRequests: number
loginCount: number
createdBy: number
}
export interface Request<T = any> extends express.Request {
body: T
cookies: any
session: any
files: any
query: { [key: string]: string }
}
export interface SubmoduleData {
app: express.Application
url: string
publicdirs: Array<string>
userDB?: Database
nextdir?: string
moduleSpecificData?: any
httpServer: http.Server
httpsServer: https.Server
}
export interface QuestionFromScript {
questions: Array<Question>
testUrl: string
subj: string
}
export interface DbSearchResult {
message?: string
recievedData?: string
question: Question
result: SearchResultQuestion[]
success: boolean
}
export interface RegisteredUserEntry {
cid: string
version: string
installSource: string
date: string
userAgent: string
loginDate?: string
uid?: number
}
export interface Submodule {
dailyAction?: () => void
load?: () => void
}
export interface ModuleType {
app: express.Application
dailyAction?: Function
}
export interface Socket extends SocketIoSocket {
user: User
}