Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pre-handlers): Add requireAccessToken middleware
This commit adds a new file, require-access-token.ts, which contains a middleware function for Nanotron API requests. The function checks the authorization header for a Bearer token and compares it to the provided access token. If the token is missing or invalid, it sends an appropriate error response and prevents further handlers from executing. Example usage: nanotronApiServer.defineRoute({ method: 'POST', url: 'secure-endpoint', preHandlers: [requireAccessToken('mySecretToken')], async handler() { this.serverResponse.replyJson({ ok: true, message: 'Access granted!', }); }, });
- Loading branch information