In-takes HTTP status code and language code (default to 'en'), spits out human-readable response text.
npm install http-response-textpnpm add http-response-text
npm install http-response-text
javascript
import { MongoClient, ObjectId } from "mongodb";
import { getStatus } from "http-response-text";
const findById = async (collectionName, id) => {
// console.log("findById: ", collectionName, id);
if (!ObjectId.isValid(id)) return getStatus(404) ?? null;
// ...
};
`
Which would return you a response object like this:
`javascript
{
code: 404,
message: 'Not Found'
}
``