Example:
import { HttpServerRequest } from '@effect/platform'
import { Schema } from '@effect/schema'
import { Effect, flow, pipe } from 'effect'
import { Api, RouterBuilder, Security } from 'effect-http'
import { NodeTesting } from 'effect-http-node'
const AuthorizationSchema = Schema.Struct({ authorization: Schema.String })
export const authHeader = Security.make(
pipe(
HttpServerRequest.schemaHeaders(
AuthorizationSchema,
),
),
{
myApiKey: {
name: 'Authorization',
type: 'apiKey',
in: 'header',
description: 'signed authorization token',
},
},
)
export const addAuthHeader = Api.setRequestHeaders(
AuthorizationSchema,
)
export const addAuth = flow(
Api.setSecurity(authHeader),
addAuthHeader,
)
const testApi = Api.make().pipe(
Api.addEndpoint(
pipe(
Api.get('test', '/test'),
Api.setResponseBody(Schema.String),
addAuth,
),
),
)
const app = RouterBuilder.make(testApi).pipe(
RouterBuilder.handle(
'test',
_ => Effect.succeed('ok'),
),
RouterBuilder.build,
)
const testClient = NodeTesting.make(app, testApi)
// Using the client:
Effect
.gen(function*() {
const client = yield* testClient
const result = yield* client.test({
headers: { authorization: 'somevalue' },
body: undefined,
query: undefined,
path: undefined,
})
})
Seems like extra props in type show as any. Since they are not defined on the spec, they shouldn't be allowed

Updated the code, it seems to come from the flow based addition of security
Example:
Seems like extra props in type show as

any. Since they are not defined on the spec, they shouldn't be allowedUpdated the code, it seems to come from the
flowbased addition of security