샘플
mime-types 2.1.35: mime.lookup, mime.contentType, mime.extension
검증된 샘플 — npm mime-types 2.1.35: mime.lookup, mime.contentType, mime.extension. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:a9c257ce5641bd69b392a233f5e16cd12b03bf496374a0d697f846f19ac4ef05
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
windows 11 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-19 |
케이스
HOW- 목표
- verify pkg:npm/mime-types@2.1.35
- 심벌
-
- mime.lookup
- mime.contentType
- mime.extension
- 생성일
- 2026-08-18T18:08:34Z
컨트랙트
- mime.lookup returns MIME type for path or extension, or false when unknown
- mime.contentType returns full Content-Type header with charset parameter or false
- mime.extension returns default file extension for a MIME type or false
파일
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.js
소스
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:npm/mime-types@2.1.35
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/mime-types@2.1.35
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@11.8.0
- runtime: node@24.13.1
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:3f78c6cea81016d7ce110067334368abdda208d8953daf481a6557222099fcd0","constraints":{"executionContext":"node"},"contract":["mime.lookup returns MIME type for path or extension, or false when unknown","mime.contentType returns full Content-Type header with charset parameter or false","mime.extension returns default file extension for a MIME type or false"],"goal":"verify pkg:npm/mime-types@2.1.35","kind":"HOW","packages":["pkg:npm/mime-types@2.1.35"],"schemaVersion":1,"symbols":["mime.lookup","mime.contentType","mime.extension"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","ecosystem":"npm","os":"windows","osVersionBucket":"11","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/mime-types@2.1.35"],"schemaVersion":1,"symbols":["mime.lookup","mime.contentType","mime.extension"],"verifierAdapter":"node-typescript@1"}
const mime = require('mime-types');
/**
* Look up the MIME type for a file path or extension.
* @param {string} path
* @returns {string | false}
*/
function lookupType(path) {
return mime.lookup(path);
}
/**
* Get the full Content-Type header value with charset if applicable.
* @param {string} str
* @returns {string | false}
*/
function getContentType(str) {
return mime.contentType(str);
}
/**
* Get the default extension for a MIME type.
* @param {string} type
* @returns {string | false}
*/
function getExtension(type) {
return mime.extension(type);
}
module.exports = {
lookupType,
getContentType,
getExtension
};
{
"name": "sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample",
"version": "1.0.0",
"dependencies": {
"mime-types": "2.1.35"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
}
}
}
{
"name": "sample",
"version": "1.0.0",
"dependencies": {
"mime-types": "2.1.35"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/mime-types@2.1.35",
"kind": "HOW",
"packages": [
"pkg:npm/mime-types@2.1.35"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@11.8.0",
"runtime": "node@24.13.1"
}
}
const assert = require('node:assert/strict');
const mime = require('mime-types');
const { lookupType, getContentType, getExtension } = require('../index.js');
// Contract 1: mime.lookup returns MIME type for path or extension, or false when unknown
{
assert.equal(lookupType('json'), 'application/json');
assert.equal(lookupType('.md'), 'text/markdown');
assert.equal(lookupType('document.pdf'), 'application/pdf');
assert.equal(lookupType('archive.tar.gz'), 'application/gzip');
assert.equal(lookupType('path/to/image.png'), 'image/png');
assert.equal(lookupType('unknown.custom_ext_xyz'), false);
assert.equal(mime.lookup('index.html'), 'text/html');
}
// Contract 2: mime.contentType returns full Content-Type header with charset parameter or false
{
assert.equal(getContentType('markdown'), 'text/markdown; charset=utf-8');
assert.equal(getContentType('text/html'), 'text/html; charset=utf-8');
assert.equal(getContentType('file.json'), 'application/json; charset=utf-8');
assert.equal(getContentType('image/png'), 'image/png');
assert.equal(getContentType('application/octet-stream'), 'application/octet-stream');
assert.equal(getContentType('nonexistent'), false);
assert.equal(getContentType('file.unknownextensionxyz'), false);
assert.equal(mime.contentType('application/json'), 'application/json; charset=utf-8');
}
// Contract 3: mime.extension returns default file extension for a MIME type or false
{
assert.equal(getExtension('text/html'), 'html');
assert.equal(getExtension('application/json'), 'json');
assert.equal(getExtension('text/markdown; charset=utf-8'), 'markdown');
assert.equal(getExtension('application/octet-stream'), 'bin');
assert.equal(getExtension('image/svg+xml'), 'svg');
assert.equal(getExtension('invalid/not-real-mime-xyz'), false);
assert.equal(mime.extension('application/pdf'), 'pdf');
}
console.log('All mime-types contract assertions passed successfully.');
오리진 시더
익명