From 66b81755c2e0ed1bdea4f3eb5b8b36e091c44b3c Mon Sep 17 00:00:00 2001 From: Harshit Budhlakoti Date: Fri, 10 Feb 2023 15:07:02 +0530 Subject: [PATCH 1/2] initial commit --- app/Controllers/Http/MoviesController.ts | 9 ++ app/Models/Movie.ts | 24 +++++ database/migrations/1676021598608_movies.ts | 21 ++++ database/seeders/Movie.ts | 112 ++++++++++++++++++++ database/sqlite/db.sqlite3 | Bin 90112 -> 102400 bytes package-lock.json | 29 ++++- start/routes.ts | 4 + 7 files changed, 194 insertions(+), 5 deletions(-) create mode 100644 app/Controllers/Http/MoviesController.ts create mode 100644 app/Models/Movie.ts create mode 100644 database/migrations/1676021598608_movies.ts create mode 100644 database/seeders/Movie.ts diff --git a/app/Controllers/Http/MoviesController.ts b/app/Controllers/Http/MoviesController.ts new file mode 100644 index 0000000..b53a960 --- /dev/null +++ b/app/Controllers/Http/MoviesController.ts @@ -0,0 +1,9 @@ +// import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext' +import Movie from 'App/Models/Movie' + +export default class MoviesController { + public async index() { + const movies = await Movie.all() + return movies + } +} diff --git a/app/Models/Movie.ts b/app/Models/Movie.ts new file mode 100644 index 0000000..0fd37a3 --- /dev/null +++ b/app/Models/Movie.ts @@ -0,0 +1,24 @@ +import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm' + +export default class Movie extends BaseModel { + @column({ isPrimary: true }) + public id: number + + @column() + public directorName: string + + @column() + public title: string + + @column() + public description: string + + @column() + public image: string + + @column() + public featured: boolean + + @column() + public release: string +} diff --git a/database/migrations/1676021598608_movies.ts b/database/migrations/1676021598608_movies.ts new file mode 100644 index 0000000..3e2e190 --- /dev/null +++ b/database/migrations/1676021598608_movies.ts @@ -0,0 +1,21 @@ +import BaseSchema from '@ioc:Adonis/Lucid/Schema' + +export default class extends BaseSchema { + protected tableName = 'movies' + + public async up() { + this.schema.createTable(this.tableName, (table) => { + table.increments('id').primary() + table.string('director_name') + table.string('title') + table.text('description') + table.text('image') + table.boolean('featured') + table.string('release') + }) + } + + public async down() { + this.schema.dropTable(this.tableName) + } +} \ No newline at end of file diff --git a/database/seeders/Movie.ts b/database/seeders/Movie.ts new file mode 100644 index 0000000..3479d59 --- /dev/null +++ b/database/seeders/Movie.ts @@ -0,0 +1,112 @@ +import BaseSeeder from '@ioc:Adonis/Lucid/Seeder' +import Movie from 'App/Models/Movie' + +export default class extends BaseSeeder { + public async run() { + await Movie.updateOrCreateMany( + [], + [ + { + directorName: 'J.J. Abrams', + title: 'Star Trek', + description: + 'Aboard the USS Enterprise, the most-sophisticated starship ever built, a novice crew embarks on its maiden voyage. Their path takes them on a collision course with Nero (Eric Bana), a Romulan commander whose mission of vengeance threatens all mankind. If humanity would survive, a rebellious young officer directorNamed James T. Kirk (Chris Pine) and a coolly logical Vulcan directorNamed Spock (Zachary Quinto) must move beyond their rivalry and find a way to defeat Nero before it is too late.', + image: 'https://i.pinimg.com/originals/82/8b/b3/828bb3783453b22bb9f8ff59a77658da.jpg', + featured: false, + release: '2009', + }, + { + directorName: 'Joss Whedon', + + title: 'The Avengers', + description: + "When Thor's evil brother, Loki (Tom Hiddleston), gains access to the unlimited power of the energy cube called the Tesseract, Nick Fury (Samuel L. Jackson), director of S.H.I.E.L.D., initiates a superhero recruitment effort to defeat the unprecedented threat to Earth. Joining Fury's dream team are Iron Man (Robert Downey Jr.), Captain America (Chris Evans), the Hulk (Mark Ruffalo), Thor (Chris Hemsworth), the Black Widow (Scarlett Johansson) and Hawkeye (Jeremy Renner).", + image: 'https://i.pinimg.com/originals/0f/03/e6/0f03e6733b0cf567cc92e8e20290462f.jpg', + featured: true, + release: '2012', + }, + { + directorName: 'Matthew Vaughn', + + title: 'Stardust', + description: + "To win the heart of his beloved (Sienna Miller), a young man directorNamed Tristan (Charlie Cox) ventures into the realm of fairies to retrieve a fallen star. What Tristan finds, however, is not a chunk of space rock, but a woman (Claire Danes) directorNamed Yvaine. Yvaine is in great danger, for the king's sons need her powers to secure the throne, and an evil witch (Michelle Pfeiffer) wants to use her to achieve eternal youth and beauty.", + image: 'https://images-na.ssl-images-amazon.com/images/I/5100B4U4ylL._AC_.jpg', + featured: true, + release: '2007', + }, + { + directorName: 'Matthew Vaughn', + + title: 'X-Men: First Class', + description: + 'In the early 1960s, during the height of the Cold War, a mutant directorNamed Charles Xavier (James McAvoy) meets a fellow mutant directorNamed Erik Lehnsherr (Michael Fassbender). Despite their vastly different backgrounds -- Charles grew up with a wealthy family, while Erik lost his parents at Auschwitz -- the two become close friends. As the world teeters on the brink of a nuclear war, Charles and Erik with other mutants join forces to save humanity. However, a situation soon tears the friends apart.', + image: 'https://m.media-amazon.com/images/M/MV5BMTg5OTMxNzk4Nl5BMl5BanBnXkFtZTcwOTk1MjAwNQ@@._V1_UY1200_CR90,0,630,1200_AL_.jpg', + featured: false, + release: '2011', + }, + { + directorName: 'Jon Watts', + + title: 'Spider-Man: Homecoming', + description: + 'Thrilled by his experience with the Avengers, young Peter Parker returns home to live with his Aunt May. Under the watchful eye of mentor Tony Stark, Parker starts to embrace his newfound identity as Spider-Man. He also tries to return to his normal daily routine -- distracted by thoughts of proving himself to be more than just a friendly neighborhood superhero. Peter must soon put his powers to the test when the evil Vulture emerges to threaten everything that he holds dear.', + image: + 'https://media.vanityfair.com/photos/592592596736887ada186bcd/master/w_1600%2Cc_limit/spider-man-homecoming-SMH_DOM_Online_FNL_1SHT_3DRD3DIMX_AOJ_300dpi_01_rgb.jpg', + featured: false, + release: '2017', + }, + { + directorName: 'Alfonso CuarĂ³n', + + title: 'Harry Potter and the Prisoner of Azkaban', + description: + "Harry Potter's (Daniel Radcliffe) third year at Hogwarts starts off badly when he learns deranged killer Sirius Black (Gary Oldman) has escaped from Azkaban prison and is bent on murdering the teenage wizard. While Hermione's (Emma Watson) cat torments Ron's (Rupert Grint) sickly rat, causing a rift among the trio, a swarm of nasty Dementors is sent to protect the school from Black. A mysterious new teacher helps Harry learn to defend himself, but what is his secret tie to Sirius Black?", + image: + 'https://static.wikia.nocookie.net/harrypotter/images/a/a8/Harry_Potter_and_the_Prisoner_of_Azkaban_2.jpg/revision/latest?cb=20130803163319', + featured: false, + release: '2004', + }, + { + directorName: 'Peter Jackson', + + title: 'The Lord of the Rings: Return of the King', + description: + "The culmination of nearly 10 years of work and conclusion to Peter Jackson's epic trilogy, The Lord of the Rings: The Return of the King presents the final confrontation between the forces of good and evil fighting for control of the future of Middle-earth. Hobbits Frodo and Sam reach Mordor in their quest to destroy the one ring, while Aragorn leads the forces of good against Sauron's evil army at the stone city of Minas Tirith.", + image: 'http://www.limitedruns.com/media/cache/7e/6b/7e6b6743a7e45d096838abd67b2464e2.jpg', + featured: false, + release: '2003', + }, + { + directorName: 'James Gunn', + + title: 'Guardians of the Galaxy', + description: + "Brash space adventurer Peter Quill (Chris Pratt) finds himself the quarry of relentless bounty hunters after he steals an orb coveted by Ronan, a powerful villain. To evade Ronan, Quill is forced into an uneasy truce with four disparate misfits: gun-toting Rocket Raccoon, treelike-humanoid Groot, enigmatic Gamora, and vengeance-driven Drax the Destroyer. But when he discovers the orb's true power and the cosmic threat it poses, Quill must rally his ragtag group to save the universe.", + image: 'https://images-na.ssl-images-amazon.com/images/I/71kvH7JJFlL._AC_SY679_.jpg', + featured: false, + release: '2014', + }, + { + directorName: 'Jon Favreau', + + title: 'Iron Man', + description: + 'A billionaire industrialist and genius inventor, Tony Stark (Robert Downey Jr.), is conducting weapons tests overseas, but terrorists kidnap him to force him to build a devastating weapon. Instead, he builds an armored suit and upends his captors. Returning to America, Stark refines the suit and uses it to combat crime and terrorism.', + image: 'https://www.themoviedb.org/t/p/original/aGsjgTNMSF0kswDx57YCVPqCivW.jpg', + featured: false, + release: '2008', + }, + { + directorName: 'Steven Spielberg', + title: 'Jurassic Park', + description: + "Paleontologists Alan Grant (Sam Neill) and Ellie Sattler (Laura Dern) and mathematician Ian Malcolm (Jeff Goldblum) are among a select group chosen to tour an island theme park populated by dinosaurs created from prehistoric DNA. While the park's mastermind, billionaire John Hammond (Richard Attenborough), assures everyone that the facility is safe, they find out otherwise when various ferocious predators break free and go on the hunt.", + image: 'https://image.posterlounge.com/images/l/1894261.jpg', + featured: false, + release: '1993', + }, + ] + ) + } +} diff --git a/database/sqlite/db.sqlite3 b/database/sqlite/db.sqlite3 index 514344937bbc565b56fcb2858f15a258076dc21e..04c980edc4ee388ae78e9ac248aa32ff6f838007 100644 GIT binary patch delta 10546 zcmeHN&vP3`b_Oj`Kd2v+)|PFp)={e*m&h{ln*>0m5*y+VQ8Yox1T5K`a=|?_4NMC& z({T3;A!w^IrdM9&=q;UcQ{_Lfb;xbkTd5rOyp=y7*Hm)LZ4b%!dH~AOCY791bXg!U z81%e;?|ZLbe_wy~!|YejPJDai;@w;>cNzbt|K0fYQuW&1T%r53bGS5jGR@6jIsg0f zJLj&Q{mmJ7?%z&-f66^diATD z$7XXJBVB&lzWV0;E8jkSc(wi~*M4)g@@KEyw@hw5Hvfm*{J+ot%lsdnUo8F8eE#gQ zWADriwek`-Hs0K8$1cxg2F_iaId*-9dn%HqYg}K1eD?d&@e8lzF5s8{I{)i$FPxa8 z(7pIb<-!%b%)gG8^K&mh;|&^gX8w8#j((gM;?oP!R~5lRD=tv$C{4@+~F_Xcipgsbsk9( zus!a%f$a6fB7P{f$HszVoS1E?{)p??FcYWtuj=)f!@Xe4M!tv`o&o^r$S_Z69`%LC z1~Lfn%(m1rG3;i*-2q#;#bMr^zzcb_$b4>?FfJeB?w(fR)HpV@23z~3VUCDmrXm(5 z8iUI;>f2exLPUTy8_7ppdj)pimw{kgLWdHQrAcjsA!qk_jL9!D7qdW$gc!`QJr&Un zd&yAfnBCGciWixY?f~=A97*Ex#7I1dGc9{DjbAdBtTQ*PYi~?)2aBL7Lsoj#Ff=TSrFAO}=82v_ zK>bvPMg+Yj<|Hwkk7?nFzJ02z1s)~^-Tq_0f8fXQ(A+2%P0VBI7DjR)c_C7+QUfUp zk%)_^7kWIjxGCClVT!!S8%1kGHv?1`fa=DnFS=7ibycrBK~%R=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`LAgRU8z{{tR>JKG{~uX}h7v_pX)B~uaUAoA;+O=SV}>;jF|uKbSSSsQ zm{s1OP;0^|(?TQ7)l00k(^au2$$M<3=3bIEe;z6=1ZM%YO`IY@$Ycnijt~lD%vcyi z0kHyDI>ur+ssiOGxB+Xj=I>3F4 zPR~Z?wR>Q6`-~lLJ8Pl)q=l`AEp&ZgVGFYW1}yk{E#!JFbaq?lXs_LH8F0V>55RX| z5gf38M+2Y=Gp&y6x`d=s*@kr<-$VAQMXX7vkZyIn`iizDvrR&Ul%?=2#k*c(_K7*e c;uw5-`#p_8IOtl6+KO$P7Bv0-#)EtR0s=N6wg3PC diff --git a/package-lock.json b/package-lock.json index 795825d..04f56bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9153,6 +9153,13 @@ "openapi-types": ">=7" } }, + "node_modules/swagger-parser/node_modules/openapi-types": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-12.1.0.tgz", + "integrity": "sha512-XpeCy01X6L5EpP+6Hc3jWN7rMZJ+/k1lwki/kTmWzbVhdPie3jd5O2ZtedEx8Yp58icJ0osVldLMrTB/zslQXA==", + "dev": true, + "peer": true + }, "node_modules/swagger-schema-official": { "version": "2.0.0-bab6bed", "resolved": "https://registry.npmjs.org/swagger-schema-official/-/swagger-schema-official-2.0.0-bab6bed.tgz", @@ -9904,7 +9911,8 @@ "@poppinss/hooks": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/@poppinss/hooks/-/hooks-5.0.3.tgz", - "integrity": "sha512-M5a151VUl+RslVP5qwDW+u+0VmzKt5Nfplzdx2nrtXol3yVlLN3u2Jp6UADESid3DDI7IRHmFrA3sQusey3eUA==" + "integrity": "sha512-M5a151VUl+RslVP5qwDW+u+0VmzKt5Nfplzdx2nrtXol3yVlLN3u2Jp6UADESid3DDI7IRHmFrA3sQusey3eUA==", + "requires": {} }, "@poppinss/utils": { "version": "4.0.4", @@ -10377,7 +10385,8 @@ "@poppinss/hooks": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/@poppinss/hooks/-/hooks-5.0.3.tgz", - "integrity": "sha512-M5a151VUl+RslVP5qwDW+u+0VmzKt5Nfplzdx2nrtXol3yVlLN3u2Jp6UADESid3DDI7IRHmFrA3sQusey3eUA==" + "integrity": "sha512-M5a151VUl+RslVP5qwDW+u+0VmzKt5Nfplzdx2nrtXol3yVlLN3u2Jp6UADESid3DDI7IRHmFrA3sQusey3eUA==", + "requires": {} } } }, @@ -11397,12 +11406,14 @@ "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true + "dev": true, + "requires": {} }, "acorn-private-class-elements": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/acorn-private-class-elements/-/acorn-private-class-elements-1.0.0.tgz", - "integrity": "sha512-zYNcZtxKgVCg1brS39BEou86mIao1EV7eeREG+6WMwKbuYTeivRRs6S2XdWnboRde6G9wKh2w+WBydEyJsJ6mg==" + "integrity": "sha512-zYNcZtxKgVCg1brS39BEou86mIao1EV7eeREG+6WMwKbuYTeivRRs6S2XdWnboRde6G9wKh2w+WBydEyJsJ6mg==", + "requires": {} }, "acorn-private-methods": { "version": "1.0.0", @@ -12923,7 +12934,8 @@ "version": "8.5.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz", "integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==", - "dev": true + "dev": true, + "requires": {} }, "eslint-plugin-adonis": { "version": "2.1.1", @@ -16906,6 +16918,13 @@ "call-me-maybe": "^1.0.1", "z-schema": "^5.0.1" } + }, + "openapi-types": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-12.1.0.tgz", + "integrity": "sha512-XpeCy01X6L5EpP+6Hc3jWN7rMZJ+/k1lwki/kTmWzbVhdPie3jd5O2ZtedEx8Yp58icJ0osVldLMrTB/zslQXA==", + "dev": true, + "peer": true } } }, diff --git a/start/routes.ts b/start/routes.ts index 8522fb2..458d551 100644 --- a/start/routes.ts +++ b/start/routes.ts @@ -35,8 +35,12 @@ Route.get('/products', 'ProductsController.index') Route.get('/product/:id', 'ProductsController.show') Route.get('/products/bulk', 'ProductsController.showByIds') +//Movies +Route.get('/movies', 'MoviesController.index') + //Cart Route.group(() => { Route.get('/carts', 'CartsController.index') Route.post('/carts', 'CartsController.store') }).middleware('auth') + From d1d6c4ad23e727454557bb06ba653dbac6b38790 Mon Sep 17 00:00:00 2001 From: Harshit Budhlakoti Date: Fri, 10 Feb 2023 15:13:07 +0530 Subject: [PATCH 2/2] show route added --- app/Controllers/Http/MoviesController.ts | 8 +++++++- start/routes.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Controllers/Http/MoviesController.ts b/app/Controllers/Http/MoviesController.ts index b53a960..ab1ad8b 100644 --- a/app/Controllers/Http/MoviesController.ts +++ b/app/Controllers/Http/MoviesController.ts @@ -1,4 +1,4 @@ -// import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext' +import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext' import Movie from 'App/Models/Movie' export default class MoviesController { @@ -6,4 +6,10 @@ export default class MoviesController { const movies = await Movie.all() return movies } + + public async show({ request }: HttpContextContract) { + const { id } = request.params() + const movie = await Movie.findOrFail(id) + return movie + } } diff --git a/start/routes.ts b/start/routes.ts index 458d551..5537180 100644 --- a/start/routes.ts +++ b/start/routes.ts @@ -37,10 +37,10 @@ Route.get('/products/bulk', 'ProductsController.showByIds') //Movies Route.get('/movies', 'MoviesController.index') +Route.get('/movie/:id', 'MoviesController.show') //Cart Route.group(() => { Route.get('/carts', 'CartsController.index') Route.post('/carts', 'CartsController.store') }).middleware('auth') -