File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 1+ import express , { Router , RequestHandler } from 'express' ;
2+ import { McpAuthOptions } from '@asgardeo/mcp-node' ;
3+ import protectedRoute from './middlewares/protected-route' ;
4+ import AuthRouter from './routes/auth' ;
5+
6+ export class McpAuthServer {
7+ private options : McpAuthOptions ;
8+ private routerInstance : Router ;
9+
10+ constructor ( options : McpAuthOptions ) {
11+ if ( ! options . baseUrl ) {
12+ throw new Error ( 'baseUrl must be provided' ) ;
13+ }
14+ this . options = options ;
15+ this . routerInstance = AuthRouter ( this . options ) ;
16+ }
17+
18+ public router ( ) : Router {
19+ return this . routerInstance ;
20+ }
21+
22+ public protect ( handler : RequestHandler ) : Router {
23+ const protectedRouter = express . Router ( ) ;
24+ protectedRouter . use ( protectedRoute ( this . options ) , handler ) ;
25+ return protectedRouter ;
26+ }
27+ }
Original file line number Diff line number Diff line change 1616 * under the License.
1717 */
1818
19- export { default as McpAuth } from './routes/auth' ;
20- export { default as protectedRoute } from './middlewares/protected-route' ;
19+ export { McpAuthServer } from './McpAuthServer' ;
You can’t perform that action at this time.
0 commit comments