Spaces:
Paused
Paused
Upload app.ts with huggingface_hub
Browse files
app.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
| 1 |
-
import express, { Router, type Request as ExpressRequest
|
| 2 |
import path from "path";
|
| 3 |
import { fileURLToPath } from "url";
|
| 4 |
import fs from "fs";
|
| 5 |
import detectPort from "detect-port";
|
| 6 |
import type { Db } from "@paperclipai/db";
|
| 7 |
import {
|
| 8 |
-
type Actor,
|
| 9 |
type DeploymentExposure,
|
| 10 |
type DeploymentMode,
|
| 11 |
resolvePrivateHostnameAllowSet,
|
|
@@ -108,19 +107,24 @@ export async function createApp(
|
|
| 108 |
resolveSession: opts.resolveSession,
|
| 109 |
}),
|
| 110 |
);
|
| 111 |
-
app.get("/api/auth/get-session", (req
|
| 112 |
-
|
|
|
|
| 113 |
res.status(401).json({ error: "Unauthorized" });
|
| 114 |
return;
|
| 115 |
}
|
| 116 |
res.json({
|
| 117 |
session: {
|
| 118 |
-
|
|
|
|
|
|
|
| 119 |
userId: req.actor.userId,
|
| 120 |
},
|
| 121 |
user: {
|
|
|
|
| 122 |
id: req.actor.userId,
|
| 123 |
email: null,
|
|
|
|
| 124 |
name: req.actor.source === "local_implicit" ? "Local Board" : null,
|
| 125 |
},
|
| 126 |
});
|
|
|
|
| 1 |
+
import express, { Router, type Request as ExpressRequest } from "express";
|
| 2 |
import path from "path";
|
| 3 |
import { fileURLToPath } from "url";
|
| 4 |
import fs from "fs";
|
| 5 |
import detectPort from "detect-port";
|
| 6 |
import type { Db } from "@paperclipai/db";
|
| 7 |
import {
|
|
|
|
| 8 |
type DeploymentExposure,
|
| 9 |
type DeploymentMode,
|
| 10 |
resolvePrivateHostnameAllowSet,
|
|
|
|
| 107 |
resolveSession: opts.resolveSession,
|
| 108 |
}),
|
| 109 |
);
|
| 110 |
+
app.get("/api/auth/get-session", (req, res) => {
|
| 111 |
+
// @ts-expect-error type augmentation for actor doesn't work during docker build
|
| 112 |
+
if (req.actor.type !== "board" || !req.actor.userId) {
|
| 113 |
res.status(401).json({ error: "Unauthorized" });
|
| 114 |
return;
|
| 115 |
}
|
| 116 |
res.json({
|
| 117 |
session: {
|
| 118 |
+
// @ts-expect-error type augmentation for actor doesn't work during docker build
|
| 119 |
+
id: `paperclip:${req.actor.source}:${req.actor.userId}`,
|
| 120 |
+
// @ts-expect-error type augmentation for actor doesn't work during docker build
|
| 121 |
userId: req.actor.userId,
|
| 122 |
},
|
| 123 |
user: {
|
| 124 |
+
// @ts-expect-error type augmentation for actor doesn't work during docker build
|
| 125 |
id: req.actor.userId,
|
| 126 |
email: null,
|
| 127 |
+
// @ts-expect-error type augmentation for actor doesn't work during docker build
|
| 128 |
name: req.actor.source === "local_implicit" ? "Local Board" : null,
|
| 129 |
},
|
| 130 |
});
|