Moved contents of seasoned_api up to root folder

This commit is contained in:
2022-08-19 01:03:27 +02:00
parent 0efc109992
commit 56262a45c8
134 changed files with 885 additions and 32 deletions

34
src/request/utils.js Normal file
View File

@@ -0,0 +1,34 @@
// TODO : test title and date are valid matches to columns in the database
const validSortParams = ['title', 'date']
const validSortDirs = ['asc', 'desc']
const validFilterParams = ['movie', 'show', 'seeding', 'downloading', 'paused', 'finished', 'downloaded']
function validSort(by, direction) {
return new Promise((resolve, reject) => {
if (by === undefined) {
resolve()
}
if (validSortParams.includes(by) && validSortDirs.includes(direction)) {
resolve()
} else {
reject(new Error(`invalid sort parameter, must be of: ${validSortParams} with optional sort directions: ${validSortDirs} appended with ':'`))
}
});
}
function validFilter(filter_param) {
return new Promise((resolve, reject) => {
if (filter_param === undefined) {
resolve()
}
if (filter_param && validFilterParams.includes(filter_param)) {
resolve()
} else {
reject(new Error(`filter parameteres must be of type: ${validFilterParams}`))
}
});
}
module.exports = { validSort, validFilter }