-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c17ed0
commit 14a7923
Showing
5 changed files
with
29 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
import { getStore } from "@netlify/blobs"; | ||
import type { Config, Context } from "@netlify/functions"; | ||
import { getStore } from '@netlify/blobs'; | ||
import type { Config, Context } from '@netlify/functions'; | ||
|
||
export default async (req: Request, context: Context) => { | ||
const share = getStore("share"); | ||
const share = getStore('share'); | ||
const { shareId } = context.params; | ||
|
||
if (!shareId) { | ||
return new Response("Not found", { status: 404 }); | ||
return new Response('Not found', { status: 404 }); | ||
} | ||
|
||
const shareData = await share.get(shareId); | ||
|
||
if (!shareData) { | ||
return new Response("Not found", { status: 404 }); | ||
return new Response('Not found', { status: 404 }); | ||
} | ||
|
||
return new Response(shareData, { | ||
headers: { | ||
"content-type": "application/json", | ||
'content-type': 'application/json', | ||
}, | ||
}); | ||
} | ||
|
||
export const config: Config = { | ||
path: "/share/:shareId", | ||
path: '/share/:shareId', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import { getStore } from "@netlify/blobs"; | ||
import type { Config, Context } from "@netlify/functions"; | ||
import { randomUUID } from "crypto"; | ||
import { getStore } from '@netlify/blobs'; | ||
import type { Config, Context } from '@netlify/functions'; | ||
import { randomUUID } from 'crypto'; | ||
|
||
export default async (req: Request, context: Context) => { | ||
const share = getStore("share"); | ||
const share = getStore('share'); | ||
const shareId = randomUUID(); | ||
|
||
const state = await req.json(); | ||
|
||
await share.set(shareId, JSON.stringify({ | ||
URL: context.site.url + "?share=" + shareId, | ||
URL: `${context.site.url }?share=${ shareId}`, | ||
...state, | ||
created: Date.now(), | ||
})) | ||
|
||
return new Response(shareId, { | ||
headers: { | ||
"content-type": "text/plain", | ||
'content-type': 'text/plain', | ||
}, | ||
}); | ||
}; | ||
|
||
export const config: Config = { | ||
path: "/share", | ||
path: '/share', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.