upgrade versions
This commit is contained in:
Generated
+402
-801
File diff suppressed because it is too large
Load Diff
@@ -10,17 +10,17 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^17.4.2",
|
"dotenv": "^17.4.2",
|
||||||
"drizzle-orm": "^0.44.7",
|
"drizzle-orm": "^1.0.0-rc.4",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
"pg": "^8.21.0",
|
"pg": "^8.22.0",
|
||||||
"uuid": "^13.0.0"
|
"uuid": "^13.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/express": "^5.0.5",
|
"@types/express": "^5.0.5",
|
||||||
"@types/node": "^24.10.1",
|
"@types/node": "^24.10.1",
|
||||||
"@types/pg": "^8.20.0",
|
"@types/pg": "^8.20.0",
|
||||||
"drizzle-kit": "^0.31.10",
|
"drizzle-kit": "^1.0.0-rc.4",
|
||||||
"tsx": "^4.22.3"
|
"tsx": "^4.22.4"
|
||||||
},
|
},
|
||||||
"type": "module"
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-10
@@ -13,7 +13,7 @@ import {
|
|||||||
smallint,
|
smallint,
|
||||||
check
|
check
|
||||||
} from "drizzle-orm/pg-core";
|
} from "drizzle-orm/pg-core";
|
||||||
import { sql, relations } from "drizzle-orm";
|
import { sql, defineRelations } from "drizzle-orm";
|
||||||
|
|
||||||
export const blockTypeEnum = pgEnum("post_block_type", [
|
export const blockTypeEnum = pgEnum("post_block_type", [
|
||||||
"title",
|
"title",
|
||||||
@@ -90,13 +90,14 @@ export const users = pgTable("users", {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
export const articlesRelations = relations(articles, ({ many }) => ({
|
export const relations = defineRelations({ articles, articleBlocks }, (r) => ({
|
||||||
blocks: many(articleBlocks),
|
articles: {
|
||||||
}));
|
blocks: r.many.articleBlocks()
|
||||||
|
},
|
||||||
export const articleBlocksRelations = relations(articleBlocks, ({ one }) => ({
|
articleBlocks: {
|
||||||
article: one(articles, {
|
article: r.one.articles({
|
||||||
fields: [articleBlocks.article_id],
|
from: r.articleBlocks.article_id,
|
||||||
references: [articles.id],
|
to: r.articles.id
|
||||||
}),
|
})
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ export async function auth(
|
|||||||
decodedToken.header.alg === "HS256" &&
|
decodedToken.header.alg === "HS256" &&
|
||||||
decodedToken.header.typ === "JWT";
|
decodedToken.header.typ === "JWT";
|
||||||
|
|
||||||
|
|
||||||
if (validJWT && validClaims) {
|
if (validJWT && validClaims) {
|
||||||
req.jwt = decodedToken;
|
req.jwt = decodedToken;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -13,19 +13,21 @@ articlesRouter.get("/getAllArticles", async (_, res: Response) => {
|
|||||||
|
|
||||||
articlesRouter.get("/getArticle/:articleId", async (req: Request, res: Response) => {
|
articlesRouter.get("/getArticle/:articleId", async (req: Request, res: Response) => {
|
||||||
const { articleId } = req.params;
|
const { articleId } = req.params;
|
||||||
|
const parsedId = Array.isArray(articleId) ? articleId[0] : articleId;
|
||||||
|
|
||||||
const resp = await db.select()
|
const resp = await db.select()
|
||||||
.from(articles)
|
.from(articles)
|
||||||
.where(eq(articles.id, articleId));
|
.where(eq(articles.id, parsedId));
|
||||||
res.json(resp);
|
res.json(resp);
|
||||||
});
|
});
|
||||||
|
|
||||||
articlesRouter.get("/getArticleBySlug/:slug", async (req: Request, res: Response) => {
|
articlesRouter.get("/getArticleBySlug/:slug", async (req: Request, res: Response) => {
|
||||||
const { slug } = req.params;
|
const { slug } = req.params;
|
||||||
|
const parsedSlug = Array.isArray(slug) ? slug[0] : slug;
|
||||||
|
|
||||||
const resp = await db.select()
|
const resp = await db.select()
|
||||||
.from(articles)
|
.from(articles)
|
||||||
.where(eq(articles.slug, slug));
|
.where(eq(articles.slug, parsedSlug));
|
||||||
res.json(resp);
|
res.json(resp);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -41,6 +43,8 @@ articlesRouter.post("/postArticle", async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
articlesRouter.put("/updateArticle/:articleId", async (req: Request, res: Response) => {
|
articlesRouter.put("/updateArticle/:articleId", async (req: Request, res: Response) => {
|
||||||
const { articleId } = req.params;
|
const { articleId } = req.params;
|
||||||
|
const parsedId = Array.isArray(articleId) ? articleId[0] : articleId;
|
||||||
|
|
||||||
const resp = await db.update(articles)
|
const resp = await db.update(articles)
|
||||||
.set({
|
.set({
|
||||||
name: req.body.name,
|
name: req.body.name,
|
||||||
@@ -51,14 +55,16 @@ articlesRouter.put("/updateArticle/:articleId", async (req: Request, res: Respon
|
|||||||
last_edit: new Date(Date.now()),
|
last_edit: new Date(Date.now()),
|
||||||
date_published: req.body.article_status == "published" ? new Date(Date.now()) : null
|
date_published: req.body.article_status == "published" ? new Date(Date.now()) : null
|
||||||
})
|
})
|
||||||
.where(eq(articles.id, articleId));
|
.where(eq(articles.id, parsedId));
|
||||||
res.json(resp);
|
res.json(resp);
|
||||||
});
|
});
|
||||||
|
|
||||||
articlesRouter.delete("/deleteArticle/:articleId", async (req: Request, res: Response) => {
|
articlesRouter.delete("/deleteArticle/:articleId", async (req: Request, res: Response) => {
|
||||||
const { articleId } = req.params;
|
const { articleId } = req.params;
|
||||||
|
const parsedId = Array.isArray(articleId) ? articleId[0] : articleId;
|
||||||
|
|
||||||
const resp = await db.delete(articles)
|
const resp = await db.delete(articles)
|
||||||
.where(eq(articles.id, articleId));
|
.where(eq(articles.id, parsedId));
|
||||||
|
|
||||||
res.json(resp);
|
res.json(resp);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ export const usersRouter = express.Router();
|
|||||||
|
|
||||||
usersRouter.get("/getUser/:userId", auth, async (req: Request, res: Response) => {
|
usersRouter.get("/getUser/:userId", auth, async (req: Request, res: Response) => {
|
||||||
const { userId } = req.params;
|
const { userId } = req.params;
|
||||||
|
const parsedId = Array.isArray(userId) ? userId[0] : userId;
|
||||||
|
|
||||||
const resp = await db.select()
|
const resp = await db.select()
|
||||||
.from(users)
|
.from(users)
|
||||||
.where(eq(users.id, userId));
|
.where(eq(users.id, parsedId));
|
||||||
|
|
||||||
res.json(resp);
|
res.json(resp);
|
||||||
});
|
});
|
||||||
|
|||||||
Generated
+8
-4
@@ -26,6 +26,7 @@
|
|||||||
"@types/react-dom": "^19.1.9",
|
"@types/react-dom": "^19.1.9",
|
||||||
"@vitejs/plugin-react": "^5.0.4",
|
"@vitejs/plugin-react": "^5.0.4",
|
||||||
"babel-plugin-react-compiler": "^19.1.0-rc.3",
|
"babel-plugin-react-compiler": "^19.1.0-rc.3",
|
||||||
|
"baseline-browser-mapping": "^2.10.40",
|
||||||
"eslint": "^9.36.0",
|
"eslint": "^9.36.0",
|
||||||
"eslint-plugin-react-hooks": "^5.2.0",
|
"eslint-plugin-react-hooks": "^5.2.0",
|
||||||
"eslint-plugin-react-refresh": "^0.4.22",
|
"eslint-plugin-react-refresh": "^0.4.22",
|
||||||
@@ -2068,13 +2069,16 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/baseline-browser-mapping": {
|
"node_modules/baseline-browser-mapping": {
|
||||||
"version": "2.8.25",
|
"version": "2.10.40",
|
||||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.25.tgz",
|
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.40.tgz",
|
||||||
"integrity": "sha512-2NovHVesVF5TXefsGX1yzx1xgr7+m9JQenvz6FQY3qd+YXkKkYiv+vTCc7OriP9mcDZpTC5mAOYN4ocd29+erA==",
|
"integrity": "sha512-BSSLZ9/Cjjv7Gtj5B68ZzXcXUg8iOf3fme+FCuh8rC/Go+Kmh8cox7M3A8dolou16s64QjLPOSdngh7GxXvkSw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
"baseline-browser-mapping": "dist/cli.js"
|
"baseline-browser-mapping": "dist/cli.cjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/brace-expansion": {
|
"node_modules/brace-expansion": {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
"@types/react-dom": "^19.1.9",
|
"@types/react-dom": "^19.1.9",
|
||||||
"@vitejs/plugin-react": "^5.0.4",
|
"@vitejs/plugin-react": "^5.0.4",
|
||||||
"babel-plugin-react-compiler": "^19.1.0-rc.3",
|
"babel-plugin-react-compiler": "^19.1.0-rc.3",
|
||||||
|
"baseline-browser-mapping": "^2.10.40",
|
||||||
"eslint": "^9.36.0",
|
"eslint": "^9.36.0",
|
||||||
"eslint-plugin-react-hooks": "^5.2.0",
|
"eslint-plugin-react-hooks": "^5.2.0",
|
||||||
"eslint-plugin-react-refresh": "^0.4.22",
|
"eslint-plugin-react-refresh": "^0.4.22",
|
||||||
|
|||||||
Reference in New Issue
Block a user