Skip to content

Instantly share code, notes, and snippets.

@MSakamaki
Last active January 7, 2019 02:54
Show Gist options
  • Save MSakamaki/02aa9d9beb70f4e35287ceedf3a48c36 to your computer and use it in GitHub Desktop.
Save MSakamaki/02aa9d9beb70f4e35287ceedf3a48c36 to your computer and use it in GitHub Desktop.
deno.scripts
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist",
"sourceMap": true,
"declaration": true,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"types": [
],
"paths": {
"http://*": ["../../.deno/deps/http/*"],
"https://*": ["../../.deno/deps/https/*"]
},
"typeRoots": [
// deno --types > types/deno.d.ts
"types"
],
"lib": [
]
}
}
import { args, readDir } from "deno";
import { parse } from "https://deno.land/x/flags/index.ts";
const argPath = parse(args)._[1] as string;
const path = argPath.startsWith('/') ? argPath : `./${argPath}`;
(async () => {
const files = await readDir(path);
files
.sort((a, b) => (a.isFile() === b.isFile()) ? 0 : a.isFile() ? 1 : -1)
.forEach(file => {
console.log(file.isFile() ? 'F:' : 'D:', file.name);
});
})();
import { serve } from "https://deno.land/x/net/http.ts";
const s = serve("0.0.0.0:8000");
async function main() {
for await (const req of s) {
req.respond({ body: new TextEncoder().encode("Hello World\n") });
}
}
main();
import { listen, copy } from "deno";
(async () => {
const addr = "0.0.0.0:8080";
const listener = listen("tcp", addr);
console.log("listening on", addr);
while (true) {
const conn = await listener.accept();
copy(conn, conn);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment