Skip to content

Latest commit

 

History

History
1183 lines (721 loc) · 29.6 KB

DOCS.md

File metadata and controls

1183 lines (721 loc) · 29.6 KB

🧰 Functions

⚙️ getImgById

Gets image object by id

Function Type
getImgById (id: number) => Promise<Image or null>

Parameters:

  • id: Image id

🔗 Source

⚙️ getImgsByTagId

Gets image objects lits by attached tag id

Function Type
getImgsByTagId (tagid: number, list: number) => Promise<Image[]>

Parameters:

  • id: Tag id

🔗 Source

⚙️ getNextImg

Gets next image object by of image id

Function Type
getNextImg (id: number) => Promise<number or null>

Parameters:

  • id: Current image id

🔗 Source

⚙️ getPreviousImg

Gets previous image object of current image id

Function Type
getPreviousImg (id: number) => Promise<number or null>

Parameters:

  • id: Current image id

🔗 Source

⚙️ getRandomImg

Gets random image object

Function Type
getRandomImg () => Promise<number or null>

🔗 Source

⚙️ addImg

Adds image object

  • Image object have to have src or local to be added
Function Type
addImg (src?: string or undefined, local?: string or undefined) => Promise<number or null>

Parameters:

  • src: Source web url
  • local: Name of local file saved on server

🔗 Source

⚙️ updateImg

Updates image object

Function Type
updateImg (id: number, src: string, local: string) => Promise<void>

Parameters:

  • id: Image id
  • src: New source web url
  • local: New name of local file saved on server

🔗 Source

⚙️ deleteImage

Deletes image object and all its tag relations

Function Type
deleteImage (id: number) => Promise<void>

Parameters:

  • id: Image id

🔗 Source

⚙️ addTag

Adds tag relation to given image

Function Type
addTag (imageId: number, tagId: number) => Promise<Teacher or null>

Parameters:

  • imageId: Image id
  • tagId: Tag id

🔗 Source

⚙️ deleteTag

Removes tag relation to given image

Function Type
deleteTag (imageId: number, tagId: number) => Promise<void>

Parameters:

  • imageId: Image id
  • tagId: Tag id

🔗 Source

⚙️ getTags

Gets all tag objects

Function Type
getTags () => Promise<Teacher[]>

🔗 Source

⚙️ addToTags

Adds tag object

Function Type
addToTags (name: string) => Promise<number or null>

Parameters:

  • name: Tag name

🔗 Source

⚙️ updateInTags

Updates tag object

Function Type
updateInTags (id: number, name: string) => Promise<void>

Parameters:

  • id: Tag id
  • name: New tag name

🔗 Source

⚙️ deleteFromTags

Deletes tag object and all its image relations

Function Type
deleteFromTags (id: number) => Promise<void>

Parameters:

  • id: Tag id

🔗 Source

⚙️ getSelectedTeachers

Returns all tags related to image

Function Type
getSelectedTeachers (id: number) => Promise<Teacher[]>

Parameters:

  • id: Image id

🔗 Source

⚙️ searchTeachers

Searches for tags by name prompt

Function Type
searchTeachers (prompt: string) => Promise<Teacher[]>

Parameters:

  • prompt: Tag name prompt

🔗 Source

⚙️ searchUnselectedTeachers

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 id
  • prompt: Tag name prompt

🔗 Source

⚙️ getUsers

Gets all user logins

Function Type
getUsers () => Promise<string[]>

🔗 Source

⚙️ getUser

Gets user password

Function Type
getUser (login: string) => Promise<string or null>

Parameters:

  • login: User login

🔗 Source

⚙️ getUserByToken

Gets user login by given auth token

Function Type
getUserByToken (token: string) => Promise<string or null>

Parameters:

  • token: User auth token

🔗 Source

⚙️ updateUserToken

Updates user auth token

Function Type
updateUserToken (login: string, token: string) => Promise<void>

Parameters:

  • login: User login
  • token: User auth token

🔗 Source

⚙️ updateUserPassword

Updates users password

Function Type
updateUserPassword (login: string, password: string) => Promise<void>

Parameters:

  • login: User login
  • password: User password

🔗 Source

⚙️ addUser

Adds user

Function Type
addUser (login: string, password: string) => Promise<void>

Parameters:

  • login: User login
  • password: User password

🔗 Source

⚙️ deleteUser

Deletes user

Function Type
deleteUser (login: string) => Promise<void>

Parameters:

  • login: User login

🔗 Source

⚙️ getImageAmmount

Gets ammount of images

Function Type
getImageAmmount () => Promise<number or null>

🔗 Source

⚙️ getImageWithTagAmmount

Gets ammount of images grouped by tags

Function Type
getImageWithTagAmmount () => Promise<number or null>

🔗 Source

⚙️ getImageAmmountOnTeachers

Gets tags with ammount of related images order descendly

Function Type
getImageAmmountOnTeachers () => Promise<TeacherCount[]>

🔗 Source

⚙️ setScrapedImageAsRejected

Sets scraped image status as rejected

Function Type
setScrapedImageAsRejected (id: number) => Promise<void>

Parameters:

  • id: Scraped image id

🔗 Source

⚙️ getRandomScrapedImage

Gets random scraped image which is not rejected

Function Type
getRandomScrapedImage () => Promise<ScrapedImage or null>

🔗 Source

⚙️ getScrapedImageAmount

Gets number of not rejected scraped images

Function Type
getScrapedImageAmount () => Promise<number>

🔗 Source

⚙️ transferScrapedImageToImages

Sets scraped image status as rejected

Function Type
transferScrapedImageToImages (id: number) => Promise<number or null>

Parameters:

  • id: Scraped image id

🔗 Source

⚙️ default

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)

🔗 Source

⚙️ uploadImage

Uploads file to server

Function Type
uploadImage (uploadFile: File) => string

Parameters:

  • uploadFile: File to upload

🔗 Source

⚙️ deleteImage

Deletes file from server

Function Type
deleteImage (filename: string) => void

Parameters:

  • filename: Name of file to delete

🔗 Source

⚙️ authenticate

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>

🔗 Source

⚙️ authorizePageRootAdmin

Middleweare for user authorization only for root admin.

Function Type
authorizePageRootAdmin (req: Request, res: Response<any, Record<string, any>>, next: () => void) => void

🔗 Source

⚙️ authorizeApiRootAdmin

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

🔗 Source

⚙️ authorizePage

Middleweare for user authorization.

Function Type
authorizePage (req: Request, res: Response<any, Record<string, any>>, next: () => void) => void

🔗 Source

⚙️ authorizeApi

Middleweare for user authorization on api route.

Function Type
authorizeApi (req: Request, res: Response<any, Record<string, any>>, next: () => void) => void

🔗 Source

⚙️ authorizePageToAdmin

Middleweare for user redirection if authorized.

Function Type
authorizePageToAdmin (req: Request, res: Response<any, Record<string, any>>, next: () => void) => void

🔗 Source

⚙️ authorizeApiToAdmin

Middleweare for user redirection if authorized on api route.

Function Type
authorizeApiToAdmin (req: Request, res: Response<any, Record<string, any>>, next: () => void) => void

🔗 Source

⚙️ hashString

Hashes given string.

Function Type
hashString (string: string) => string

Parameters:

  • string: Value to be hashed

🔗 Source

⚙️ authenticateUser

Authenticates user by given credentials.

Function Type
authenticateUser (login: string, password: string) => Promise<string or null>

Parameters:

  • login: User login
  • password: User password

🔗 Source

⚙️ validatePassword

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

🔗 Source

⚙️ getRoot

Function Type
getRoot (req: Request, res: Response<any, Record<string, any>>) => void

🔗 Source

⚙️ getStatistics

