File tree 3 files changed +370
-25
lines changed
3 files changed +370
-25
lines changed Original file line number Diff line number Diff line change 1
1
const express = require ( "express" ) ;
2
2
const { mf2 } = require ( "microformats-parser" ) ;
3
- const undici = require ( "undici" ) ;
4
3
const pkg = require ( "./package.json" ) ;
5
4
const app = express ( ) ;
6
5
const port = process . env . PORT || 9000 ;
@@ -36,15 +35,15 @@ app.use(express.static("public"));
36
35
app . get ( "/" , async ( req , res ) => {
37
36
if ( req . query . url ) {
38
37
const url = req . query . url ;
39
- const { body } = await undici . request ( url , {
40
- maxRedirections : 2 ,
38
+ await fetch ( url , {
41
39
headers : {
42
40
accept : "text/html, text/mf2+html" ,
43
41
} ,
44
42
method : "GET" ,
43
+ } ) . then ( async ( response ) => {
44
+ const html = await response . text ( ) ;
45
+ htmlToMf2 ( url , html , res ) ;
45
46
} ) ;
46
- const text = await body . text ( ) ;
47
- htmlToMf2 ( url , text , res ) ;
48
47
} else {
49
48
res . render ( "index.html.ejs" , {
50
49
version : `${ pkg . version } (lib: ${ mf2version } )` ,
Original file line number Diff line number Diff line change 8
8
"yarn" : " 1.x"
9
9
},
10
10
"scripts" : {
11
- "start" : " node index.js"
11
+ "start" : " node index.js" ,
12
+ "prepare" : " husky install"
12
13
},
13
14
"dependencies" : {
14
15
"@yarnpkg/lockfile" : " ^1.1.0" ,
15
16
"ejs" : " ^3.1.8" ,
16
17
"express" : " ^4.18.1" ,
17
- "microformats-parser" : " ^1.5.2" ,
18
- "undici" : " ^5.6.1"
18
+ "microformats-parser" : " ^1.5.2"
19
+ },
20
+ "devDependencies" : {
21
+ "husky" : " >=6" ,
22
+ "lint-staged" : " >=10" ,
23
+ "prettier" : " ^3.0.3"
24
+ },
25
+ "lint-staged" : {
26
+ "*.{js,css,md}" : " prettier --write"
19
27
}
20
28
}
You can’t perform that action at this time.
0 commit comments