This repository was archived by the owner on Mar 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -92,18 +92,26 @@ func gracefulShutdown(ctx context.Context, app *fiber.App) {
9292}
9393
9494func (s * Server ) registerRoutes (app * fiber.App ) {
95- v0 := app .Group ("/api/v0" )
95+ // API Usage
96+ v0 := app .Group ("/api/v0" )
9697 v0 .Post ("/upload" , s .handleUpload )
9798 v0 .Get ("/gallery" , s .handleGallery )
9899 v0 .Get ("/:cid/:file" , s .handleCat )
100+
101+ // Terminal Upload
99102 v0 .Post ("/" , s .handlePut )
100103 v0 .Put ("/:name" , s .handlePut )
101104
105+ // Root shorter upload url.
102106 // app.Post("/", s.handlePut)
103107 // app.Put("/:name", s.handlePut)
104108
105109 app .Get ("/:cid/raw/:file" , s .handleCat )
106110
111+ // IPFS paths
112+ app .Get ("/ipfs/:cid/:file" , s .handleCat )
113+
114+ // Static files or frontend
107115 app .Static ("/" , "./dist" )
108116 app .Get ("/*" , func (c * fiber.Ctx ) error {
109117 return c .SendFile ("./dist/index.html" )
Original file line number Diff line number Diff line change @@ -19,14 +19,14 @@ interface ViewProps {
1919}
2020
2121async function getMetadata ( cid : string ) : Promise < CidResource > {
22- return await fetch ( import . meta. env . VITE_API_URL + `/api/v0 /${ cid } /__metadata.json` ) . then ( ( res ) => {
22+ return await fetch ( import . meta. env . VITE_API_URL + `/ipfs /${ cid } /__metadata.json` ) . then ( ( res ) => {
2323 console . log ( res . json )
2424 return res . json ( ) as Promise < CidResource >
2525 } )
2626}
2727
2828async function getFile ( cid : string , filename : string ) : Promise < string > {
29- return await fetch ( import . meta. env . VITE_API_URL + `/api/v0 /${ cid } /${ filename } ` ) . then ( ( res ) => {
29+ return await fetch ( import . meta. env . VITE_API_URL + `/ipfs /${ cid } /${ filename } ` ) . then ( ( res ) => {
3030 console . log ( res . text )
3131 return res . text ( )
3232 } )
@@ -126,7 +126,7 @@ function View(props: RouteComponentProps<ViewProps>) {
126126 href = {
127127 revealText !== ''
128128 ? `data:text/plain;base64,${ btoa ( unescape ( encodeURIComponent ( revealText ) ) ) } `
129- : import . meta. env . VITE_API_URL + `/api/v0 /${ cid } /${ metadata ?. objects [ 0 ] . name } `
129+ : import . meta. env . VITE_API_URL + `/ipfs /${ cid } /${ metadata ?. objects [ 0 ] . name } `
130130 }
131131 >
132132 Raw
You can’t perform that action at this time.
0 commit comments