deno install \
-n hoge \
--import-map=https://gist.githubusercontent.com/junkor-1011/96efc32a454e956d468ba5516e811ca9/raw/ed87f6757b1524c02db5de2d00e513b6bef00d90/import_map.json \
# --no-check \
https://gist.githubusercontent.com/junkor-1011/96efc32a454e956d468ba5516e811ca9/raw/ed87f6757b1524c02db5de2d00e513b6bef00d90/cli.ts
Last active
May 13, 2023 15:46
-
-
Save junkor-1011/96efc32a454e956d468ba5516e811ca9 to your computer and use it in GitHub Desktop.
deno test
This file contains hidden or 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
import { messageSchema, type TMessageSchema } from './mod.ts'; | |
Deno.addSignalListener('SIGINT', () => { | |
console.log('interrupted, I\'ll terminate.'); | |
Deno.exit(); | |
}); | |
function main(): void { | |
setInterval(() => { | |
console.log('waiting...'); | |
}, 2 * 1000); | |
setInterval(() => { | |
const dt = new Date(); | |
const _payload = { | |
message: 'Hello, World!', | |
date: dt.toISOString(), | |
} as const satisfies TMessageSchema; | |
const payload = messageSchema.parse(_payload); | |
console.log(JSON.stringify(payload, null, 2)); | |
}, 5 * 1000); | |
} | |
main(); |
This file contains hidden or 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
Show hidden characters
{ | |
"compilerOptions": { | |
"allowJs": false, | |
"jsx": "react", | |
"lib": ["deno.window"], | |
"strict": true | |
}, | |
"lint": { | |
"files": { | |
"include": ["."], | |
"exclude": ["public"] | |
}, | |
"rules": { | |
"tags": ["recommended"], | |
"exclude": [] | |
} | |
}, | |
"fmt": { | |
"include": ["./"], | |
"exclude": [".vscode", ".env"], | |
"useTabs": false, | |
"lineWidth": 80, | |
"indentWidth": 2, | |
"singleQuote": true, | |
"proseWrap": "preserve" | |
}, | |
"importMap": "import_map.json", | |
"tasks": { | |
// "test": "deno test" | |
"start": "deno run cli.ts" | |
} | |
} |
This file contains hidden or 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
{ | |
"version": "2", | |
"remote": {}, | |
"npm": { | |
"specifiers": { | |
"[email protected]": "[email protected]" | |
}, | |
"packages": { | |
"[email protected]": { | |
"integrity": "sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==", | |
"dependencies": {} | |
} | |
} | |
} | |
} |
This file contains hidden or 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
{ | |
"imports": { | |
"zod": "npm:[email protected]" | |
} | |
} |
This file contains hidden or 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
import { z } from 'zod'; | |
export const messageSchema = z.object({ | |
message: z.string(), | |
date: z.string().datetime(), | |
}); | |
export type TMessageSchema = z.infer<typeof messageSchema>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment