move jwt type extension

This commit is contained in:
2026-06-28 20:29:51 -05:00
parent 58996792da
commit 5cbaef08d0
5 changed files with 39 additions and 2 deletions
+14
View File
@@ -13,6 +13,7 @@
"drizzle-orm": "^1.0.0-rc.4",
"express": "^5.1.0",
"pg": "^8.22.0",
"typescript": "^6.0.3",
"uuid": "^13.0.0"
},
"devDependencies": {
@@ -2341,6 +2342,19 @@
"url": "https://opencollective.com/express"
}
},
"node_modules/typescript": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",
"integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/undici-types": {
"version": "7.18.2",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz",
+1
View File
@@ -13,6 +13,7 @@
"drizzle-orm": "^1.0.0-rc.4",
"express": "^5.1.0",
"pg": "^8.22.0",
"typescript": "^6.0.3",
"uuid": "^13.0.0"
},
"devDependencies": {
+6 -1
View File
@@ -7,7 +7,12 @@ import { auth } from '../middleware/auth.ts';
const db = drizzle(process.env.DATABASE_URL!);
export const usersRouter = express.Router();
usersRouter.get("/getUsers", async (_: Request, res: Response) => {
usersRouter.get("/getUsers", auth, async (req: Request, res: Response) => {
if (req.jwt.payload.prm === 44)
return res
.status(401)
.json({ error: "Cannot access endpoint with default permissions" });
const resp = await db.select().from(users);
res.json(resp)
});
@@ -1,4 +1,4 @@
import JsonWebToken from './src/types/JsonWebToken.ts';
import JsonWebToken from '../JsonWebToken.ts';
export { }
+17
View File
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"esModuleInterop": true,
"allowImportingTsExtensions": true,
"skipLibCheck": true,
"types": [
"node"
]
},
"include": [
"src"
]
}