first commit

This commit is contained in:
2026-01-16 12:37:08 +05:30
commit ecfee6732e
11 changed files with 407 additions and 0 deletions

175
.gitignore vendored Normal file
View File

@@ -0,0 +1,175 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
# Logs
logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Caches
.cache
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# Runtime data
pids
_.pid
_.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# IntelliJ based IDEs
.idea
# Finder (MacOS) folder config
.DS_Store

15
README.md Normal file
View File

@@ -0,0 +1,15 @@
# redis-playground
To install dependencies:
```bash
bun install
```
To run:
```bash
bun run index.ts
```
This project was created using `bun init` in bun v1.1.7. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.

BIN
bun.lockb Normal file

Binary file not shown.

3
client.ts Normal file
View File

@@ -0,0 +1,3 @@
const {Redis} = require("ioredis");
const client = new Redis();
module.exports = client;

28
docker-compose.yml Normal file
View File

@@ -0,0 +1,28 @@
services:
redis:
image: redis/redis-stack:latest
container_name: redis
restart: no
ports:
- "6379:6379"
- "8001:8001"
volumes:
- redisdata:/data
volumes:
redisdata:
name: volunename that dispaly on docker desktop
services:
redis2:
image: redis:7-alpine
container_name: redis2
restart: no
ports:
- "6379:6379"
volumes:
- redisdata2:/data
volumes:
redisdata2:

1
index.ts Normal file
View File

@@ -0,0 +1 @@
console.log("Hello via Bun!");

17
package.json Normal file
View File

@@ -0,0 +1,17 @@
{
"name": "redis-playground",
"module": "index.ts",
"type": "module",
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.962.0",
"@qdrant/js-client-rest": "^1.16.2",
"aws-sdk": "^2.1693.0",
"ioredis": "^5.4.1"
}
}

74
s3.js Normal file
View File

@@ -0,0 +1,74 @@
const { S3Client, PutObjectCommand, ListBucketsCommand, GetObjectCommand } = require('@aws-sdk/client-s3');
// const { fromIni } = require('@aws-sdk/credential-providers');
const minioClient = new S3Client({
endpoint: 'http://localhost:9000/test', // MinIO server URL
region: 'us-east-1', // Required but not used by MinIO
credentials: {
accessKeyId: 'minioadmin', // Default MinIO credentials
secretAccessKey: 'minioadmin'
},
forcePathStyle: true, // REQUIRED for MinIO
sslEnabled: false // Set to true if using HTTPS
});
// List all buckets
async function listBuckets() {
try {
const command = new ListBucketsCommand({});
const response = await minioClient.send(command);
console.log('Buckets:', response.Buckets);
return response.Buckets;
} catch (error) {
console.error('Error listing buckets:', error);
}
}
// Upload a file
async function uploadFile(bucketName, objectName, fileContent) {
try {
const command = new PutObjectCommand({
Bucket: bucketName,
Key: objectName,
Body: fileContent,
ContentType: 'text/plain'
});
const response = await minioClient.send(command);
console.log('File uploaded:', response);
return response;
} catch (error) {
console.error('Upload error:', error);
}
}
// Download a file
async function downloadFile(bucketName, objectName) {
try {
const command = new GetObjectCommand({
Bucket: bucketName,
Key: objectName
});
const response = await minioClient.send(command);
const content = await response.Body.transformToString();
console.log('File content:', content);
return content;
} catch (error) {
console.error('Download error:', error);
}
}
// Example usage
(async () => {
// Create a bucket first (you need to create buckets via console or CLI)
const buckets = await listBuckets();
// console.log('Available buckets:', buckets);
// Upload a file
await uploadFile('cap-web', 'textfiles/test2.txt', 'Hello MinIO from Node.js!');
// // Download the file
// await downloadFile('cap-web', 'test.txt');
})();

35
server.js Normal file
View File

@@ -0,0 +1,35 @@
import Redis from 'ioredis';
// Create a new Redis client (default localhost:6379)
const redis = new Redis({
host: '72.60.220.57',
port: 6379,
username: 'default',
password: '4~pI27tEpI4(',
});
async function run() {
try {
// Set a key
// await redis.set('username', 'yash946');
// Get the key
const value = await redis.get('username');
console.log('Fetched from Redis:', value);
// Set a key with expiry (in seconds)
await redis.set('session', 'xyz123', 'EX', 20); // expires in 10 seconds
// Get all keys
const keys = await redis.keys('*');
console.log('All keys:', keys);
// Close the connection`
redis.disconnect();
} catch (err) {
console.error('Redis error:', err);
}
}
run();

27
tsconfig.json Normal file
View File

@@ -0,0 +1,27 @@
{
"compilerOptions": {
// Enable latest features
"lib": ["ESNext", "DOM"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,
// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
}
}

32
vector.ts Normal file
View File

@@ -0,0 +1,32 @@
import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ url: "http://72.60.220.57:6333", apiKey:"yyz9cggxpudyjc8uqktm0lixnqagfsrl" });
// await client.createCollection("test_collection", {
// vectors: { size: 4, distance: "Dot" },
// });
// const operationInfo = await client.upsert("test_collection", {
// wait: true,
// points: [
// { id: 1, vector: [0.05, 0.61, 0.76, 0.74], payload: { city: "Berlin" } },
// { id: 2, vector: [0.19, 0.81, 0.75, 0.11], payload: { city: "London" } },
// { id: 3, vector: [0.36, 0.55, 0.47, 0.94], payload: { city: "Moscow" } },
// { id: 4, vector: [0.18, 0.01, 0.85, 0.80], payload: { city: "New York" } },
// { id: 5, vector: [0.24, 0.18, 0.22, 0.44], payload: { city: "Beijing" } },
// { id: 6, vector: [0.35, 0.08, 0.11, 0.44], payload: { city: "Mumbai" } },
// ],
// });
// console.debug(operationInfo);
let searchResult = await client.query(
"test_collection", {
query: [0.2, 0.1, 0.9, 0.7],
with_vector: true,
with_payload: true,
limit: 3
});
console.debug(searchResult.points);