Express.js (Backend)
Backend integration with Express.js
Scute can be integrated into an Express.js application using the @scute/node
package. This package provides a middleware and a method called authenticateRequest
that can be used to handle the authentication and authorization of users in your Express.js application.
Head over to the example project repo to run this example project and check out the type docs for more scuteClient
methods.
Install the @scute/node
package
First, install the @scute/node
package using npm or yarn:
Initialize the Scute client
In your entry point (usually app.ts
) initialize the Scute client using the createClient
method exposed by the @scute/node
package:
Using the Scute middleware
You can use the scuteAuthMiddleware
to protect routes that require authentication. The middleware will check if the user is authenticated and attach the user object to the request object.
Using the authenticateRequest
helper method
You can also use the authenticateRequest
method to authenticate the user manually in your route handlers:
Last updated on