use TS natively and switch to pnpm (#1672)

* use TS natively

* use pnpm
This commit is contained in:
typicode
2026-01-15 00:04:05 +01:00
committed by GitHub
parent 89c714c895
commit 193b12960c
11 changed files with 826 additions and 2999 deletions

View File

@@ -1,31 +1,17 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Node.js CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
- uses: actions/checkout@v5
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: '22.x'
cache: 'pnpm'
- run: pnpm install
- run: pnpm run typecheck
- run: pnpm test

View File

@@ -1,38 +1,23 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
name: Node.js Package
name: Publish Package to npmjs
on:
release:
types: [published]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
- run: npm test
publish-npm:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish --provenance --access public
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- run: pnpm install
- run: pnpm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

2912
package-lock.json generated
View File

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,6 @@
"bin": {
"json-server": "lib/bin.js"
},
"types": "lib",
"files": [
"lib",
"views"
@@ -15,12 +14,13 @@
"node": ">=22.12.0"
},
"scripts": {
"dev": "tsx watch src/bin.ts fixtures/db.json",
"dev": "node --experimental-strip-types src/bin.ts fixtures/db.json",
"build": "rm -rf lib && tsc",
"test": "node --import tsx/esm --test src/*.test.ts",
"prepublishOnly": "rm -rf lib && tsc",
"typecheck": "tsc --noEmit",
"test": "node --experimental-strip-types --test src/*.test.ts",
"lint": "oxlint src",
"prepare": "husky",
"prepublishOnly": "npm run build"
"prepare": "husky"
},
"keywords": [],
"author": "typicode <typicode@gmail.com>",
@@ -30,31 +30,28 @@
"url": "git+https://github.com/typicode/json-server.git"
},
"devDependencies": {
"@sindresorhus/tsconfig": "^6.0.0",
"@tailwindcss/typography": "^0.5.15",
"@types/node": "^22.5.5",
"concurrently": "^9.0.1",
"@types/node": "^25.0.8",
"concurrently": "^9.2.1",
"get-port": "^7.1.0",
"husky": "^9.1.6",
"husky": "^9.1.7",
"oxlint": "^1.39.0",
"tempy": "^3.1.0",
"tsx": "^4.19.1",
"type-fest": "^4.26.1",
"type-fest": "^5.4.0",
"typescript": "^5.9.3"
},
"dependencies": {
"@tinyhttp/app": "^2.4.0",
"@tinyhttp/app": "^3.0.1",
"@tinyhttp/cors": "^2.0.1",
"@tinyhttp/logger": "^2.0.0",
"chalk": "^5.3.0",
"chokidar": "^4.0.1",
"dot-prop": "^9.0.0",
"eta": "^3.5.0",
"inflection": "^3.0.0",
"@tinyhttp/logger": "^2.1.0",
"chalk": "^5.6.2",
"chokidar": "^5.0.0",
"dot-prop": "^10.1.0",
"eta": "^4.5.0",
"inflection": "^3.0.2",
"json5": "^2.2.3",
"lowdb": "^7.0.1",
"milliparsec": "^4.0.0",
"sirv": "^2.0.4",
"sort-on": "^6.1.0"
"milliparsec": "^5.1.0",
"sirv": "^3.0.2",
"sort-on": "^7.0.0"
}
}

763
pnpm-lock.yaml generated Normal file
View File

