MCPcopy
hub / github.com/Effect-TS/effect / makeConfig

Function makeConfig

packages/platform/src/Multipart.ts:247–267  ·  view source on GitHub ↗
(
  headers: Record<string, string>
)

Source from the content-addressed store, hash-verified

245 * @category Config
246 */
247export const makeConfig = (
248 headers: Record<string, string>
249): Effect.Effect<MP.BaseConfig> =>
250 Effect.withFiberRuntime((fiber) => {
251 const mimeTypes = Context.get(fiber.currentContext, FieldMimeTypes)
252 return Effect.succeed<MP.BaseConfig>({
253 headers,
254 maxParts: Option.getOrUndefined(Context.get(fiber.currentContext, MaxParts)),
255 maxFieldSize: Number(Context.get(fiber.currentContext, MaxFieldSize)),
256 maxPartSize: Context.get(fiber.currentContext, MaxFileSize).pipe(Option.map(Number), Option.getOrUndefined),
257 maxTotalSize: Context.get(fiber.currentContext, IncomingMessage.MaxBodySize).pipe(
258 Option.map(Number),
259 Option.getOrUndefined
260 ),
261 isFile: mimeTypes.length === 0 ? undefined : (info: MP.PartInfo): boolean =>
262 !Chunk.some(
263 mimeTypes,
264 (_) => info.contentType.includes(_)
265 ) && MP.defaultIsFile(info)
266 })
267 })
268
269/**
270 * @since 1.0.0

Callers 1

makeChannelFunction · 0.85

Calls 4

NumberInterface · 0.85
getMethod · 0.65
pipeMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected