Create an endpoint that is only available to logged-in users.
app.addEndpoint({
method: 'GET',
path: '/example',
outputSchema: {
message: sString().type(),
},
// Require the user to be logged in
isLoggedIn: true,
run: (system) => {
// Only users that are logged in can reach this point
// All others will receive a 401 Unauthorized response
return {
message: `You are logged in as "${system.user.name}" with email "${system.user.email}".`
}
}
});