heroku
publicで公開できるようになった
- 一旦はherokuの中のjobがないことがわかったので、jobを作って置いて、18:30ぐらいに設定されているので、そのときログを確認してみる
- now(15:30)なのに、10mごとにしたのに、18時半になってしまった
- lambdaでやってもDenoがエラー吐くので、なかなかできない
- エラーも初期の段階で出るので、代替案を探している
追記
aws上で動くように実装
import { APIGatewayProxyEventV2, APIGatewayProxyResultV2, Context } from 'https://deno.land/x/lambda/mod.ts';
import { assertString, exportPages, importPages } from './deps.ts';
// deno-lint-ignore require-await
export async function handler(_event: APIGatewayProxyEventV2, _context: Context): Promise<APIGatewayProxyResultV2> {
const sid = '' // インポート元のsid
const exportingProjectName ="" //インポート元(本来はprivateプロジェクト)
const importingProjectName ="" //インポート先(publicプロジェクト)
const shouldDuplicateByDefault = false
assertString(sid);
assertString(exportingProjectName);
assertString(importingProjectName);
console.log(`Exporting a json file from "/${exportingProjectName}"...`);
const result = await exportPages(exportingProjectName, {
sid,
metadata: true,
});
if (!result.ok) {
const error = new Error();
error.name = `${result.value.name} when exporting a json file`;
error.message = result.value.message;
throw error;
}
const { pages } = result.value;
console.log(`Export ${pages.length}pages:`);
for (const page of pages) {
console.log(`\t${page.title}`);
}
const importingPages = pages.filter(({ lines }) => {
if (lines.some((line) => line.text.includes('[private.icon]'))) {
return false;
} else if (lines.some((line) => line.text.includes('[public.icon]'))) {
return true;
} else {
return shouldDuplicateByDefault;
}
});
if (importingPages.length === 0) {
console.log('No page to be imported found.');
} else {
console.log(`Importing ${importingPages.length} pages to "/${importingProjectName}"...`);
const result = await importPages(
importingProjectName,
{
pages: importingPages,
},
{
sid,
}
);
if (!result.ok) {
const error = new Error();
error.name = `${result.value.name} when importing pages`;
error.message = result.value.message;
throw error;
}
console.log(result.value);
}
return {
statusCode: 200,
headers: { 'content-type': 'text/html;charset=utf8' },
body: `Welcome to deno ${Deno.version.deno} 🦕`,
};
}
import "https://deno.land/x/[email protected]/load.ts";
export * from "https://raw.githubusercontent.com/takker99/scrapbox-userscript-std/0.14.1/rest/page-data.ts";
export { assertString } from "https://deno.land/x/[email protected]/mod.ts";