Добавить lib/module-store.js
This commit is contained in:
parent
0d946df109
commit
c6adbee115
31
lib/module-store.js
Normal file
31
lib/module-store.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
|
||||||
|
const modules = []
|
||||||
|
let nextId = 1
|
||||||
|
|
||||||
|
function getModules() {
|
||||||
|
return modules
|
||||||
|
}
|
||||||
|
|
||||||
|
function addModule(moduleData) {
|
||||||
|
const newModule = {
|
||||||
|
id: (nextId++).toString(),
|
||||||
|
name: moduleData.name,
|
||||||
|
file_id: moduleData.file_id,
|
||||||
|
source_channel: moduleData.source_channel,
|
||||||
|
uploaded_at: new Date().toISOString(),
|
||||||
|
}
|
||||||
|
modules.push(newModule)
|
||||||
|
console.log("Module added:", newModule)
|
||||||
|
}
|
||||||
|
|
||||||
|
function findModules(query) {
|
||||||
|
const lowerCaseQuery = query.toLowerCase()
|
||||||
|
return modules.filter((module) => module.name.toLowerCase().includes(lowerCaseQuery))
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
getModules,
|
||||||
|
addModule,
|
||||||
|
findModules,
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user