@@ -0,0 +1,763 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
dependencies:
'@tinyhttp/app':
specifier: ^3.0.1
version: 3.0.1
'@tinyhttp/cors':
specifier: ^2.0.1
version: 2.0.1
'@tinyhttp/logger':
specifier: ^2.1.0
version: 2.1.0
chalk:
specifier: ^5.6.2
version: 5.6.2
chokidar:
specifier: ^5.0.0
version: 5.0.0
dot-prop:
specifier: ^10.1.0
version: 10.1.0
eta:
specifier: ^4.5.0
version: 4.5.0
inflection:
specifier: ^3.0.2
version: 3.0.2
json5:
specifier: ^2.2.3
version: 2.2.3
lowdb:
specifier: ^7.0.1
version: 7.0.1
milliparsec:
specifier: ^5.1.0
version: 5.1.0
sirv:
specifier: ^3.0.2
version: 3.0.2
sort-on:
specifier: ^7.0.0
version: 7.0.0
devDependencies:
'@types/node':
specifier: ^25.0.8
version: 25.0.8
concurrently:
specifier: ^9.2.1
version: 9.2.1
get-port:
specifier: ^7.1.0
version: 7.1.0
husky:
specifier: ^9.1.7
version: 9.1.7
oxlint:
specifier: ^1.39.0
version: 1.39.0
tempy:
specifier: ^3.1.0
version: 3.1.0
type-fest:
specifier: ^5.4.0
version: 5.4.0
typescript:
specifier: ^5.9.3
version: 5.9.3
packages:
'@oxlint/darwin-arm64@1.39.0':
resolution: {integrity: sha512-lT3hNhIa02xCujI6YGgjmYGg3Ht/X9ag5ipUVETaMpx5Rd4BbTNWUPif1WN1YZHxt3KLCIqaAe7zVhatv83HOQ==}
cpu: [arm64]
os: [darwin]
'@oxlint/darwin-x64@1.39.0':
resolution: {integrity: sha512-UT+rfTWd+Yr7iJeSLd/7nF8X4gTYssKh+n77hxl6Oilp3NnG1CKRHxZDy3o3lIBnwgzJkdyUAiYWO1bTMXQ1lA==}
cpu: [x64]
os: [darwin]
'@oxlint/linux-arm64-gnu@1.39.0':
resolution: {integrity: sha512-qocBkvS2V6rH0t9AT3DfQunMnj3xkM7srs5/Ycj2j5ZqMoaWd/FxHNVJDFP++35roKSvsRJoS0mtA8/77jqm6Q==}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@oxlint/linux-arm64-musl@1.39.0':
resolution: {integrity: sha512-arZzAc1PPcz9epvGBBCMHICeyQloKtHX3eoOe62B3Dskn7gf6Q14wnDHr1r9Vp4vtcBATNq6HlKV14smdlC/qA==}
cpu: [arm64]
os: [linux]
libc: [musl]
'@oxlint/linux-x64-gnu@1.39.0':
resolution: {integrity: sha512-ZVt5qsECpuNprdWxAPpDBwoixr1VTcZ4qAEQA2l/wmFyVPDYFD3oBY/SWACNnWBddMrswjTg9O8ALxYWoEpmXw==}
cpu: [x64]
os: [linux]
libc: [glibc]
'@oxlint/linux-x64-musl@1.39.0':
resolution: {integrity: sha512-pB0hlGyKPbxr9NMIV783lD6cWL3MpaqnZRM9MWni4yBdHPTKyFNYdg5hGD0Bwg+UP4S2rOevq/+OO9x9Bi7E6g==}
cpu: [x64]
os: [linux]
libc: [musl]
'@oxlint/win32-arm64@1.39.0':
resolution: {integrity: sha512-Gg2SFaJohI9+tIQVKXlPw3FsPQFi/eCSWiCgwPtPn5uzQxHRTeQEZKuluz1fuzR5U70TXubb2liZi4Dgl8LJQA==}
cpu: [arm64]
os: [win32]
'@oxlint/win32-x64@1.39.0':
resolution: {integrity: sha512-sbi25lfj74hH+6qQtb7s1wEvd1j8OQbTaH8v3xTcDjrwm579Cyh0HBv1YSZ2+gsnVwfVDiCTL1D0JsNqYXszVA==}
cpu: [x64]
os: [win32]
'@polka/url@1.0.0-next.29':
resolution: {integrity: sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==}
'@tinyhttp/accepts@2.2.4':
resolution: {integrity: sha512-zYkSyzPOSjDdfGyV4H8J6TVc2Jz62UEbp4Pz0wc9uSEoGxxgpBYHVD2ki8wDnaUavDi2DYEss1plW0kTnX3LKw==}
engines: {node: '>=14.13.1'}
'@tinyhttp/app@3.0.1':
resolution: {integrity: sha512-Uy5O6n5GsyW76MbLEpfGoMuis9qQUk5/c/99AlsPwHf1Df24FFaxeE44RLmX/JJW8Q1QbWtX3fz649TXY1DCaw==}
engines: {node: '>=16.10.0'}
'@tinyhttp/content-disposition@2.2.2':
resolution: {integrity: sha512-crXw1txzrS36huQOyQGYFvhTeLeG0Si1xu+/l6kXUVYpE0TjFjEZRqTbuadQLfKGZ0jaI+jJoRyqaWwxOSHW2g==}
engines: {node: '>=12.20.0'}
'@tinyhttp/content-type@0.1.4':
resolution: {integrity: sha512-dl6f3SHIJPYbhsW1oXdrqOmLSQF/Ctlv3JnNfXAE22kIP7FosqJHxkz/qj2gv465prG8ODKH5KEyhBkvwrueKQ==}
engines: {node: '>=12.4'}
'@tinyhttp/cookie-signature@2.1.1':
resolution: {integrity: sha512-VDsSMY5OJfQJIAtUgeQYhqMPSZptehFSfvEEtxr+4nldPA8IImlp3QVcOVuK985g4AFR4Hl1sCbWCXoqBnVWnw==}
engines: {node: '>=12.20.0'}
'@tinyhttp/cookie@2.1.1':
resolution: {integrity: sha512-h/kL9jY0e0Dvad+/QU3efKZww0aTvZJslaHj3JTPmIPC9Oan9+kYqmh3M6L5JUQRuTJYFK2nzgL2iJtH2S+6dA==}
engines: {node: '>=12.20.0'}
'@tinyhttp/cors@2.0.1':
resolution: {integrity: sha512-qrmo6WJuaiCzKWagv2yA/kw6hIISfF/hOqPWwmI6w0o8apeTMmRN3DoCFvQ/wNVuWVdU5J4KU7OX8aaSOEq51A==}
engines: {node: '>=12.20 || 14.x || >=16'}
'@tinyhttp/encode-url@2.1.1':
resolution: {integrity: sha512-AhY+JqdZ56qV77tzrBm0qThXORbsVjs/IOPgGCS7x/wWnsa/Bx30zDUU/jPAUcSzNOzt860x9fhdGpzdqbUeUw==}
engines: {node: '>=12.20.0'}
'@tinyhttp/etag@2.1.2':
resolution: {integrity: sha512-j80fPKimGqdmMh6962y+BtQsnYPVCzZfJw0HXjyH70VaJBHLKGF+iYhcKqzI3yef6QBNa8DKIPsbEYpuwApXTw==}
engines: {node: '>=12.20.0'}
'@tinyhttp/forwarded@2.1.2':
resolution: {integrity: sha512-9H/eulJ68ElY/+zYpTpNhZ7vxGV+cnwaR6+oQSm7bVgZMyuQfgROW/qvZuhmgDTIxnGMXst+Ba4ij6w6Krcs3w==}
engines: {node: '>=12.20.0'}
'@tinyhttp/logger@2.1.0':
resolution: {integrity: sha512-Ma1fJ9CwUbn9r61/4HW6+nflsVoslpOnCrfQ6UeZq7GGIgwLzofms3HoSVG7M+AyRMJpxlfcDdbH5oFVroDMKA==}
engines: {node: '>=14.18 || >=16.20'}
'@tinyhttp/proxy-addr@3.0.0':
resolution: {integrity: sha512-K1r1nTO6IJwZdmDTsS8q+o6FdDfYAVbm4peItnaydbe25ENAncJFWbFRvV+RxCSuX4H/vOIe3jd28ItSaNxNKw==}
engines: {node: '>=16.10.0'}
'@tinyhttp/req@2.2.6':
resolution: {integrity: sha512-il4ZZmIvB6sA0G4NGE+dChWxauYPLb9M2HZGVjryH2MwMV14MWBlUKTagLpI6lmWzPtlnR9a3jF3sK0AEZig/w==}
engines: {node: '>=14.13.1'}
'@tinyhttp/res@2.2.6':
resolution: {integrity: sha512-w8+5Z/Nd2gsDFG/6s3v2QszcuyfmxEFhgEZ9FHjIGQWukV3i/Npo8GdW4Psu20JXUAGIxh0ynZ/jbATSxHWSaQ==}
engines: {node: '>=14.13.1'}
'@tinyhttp/router@2.2.3':
resolution: {integrity: sha512-O0MQqWV3Vpg/uXsMYg19XsIgOhwjyhTYWh51Qng7bxqXixxx2PEvZWnFjP7c84K7kU/nUX41KpkEBTLnznk9/Q==}
engines: {node: '>=12.20.0'}
'@tinyhttp/send@2.2.4':
resolution: {integrity: sha512-DgEY185oQUd2LTKHM+he/m3sjYWB7yL0WLNrasoSEHaCfzstm0+viltqqOvEV7UtkSB3oRRo+OWiEtYKmd6h5w==}
engines: {node: '>=14.13.1'}
'@tinyhttp/type-is@2.2.5':
resolution: {integrity: sha512-BCPEB+NV8v/9lzEE9GbfRPAKVsyayp84m6SSWn70j8yFkPBXeuVeq004pwVrjW1CRdmAZz9ZSH147pqqzAdr5g==}
engines: {node: '>=14.13.1'}
'@tinyhttp/url@2.1.1':
resolution: {integrity: sha512-POJeq2GQ5jI7Zrdmj22JqOijB5/GeX+LEX7DUdml1hUnGbJOTWDx7zf2b5cCERj7RoXL67zTgyzVblBJC+NJWg==}
engines: {node: '>=12.20.0'}
'@tinyhttp/vary@0.1.3':
resolution: {integrity: sha512-SoL83sQXAGiHN1jm2VwLUWQSQeDAAl1ywOm6T0b0Cg1CZhVsjoiZadmjhxF6FHCCY7OHHVaLnTgSMxTPIDLxMg==}
engines: {node: '>=12.20'}
'@types/node@25.0.8':
resolution: {integrity: sha512-powIePYMmC3ibL0UJ2i2s0WIbq6cg6UyVFQxSCpaPxxzAaziRfimGivjdF943sSGV6RADVbk0Nvlm5P/FB44Zg==}
ansi-regex@5.0.1:
resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==}
engines: {node: '>=8'}
ansi-styles@4.3.0:
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
engines: {node: '>=8'}
chalk@4.1.2:
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
engines: {node: '>=10'}
chalk@5.6.2:
resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==}
engines: {node: ^12.17.0 || ^14.13 || >=16.0.0}
chokidar@5.0.0:
resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==}
engines: {node: '>= 20.19.0'}
cliui@8.0.1:
resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==}
engines: {node: '>=12'}
color-convert@2.0.1:
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
engines: {node: '>=7.0.0'}
color-name@1.1.4:
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
colorette@2.0.20:
resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==}
concurrently@9.2.1:
resolution: {integrity: sha512-fsfrO0MxV64Znoy8/l1vVIjjHa29SZyyqPgQBwhiDcaW8wJc2W3XWVOGx4M3oJBnv/zdUZIIp1gDeS98GzP8Ng==}
engines: {node: '>=18'}
hasBin: true
crypto-random-string@4.0.0:
resolution: {integrity: sha512-x8dy3RnvYdlUcPOjkEHqozhiwzKNSq7GcPuXFbnyMOCHxX8V3OgIg/pYuabl2sbUPfIJaeAQB7PMOK8DFIdoRA==}
engines: {node: '>=12'}
dayjs@1.11.19:
resolution: {integrity: sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==}
dot-prop@10.1.0:
resolution: {integrity: sha512-MVUtAugQMOff5RnBy2d9N31iG0lNwg1qAoAOn7pOK5wf94WIaE3My2p3uwTQuvS2AcqchkcR3bHByjaM0mmi7Q==}
engines: {node: '>=20'}
emoji-regex@8.0.0:
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
es-escape-html@0.1.1:
resolution: {integrity: sha512-yUx1o+8RsG7UlszmYPtks+dm6Lho2m8lgHMOsLJQsFI0R8XwUJwiMhM1M4E/S8QLeGyf6MkDV/pWgjQ0tdTSyQ==}
engines: {node: '>=12.x'}
escalade@3.2.0:
resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==}
engines: {node: '>=6'}
eta@4.5.0:
resolution: {integrity: sha512-qifAYjuW5AM1eEEIsFnOwB+TGqu6ynU3OKj9WbUTOtUBHFPZqL03XUW34kbp3zm19Ald+U8dEyRXaVsUck+Y1g==}
engines: {node: '>=20'}
get-caller-file@2.0.5:
resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==}
engines: {node: 6.* || 8.* || >= 10.*}
get-port@7.1.0:
resolution: {integrity: sha512-QB9NKEeDg3xxVwCCwJQ9+xycaz6pBB6iQ76wiWMl1927n0Kir6alPiP+yuiICLLU4jpMe08dXfpebuQppFA2zw==}
engines: {node: '>=16'}
has-flag@4.0.0:
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
engines: {node: '>=8'}
header-range-parser@1.1.3:
resolution: {integrity: sha512-B9zCFt3jH8g09LR1vHL4pcAn8yMEtlSlOUdQemzHMRKMImNIhhszdeosYFfNW0WXKQtXIlWB+O4owHJKvEJYaA==}
engines: {node: '>=12.22.0'}
http-status-emojis@2.2.0:
resolution: {integrity: sha512-ompKtgwpx8ff0hsbpIB7oE4ax1LXoHmftsHHStMELX56ivG3GhofTX8ZHWlUaFKfGjcGjw6G3rPk7dJRXMmbbg==}
husky@9.1.7:
resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==}
engines: {node: '>=18'}
hasBin: true
inflection@3.0.2:
resolution: {integrity: sha512-+Bg3+kg+J6JUWn8J6bzFmOWkTQ6L/NHfDRSYU+EVvuKHDxUDHAXgqixHfVlzuBQaPOTac8hn43aPhMNk6rMe3g==}
engines: {node: '>=18.0.0'}
ipaddr.js@2.3.0:
resolution: {integrity: sha512-Zv/pA+ciVFbCSBBjGfaKUya/CcGmUHzTydLMaTwrUUEM2DIEO3iZvueGxmacvmN50fGpGVKeTXpb2LcYQxeVdg==}
engines: {node: '>= 10'}
is-fullwidth-code-point@3.0.0:
resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==}
engines: {node: '>=8'}
is-stream@3.0.0:
resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
json5@2.2.3:
resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==}
engines: {node: '>=6'}
hasBin: true
lowdb@7.0.1:
resolution: {integrity: sha512-neJAj8GwF0e8EpycYIDFqEPcx9Qz4GUho20jWFR7YiFeXzF1YMLdxB36PypcTSPMA+4+LvgyMacYhlr18Zlymw==}
engines: {node: '>=18'}
milliparsec@5.1.0:
resolution: {integrity: sha512-/xFIv79W7RhnnRLcQOlNpm0xO5FrodBdWFIysI4jIimqCCOnYwBekh6p+Qx61MVooewwBI7WEanFYeo8KtR2dA==}
engines: {node: '>=18.13 || >=19.20 || >=20'}
mime@4.1.0:
resolution: {integrity: sha512-X5ju04+cAzsojXKes0B/S4tcYtFAJ6tTMuSPBEn9CPGlrWr8Fiw7qYeLT0XyH80HSoAoqWCaz+MWKh22P7G1cw==}
engines: {node: '>=16'}
hasBin: true
mrmime@2.0.1:
resolution: {integrity: sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==}
engines: {node: '>=10'}
negotiator@1.0.0:
resolution: {integrity: sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==}
engines: {node: '>= 0.6'}
oxlint@1.39.0:
resolution: {integrity: sha512-wSiLr0wjG+KTU6c1LpVoQk7JZ7l8HCKlAkVDVTJKWmCGazsNxexxnOXl7dsar92mQcRnzko5g077ggP3RINSjA==}
engines: {node: ^20.19.0 || >=22.12.0}
hasBin: true
peerDependencies:
oxlint-tsgolint: '>=0.10.0'
peerDependenciesMeta:
oxlint-tsgolint:
optional: true
readdirp@5.0.0:
resolution: {integrity: sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==}
engines: {node: '>= 20.19.0'}
regexparam@2.0.2:
resolution: {integrity: sha512-A1PeDEYMrkLrfyOwv2jwihXbo9qxdGD3atBYQA9JJgreAx8/7rC6IUkWOw2NQlOxLp2wL0ifQbh1HuidDfYA6w==}
engines: {node: '>=8'}
require-directory@2.1.1:
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
engines: {node: '>=0.10.0'}
rxjs@7.8.2:
resolution: {integrity: sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==}
shell-quote@1.8.3:
resolution: {integrity: sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==}
engines: {node: '>= 0.4'}
sirv@3.0.2:
resolution: {integrity: sha512-2wcC/oGxHis/BoHkkPwldgiPSYcpZK3JU28WoMVv55yHJgcZ8rlXvuG9iZggz+sU1d4bRgIGASwyWqjxu3FM0g==}
engines: {node: '>=18'}
sort-on@7.0.0:
resolution: {integrity: sha512-e+4RRxt7jsWdGPp4H5PKOER/ELYlemNB1plvW686Qi3j4WVaCjCpro2zaTD7Cn0VtBImq/hg3x1JfovMNXXfJQ==}
engines: {node: '>=20'}
steno@4.0.2:
resolution: {integrity: sha512-yhPIQXjrlt1xv7dyPQg2P17URmXbuM5pdGkpiMB3RenprfiBlvK415Lctfe0eshk90oA7/tNq7WEiMK8RSP39A==}
engines: {node: '>=18'}
string-width@4.2.3:
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
engines: {node: '>=8'}
strip-ansi@6.0.1:
resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}
engines: {node: '>=8'}
supports-color@7.2.0:
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
engines: {node: '>=8'}
supports-color@8.1.1:
resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==}
engines: {node: '>=10'}
tagged-tag@1.0.0:
resolution: {integrity: sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng==}
engines: {node: '>=20'}
temp-dir@3.0.0:
resolution: {integrity: sha512-nHc6S/bwIilKHNRgK/3jlhDoIHcp45YgyiwcAk46Tr0LfEqGBVpmiAyuiuxeVE44m3mXnEeVhaipLOEWmH+Njw==}
engines: {node: '>=14.16'}
tempy@3.1.0:
resolution: {integrity: sha512-7jDLIdD2Zp0bDe5r3D2qtkd1QOCacylBuL7oa4udvN6v2pqr4+LcCr67C8DR1zkpaZ8XosF5m1yQSabKAW6f2g==}
engines: {node: '>=14.16'}
totalist@3.0.1:
resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==}
engines: {node: '>=6'}
tree-kill@1.2.2:
resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==}
hasBin: true
tslib@2.8.1:
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
type-fest@1.4.0:
resolution: {integrity: sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==}
engines: {node: '>=10'}
type-fest@2.19.0:
resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==}
engines: {node: '>=12.20'}
type-fest@5.4.0:
resolution: {integrity: sha512-wfkA6r0tBpVfGiyO+zbf9e10QkRQSlK9F2UvyfnjoCmrvH2bjHyhPzhugSBOuq1dog3P0+FKckqe+Xf6WKVjwg==}
engines: {node: '>=20'}
typescript@5.9.3:
resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==}
engines: {node: '>=14.17'}
hasBin: true
undici-types@7.16.0:
resolution: {integrity: sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==}
unique-string@3.0.0:
resolution: {integrity: sha512-VGXBUVwxKMBUznyffQweQABPRRW1vHZAbadFZud4pLFAqRGvv/96vafgjWFqzourzr8YonlQiPgH0YCJfawoGQ==}
engines: {node: '>=12'}
wrap-ansi@7.0.0:
resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==}
engines: {node: '>=10'}
y18n@5.0.8:
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
engines: {node: '>=10'}
yargs-parser@21.1.1:
resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==}
engines: {node: '>=12'}
yargs@17.7.2:
resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==}
engines: {node: '>=12'}
snapshots:
'@oxlint/darwin-arm64@1.39.0':
optional: true
'@oxlint/darwin-x64@1.39.0':
optional: true
'@oxlint/linux-arm64-gnu@1.39.0':
optional: true
'@oxlint/linux-arm64-musl@1.39.0':
optional: true
'@oxlint/linux-x64-gnu@1.39.0':
optional: true
'@oxlint/linux-x64-musl@1.39.0':
optional: true
'@oxlint/win32-arm64@1.39.0':
optional: true
'@oxlint/win32-x64@1.39.0':
optional: true
'@polka/url@1.0.0-next.29': {}
'@tinyhttp/accepts@2.2.4':
dependencies:
mime: 4.1.0
negotiator: 1.0.0
'@tinyhttp/app@3.0.1':
dependencies:
'@tinyhttp/cookie': 2.1.1
'@tinyhttp/proxy-addr': 3.0.0
'@tinyhttp/req': 2.2.6
'@tinyhttp/res': 2.2.6
'@tinyhttp/router': 2.2.3
header-range-parser: 1.1.3
regexparam: 2.0.2
'@tinyhttp/content-disposition@2.2.2': {}
'@tinyhttp/content-type@0.1.4': {}
'@tinyhttp/cookie-signature@2.1.1': {}
'@tinyhttp/cookie@2.1.1': {}
'@tinyhttp/cors@2.0.1':
dependencies:
'@tinyhttp/vary': 0.1.3
'@tinyhttp/encode-url@2.1.1': {}
'@tinyhttp/etag@2.1.2': {}
'@tinyhttp/forwarded@2.1.2': {}
'@tinyhttp/logger@2.1.0':
dependencies:
colorette: 2.0.20
dayjs: 1.11.19
http-status-emojis: 2.2.0
'@tinyhttp/proxy-addr@3.0.0':
dependencies:
'@tinyhttp/forwarded': 2.1.2
ipaddr.js: 2.3.0
'@tinyhttp/req@2.2.6':
dependencies:
'@tinyhttp/accepts': 2.2.4
'@tinyhttp/type-is': 2.2.5
'@tinyhttp/url': 2.1.1
header-range-parser: 1.1.3
'@tinyhttp/res@2.2.6':
dependencies:
'@tinyhttp/content-disposition': 2.2.2
'@tinyhttp/cookie': 2.1.1
'@tinyhttp/cookie-signature': 2.1.1
'@tinyhttp/encode-url': 2.1.1
'@tinyhttp/req': 2.2.6
'@tinyhttp/send': 2.2.4
'@tinyhttp/vary': 0.1.3
es-escape-html: 0.1.1
mime: 4.1.0
'@tinyhttp/router@2.2.3': {}
'@tinyhttp/send@2.2.4':
dependencies:
'@tinyhttp/content-type': 0.1.4
'@tinyhttp/etag': 2.1.2
mime: 4.1.0
'@tinyhttp/type-is@2.2.5':
dependencies:
'@tinyhttp/content-type': 0.1.4
mime: 4.1.0
'@tinyhttp/url@2.1.1': {}
'@tinyhttp/vary@0.1.3': {}
'@types/node@25.0.8':
dependencies:
undici-types: 7.16.0
ansi-regex@5.0.1: {}
ansi-styles@4.3.0:
dependencies:
color-convert: 2.0.1
chalk@4.1.2:
dependencies:
ansi-styles: 4.3.0
supports-color: 7.2.0
chalk@5.6.2: {}
chokidar@5.0.0:
dependencies:
readdirp: 5.0.0
cliui@8.0.1:
dependencies:
string-width: 4.2.3
strip-ansi: 6.0.1
wrap-ansi: 7.0.0
color-convert@2.0.1:
dependencies:
color-name: 1.1.4
color-name@1.1.4: {}
colorette@2.0.20: {}
concurrently@9.2.1:
dependencies:
chalk: 4.1.2
rxjs: 7.8.2
shell-quote: 1.8.3
supports-color: 8.1.1
tree-kill: 1.2.2
yargs: 17.7.2
crypto-random-string@4.0.0:
dependencies:
type-fest: 1.4.0
dayjs@1.11.19: {}
dot-prop@10.1.0:
dependencies:
type-fest: 5.4.0
emoji-regex@8.0.0: {}
es-escape-html@0.1.1: {}
escalade@3.2.0: {}
eta@4.5.0: {}
get-caller-file@2.0.5: {}
get-port@7.1.0: {}
has-flag@4.0.0: {}
header-range-parser@1.1.3: {}
http-status-emojis@2.2.0: {}
husky@9.1.7: {}
inflection@3.0.2: {}
ipaddr.js@2.3.0: {}
is-fullwidth-code-point@3.0.0: {}
is-stream@3.0.0: {}
json5@2.2.3: {}
lowdb@7.0.1:
dependencies:
steno: 4.0.2
milliparsec@5.1.0: {}
mime@4.1.0: {}
mrmime@2.0.1: {}
negotiator@1.0.0: {}
oxlint@1.39.0:
optionalDependencies:
'@oxlint/darwin-arm64': 1.39.0
'@oxlint/darwin-x64': 1.39.0
'@oxlint/linux-arm64-gnu': 1.39.0
'@oxlint/linux-arm64-musl': 1.39.0
'@oxlint/linux-x64-gnu': 1.39.0
'@oxlint/linux-x64-musl': 1.39.0
'@oxlint/win32-arm64': 1.39.0
'@oxlint/win32-x64': 1.39.0
readdirp@5.0.0: {}
regexparam@2.0.2: {}
require-directory@2.1.1: {}
rxjs@7.8.2:
dependencies:
tslib: 2.8.1
shell-quote@1.8.3: {}
sirv@3.0.2:
dependencies:
'@polka/url': 1.0.0-next.29
mrmime: 2.0.1
totalist: 3.0.1
sort-on@7.0.0:
dependencies:
dot-prop: 10.1.0
steno@4.0.2: {}
string-width@4.2.3:
dependencies:
emoji-regex: 8.0.0
is-fullwidth-code-point: 3.0.0
strip-ansi: 6.0.1
strip-ansi@6.0.1:
dependencies:
ansi-regex: 5.0.1
supports-color@7.2.0:
dependencies:
has-flag: 4.0.0
supports-color@8.1.1:
dependencies:
has-flag: 4.0.0
tagged-tag@1.0.0: {}
temp-dir@3.0.0: {}
tempy@3.1.0:
dependencies:
is-stream: 3.0.0
temp-dir: 3.0.0
type-fest: 2.19.0
unique-string: 3.0.0
totalist@3.0.1: {}
tree-kill@1.2.2: {}
tslib@2.8.1: {}
type-fest@1.4.0: {}
type-fest@2.19.0: {}
type-fest@5.4.0:
dependencies:
tagged-tag: 1.0.0
typescript@5.9.3: {}
undici-types@7.16.0: {}
unique-string@3.0.0:
dependencies:
crypto-random-string: 4.0.0
wrap-ansi@7.0.0:
dependencies:
ansi-styles: 4.3.0
string-width: 4.2.3
strip-ansi: 6.0.1
y18n@5.0.8: {}
yargs-parser@21.1.1: {}
yargs@17.7.2:
dependencies:
cliui: 8.0.1
escalade: 3.2.0
get-caller-file: 2.0.5
require-directory: 2.1.1
string-width: 4.2.3
y18n: 5.0.8
yargs-parser: 21.1.1

