Skip to content

Commit 1be51c0

Browse files
committed
feat: reduce minimum username and node name length to 3, remove host remark uniqueness
- Reduces minimum length requirements for usernames and node names from 5-6 to 3 characters - Removes unique constraint on host remarks and adds duplicate handling with suffixes - Implements subscription settings caching with Redis in SubscrtipionService - Adds remark field to raw subscription response schema
1 parent f5a463c commit 1be51c0

File tree

16 files changed

+138
-57
lines changed

16 files changed

+138
-57
lines changed

libs/contract/commands/nodes/create.command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export namespace CreateNodeCommand {
1414
);
1515

1616
export const RequestSchema = z.object({
17-
name: z.string().min(5, 'Minimum 5 characters!'),
17+
name: z.string().min(3, 'Minimum 3 characters!'),
1818
address: z.string().min(2, 'Minimum 2 characters!'),
1919
port: z.number().int().min(1, 'Port is required').optional(),
2020
isTrafficTrackingActive: z.boolean().optional().default(false),

libs/contract/commands/nodes/update.command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export namespace UpdateNodeCommand {
1313
export const RequestSchema = NodesSchema.pick({
1414
uuid: true,
1515
}).extend({
16-
name: z.optional(z.string().min(5, 'Min. 5 characters')),
16+
name: z.optional(z.string().min(3, 'Min. 3 characters')),
1717
address: z.optional(z.string().min(2, 'Min. 2 characters')),
1818
port: z.optional(z.number()),
1919
isTrafficTrackingActive: z.optional(z.boolean()),

libs/contract/commands/subscription/get-raw-subscription-by-short-uuid.command.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export namespace GetRawSubscriptionByShortUuidCommand {
100100
configProfileInboundUuid: z.nullable(z.string()),
101101
isDisabled: z.boolean(),
102102
viewPosition: z.number(),
103+
remark: z.string(),
103104
}),
104105
),
105106
}),

libs/contract/commands/users/create-user.command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export namespace CreateUserCommand {
2525
'Username can only contain letters, numbers, underscores and dashes',
2626
)
2727
.max(36, 'Username must be less than 36 characters')
28-
.min(6, 'Username must be at least 6 characters')
28+
.min(3, 'Username must be at least 3 characters')
2929
.describe(
30-
'Unique username for the user. Required. Must be 6-36 characters long and contain only letters, numbers, underscores and dashes.',
30+
'Unique username for the user. Required. Must be 3-36 characters long and contain only letters, numbers, underscores and dashes.',
3131
),
3232
status: UsersSchema.shape.status
3333
.optional()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const CACHE_KEYS = {
2+
SUBSCRIPTION_SETTINGS: 'subscription_settings',
3+
} as const;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './cache-keys.constants';

libs/contract/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from './cache-keys';
12
export * from './endpoint-details';
23
export * from './errors';
34
export * from './events';

libs/contract/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@remnawave/backend-contract",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"public": true,
55
"license": "AGPL-3.0-only",
66
"description": "A contract library for Remnawave Backend. It can be used in backend and frontend.",
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
-- DropIndex
2+
DROP INDEX "hosts_remark_key";
3+
4+
-- AlterTable
5+
ALTER TABLE "admin" ALTER COLUMN "created_at" SET DEFAULT now(),
6+
ALTER COLUMN "updated_at" SET DEFAULT now();
7+
8+
-- AlterTable
9+
ALTER TABLE "api_tokens" ALTER COLUMN "created_at" SET DEFAULT now(),
10+
ALTER COLUMN "updated_at" SET DEFAULT now();
11+
12+
-- AlterTable
13+
ALTER TABLE "config_profiles" ALTER COLUMN "created_at" SET DEFAULT now(),
14+
ALTER COLUMN "updated_at" SET DEFAULT now();
15+
16+
-- AlterTable
17+
ALTER TABLE "hwid_user_devices" ALTER COLUMN "created_at" SET DEFAULT now(),
18+
ALTER COLUMN "updated_at" SET DEFAULT now();
19+
20+
-- AlterTable
21+
ALTER TABLE "infra_billing_nodes" ALTER COLUMN "created_at" SET DEFAULT now(),
22+
ALTER COLUMN "updated_at" SET DEFAULT now();
23+
24+
-- AlterTable
25+
ALTER TABLE "infra_providers" ALTER COLUMN "created_at" SET DEFAULT now(),
26+
ALTER COLUMN "updated_at" SET DEFAULT now();
27+
28+
-- AlterTable
29+
ALTER TABLE "internal_squads" ALTER COLUMN "created_at" SET DEFAULT now(),
30+
ALTER COLUMN "updated_at" SET DEFAULT now();
31+
32+
-- AlterTable
33+
ALTER TABLE "keygen" ALTER COLUMN "created_at" SET DEFAULT now(),
34+
ALTER COLUMN "updated_at" SET DEFAULT now();
35+
36+
-- AlterTable
37+
ALTER TABLE "nodes" ALTER COLUMN "created_at" SET DEFAULT now(),
38+
ALTER COLUMN "updated_at" SET DEFAULT now();
39+
40+
-- AlterTable
41+
ALTER TABLE "nodes_traffic_usage_history" ALTER COLUMN "reset_at" SET DEFAULT now();
42+
43+
-- AlterTable
44+
ALTER TABLE "nodes_usage_history" ALTER COLUMN "created_at" SET DEFAULT date_trunc('hour', now()),
45+
ALTER COLUMN "updated_at" SET DEFAULT now();
46+
47+
-- AlterTable
48+
ALTER TABLE "nodes_user_usage_history" ALTER COLUMN "updated_at" SET DEFAULT now();
49+
50+
-- AlterTable
51+
ALTER TABLE "subscription_settings" ALTER COLUMN "created_at" SET DEFAULT now(),
52+
ALTER COLUMN "updated_at" SET DEFAULT now();
53+
54+
-- AlterTable
55+
ALTER TABLE "subscription_templates" ALTER COLUMN "created_at" SET DEFAULT now(),
56+
ALTER COLUMN "updated_at" SET DEFAULT now();
57+
58+
-- AlterTable
59+
ALTER TABLE "user_traffic_history" ALTER COLUMN "reset_at" SET DEFAULT now();
60+
61+
-- AlterTable
62+
ALTER TABLE "users" ALTER COLUMN "created_at" SET DEFAULT now(),
63+
ALTER COLUMN "updated_at" SET DEFAULT now();

prisma/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ model UserTrafficHistory {
232232
model Hosts {
233233
uuid String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
234234
viewPosition Int @default(autoincrement()) @map("view_position")
235-
remark String @unique @map("remark")
235+
remark String @map("remark")
236236
address String @map("address")
237237
port Int @map("port")
238238
path String? @map("path")

0 commit comments

Comments
 (0)