Authentication and tokensintermediate
A JWT is a signed note saying who the caller is; issuing one, refreshing it before it expires, and never storing a password in plain text are the three things every API has to get right.
Anyone can change any order, and the audit line reaches for a vendor nothing ever attached, through (req as any). Write requireVendor: check the key, attach the vendor to the request through Express’s own types, and gate only the routes that change things.
The gate works both ways, reads stay open, the type is extended rather than escaped, and the audit line names the vendor.
Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.
A JWT is a signed note saying who the caller is; issuing one, refreshing it before it expires, and never storing a password in plain text are the three things every API has to get right.
A type is a note to your future self that the compiler checks — annotating what goes in and what comes out is where most of the value is, before any advanced feature.