init project
This commit is contained in:
12
src/use-cases/category-converter-use-case.js
Normal file
12
src/use-cases/category-converter-use-case.js
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
class CategoryConverterUseCase {
|
||||
constructor(categoriesMapping) {
|
||||
this.categoriesMapping = categoriesMapping
|
||||
}
|
||||
|
||||
execute() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.export = { CategoryConverterUseCase }
|
||||
27
src/use-cases/get-category-use-case.js
Normal file
27
src/use-cases/get-category-use-case.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const { exec } = require("node:child_process")
|
||||
|
||||
class GetCategoryUseCase {
|
||||
constructor({categoriesMapping}) {
|
||||
this.categoriesMapping = categoriesMapping
|
||||
}
|
||||
|
||||
execute(domain) {
|
||||
exec(`echo ${domain} | bin/gcf1check.sh etc check_categorize_hybrid`, { cwd: '/usr/local/gcf1' }, (error, stdout, stderr)=>{
|
||||
if (error) {
|
||||
console.error(error)
|
||||
return
|
||||
}
|
||||
|
||||
const outputParts = stdout.split(/\s+/); // Split by whitespace
|
||||
if (outputParts[3]) {
|
||||
const categoryId = outputParts[2];
|
||||
console.log({ categoryId });
|
||||
} else {
|
||||
console.log({ error: 'Category ID not found' });
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { GetCategoryUseCase }
|
||||
|
||||
Reference in New Issue
Block a user