Skip to content

Commit

Permalink
chore: use crypto.randomBytes to generate uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Nov 22, 2024
1 parent 162feb1 commit 403f567
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions examples/redis/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const tracer = setupTracing('example-redis-server');
import * as express from 'express';
import axios from 'axios';
import * as tracerHandlers from './express-tracer-handlers';
import { randomBytes } from 'crypto';
const redisPromise = require('./setup-redis').redis;

// Setup express
Expand All @@ -20,12 +21,7 @@ async function setupRoutes() {
const redis = await redisPromise;

app.get('/run_test', async (req: express.Request, res: express.Response) => {
const uuid = Math.random()
.toString(36)
.substring(2, 15)
+ Math.random()
.toString(36)
.substring(2, 15);
const uuid = randomBytes(16).toString('hex');
await axios.get(`http://localhost:${PORT}/set?args=uuid,${uuid}`);
const body = await axios.get(`http://localhost:${PORT}/get?args=uuid`);

Expand Down

0 comments on commit 403f567

Please sign in to comment.