Effect CommunityEC
Effect Community3y ago
12 replies
ts

Struggling with Writing an Auth Middleware

Sorry for spamming questions today, last one:

I'm struggling to write an auth middleware. Both of the following middlewares "work", but they run after my handlers.
            Http.middleware.make(
                E.Effect.tap(() =>
                    E.Effect.tap(Http.request.ServerRequest, request =>
                        request.method !== 'OPTIONS'
                            ? auth.verify(request)
                            : E.Effect.unit,
                    ),
                ),
            ),
            Http.middleware.make(
                E.Effect.tap(
                    E.Effect.zipLeft(
                        Http.app.appendPreResponseHandler((request, response) =>
                            E.Effect.tap(response, () =>
                                request.method !== 'OPTIONS'
                                    ? auth.verify(request)
                                    : E.Effect.unit,
                            ),
                        ),
                    ),
                ),
            ),
Was this page helpful?