-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from ASparton/feat/32-get-one-article-route
Get one article by ID
- Loading branch information
Showing
9 changed files
with
140 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
back/prisma/migrations/20231121160201_article_feed_id_from_string_to_int/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
Warnings: | ||
- The primary key for the `Article` table will be changed. If it partially fails, the table could be left without primary key constraint. | ||
- The `id` column on the `Article` table would be dropped and recreated. This will lead to data loss if there is data in the column. | ||
- The primary key for the `Feed` table will be changed. If it partially fails, the table could be left without primary key constraint. | ||
- The `id` column on the `Feed` table would be dropped and recreated. This will lead to data loss if there is data in the column. | ||
- Changed the type of `source_feed_id` on the `Article` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "Article" DROP CONSTRAINT "Article_source_feed_id_fkey"; | ||
|
||
-- DropIndex | ||
DROP INDEX "Article_id_key"; | ||
|
||
-- DropIndex | ||
DROP INDEX "Feed_id_key"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Article" DROP CONSTRAINT "Article_pkey", | ||
DROP COLUMN "id", | ||
ADD COLUMN "id" SERIAL NOT NULL, | ||
DROP COLUMN "source_feed_id", | ||
ADD COLUMN "source_feed_id" INTEGER NOT NULL, | ||
ADD CONSTRAINT "Article_pkey" PRIMARY KEY ("id"); | ||
|
||
-- AlterTable | ||
ALTER TABLE "Feed" DROP CONSTRAINT "Feed_pkey", | ||
DROP COLUMN "id", | ||
ADD COLUMN "id" SERIAL NOT NULL, | ||
ADD CONSTRAINT "Feed_pkey" PRIMARY KEY ("id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "Article_source_feed_id_idx" ON "Article"("source_feed_id"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Article" ADD CONSTRAINT "Article_source_feed_id_fkey" FOREIGN KEY ("source_feed_id") REFERENCES "Feed"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,91 +10,91 @@ const exampleUsers: User[] = [ | |
email: '[email protected]', | ||
username: 'Alexis Moins', | ||
currency: 'EUR', | ||
is_admin: true | ||
is_admin: true, | ||
}, | ||
{ | ||
id: '2', | ||
email: '[email protected]', | ||
username: 'Alexandre Sparton', | ||
currency: 'EUR', | ||
is_admin: false | ||
is_admin: false, | ||
}, | ||
{ | ||
id: '3', | ||
email: '[email protected]', | ||
username: 'Amaury Bourget', | ||
currency: 'EUR', | ||
is_admin: true | ||
is_admin: true, | ||
}, | ||
{ | ||
id: '4', | ||
email: '[email protected]', | ||
username: 'Medhi', | ||
currency: 'EUR', | ||
is_admin: false | ||
is_admin: false, | ||
}, | ||
]; | ||
|
||
const exampleFeeds: Feed[] = [ | ||
{ | ||
id: '1', | ||
id: 1, | ||
url: 'https://cointelegraph.com/rss/tag/bitcoin', | ||
}, | ||
{ | ||
id: '2', | ||
id: 2, | ||
url: 'https://cointelegraph.com/rss/tag/altcoin', | ||
}, | ||
{ | ||
id: '3', | ||
id: 3, | ||
url: 'https://cointelegraph.com/rss/tag/ethereum', | ||
}, | ||
]; | ||
|
||
export const exampleArticles: Article[] = [ | ||
{ | ||
id: '1', | ||
id: 1, | ||
title: | ||
'Atomic Wallet asks to toss suit over $100M hack, saying it has ‘no US ties’', | ||
url: 'https://cointelegraph.com/news/atomic-wallet-dimissal-of-hack-suit-no-us-ties', | ||
content: | ||
'<p style="float:right; margin:0 0 10px 15px; width:240px;"><img src="https://images.cointelegraph.com/cdn-cgi/image/format=auto,onerror=redirect,quality=90,width=840/https://s3.cointelegraph.com/uploads/2023-11/7d575f59-4dc0-40f9-9591-8ca0fead6890.jpg"></p><p>The Estonia-based firm noted that only one plaintiff in the class action lawsuit is actually based in Colorado, where the suit was filed.</p>', | ||
published: new Date('Mon, 20 Nov 2023 06:33:35 +0000'), | ||
source_feed_id: '2', | ||
source_feed_id: 2, | ||
image_url: | ||
'https://images.cointelegraph.com/cdn-cgi/image/format=auto,onerror=redirect,quality=90,width=840/https://s3.cointelegraph.com/uploads/2023-11/7d575f59-4dc0-40f9-9591-8ca0fead6890.jpg', | ||
}, | ||
{ | ||
id: '2', | ||
id: 2, | ||
title: | ||
'SOL, LINK, NEAR and THETA flash bullish as Bitcoin takes a breather', | ||
url: 'https://cointelegraph.com/news/sol-link-near-and-theta-flash-bullish-as-bitcoin-takes-a-breather', | ||
content: | ||
'<p style="float:right; margin:0 0 10px 15px; width:240px;"><img src="https://images.cointelegraph.com/cdn-cgi/image/format=auto,onerror=redirect,quality=90,width=840/https://s3.cointelegraph.com/uploads/2023-11/797d2bb6-95f2-45ee-a44d-a0da64c4bad2.jpg"></p><p>Bitcoin price range trades as SOL, LINK, NEAR and THETA play catch up.</p>', | ||
published: new Date('Sun, 19 Nov 2023 19:45:01 +0000'), | ||
source_feed_id: '2', | ||
source_feed_id: 2, | ||
image_url: | ||
'https://images.cointelegraph.com/cdn-cgi/image/format=auto,onerror=redirect,quality=90,width=840/https://s3.cointelegraph.com/uploads/2023-11/797d2bb6-95f2-45ee-a44d-a0da64c4bad2.jpg', | ||
}, | ||
{ | ||
id: '3', | ||
id: 3, | ||
title: | ||
'ARK, 21Shares update spot Bitcoin ETF application as next SEC deadline looms', | ||
url: 'https://cointelegraph.com/news/cathie-wood-ark-spot-bitcoin-etf-amend', | ||
content: | ||
'<p style="float:right; margin:0 0 10px 15px; width:240px;"><img src="https://images.cointelegraph.com/cdn-cgi/image/format=auto,onerror=redirect,quality=90,width=840/https://s3.cointelegraph.com/uploads/2023-11/7af33720-0dcf-4f6f-9983-7fd9caff3160.jpg"></p><p>The latest update is the third amendment to the Bitcoin ETF prospectus by ARK and 21Shares after the firms first filed for a spot Bitcoin ETF in April 2023.</p>', | ||
published: new Date('Mon, 20 Nov 2023 15:03:43 +0000'), | ||
source_feed_id: '1', | ||
source_feed_id: 1, | ||
image_url: null, | ||
}, | ||
{ | ||
id: '4', | ||
id: 4, | ||
title: | ||
'OpenAI’s Sam Altman ousted, BlackRock and Fidelity seek Ether ETF, and more: Hodler’s Digest, Nov. 12-18', | ||
url: 'https://cointelegraph.com/magazine/openais-sam-altman-ousted-blackrock-and-fidelity-seek-ether-etf-and-more-hodlers-digest-nov-12-18', | ||
content: | ||
'<p style="float:right; margin:0 0 10px 15px; width:240px;"><img src="https://images.cointelegraph.com/cdn-cgi/image/format=auto,onerror=redirect,quality=90,width=840/https://s3.cointelegraph.com/uploads/2023-11/797d2bb6-95f2-45ee-a44d-a0da64c4bad2.jpg"></p><p>Bitcoin price range trades as SOL, LINK, NEAR and THETA play catch up.</p>', | ||
published: new Date('Sat, 18 Nov 2023 21:30:10 +0000'), | ||
source_feed_id: '3', | ||
source_feed_id: 3, | ||
image_url: | ||
'https://cointelegraph.com/magazine/wp-content/uploads/2023/11/nov-18-scaled.jpg', | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { z } from 'zod'; | ||
|
||
const OneArticleDTO = z.object({ | ||
id: z.coerce.number(), | ||
}); | ||
|
||
export default OneArticleDTO; |