mirror of
https://github.com/kmitresse/Compo-Service-Log-Project.git
synced 2026-07-09 12:07:45 +00:00
feat: Use container for the API service
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { Transform } from "node:stream";
|
||||
|
||||
type OpenfoodfactsData = {
|
||||
code: string;
|
||||
countries_en: string;
|
||||
};
|
||||
|
||||
export default class OpenfoodfactsDataTransformer extends Transform {
|
||||
constructor() {
|
||||
super({ objectMode: true });
|
||||
}
|
||||
|
||||
_transform(chunk: OpenfoodfactsData, encoding: string, callback: () => void) {
|
||||
const { code, countries_en } = chunk;
|
||||
|
||||
if (code && countries_en) {
|
||||
this.push({
|
||||
"Barcode (EAN 13)": code,
|
||||
Country: countries_en,
|
||||
});
|
||||
}
|
||||
|
||||
callback();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user