File tree Expand file tree Collapse file tree 3 files changed +308
-0
lines changed Expand file tree Collapse file tree 3 files changed +308
-0
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ import { RestHandler } from "msw" ;
12import allHandlers from "./handlers/all" ;
23import feedHandlers from "./handlers/tags/feed" ;
34import nameHandlers from "./handlers/tags/name" ;
45import profileHandlers from "./handlers/users/profile" ;
56import tagWorksHandlers from "./handlers/tags/works" ;
67import workPageHandlers from "./handlers/works" ;
78import worksHandlers from "./handlers/works" ;
9+ // TODO: export these directly from worksHandlers
10+ import worksNavigateHandlers from "./handlers/works/navigate" ;
811
912export default [
1013 profileHandlers ,
@@ -13,5 +16,6 @@ export default [
1316 worksHandlers ,
1417 nameHandlers ,
1518 workPageHandlers ,
19+ worksNavigateHandlers ,
1620 allHandlers ,
1721] ;
Original file line number Diff line number Diff line change 1+ import { fileURLToPath } from "url" ;
2+ import filenamify from "filenamify" ;
3+ import fs from "fs" ;
4+ import path from "path" ;
5+ import { rest } from "msw" ;
6+
7+ const WORKS_DATA_DIR = path . resolve (
8+ fileURLToPath ( import . meta. url ) ,
9+ "../../../data/works"
10+ ) ;
11+
12+ export default rest . all (
13+ "https://archiveofourown.org/works/:work_id/navigate" ,
14+ ( req , res , ctx ) => {
15+ const html = fs . readFileSync (
16+ path . resolve (
17+ WORKS_DATA_DIR ,
18+ filenamify ( req . params . work_id as string ) ,
19+ "navigate.html"
20+ )
21+ ) ;
22+
23+ return res ( ctx . set ( "Content-Type" , "text/html" ) , ctx . body ( html ) ) ;
24+ }
25+ ) ;
You can’t perform that action at this time.
0 commit comments