Add environment variable for API URL; update TypeScript configuration to include vite-env; refactor API client to use environment variable; modify timestamp fields in database schemas to include timezone support

This commit is contained in:
2025-10-06 13:00:32 +05:00
parent 0b024af454
commit 9e4bc7b0f8
10 changed files with 50 additions and 13 deletions
+6 -2
View File
@@ -15,8 +15,12 @@ export const apps = pgTable("apps", {
title: varchar("title").notNull(), // Название приложения (например, "Майнкрафт")
gpuLimitMb: integer("gpu_limit_mb"), // Лимит GPU в мегабайтах (только для stream серверов)
psVersion: integer("ps_version"), // Версия Pixel Streaming (например, "1")
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
createdAt: timestamp("created_at", { withTimezone: true })
.defaultNow()
.notNull(),
updatedAt: timestamp("updated_at", { withTimezone: true })
.defaultNow()
.notNull(),
});
// Zod schemas for validation
+6 -2
View File
@@ -11,8 +11,12 @@ export const branches = pgTable("branches", {
address: varchar("address", { length: 500 }),
city: varchar("city", { length: 100 }),
country: varchar("country", { length: 100 }),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
createdAt: timestamp("created_at", { withTimezone: true })
.defaultNow()
.notNull(),
updatedAt: timestamp("updated_at", { withTimezone: true })
.defaultNow()
.notNull(),
});
// Zod schemas for validation
+6 -2
View File
@@ -5,8 +5,12 @@ export const companies = pgTable("companies", {
id: uuid("id").primaryKey().defaultRandom(),
name: varchar("name", { length: 255 }).notNull(),
description: varchar("description", { length: 1000 }),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
createdAt: timestamp("created_at", { withTimezone: true })
.defaultNow()
.notNull(),
updatedAt: timestamp("updated_at", { withTimezone: true })
.defaultNow()
.notNull(),
});
// Zod schemas for validation
+6 -2
View File
@@ -31,8 +31,12 @@ export const serverSessions = pgTable("server_sessions", {
cirrusPid: integer("cirrus_pid"),
mode: sessionModeEnum("mode").notNull(), // stream, local
status: sessionStatusEnum("status").notNull(), // starting, started, ending, ended
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
createdAt: timestamp("created_at", { withTimezone: true })
.defaultNow()
.notNull(),
updatedAt: timestamp("updated_at", { withTimezone: true })
.defaultNow()
.notNull(),
});
// Relations
+10 -2
View File
@@ -1,7 +1,8 @@
import { pgTable, uuid, varchar, pgEnum } from "drizzle-orm/pg-core";
import { pgTable, uuid, varchar, pgEnum, timestamp } from "drizzle-orm/pg-core";
import { relations } from "drizzle-orm";
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import { serverSessions } from "./serverSessions";
import { branches } from "./branches";
// Enums
export const serverLocationEnum = pgEnum("server_location", ["ru1", "uae1"]);
@@ -11,10 +12,17 @@ export const serverTierEnum = pgEnum("server_tier", ["demo", "prod"]);
export const servers = pgTable("servers", {
id: uuid("id").primaryKey().defaultRandom(),
localIp: varchar("local_ip", { length: 45 }).notNull(), // IPv6 can be up to 45 chars
hostname: varchar("hostname").notNull(),
hostname: varchar("hostname").notNull(), // hostname сервера
type: serverTypeEnum("type").notNull(), // stream, local
branchId: uuid("branch_id").references(() => branches.id), // филиал, на котором находится сервер (nullable для локальных серверов)
location: serverLocationEnum("location"), // ru1, uae1 (только для stream)
tier: serverTierEnum("tier"), // demo, prod (только для stream)
createdAt: timestamp("created_at", { withTimezone: true })
.defaultNow()
.notNull(),
updatedAt: timestamp("updated_at", { withTimezone: true })
.defaultNow()
.notNull(),
});
// Zod schemas for validation
+3 -1
View File
@@ -14,7 +14,9 @@ export const userBranches = pgTable(
branchId: uuid("branch_id")
.notNull()
.references(() => branches.id, { onDelete: "cascade" }),
createdAt: timestamp("created_at").defaultNow().notNull(),
createdAt: timestamp("created_at", { withTimezone: true })
.defaultNow()
.notNull(),
},
(table) => ({
pk: primaryKey({ columns: [table.userId, table.branchId] }),