From 6004433ad41fac738f8bd0ae9c4d0ff72ac7c3a0 Mon Sep 17 00:00:00 2001 From: Thada Wangthammang Date: Sat, 18 May 2024 09:41:14 +0700 Subject: [PATCH] feat: add license --- LICENSE | 5 +++++ README.md | 42 +++++++++++++++++++++++++++++---------- docs/.vitepress/config.ts | 5 ++++- 3 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..18eb34f --- /dev/null +++ b/LICENSE @@ -0,0 +1,5 @@ +Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License + +This work by Thada Wangthammang, @2024 is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. +You may copy and redistribute the material in any medium or format for non-commercial purposes only, provided proper attribution is given, but you may not distribute any modified material. +For details, see the full license at https://creativecommons.org/licenses/by-nc-nd/4.0/ diff --git a/README.md b/README.md index 0ad2721..bd17f5f 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,37 @@ -# book-type-safe-design-pattern +# Type-safe Design Pattern in Modern TypeScript -To install dependencies: +This book provide ready to use design pattern for type-safe approach in modern typescript +by Thada Wangthammang -```bash -bun install -``` +## Table of Contents -To run: +- TypeScript Config + - Use strict +- Data Structure + - Use literal type rathen than string + - Use Record object rather than list/array + - Use Tuple rather than list/array +- Design Patterns + - Use builder pattern + - Use function argument instead of plain object + - Use function overload -```bash -bun run index.ts -``` +## Prerequisites +Please make sure you have a good understanding of TypeScript before reading this book. If you are new to TypeScript, I recommend reading the [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/intro.html) first. -This project was created using `bun init` in bun v1.1.7. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. +Generics are a fundamental concept in TypeScript, so make sure you understand them. You can read the [Generics](https://www.typescriptlang.org/docs/handbook/2/generics.html) section of the TypeScript Handbook. + +After that, make sure you have understand type-level programming. You can read the [Type-Level Programming](https://type-level-typescript.com/) book. +There are many free chapters available. However, I recommend buying the book to support the author. + +## Disclaimer + +I did not create these design patterns. I learned from various modern TypeScript open-source projects, including famous ones like Zod, tRPC, Hono, Elysia, and many others, as well as writing the [Nammtham](https://nammatham.thaitype.dev/) (Azure Functions Framework). This process has helped me distill commonly used patterns. + +The type-safe design patterns is not suitable for every project. It is intended for projects that require high code quality and design. Make sure to evaluate whether these patterns are suitable for your project before using them. + +## Contributing +If you have any suggestions or feedback, please feel free to open an issue or submit a pull request on [GitHub](https://github.com/mildronize/type-safe-design-pattern) + +## License +This book is licensed under the [CC BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/) \ No newline at end of file diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 851ec9a..a0c7c4b 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -50,7 +50,10 @@ export default defineConfig({ ], }, ], - + footer: { + message: 'Content License under CC BY-NC-ND 4.0', + copyright: 'Copyright © 2024-present Thada Wangthammang' + }, socialLinks: [ { icon: "github",