mirror of
https://github.com/vitalityAI/therapist.git
synced 2025-04-06 04:50:16 -04:00
feat: added status route to api
This commit is contained in:
parent
4bf903eede
commit
a1dfa54681
20
src/api/status.js
Normal file
20
src/api/status.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { Router } from "express";
|
||||
import { db } from "../lib/db.js";
|
||||
|
||||
const app = Router();
|
||||
|
||||
app.get("/", async (req, res) => {
|
||||
const messageCount = await db.message.count();
|
||||
const sessionCount = await db.session.count();
|
||||
const operatorCount = await db.operator.count();
|
||||
|
||||
return res.status(200).json({
|
||||
status: "OK",
|
||||
time: new Date().toISOString(),
|
||||
messageCount: messageCount,
|
||||
sessionCount: sessionCount,
|
||||
operatorCount: operatorCount,
|
||||
});
|
||||
});
|
||||
|
||||
export default app;
|
19
src/index.js
19
src/index.js
|
@ -1,17 +1,20 @@
|
|||
import express from "express";
|
||||
import cors from "cors";
|
||||
|
||||
import call from "./api/call.js";
|
||||
import operator from "./api/operator.js"
|
||||
import session from "./api/session.js"
|
||||
import cors from "cors"
|
||||
import operator from "./api/operator.js";
|
||||
import session from "./api/session.js";
|
||||
import status from "./api/status.js";
|
||||
|
||||
const app = express();
|
||||
app.use(express.urlencoded({ extended: false }));
|
||||
app.use(express.json())
|
||||
app.use(cors())
|
||||
app.use(express.json());
|
||||
app.use(cors());
|
||||
|
||||
app.use('/call', call)
|
||||
app.use('/operator', operator)
|
||||
app.use('/session', session)
|
||||
app.use("/call", call);
|
||||
app.use("/operator", operator);
|
||||
app.use("/session", session);
|
||||
app.use("/status", status);
|
||||
|
||||
// Create an HTTP server and listen for requests on port 3000
|
||||
app.listen(8080, () => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user