Compare commits

...

3 Commits

Author SHA1 Message Date
0a4a8e2009 CHG: readme 2023-01-06 17:49:46 +09:00
94b624f312 add keyout option 2023-01-06 17:48:51 +09:00
b5a1ab29bc add command 2023-01-06 17:48:40 +09:00
3 changed files with 27 additions and 12 deletions

View File

@ -4,16 +4,16 @@
- [x] Simple file server
- [x] Serve static files
- [ ] Search files
- [ ] Preview files
- [x] Search files
- [x] Preview files
- [ ] Plugin system
- [ ] Support for multiple languages
- [ ] Support for multiple themes
- [ ] Upload files
- [ ] Authentication
- [ ] Sort files
- [ ] Download files
- [ ] DESCRIPTION.md for index
- [x] Authentication
- [x] Sort files
- [x] Download files
- [x] SUMMARY.md for index
### Usage

View File

@ -5,10 +5,21 @@ import { prepareSecretKey } from "./util/secret.ts";
export const key_out_cmd = new Command();
key_out_cmd.name("keyout")
.description("Output the secret key.")
.action(async () => {
.option("-f, --file <file:string>", "The file to output the key to. (default: stdout)")
.option("--dotenv", "Output the key in dotenv format.")
.action(async ({file, dotenv}) => {
const key = await prepareSecretKey();
const out = await crypto.subtle.exportKey("jwk", key);
console.log(JSON.stringify(out));
const keyout = await crypto.subtle.exportKey("jwk", key);
let out = JSON.stringify(keyout);
if (dotenv){
out = [`SECRET_KEY='${out}'`].join("\n");
}
if (file){
await Deno.writeTextFile(file, out);
} else {
console.log(out);
}
});
if ( import.meta.main ){

10
main.ts
View File

@ -17,6 +17,9 @@ import { fromFileUrl, join } from "path/mod.ts";
import { prepareSecretKey } from "./util/secret.ts";
import { serve } from "http/server.ts";
import { user_command } from "./user.ts";
import { key_out_cmd } from "./keyout.ts";
const github_markdown= await Deno.readTextFile(join(fromFileUrl(import.meta.url), "..", "static", "github-markdown.css"))
const CSSPlugin: Plugin = {
@ -45,7 +48,7 @@ async function startServer(manifest: Manifest, options: StartOptions = {}){
}
}
async function start({port = 8000, hostname = "localhost"}: {port?: number, hostname?: string}){
async function start({port = 8000, hostname = "localhost"}: {port?: number, hostname?: string} = {}){
await startServer(manifest, { plugins: [twindPlugin(twindConfig), CSSPlugin],
port: port,
hostname: hostname,
@ -77,10 +80,11 @@ if (import.meta.main){
});
}
)
//.command("user")
.command("user", user_command)
.command("keyout", key_out_cmd)
;
await cmd.parse(Deno.args);
}
else {
await start({});
await start();
}