- getImgById
- getImgsByTagId
- getNextImg
- getPreviousImg
- getRandomImg
- addImg
- updateImg
- deleteImage
- addTag
- deleteTag
- getTags
- addToTags
- updateInTags
- deleteFromTags
- getSelectedTeachers
- searchTeachers
- searchUnselectedTeachers
- getUsers
- getUser
- getUserByToken
- updateUserToken
- updateUserPassword
- addUser
- deleteUser
- getImageAmmount
- getImageWithTagAmmount
- getImageAmmountOnTeachers
- setScrapedImageAsRejected
- getRandomScrapedImage
- getScrapedImageAmount
- transferScrapedImageToImages
- default
- uploadImage
- deleteImage
- authenticate
- authorizePageRootAdmin
- authorizeApiRootAdmin
- authorizePage
- authorizeApi
- authorizePageToAdmin
- authorizeApiToAdmin
- hashString
- authenticateUser
- validatePassword
- getRoot
- getStatistics
- getAbout
- getLogin
- postLogin
- getAdmin
- getLogout
- getReset
- postReset
- getLogs
- deleteLogs
- getUsers
- postAddAdminUser
- deleteDeleteUser
- getImg
- getImgUpdate
- deleteImageDelete
- postImgUpdate
- getRandomImg
- getAddImg
- postApiAddImg
- getTags
- patchUpdateInTags
- deleteDeleteFromTags
- putAddToTags
- putImgTag
- deleteImgTag
- getImgTag
- getTag
- getImageTaglist
- getScraper
- postScraperScrape
- getScraperImage
- deleteScraperImageId
- postScraperImageId
Gets image object by id
Function | Type |
---|---|
getImgById |
(id: number) => Promise<Image or null> |
Parameters:
id
: Image id
Gets image objects lits by attached tag id
Function | Type |
---|---|
getImgsByTagId |
(tagid: number, list: number) => Promise<Image[]> |
Parameters:
id
: Tag id
Gets next image object by of image id
Function | Type |
---|---|
getNextImg |
(id: number) => Promise<number or null> |
Parameters:
id
: Current image id
Gets previous image object of current image id
Function | Type |
---|---|
getPreviousImg |
(id: number) => Promise<number or null> |
Parameters:
id
: Current image id
Gets random image object
Function | Type |
---|---|
getRandomImg |
() => Promise<number or null> |
Adds image object
- Image object have to have
src
orlocal
to be added
Function | Type |
---|---|
addImg |
(src?: string or undefined, local?: string or undefined) => Promise<number or null> |
Parameters:
src
: Source web urllocal
: Name of local file saved on server
Updates image object
Function | Type |
---|---|
updateImg |
(id: number, src: string, local: string) => Promise<void> |
Parameters:
id
: Image idsrc
: New source web urllocal
: New name of local file saved on server
Deletes image object and all its tag relations
Function | Type |
---|---|
deleteImage |
(id: number) => Promise<void> |
Parameters:
id
: Image id
Adds tag relation to given image
Function | Type |
---|---|
addTag |
(imageId: number, tagId: number) => Promise<Teacher or null> |
Parameters:
imageId
: Image idtagId
: Tag id
Removes tag relation to given image
Function | Type |
---|---|
deleteTag |
(imageId: number, tagId: number) => Promise<void> |
Parameters:
imageId
: Image idtagId
: Tag id
Gets all tag objects
Function | Type |
---|---|
getTags |
() => Promise<Teacher[]> |
Adds tag object
Function | Type |
---|---|
addToTags |
(name: string) => Promise<number or null> |
Parameters:
name
: Tag name
Updates tag object
Function | Type |
---|---|
updateInTags |
(id: number, name: string) => Promise<void> |
Parameters:
id
: Tag idname
: New tag name
Deletes tag object and all its image relations
Function | Type |
---|---|
deleteFromTags |
(id: number) => Promise<void> |
Parameters:
id
: Tag id
Returns all tags related to image
Function | Type |
---|---|
getSelectedTeachers |
(id: number) => Promise<Teacher[]> |
Parameters:
id
: Image id
Searches for tags by name prompt
Function | Type |
---|---|
searchTeachers |
(prompt: string) => Promise<Teacher[]> |
Parameters:
prompt
: Tag name prompt
Searches for tags, by name prompt, that are not related to given image
Function | Type |
---|---|
searchUnselectedTeachers |
(imageId: number, prompt: string) => Promise<Teacher[]> |
Parameters:
id
: Image idprompt
: Tag name prompt
Gets all user logins
Function | Type |
---|---|
getUsers |
() => Promise<string[]> |
Gets user password
Function | Type |
---|---|
getUser |
(login: string) => Promise<string or null> |
Parameters:
login
: User login
Gets user login by given auth token
Function | Type |
---|---|
getUserByToken |
(token: string) => Promise<string or null> |
Parameters:
token
: User auth token
Updates user auth token
Function | Type |
---|---|
updateUserToken |
(login: string, token: string) => Promise<void> |
Parameters:
login
: User logintoken
: User auth token
Updates users password
Function | Type |
---|---|
updateUserPassword |
(login: string, password: string) => Promise<void> |
Parameters:
login
: User loginpassword
: User password
Adds user
Function | Type |
---|---|
addUser |
(login: string, password: string) => Promise<void> |
Parameters:
login
: User loginpassword
: User password
Deletes user
Function | Type |
---|---|
deleteUser |
(login: string) => Promise<void> |
Parameters:
login
: User login
Gets ammount of images
Function | Type |
---|---|
getImageAmmount |
() => Promise<number or null> |
Gets ammount of images grouped by tags
Function | Type |
---|---|
getImageWithTagAmmount |
() => Promise<number or null> |
Gets tags with ammount of related images order descendly
Function | Type |
---|---|
getImageAmmountOnTeachers |
() => Promise<TeacherCount[]> |
Sets scraped image status as rejected
Function | Type |
---|---|
setScrapedImageAsRejected |
(id: number) => Promise<void> |
Parameters:
id
: Scraped image id
Gets random scraped image which is not rejected
Function | Type |
---|---|
getRandomScrapedImage |
() => Promise<ScrapedImage or null> |
Gets number of not rejected scraped images
Function | Type |
---|---|
getScrapedImageAmount |
() => Promise<number> |
Sets scraped image status as rejected
Function | Type |
---|---|
transferScrapedImageToImages |
(id: number) => Promise<number or null> |
Parameters:
id
: Scraped image id
Scrapes image urls from www.zsi.kielce.pl
Function | Type |
---|---|
default |
(limit?: number or undefined) => Promise<string[]> |
Parameters:
limit
: Limit of read article pages (If unset scrapes all pages)
Uploads file to server
Function | Type |
---|---|
uploadImage |
(uploadFile: File) => string |
Parameters:
uploadFile
: File to upload
Deletes file from server
Function | Type |
---|---|
deleteImage |
(filename: string) => void |
Parameters:
filename
: Name of file to delete
Middleweare for user authentication. Attaches authorized
token to given request.
Function | Type |
---|---|
authenticate |
(req: Request, res: Response<any, Record<string, any>>, next: () => void) => Promise<void> |
Middleweare for user authorization only for root admin
.
Function | Type |
---|---|
authorizePageRootAdmin |
(req: Request, res: Response<any, Record<string, any>>, next: () => void) => void |
Middleweare for user authorization only for root admin
on api route.
Function | Type |
---|---|
authorizeApiRootAdmin |
(req: Request, res: Response<any, Record<string, any>>, next: () => void) => void |
Middleweare for user authorization.
Function | Type |
---|---|
authorizePage |
(req: Request, res: Response<any, Record<string, any>>, next: () => void) => void |
Middleweare for user authorization on api route.
Function | Type |
---|---|
authorizeApi |
(req: Request, res: Response<any, Record<string, any>>, next: () => void) => void |
Middleweare for user redirection if authorized.
Function | Type |
---|---|
authorizePageToAdmin |
(req: Request, res: Response<any, Record<string, any>>, next: () => void) => void |
Middleweare for user redirection if authorized on api route.
Function | Type |
---|---|
authorizeApiToAdmin |
(req: Request, res: Response<any, Record<string, any>>, next: () => void) => void |
Hashes given string.
Function | Type |
---|---|
hashString |
(string: string) => string |
Parameters:
string
: Value to be hashed
Authenticates user by given credentials.
Function | Type |
---|---|
authenticateUser |
(login: string, password: string) => Promise<string or null> |
Parameters:
login
: User loginpassword
: User password
Validates user password. Checks if:
- is present
- is at least 8 characters long
- does it have a lowercase letter
- does it have a biggercase letter
- does it have a number
- does it have a special symbol (
!@#$%,.?:;
)
Function | Type |
---|---|
validatePassword |
(password?: string or undefined) => string or null |
Parameters:
password
: User password
Function | Type |
---|---|
getRoot |
(req: Request, res: Response<any, Record<string, any>>) => void |
Function | Type |
---|---|
getStatistics |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getAbout |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getLogin |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
postLogin |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getAdmin |
(req: Request, res: Response<any, Record<string, any>>) => void |
Function | Type |
---|---|
getLogout |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getReset |
(req: Request, res: Response<any, Record<string, any>>) => void |
Function | Type |
---|---|
postReset |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getLogs |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
deleteLogs |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getUsers |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
postAddAdminUser |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
deleteDeleteUser |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getImg |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getImgUpdate |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
deleteImageDelete |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
postImgUpdate |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getRandomImg |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getAddImg |
(req: Request, res: Response<any, Record<string, any>>) => void |
Function | Type |
---|---|
postApiAddImg |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getTags |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
patchUpdateInTags |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
deleteDeleteFromTags |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
putAddToTags |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
putImgTag |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
deleteImgTag |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getImgTag |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getTag |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getImageTaglist |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getScraper |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
postScraperScrape |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
getScraperImage |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
deleteScraperImageId |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Function | Type |
---|---|
postScraperImageId |
(req: Request, res: Response<any, Record<string, any>>) => Promise<void> |
Root directory of project
Constant | Type |
---|---|
directory |
any |
Logging static class
Saves to log given message with tag INFO
Method | Type |
---|---|
info |
(message: string) => Promise<void> |
Parameters:
message
: Message to log
Saves to log given message with tag WARNING
Method | Type |
---|---|
warning |
(message: string) => Promise<void> |
Parameters:
message
: Message to log
Saves to log given message with tag ERROR
Method | Type |
---|---|
error |
(message: string) => Promise<void> |
Parameters:
message
: Message to log
Deletes all saved logs
Method | Type |
---|---|
clear |
() => Promise<void> |
Property | Type |
---|---|
LOGFILE |
"logs.log" |
Allows for quick single-connection handling of scraped images
Connects handler to db
You have to connect to db before using db queries!
Method | Type |
---|---|
connect |
() => Promise<void> |
Disconnects from db
You should always disconnect from db when finished using handler!
Method | Type |
---|---|
disconnect |
() => Promise<void> |
Check if image url is present in scrapedimages
table or images
table
Method | Type |
---|---|
isSrcPresent |
(src: string) => Promise<boolean> |
Parameters:
src
: Image url
Adds scraped image
Method | Type |
---|---|
addScrapedImage |
(src: string) => Promise<void> |
Parameters:
src
: Source url for scraped image
Image object interface
Property | Type | Description |
---|---|---|
id |
number |
|
src |
string |
|
local |
string |
Tag object interface
Property | Type | Description |
---|---|---|
id |
number |
|
name |
string |
Tag count object interface
Property | Type | Description |
---|---|---|
name |
string |
|
ammount |
number |
Scraped image object interface
Property | Type | Description |
---|---|---|
id |
number |
|
src |
string |
Property | Type | Description |
---|---|---|
authorized |
string or null |