feat: trying to add hashes to scripts
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import { FreshContext, Handlers } from "$fresh/server.ts";
|
||||
import { fileExtension } from "https://deno.land/x/file_extension@v2.1.0/mod.ts";
|
||||
import { formatDate, safeFileName } from "@lib/string.ts";
|
||||
import { fileExtension, formatDate, safeFileName } from "@lib/string.ts";
|
||||
import { createStreamResponse } from "@lib/helpers.ts";
|
||||
import {
|
||||
AccessDeniedError,
|
||||
@@ -13,6 +11,7 @@ import { webScrape } from "@lib/webScraper.ts";
|
||||
import * as openai from "@lib/openai.ts";
|
||||
import * as unsplash from "@lib/unsplash.ts";
|
||||
import { createLogger } from "@lib/log/index.ts";
|
||||
import { define } from "../../../../utils.ts";
|
||||
|
||||
function ext(str: string) {
|
||||
try {
|
||||
@@ -163,29 +162,24 @@ async function processEnhanceArticle(
|
||||
streamResponse.send({ type: "finished", url: name.replace(/$\.md/, "") });
|
||||
}
|
||||
|
||||
const POST = (
|
||||
_req: Request,
|
||||
ctx: FreshContext,
|
||||
): Response => {
|
||||
const session = ctx.state.session;
|
||||
if (!session) {
|
||||
throw new AccessDeniedError();
|
||||
}
|
||||
export const handler = define.handlers({
|
||||
POST: (ctx) => {
|
||||
const session = ctx.state.session;
|
||||
if (!session) {
|
||||
throw new AccessDeniedError();
|
||||
}
|
||||
|
||||
const streamResponse = createStreamResponse();
|
||||
const streamResponse = createStreamResponse();
|
||||
|
||||
processEnhanceArticle(ctx.params.name, streamResponse)
|
||||
.catch((err) => {
|
||||
log.error(err);
|
||||
streamResponse.error(err.message);
|
||||
})
|
||||
.finally(() => {
|
||||
streamResponse.cancel();
|
||||
});
|
||||
processEnhanceArticle(ctx.params.name, streamResponse)
|
||||
.catch((err) => {
|
||||
log.error(err);
|
||||
streamResponse.error(err.message);
|
||||
})
|
||||
.finally(() => {
|
||||
streamResponse.cancel();
|
||||
});
|
||||
|
||||
return streamResponse.response;
|
||||
};
|
||||
|
||||
export const handler: Handlers = {
|
||||
POST,
|
||||
};
|
||||
return streamResponse.response;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user