+
{syntax}
diff --git a/src/data/command.ts b/src/data/command.ts
index bfaf231..3808fb8 100644
--- a/src/data/command.ts
+++ b/src/data/command.ts
@@ -12,283 +12,285 @@ export const DiceCmds: { [key: string]: DiceCmdMeta } = {
title: "BITCOUNT",
syntax: "BITCOUNT key [start end]",
body: "Counts the number of set bits (population counting) in a string. The optional start and end arguments specify a range of bytes to count.",
- url: "https://dicedb.io/commands/bitcount/"
+ url: "https://dicedb.io/commands/bitcount/",
},
BITOP: {
title: "BITOP",
syntax: "BITOP operation destkey key [key ...]",
body: "The BITOP command performs bitwise operations between strings (AND, OR, XOR, NOT) and stores the result in the destination key.",
- url: "https://dicedb.io/commands/bitop/"
+ url: "https://dicedb.io/commands/bitop/",
},
BITPOS: {
title: "BITPOS",
syntax: "BITPOS key bit [start] [end]",
body: "The BITPOS command returns the position of the first bit set to 1 or 0 in a string, optionally looking within a specific range.",
- url: "https://dicedb.io/commands/bitpos/"
+ url: "https://dicedb.io/commands/bitpos/",
},
SET: {
title: "SET",
- syntax: "SET key value [NX | XX] [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL]",
+ syntax:
+ "SET key value [NX | XX] [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL]",
body: "The SET command in DiceDB is used to set the value of a key. If the key already holds a value, it is overwritten, regardless of its type. This is one of the most fundamental operations in DiceDB as it allows for both creating and updating key-value pairs.",
- url: "https://dicedb.io/commands/set/"
+ url: "https://dicedb.io/commands/set/",
},
GET: {
title: "GET",
syntax: "GET key",
body: "The GET command retrieves the value of a key. If the key does not exist, nil is returned.",
- url: "https://dicedb.io/commands/get/"
+ url: "https://dicedb.io/commands/get/",
},
DEL: {
title: "DEL",
syntax: "DEL key [key ...]",
body: "The DEL command removes the specified keys. A key is ignored if it does not exist.",
- url: "https://dicedb.io/commands/del/"
+ url: "https://dicedb.io/commands/del/",
},
EXISTS: {
title: "EXISTS",
syntax: "EXISTS key [key ...]",
body: "The EXISTS command checks if one or more keys exist. It returns the number of keys that exist.",
- url: "https://dicedb.io/commands/exists/"
+ url: "https://dicedb.io/commands/exists/",
},
INCR: {
title: "INCR",
syntax: "INCR key",
body: "The INCR command increments the number stored at the key by one. If the key does not exist, it is set to 0 before performing the operation.",
- url: "https://dicedb.io/commands/incr/"
+ url: "https://dicedb.io/commands/incr/",
},
DECR: {
title: "DECR",
syntax: "DECR key",
body: "The DECR command decrements the number stored at the key by one. If the key does not exist, it is set to 0 before performing the operation.",
- url: "https://dicedb.io/commands/decr/"
+ url: "https://dicedb.io/commands/decr/",
},
DECRBY: {
title: "DECRBY",
syntax: "DECRBY key decrement",
body: "The DECRBY command decrements the number stored at key by the given decrement.",
- url: "https://dicedb.io/commands/decrby/"
+ url: "https://dicedb.io/commands/decrby/",
},
ECHO: {
title: "ECHO",
syntax: "ECHO message",
body: "The ECHO command returns the given message as a bulk string.",
- url: "https://dicedb.io/commands/echo/"
+ url: "https://dicedb.io/commands/echo/",
},
EXPIRE: {
title: "EXPIRE",
syntax: "EXPIRE key seconds",
body: "The EXPIRE command sets a timeout on key. After the timeout has expired, the key will be automatically deleted.",
- url: "https://dicedb.io/commands/expire/"
+ url: "https://dicedb.io/commands/expire/",
},
EXPIREAT: {
title: "EXPIREAT",
syntax: "EXPIREAT key timestamp",
body: "The EXPIREAT command works exactly like EXPIRE but instead of specifying the number of seconds for the key to live, it takes an absolute Unix timestamp.",
- url: "https://dicedb.io/commands/expireat/"
+ url: "https://dicedb.io/commands/expireat/",
},
MGET: {
title: "MGET",
syntax: "MGET key [key ...]",
body: "The MGET command retrieves the values of multiple keys. If a key does not exist, nil is returned for that key.",
- url: "https://dicedb.io/commands/mget/"
+ url: "https://dicedb.io/commands/mget/",
},
MSET: {
title: "MSET",
syntax: "MSET key value [key value ...]",
body: "The MSET command sets the given keys to their respective values. This is a faster alternative to issuing multiple SET commands.",
- url: "https://dicedb.io/commands/mset/"
+ url: "https://dicedb.io/commands/mset/",
},
HSET: {
title: "HSET",
syntax: "HSET key field value [field value ...]",
body: "The HSET command sets the specified fields to their respective values in a hash stored at key. If the key does not exist, a new key holding a hash is created.",
- url: "https://dicedb.io/commands/hset/"
+ url: "https://dicedb.io/commands/hset/",
},
HGET: {
title: "HGET",
syntax: "HGET key field",
body: "The HGET command retrieves the value of a specific field from a hash stored at the key.",
- url: "https://dicedb.io/commands/hget/"
+ url: "https://dicedb.io/commands/hget/",
},
HDEL: {
title: "HDEL",
syntax: "HDEL key field [field ...]",
body: "The HDEL command removes the specified fields from a hash stored at key.",
- url: "https://dicedb.io/commands/hdel/"
+ url: "https://dicedb.io/commands/hdel/",
},
HGETALL: {
title: "HGETALL",
syntax: "HGETALL key",
body: "The HGETALL command retrieves all fields and values of a hash stored at key.",
- url: "https://dicedb.io/commands/hgetall/"
+ url: "https://dicedb.io/commands/hgetall/",
},
HEXISTS: {
title: "HEXISTS",
syntax: "HEXISTS key field",
body: "The HEXISTS command returns if the field exists in the hash stored at key.",
- url: "https://dicedb.io/commands/hexists/"
+ url: "https://dicedb.io/commands/hexists/",
},
HLEN: {
title: "HLEN",
syntax: "HLEN key",
body: "The HLEN command returns the number of fields contained in the hash stored at key.",
- url: "https://dicedb.io/commands/hlen/"
+ url: "https://dicedb.io/commands/hlen/",
},
INCRBYFLOAT: {
title: "INCRBYFLOAT",
syntax: "INCRBYFLOAT key increment",
body: "The INCRBYFLOAT command increments the float value stored at key by the specified increment.",
- url: "https://dicedb.io/commands/incrbyfloat/"
+ url: "https://dicedb.io/commands/incrbyfloat/",
},
LPUSH: {
title: "LPUSH",
syntax: "LPUSH key value [value ...]",
body: "The LPUSH command inserts the specified values at the head (left) of the list stored at key.",
- url: "https://dicedb.io/commands/lpush/"
+ url: "https://dicedb.io/commands/lpush/",
},
RPUSH: {
title: "RPUSH",
syntax: "RPUSH key value [value ...]",
body: "The RPUSH command inserts the specified values at the tail (right) of the list stored at key.",
- url: "https://dicedb.io/commands/rpush/"
+ url: "https://dicedb.io/commands/rpush/",
},
LPOP: {
title: "LPOP",
syntax: "LPOP key",
body: "The LPOP command removes and returns the first element of the list stored at key.",
- url: "https://dicedb.io/commands/lpop/"
+ url: "https://dicedb.io/commands/lpop/",
},
RPOP: {
title: "RPOP",
syntax: "RPOP key",
body: "The RPOP command removes and returns the last element of the list stored at key.",
- url: "https://dicedb.io/commands/rpop/"
+ url: "https://dicedb.io/commands/rpop/",
},
SADD: {
title: "SADD",
syntax: "SADD key member [member ...]",
body: "The SADD command adds the specified members to the set stored at key. If a member already exists, it is ignored.",
- url: "https://dicedb.io/commands/sadd/"
+ url: "https://dicedb.io/commands/sadd/",
},
SMEMBERS: {
title: "SMEMBERS",
syntax: "SMEMBERS key",
body: "The SMEMBERS command retrieves all the members of the set stored at key.",
- url: "https://dicedb.io/commands/smembers/"
+ url: "https://dicedb.io/commands/smembers/",
},
PING: {
title: "PING",
syntax: "PING",
body: "The PING command checks if the server is running and returns a PONG response.",
- url: "https://dicedb.io/commands/ping/"
+ url: "https://dicedb.io/commands/ping/",
},
- "PFADD": {
+ PFADD: {
title: "PFADD",
syntax: "PFADD key element [element ...]",
body: "The PFADD command adds elements to a HyperLogLog data structure stored at the specified key. If the key does not exist, a new HyperLogLog is created.",
- url: "https://dicedb.io/commands/pfadd/"
+ url: "https://dicedb.io/commands/pfadd/",
},
- "PFCOUNT": {
+ PFCOUNT: {
title: "PFCOUNT",
syntax: "PFCOUNT key",
body: "The PFCOUNT command returns the approximated cardinality (number of unique elements) of the HyperLogLog data structure stored at the specified key.",
- url: "https://dicedb.io/commands/pfcount/"
+ url: "https://dicedb.io/commands/pfcount/",
},
- "PFMERGE": {
+ PFMERGE: {
title: "PFMERGE",
syntax: "PFMERGE destkey sourcekey [sourcekey ...]",
body: "The PFMERGE command merges multiple HyperLogLog data structures into a single one, stored at destkey.",
- url: "https://dicedb.io/commands/pfmerge/"
+ url: "https://dicedb.io/commands/pfmerge/",
},
- "TTL": {
+ TTL: {
title: "TTL",
syntax: "TTL key",
body: "The TTL command returns the remaining time to live of a key that has an expiration set. If the key does not exist, -2 is returned.",
- url: "https://dicedb.io/commands/ttl/"
+ url: "https://dicedb.io/commands/ttl/",
},
- "HELLO": {
+ HELLO: {
title: "HELLO",
syntax: "HELLO [version]",
body: "The HELLO command is used to connect to the server and switch to the desired protocol. It can be used to specify a version of the protocol.",
- url: "https://dicedb.io/commands/hello/"
+ url: "https://dicedb.io/commands/hello/",
},
- "GETSET": {
+ GETSET: {
title: "GETSET",
syntax: "GETSET key value",
body: "The GETSET command sets the value of a key and returns its old value. This operation is atomic.",
- url: "https://dicedb.io/commands/getset/"
+ url: "https://dicedb.io/commands/getset/",
},
- "GETEX": {
+ GETEX: {
title: "GETEX",
- syntax: "GETEX key [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds]",
+ syntax:
+ "GETEX key [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds]",
body: "The GETEX command retrieves the value of a key and can set an expiration time for it in the same command.",
- url: "https://dicedb.io/commands/getex/"
+ url: "https://dicedb.io/commands/getex/",
},
- "GETDEL": {
+ GETDEL: {
title: "GETDEL",
syntax: "GETDEL key",
body: "The GETDEL command retrieves the value of a key and deletes it in the same atomic operation.",
- url: "https://dicedb.io/commands/getdel/"
+ url: "https://dicedb.io/commands/getdel/",
},
- "COMMAND": {
+ COMMAND: {
title: "COMMAND",
syntax: "COMMAND [GET | INFO | LIST | RESTORE]",
body: "The COMMAND command provides information about the commands supported by the server, including details like the command name and the number of calls.",
- url: "https://dicedb.io/commands/command/"
+ url: "https://dicedb.io/commands/command/",
},
// JSON related commands
"JSON.INGEST": {
title: "JSON.INGEST",
syntax: "JSON.INGEST key json",
body: "The JSON.INGEST command allows you to insert a JSON document into a specified key. If the key already holds a value, it will be overwritten.",
- url: "https://dicedb.io/commands/jsoningest/"
+ url: "https://dicedb.io/commands/jsoningest/",
},
"JSON.GET": {
title: "JSON.GET",
syntax: "JSON.GET key [path]",
body: "The JSON.GET command retrieves a JSON value from the specified key. You can specify a path to get a nested value.",
- url: "https://dicedb.io/commands/jsonget/"
+ url: "https://dicedb.io/commands/jsonget/",
},
"JSON.SET": {
title: "JSON.SET",
syntax: "JSON.SET key path json",
body: "The JSON.SET command sets a JSON value at a specified path in the key. If the key does not exist, a new JSON document is created.",
- url: "https://dicedb.io/commands/jsonset/"
+ url: "https://dicedb.io/commands/jsonset/",
},
"JSON.DEL": {
title: "JSON.DEL",
syntax: "JSON.DEL key [path]",
body: "The JSON.DEL command removes a JSON value at a specified path in the key. If the path does not exist, no action is taken.",
- url: "https://dicedb.io/commands/jsondel/"
+ url: "https://dicedb.io/commands/jsondel/",
},
"JSON.TYPE": {
title: "JSON.TYPE",
syntax: "JSON.TYPE key [path]",
body: "The JSON.TYPE command returns the type of a JSON value at the specified path. If the path does not exist, it returns null.",
- url: "https://dicedb.io/commands/jsontype/"
+ url: "https://dicedb.io/commands/jsontype/",
},
"JSON.NUMINCRBY": {
title: "JSON.NUMINCRBY",
syntax: "JSON.NUMINCRBY key path increment",
body: "The JSON.NUMINCRBY command increments a numeric value at a specified path in the key by the given increment.",
- url: "https://dicedb.io/commands/jsonnumincrby/"
+ url: "https://dicedb.io/commands/jsonnumincrby/",
},
"JSON.MERGE": {
title: "JSON.MERGE",
syntax: "JSON.MERGE dest key1 [key2 ...]",
body: "The JSON.MERGE command merges multiple JSON documents into a single destination key.",
- url: "https://dicedb.io/commands/jsonmerge/"
+ url: "https://dicedb.io/commands/jsonmerge/",
},
"JSON.KEYS": {
title: "JSON.KEYS",
syntax: "JSON.KEYS key [path]",
body: "The JSON.KEYS command retrieves all keys from a JSON document at a specified path.",
- url: "https://dicedb.io/commands/jsonkeys/"
+ url: "https://dicedb.io/commands/jsonkeys/",
},
"JSON.FILTER": {
title: "JSON.FILTER",
syntax: "JSON.FILTER key path filter",
body: "The JSON.FILTER command filters JSON data based on a specified filter condition.",
- url: "https://dicedb.io/commands/jsonfilter/"
- }
+ url: "https://dicedb.io/commands/jsonfilter/",
+ },
};
diff --git a/src/lib/api.ts b/src/lib/api.ts
index 9a6b6d5..b2c2bff 100644
--- a/src/lib/api.ts
+++ b/src/lib/api.ts
@@ -1,32 +1,34 @@
// src/lib/api.ts
import { CLI_COMMAND_URL } from "@/shared/constants/apiEndpoints";
-export const executeCLICommandOnServer = async (cmd: string, cmdOptions: object): Promise => {
+export const executeCLICommandOnServer = async (
+ cmd: string,
+ cmdOptions: object
+): Promise => {
try {
const response = await fetch(`${CLI_COMMAND_URL}/${cmd}`, {
- method: 'POST',
+ method: "POST",
body: JSON.stringify(cmdOptions),
headers: {
- 'Content-Type': 'application/json',
+ "Content-Type": "application/json",
},
});
// TODO: This needs to be looked at
const data = await response.json();
- if (Object.prototype.hasOwnProperty.call(data, 'data')) {
+ if (Object.prototype.hasOwnProperty.call(data, "data")) {
return data.data;
- }
- else if (Object.prototype.hasOwnProperty.call(data, 'error')) {
+ } else if (Object.prototype.hasOwnProperty.call(data, "error")) {
return data.error;
}
-
+
if (!response.ok) {
- throw new Error('Network response was not ok');
+ throw new Error("Network response was not ok");
}
return data;
} catch (error: unknown) {
- console.error('Error executing command:', error);
+ console.error("Error executing command:", error);
return `Error: ${error}`;
}
-};
\ No newline at end of file
+};
diff --git a/src/shared/components/Button.tsx b/src/shared/components/Button.tsx
index 6d1ec81..4b74084 100644
--- a/src/shared/components/Button.tsx
+++ b/src/shared/components/Button.tsx
@@ -1,12 +1,11 @@
+"use client";
-'use client';
-
-import React from 'react';
+import React from "react";
interface ButtonProps {
children: React.ReactNode;
className?: string;
- variant?: 'outline';
+ variant?: "outline";
}
export function Button({ children, className }: ButtonProps) {
@@ -17,4 +16,4 @@ export function Button({ children, className }: ButtonProps) {
{children}
);
-}
\ No newline at end of file
+}
diff --git a/src/shared/constants/apiEndpoints.ts b/src/shared/constants/apiEndpoints.ts
index 2bf4aa8..f176101 100644
--- a/src/shared/constants/apiEndpoints.ts
+++ b/src/shared/constants/apiEndpoints.ts
@@ -1,2 +1,2 @@
// This folder will contain or hold constants. For example in this particular file we can store the api endpoints as constants
-export const CLI_COMMAND_URL="http://localhost:8080/cli"
\ No newline at end of file
+export const CLI_COMMAND_URL = "http://localhost:8080/cli";
diff --git a/src/shared/utils/cliUtils.ts b/src/shared/utils/cliUtils.ts
index f10b512..909a486 100644
--- a/src/shared/utils/cliUtils.ts
+++ b/src/shared/utils/cliUtils.ts
@@ -3,10 +3,7 @@
import { executeCLICommandOnServer } from "@/lib/api";
import { CommandHandler } from "@/types";
-export const handleCommand = async ({
- command,
- setOutput,
-}: CommandHandler) => {
+export const handleCommand = async ({ command, setOutput }: CommandHandler) => {
const newOutput = `dice > ${command}`;
let result: string;
@@ -18,7 +15,7 @@ export const handleCommand = async ({
result = "Invalid command. Usage: GET key";
setOutput((prevOutput) => [...prevOutput, newOutput, result]);
return;
- }
+ }
try {
const [key] = args;
@@ -26,8 +23,8 @@ export const handleCommand = async ({
result = await executeCLICommandOnServer(cmd, cmdOptions);
setOutput((prevOutput) => [...prevOutput, newOutput, result]);
} catch (error: unknown) {
- console.error('Error executing command:', error);
- result = 'Error executing command';
+ console.error("Error executing command:", error);
+ result = "Error executing command";
return `Error: ${String(error)}`;
}
break;
@@ -40,8 +37,8 @@ export const handleCommand = async ({
result = await executeCLICommandOnServer(cmd, cmdOptions);
setOutput((prevOutput) => [...prevOutput, newOutput, result]);
} catch (error: unknown) {
- console.error('Error executing command:', error);
- result = 'Error executing command';
+ console.error("Error executing command:", error);
+ result = "Error executing command";
setOutput((prevOutput) => [...prevOutput, newOutput, result]);
return `Error: ${String((error as Error).message || error)}`;
}
@@ -55,12 +52,12 @@ export const handleCommand = async ({
if (args.length <= 1) {
const [keys] = args;
try {
- const cmdOptions = { keys: [keys]};
+ const cmdOptions = { keys: [keys] };
result = await executeCLICommandOnServer(cmd, cmdOptions);
setOutput((prevOutput) => [...prevOutput, newOutput, result]);
} catch (error: unknown) {
- console.error('Error executing command:', error);
- result = 'Error executing command';
+ console.error("Error executing command:", error);
+ result = "Error executing command";
setOutput((prevOutput) => [...prevOutput, newOutput, result]);
return `Error: ${String((error as Error).message || error)}`;
}
@@ -74,4 +71,4 @@ export const handleCommand = async ({
result = `Unknown command: ${cmd}`;
setOutput((prevOutput) => [...prevOutput, newOutput, result]);
}
-};
\ No newline at end of file
+};
diff --git a/src/shared/utils/commonUtils.ts b/src/shared/utils/commonUtils.ts
index e673707..491a776 100644
--- a/src/shared/utils/commonUtils.ts
+++ b/src/shared/utils/commonUtils.ts
@@ -1,5 +1,5 @@
export const formatTime = (seconds: number): string => {
- const minutes = Math.floor(seconds / 60);
- const remainingSeconds = seconds % 60;
- return `${minutes}:${remainingSeconds < 10 ? "0" : ""}${remainingSeconds}`;
-};
\ No newline at end of file
+ const minutes = Math.floor(seconds / 60);
+ const remainingSeconds = seconds % 60;
+ return `${minutes}:${remainingSeconds < 10 ? "0" : ""}${remainingSeconds}`;
+};
diff --git a/src/shared/utils/validation.ts b/src/shared/utils/validation.ts
index 70172a9..f41d72a 100644
--- a/src/shared/utils/validation.ts
+++ b/src/shared/utils/validation.ts
@@ -1 +1 @@
-// This file will contain shared utility functions such as validation, helpers, etc
\ No newline at end of file
+// This file will contain shared utility functions such as validation, helpers, etc
diff --git a/src/styles/globals.css b/src/styles/globals.css
index 5eedc5d..7df3e30 100644
--- a/src/styles/globals.css
+++ b/src/styles/globals.css
@@ -1,10 +1,10 @@
-@import 'tailwindcss/base';
-@import 'tailwindcss/components';
-@import 'tailwindcss/utilities';
-@import url('https://fonts.googleapis.com/css2?family=Assistant:wght@400;700&display=swap');
+@import "tailwindcss/base";
+@import "tailwindcss/components";
+@import "tailwindcss/utilities";
+@import url("https://fonts.googleapis.com/css2?family=Assistant:wght@400;700&display=swap");
body {
- font-family: 'Assistant', sans-serif;
+ font-family: "Assistant", sans-serif;
}
@layer utilities {
diff --git a/src/types/index.d.ts b/src/types/index.d.ts
index fd8054f..08695e3 100644
--- a/src/types/index.d.ts
+++ b/src/types/index.d.ts
@@ -1,6 +1,6 @@
-import * as React from 'react';
+import * as React from "react";
export interface CommandHandler {
- command: string;
- setOutput: React.Dispatch>;
-}
\ No newline at end of file
+ command: string;
+ setOutput: React.Dispatch>;
+}