View File

@@ -7,8 +7,8 @@ import getPort from 'get-port'
import { Low, Memory } from 'lowdb'
import { temporaryDirectory } from 'tempy'
import { createApp } from './app.js'
import { Data } from './service.js'
import { createApp } from './app.ts'
import type { Data } from './service.ts'
type Test = {

View File

@@ -8,7 +8,8 @@ import { Low } from 'lowdb'
import { json } from 'milliparsec'
import sirv from 'sirv'
import { Data, isItem, Service } from './service.js'
import type { Data } from './service.ts'
import { isItem, Service } from './service.ts'
const __dirname = dirname(fileURLToPath(import.meta.url))
const isProduction = process.env['NODE_ENV'] === 'production'
@@ -51,7 +52,6 @@ export function createApp(db: Low<Data>, options: AppOptions = {}) {
.options('*', cors())
// Body parser
// @ts-expect-error expected
app.use(json())
app.get('/', (_req, res) =>

View File

@@ -6,14 +6,15 @@ import { parseArgs } from 'node:util'
import chalk from 'chalk'
import { watch } from 'chokidar'
import JSON5 from 'json5'
import { Adapter, Low } from 'lowdb'
import { Low } from 'lowdb'
import type { Adapter } from 'lowdb'
import { DataFile, JSONFile } from 'lowdb/node'
import { PackageJson } from 'type-fest'
import type { PackageJson } from 'type-fest'
import { fileURLToPath } from 'node:url'
import { createApp } from './app.js'
import { Observer } from './observer.js'
import { Data } from './service.js'
import { createApp } from './app.ts'
import { Observer } from './observer.ts'
import type { Data } from './service.ts'
function help() {
console.log(`Usage: json-server [options] <file>

View File

@@ -1,4 +1,4 @@
import { Adapter } from 'lowdb'
import type { Adapter } from 'lowdb'
// Lowdb adapter to observe read/write events
export class Observer<T> {

View File

@@ -3,7 +3,8 @@ import test from 'node:test'
import { Low, Memory } from 'lowdb'
import { Data, Item, PaginatedItems, Service } from './service.js'
import type { Data, Item, PaginatedItems } from './service.ts'
import { Service } from './service.ts'
const defaultData = { posts: [], comments: [], object: {} }
const adapter = new Memory<Data>()

View File

@@ -1,8 +1,14 @@
{
"extends": "@sindresorhus/tsconfig",
"exclude": ["src/**/*.test.ts"],
"compilerOptions": {
"outDir": "./lib",
"erasableSyntaxOnly": true
"target": "esnext",
"module": "nodenext",
"skipLibCheck": true,
"strict": true,
"allowImportingTsExtensions": true,
"rewriteRelativeImportExtensions": true,
"erasableSyntaxOnly": true,
"verbatimModuleSyntax": true
}
}