You can set a custom code for not found routes using: <API>.setNotFoundHandler method.
<API>.setNotFoundHandler
var api = new API(...); api.setNotFoundHandler(`$reply[ $setCode[404] $setType[json] $setBody[{ "msg": "route not found." }]]`);