upgrade versions
This commit is contained in:
Generated
+403
-802
File diff suppressed because it is too large
Load Diff
@@ -10,17 +10,17 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"dotenv": "^17.4.2",
|
||||
"drizzle-orm": "^0.44.7",
|
||||
"drizzle-orm": "^1.0.0-rc.4",
|
||||
"express": "^5.1.0",
|
||||
"pg": "^8.21.0",
|
||||
"pg": "^8.22.0",
|
||||
"uuid": "^13.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^5.0.5",
|
||||
"@types/node": "^24.10.1",
|
||||
"@types/pg": "^8.20.0",
|
||||
"drizzle-kit": "^0.31.10",
|
||||
"tsx": "^4.22.3"
|
||||
"drizzle-kit": "^1.0.0-rc.4",
|
||||
"tsx": "^4.22.4"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
+11
-10
@@ -13,7 +13,7 @@ import {
|
||||
smallint,
|
||||
check
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { sql, relations } from "drizzle-orm";
|
||||
import { sql, defineRelations } from "drizzle-orm";
|
||||
|
||||
export const blockTypeEnum = pgEnum("post_block_type", [
|
||||
"title",
|
||||
@@ -90,13 +90,14 @@ export const users = pgTable("users", {
|
||||
]
|
||||
);
|
||||
|
||||
export const articlesRelations = relations(articles, ({ many }) => ({
|
||||
blocks: many(articleBlocks),
|
||||
}));
|
||||
|
||||
export const articleBlocksRelations = relations(articleBlocks, ({ one }) => ({
|
||||
article: one(articles, {
|
||||
fields: [articleBlocks.article_id],
|
||||
references: [articles.id],
|
||||
}),
|
||||
export const relations = defineRelations({ articles, articleBlocks }, (r) => ({
|
||||
articles: {
|
||||
blocks: r.many.articleBlocks()
|
||||
},
|
||||
articleBlocks: {
|
||||
article: r.one.articles({
|
||||
from: r.articleBlocks.article_id,
|
||||
to: r.articles.id
|
||||
})
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -46,7 +46,6 @@ export async function auth(
|
||||
decodedToken.header.alg === "HS256" &&
|
||||
decodedToken.header.typ === "JWT";
|
||||
|
||||
|
||||
if (validJWT && validClaims) {
|
||||
req.jwt = decodedToken;
|
||||
} else {
|
||||
|
||||
@@ -13,19 +13,21 @@ articlesRouter.get("/getAllArticles", async (_, res: Response) => {
|
||||
|
||||
articlesRouter.get("/getArticle/:articleId", async (req: Request, res: Response) => {
|
||||
const { articleId } = req.params;
|
||||
const parsedId = Array.isArray(articleId) ? articleId[0] : articleId;
|
||||
|
||||
const resp = await db.select()
|
||||
.from(articles)
|
||||
.where(eq(articles.id, articleId));
|
||||
.where(eq(articles.id, parsedId));
|
||||
res.json(resp);
|
||||
});
|
||||
|
||||
articlesRouter.get("/getArticleBySlug/:slug", async (req: Request, res: Response) => {
|
||||
const { slug } = req.params;
|
||||
const parsedSlug = Array.isArray(slug) ? slug[0] : slug;
|
||||
|
||||
const resp = await db.select()
|
||||
.from(articles)
|
||||
.where(eq(articles.slug, slug));
|
||||
.where(eq(articles.slug, parsedSlug));
|
||||
res.json(resp);
|
||||
});
|
||||
|
||||
@@ -41,6 +43,8 @@ articlesRouter.post("/postArticle", async (req: Request, res: Response) => {
|
||||
|
||||
articlesRouter.put("/updateArticle/:articleId", async (req: Request, res: Response) => {
|
||||
const { articleId } = req.params;
|
||||
const parsedId = Array.isArray(articleId) ? articleId[0] : articleId;
|
||||
|
||||
const resp = await db.update(articles)
|
||||
.set({
|
||||
name: req.body.name,
|
||||
@@ -51,14 +55,16 @@ articlesRouter.put("/updateArticle/:articleId", async (req: Request, res: Respon
|
||||
last_edit: new Date(Date.now()),
|
||||
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);
|
||||
});
|
||||
|
||||
articlesRouter.delete("/deleteArticle/:articleId", async (req: Request, res: Response) => {
|
||||
const { articleId } = req.params;
|
||||
const parsedId = Array.isArray(articleId) ? articleId[0] : articleId;
|
||||
|
||||
const resp = await db.delete(articles)
|
||||
.where(eq(articles.id, articleId));
|
||||
.where(eq(articles.id, parsedId));
|
||||
|
||||
res.json(resp);
|
||||
});
|
||||
|
||||
@@ -9,11 +9,11 @@ export const usersRouter = express.Router();
|
||||
|
||||
usersRouter.get("/getUser/:userId", auth, async (req: Request, res: Response) => {
|
||||
const { userId } = req.params;
|
||||
|
||||
const parsedId = Array.isArray(userId) ? userId[0] : userId;
|
||||
|
||||
const resp = await db.select()
|
||||
.from(users)
|
||||
.where(eq(users.id, userId));
|
||||
.where(eq(users.id, parsedId));
|
||||
|
||||
res.json(resp);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user