I am trying to get filetype(MIMETYPE) of a JS file at both client and server end.
at client end I am using file-type npm package and reading the mimetype. But I found that if I change the extension of Javascript file(test.js) as docx (text.docx) file-type npm package fails to read exact type and consider the file as .docx
client side code:
import * as fileTypeForMimeType from 'file-type';
...
...
const fileData = await fileTypeForMimeType.fromBuffer(bytes);
realFileType = fileData ? fileData.mime : file.type;
screen shot of client side where it is reading the file as .docx

What is right way to read files exact mime-type ? if Yes. how ?
any other packages give more accurate results ?
and finally how to get most accurate file-type at server end ? (nodejs, loopback)
Thanks