This commit is contained in:
熊潇 2025-03-22 10:55:35 +08:00
commit d570cc98a1
5 changed files with 140 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.env
node_modules
dist

23
package.json Normal file
View File

@ -0,0 +1,23 @@
{
"name": "clickhouse-test",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"ssh": "ssh -L 8123:127.0.0.1:8123 tencent"
},
"keywords": [],
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
"license": "MIT",
"packageManager": "pnpm@10.6.2",
"type": "module",
"dependencies": {
"@clickhouse/client": "^1.11.0",
"dotenv": "^16.4.7"
},
"devDependencies": {
"@types/node": "^22.13.11",
"typescript": "^5.8.2"
}
}

65
pnpm-lock.yaml generated Normal file
View File

@ -0,0 +1,65 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
dependencies:
'@clickhouse/client':
specifier: ^1.11.0
version: 1.11.0
dotenv:
specifier: ^16.4.7
version: 16.4.7
devDependencies:
'@types/node':
specifier: ^22.13.11
version: 22.13.11
typescript:
specifier: ^5.8.2
version: 5.8.2
packages:
'@clickhouse/client-common@1.11.0':
resolution: {integrity: sha512-O0xbwv7HiMXayokrf5dYIBpjBnYekcOXWz60T1cXLmiZ8vgrfNRCiOpybJkrMXKnw9D0mWCgPUu/rgMY7U1f4g==}
'@clickhouse/client@1.11.0':
resolution: {integrity: sha512-VYTQfR0y/BtrIDEjuSce1zv85OvHak5sUhZVyNYJzbAgWHy3jFf8Os7FdUSeqyKav0xGGy+2X+dRanTFjI5Oug==}
engines: {node: '>=16'}
'@types/node@22.13.11':
resolution: {integrity: sha512-iEUCUJoU0i3VnrCmgoWCXttklWcvoCIx4jzcP22fioIVSdTmjgoEvmAO/QPw6TcS9k5FrNgn4w7q5lGOd1CT5g==}
dotenv@16.4.7:
resolution: {integrity: sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==}
engines: {node: '>=12'}
typescript@5.8.2:
resolution: {integrity: sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==}
engines: {node: '>=14.17'}
hasBin: true
undici-types@6.20.0:
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
snapshots:
'@clickhouse/client-common@1.11.0': {}
'@clickhouse/client@1.11.0':
dependencies:
'@clickhouse/client-common': 1.11.0
'@types/node@22.13.11':
dependencies:
undici-types: 6.20.0
dotenv@16.4.7: {}
typescript@5.8.2: {}
undici-types@6.20.0: {}

18
src/app.ts Normal file
View File

@ -0,0 +1,18 @@
import dotenv from 'dotenv';
import { createClient } from '@clickhouse/client';
dotenv.config();
const clickhouse = createClient({
url: process.env.CLICKHOUSE_URL,
username: process.env.CLICKHOUSE_USERNAME,
password: process.env.CLICKHOUSE_PASSWORD,
});
clickhouse
.query({
query: 'SELECT 1',
})
.then((res) => {
console.log(res);
});

31
tsconfig.json Normal file
View File

@ -0,0 +1,31 @@
{
"compilerOptions": {
"module": "nodenext",
"target": "esnext",
"noImplicitAny": false,
"outDir": "./dist",
"sourceMap": false,
"allowJs": true,
"newLine": "LF",
"baseUrl": "./",
"typeRoots": [
"node_modules/@types",
],
"declaration": true,
"noEmit": false,
"allowImportingTsExtensions": true,
"emitDeclarationOnly": true,
"moduleResolution": "NodeNext",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"paths": {
"@/*": [
"src/*"
],
}
},
"include": [
"src/**/*.ts"
],
}