CSP fix:
- The previous shield.ts config used '@viteDevUrl'/'@viteHmrUrl' CSP
keywords that don't exist in this version of @adonisjs/shield (only
'@viteUrl' is registered by @adonisjs/vite, and it resolves to an empty
string here since Vite assets are proxied through AdonisJS on the same
origin). Both placeholders were sent to the browser literally, breaking
Google Fonts, the Vite HMR websocket, and pc-builder.io/favicon images.
- Replaced with concrete directives: 'self' covers same-origin Vite
assets, ws://localhost:{VITE_HMR_PORT|24678} is added only in dev for
the HMR socket, and explicit allowlists for Google Fonts
(fonts.googleapis.com/fonts.gstatic.com), pc-builder.io product images,
and Google's favicon service (www.google.com) used by the merchant
comparison UI
Real purchase links + live price comparison:
- part_scraper_service.ts: ScrapedPart.sourceUrl now stores the actual
Amazon.fr purchase link scraped from pc-builder.io's category pages
(https://www.amazon.fr/dp/{ASIN}?tag=... or a search fallback), instead
of the pc-builder.io product page, which isn't a place anyone can buy
anything from
- New merchant_price_service.ts: on-demand live price lookup across
Amazon, LDLC, Grosbill and TopAchat. Of 6 requested merchants,
Materiel.net (search requires JS/Turbo, no results via plain GET) and
Cdiscount/PCComponentes (empty body / 403) were dropped as not scrapable
without a headless browser or paid API
- Matching strategy: pc-builder.io's full product names (e.g. "AMD Ryzen 3
3200G 3.6 GHz Quad-Core Processor") return zero results on every
merchant's search engine, so we search on a short brand+series query
and then pick the specific result whose label contains the extracted
model token (e.g. "3200G"). No token match means no offer returned,
rather than risk quoting the price of a different, unrelated product
- Fixed price parsing for LDLC/Grosbill, which render prices as nested
price/sup elements for whole euros vs cents (and LDLC additionally
wraps that in a duplicate outer .price div) - naive text concatenation
was misreading "64,95" as "6495"
- New GET /scraped-parts/compare endpoint (authenticated), called on
demand per search result rather than for every row, since it makes
several outbound requests and can take a few seconds
- NewPartSearch.vue: "Compare prices" button per result shows the
cheapest merchant with its favicon and links to the actual offer;
importing a part now prefers the live cheapest price/link over
pc-builder.io's potentially stale catalog price (confirmed stale in
practice: pc-builder.io listed a Ryzen 3 3200G at 128 euros while
Amazon sells it for 66.89 euros)
- 3 new functional tests for the compare endpoint (auth required, 404 on
unknown part, 422 on invalid id)
79 lines
2.8 KiB
TypeScript
79 lines
2.8 KiB
TypeScript
/*
|
|
|--------------------------------------------------------------------------
|
|
| Routes file
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| The routes file is used for defining the HTTP routes.
|
|
|
|
|
*/
|
|
|
|
import { middleware } from '#start/kernel'
|
|
import { controllers } from '#generated/controllers'
|
|
import router from '@adonisjs/core/services/router'
|
|
|
|
router
|
|
.get('/', async ({ response }) => {
|
|
return response.redirect('/auth/login')
|
|
})
|
|
.as('home')
|
|
|
|
router
|
|
.group(() => {
|
|
router.get('signup', [controllers.NewAccount, 'create']).as('new_account.create')
|
|
router.post('signup', [controllers.NewAccount, 'store']).as('new_account.store')
|
|
|
|
router.get('login', [controllers.Session, 'create']).as('session.create')
|
|
router.post('login', [controllers.Session, 'store']).as('session.store')
|
|
})
|
|
.prefix('/auth')
|
|
.use(middleware.guest())
|
|
|
|
router
|
|
.group(() => {
|
|
router.post('logout', [controllers.Session, 'destroy'])
|
|
})
|
|
.prefix('/auth')
|
|
.use(middleware.auth())
|
|
|
|
router
|
|
.group(() => {
|
|
router.get('/', [controllers.Computers, 'index']).as('computers.index')
|
|
router.get('/create', [controllers.Computers, 'create']).as('computers.create')
|
|
router.post('/', [controllers.Computers, 'store']).as('computers.store')
|
|
router.get('/:id', [controllers.Computers, 'show']).as('computers.show')
|
|
router.get('/:id/edit', [controllers.Computers, 'edit']).as('computers.edit')
|
|
router.put('/:id', [controllers.Computers, 'update']).as('computers.update')
|
|
router.delete('/:id', [controllers.Computers, 'destroy']).as('computers.destroy')
|
|
router.put('/:id/share', [controllers.ComputerShare, 'update']).as('computers.share.update')
|
|
router
|
|
.post('/:id/share/rotate', [controllers.ComputerShare, 'rotate'])
|
|
.as('computers.share.rotate')
|
|
})
|
|
.prefix('/computers')
|
|
.use(middleware.auth())
|
|
|
|
router.get('/share/:token', [controllers.PublicComputer, 'show']).as('share.show')
|
|
|
|
router
|
|
.group(() => {
|
|
router.get('/', [controllers.Components, 'index']).as('components.index')
|
|
router.get('/create', [controllers.Components, 'create']).as('components.create')
|
|
router.post('/', [controllers.Components, 'store']).as('components.store')
|
|
router.get('/:id', [controllers.Components, 'show']).as('components.show')
|
|
router.get('/:id/edit', [controllers.Components, 'edit']).as('components.edit')
|
|
router.put('/:id', [controllers.Components, 'update']).as('components.update')
|
|
router.delete('/:id', [controllers.Components, 'destroy']).as('components.destroy')
|
|
})
|
|
.prefix('/components')
|
|
.use(middleware.auth())
|
|
|
|
router
|
|
.get('/scraped-parts', [controllers.ScrapedParts, 'index'])
|
|
.as('scraped_parts.index')
|
|
.use(middleware.auth())
|
|
|
|
router
|
|
.get('/scraped-parts/compare', [controllers.ScrapedParts, 'compare'])
|
|
.as('scraped_parts.compare')
|
|
.use(middleware.auth())
|