adbcc4b9af
feat: implement conversations API with message retrieval and posting feat: add avatar URL handling for users and update user role definitions feat: create chat system tables in the database with initial seed data fix: update user roles from "sales_user" to "sales" for consistency chore: add middleware for system API route access fixed fuckups on john's side, added a benchmark Made Graphs actualy load from database and realtime data, graphs will update and percentages will be mathematically made, and made realtime added chatcart edits, made graphs glow. added in some little small home feeling fuctions added in a slide show, in login with qoutes from creators because i want to leave a print on it saying we made this shit, we built it brick for brick login page added qoutes some random, and made them shuffle from left to right one dissapears other come in adding shape to the textbox for the qoutes Fixed my chat fuckups when it comes to chats
30 lines
728 B
TypeScript
30 lines
728 B
TypeScript
import { NextResponse } from "next/server"
|
|
import os from "os"
|
|
|
|
let prevCpu = process.cpuUsage()
|
|
let prevTime = Date.now()
|
|
|
|
export async function GET() {
|
|
const now = Date.now()
|
|
const elapsed = now - prevTime
|
|
const currentCpu = process.cpuUsage()
|
|
|
|
const user = currentCpu.user - prevCpu.user
|
|
const sys = currentCpu.system - prevCpu.system
|
|
const totalUs = user + sys
|
|
|
|
// CPU time (ms) / wall time (ms) * 100 = % of one core
|
|
const cpuPct = elapsed > 0 ? Math.round((totalUs / 1000) / elapsed * 100 * 10) / 10 : 0
|
|
|
|
prevCpu = currentCpu
|
|
prevTime = now
|
|
|
|
const mem = process.memoryUsage()
|
|
|
|
return NextResponse.json({
|
|
rssMB: Math.round(mem.rss / 1024 / 1024),
|
|
cpuPct,
|
|
cores: os.cpus().length,
|
|
})
|
|
}
|