Function Type
getStatistics (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getAbout

Function Type
getAbout (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getLogin

Function Type
getLogin (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ postLogin

Function Type
postLogin (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getAdmin

Function Type
getAdmin (req: Request, res: Response<any, Record<string, any>>) => void

🔗 Source

⚙️ getLogout

Function Type
getLogout (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getReset

Function Type
getReset (req: Request, res: Response<any, Record<string, any>>) => void

🔗 Source

⚙️ postReset

Function Type
postReset (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getLogs

Function Type
getLogs (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ deleteLogs

Function Type
deleteLogs (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getUsers

Function Type
getUsers (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ postAddAdminUser

Function Type
postAddAdminUser (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ deleteDeleteUser

Function Type
deleteDeleteUser (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getImg

Function Type
getImg (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getImgUpdate

Function Type
getImgUpdate (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ deleteImageDelete

Function Type
deleteImageDelete (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ postImgUpdate

Function Type
postImgUpdate (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getRandomImg

Function Type
getRandomImg (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getAddImg

Function Type
getAddImg (req: Request, res: Response<any, Record<string, any>>) => void

🔗 Source

⚙️ postApiAddImg

Function Type
postApiAddImg (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getTags

Function Type
getTags (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ patchUpdateInTags

Function Type
patchUpdateInTags (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ deleteDeleteFromTags

Function Type
deleteDeleteFromTags (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ putAddToTags

Function Type
putAddToTags (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ putImgTag

Function Type
putImgTag (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ deleteImgTag

Function Type
deleteImgTag (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getImgTag

Function Type
getImgTag (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getTag

Function Type
getTag (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getImageTaglist

Function Type
getImageTaglist (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getScraper

Function Type
getScraper (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ postScraperScrape

Function Type
postScraperScrape (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ getScraperImage

Function Type
getScraperImage (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ deleteScraperImageId

Function Type
deleteScraperImageId (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

⚙️ postScraperImageId

Function Type
postScraperImageId (req: Request, res: Response<any, Record<string, any>>) => Promise<void>

🔗 Source

🔧 Constants

⚙️ directory

Root directory of project

Constant Type
directory any

🔗 Source

🏭 default

Logging static class

🔗 Source

Methods

⚙️ info

Saves to log given message with tag INFO

Method Type
info (message: string) => Promise<void>

Parameters:

  • message: Message to log

🔗 Source

⚙️ warning

Saves to log given message with tag WARNING

Method Type
warning (message: string) => Promise<void>

Parameters:

  • message: Message to log

🔗 Source

⚙️ error

Saves to log given message with tag ERROR

Method Type
error (message: string) => Promise<void>

Parameters:

  • message: Message to log

🔗 Source

⚙️ clear

Deletes all saved logs

Method Type
clear () => Promise<void>

🔗 Source

Properties

⚙️ LOGFILE

Property Type
LOGFILE "logs.log"

🔗 Source

🏭 ScrapedImagseHandler

Allows for quick single-connection handling of scraped images

🔗 Source

Methods

⚙️ connect

Connects handler to db

You have to connect to db before using db queries!

Method Type
connect () => Promise<void>

🔗 Source

⚙️ disconnect

Disconnects from db

You should always disconnect from db when finished using handler!

Method Type
disconnect () => Promise<void>

🔗 Source

⚙️ isSrcPresent

Check if image url is present in scrapedimages table or images table

Method Type
isSrcPresent (src: string) => Promise<boolean>

Parameters:

  • src: Image url

🔗 Source

⚙️ addScrapedImage

Adds scraped image

Method Type
addScrapedImage (src: string) => Promise<void>

Parameters:

  • src: Source url for scraped image

🔗 Source

🍹 Interfaces

⚙️ Image

Image object interface

Property Type Description
id number
src string
local string

⚙️ Teacher

Tag object interface

Property Type Description
id number
name string

⚙️ TeacherCount

Tag count object interface

Property Type Description
name string
ammount number

⚙️ ScrapedImage

Scraped image object interface

Property Type Description
id number
src string

⚙️ Request

Property Type Description
authorized string or null