Skip to content

Commit fa260c0

Browse files
committed
feat: first commit
1 parent 1d05ef3 commit fa260c0

23 files changed

+466
-1
lines changed

.eslintrc.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
project: 'tsconfig.json',
5+
sourceType: 'module',
6+
},
7+
plugins: ['@typescript-eslint/eslint-plugin'],
8+
extends: [
9+
'plugin:@typescript-eslint/recommended',
10+
],
11+
root: true,
12+
env: {
13+
node: true,
14+
jest: true,
15+
},
16+
ignorePatterns: ['.eslintrc.js'],
17+
rules: {
18+
'@typescript-eslint/interface-name-prefix': 'off',
19+
'@typescript-eslint/explicit-function-return-type': 'off',
20+
'@typescript-eslint/explicit-module-boundary-types': 'off',
21+
'@typescript-eslint/no-explicit-any': 'off',
22+
},
23+
};

.github/ISSUE_TEMPLATE/bug-report.md

Whitespace-only changes.

.github/PULL_REQUEST_TEMPLATE.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!--
2+
Thank you for your pull request. Please review below requirements.
3+
Bug fixes and new features should include tests.
4+
Contributors guide: https://github.com/huangyanxiong01/nest-starter/blob/main/CONTRIBUTING.md
5+
6+
感谢您贡献代码。请确认下列 checklist 的完成情况。
7+
Bug 修复和新功能必须包含测试,必要时请附上性能测试。
8+
Contributors guide: https://github.com/huangyanxiong01/nest-starter/blob/main/CONTRIBUTING.md
9+
-->
10+
11+
##### Checklist
12+
13+
<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->
14+
15+
- [ ] `yarn test && yarn test:e2e` passes
16+
- [ ] commit message follows commit guidelines
17+
18+
##### Description of change
19+
20+
<!-- Provide a description of the change below this comment. -->
21+
22+
<!--
23+
- any feature?
24+
- close https://github.com/huangyanxiong01/nest-starter/ISSUE_URL
25+
-->

.github/workflows/e2e.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
on: ['push', 'pull_request']
2+
3+
name: e2e
4+
5+
jobs:
6+
test:
7+
name: e2e
8+
runs-on: ubuntu-20.04
9+
container: node:14
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: yarn test:e2e
13+
run: |
14+
yarn install
15+
yarn test:e2e

.github/workflows/test.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
on: ['push', 'pull_request']
2+
3+
name: test
4+
5+
jobs:
6+
test:
7+
name: test
8+
runs-on: ubuntu-20.04
9+
container: node:14
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Generate coverage report
13+
run: |
14+
yarn install
15+
yarn test:cov
16+
- name: Upload coverage to Codecov
17+
uses: codecov/codecov-action@v1
18+
with:
19+
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
20+
directory: ./coverage/
21+
flags: unittests # optional
22+
name: codecov-umbrella # optional
23+
fail_ci_if_error: true # optional (default = false)
24+
verbose: true # optional (default = false)

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
yarn.lock
2+
node_modules/
3+
dist/

.husky/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/commit-msg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit "$1"

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

.husky/pre-push

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npm run test:e2e
5+
npm run test

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

.vscode/launch.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"name": "vscode-jest-tests",
10+
"request": "launch",
11+
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
12+
"args": [
13+
"--testTimeout",
14+
"1200",
15+
"--runInBand",
16+
"--config",
17+
"jest.json"
18+
],
19+
"cwd": "${workspaceFolder}",
20+
"console": "integratedTerminal",
21+
"internalConsoleOptions": "neverOpen",
22+
"disableOptimisticBPs": true
23+
},
24+
{
25+
"type": "node",
26+
"console": "integratedTerminal",
27+
"request": "launch",
28+
"name": "Launch Program",
29+
"runtimeArgs": [
30+
"-r",
31+
"ts-node/register"
32+
],
33+
"args": [
34+
"--files",
35+
"${workspaceFolder}/src/main.ts",
36+
],
37+
"env": { "TS_NODE_PROJECT": "tsconfig.json" }
38+
}
39+
]
40+
}

CONTRIBUTING.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Contribution Guide
2+
3+
If you have any comment or advice, please report your [issue](https://github.com/huangyanxiong01/nest-starter/issues),
4+
or make any change as you wish and submit a [PR](https://github.com/huangyanxiong01/nest-starter/pulls).
5+
6+
## Reporting New Issues
7+
8+
- Please specify what kind of issue it is.
9+
- Before you report an issue, please search for related issues. Make sure you are not going to open a duplicate issue.
10+
- Explain your purpose clearly in tags(see **Useful Tags**), title, or content.
11+
12+
We will confirm the purpose of the issue, replace more accurate tags for it, identify related milestone.Tags can `feature`, `bug`, `documentation`, `performance`, `support` ....
13+
14+
## Submitting Code
15+
16+
### Pull Request Guide
17+
18+
We use automated test with husk. The test auto runing When you push your code remote repo. If your modification pass the tests, congradulations it's time to push your work back to us.Then you can create a Pull Request at [nest-starter](https://github.com/huangyanxiong01/nest-starter/pulls)
19+
20+
### Style Guide
21+
22+
Your any modification will be by pass eslint identify styling When you use git add file. And forma your code by Prettier
23+
24+
### Commit Message Format
25+
26+
Your commmit message format require Adheres [commitlint](https://github.com/conventional-changelog/commitlint#what-is-commitlint) specification

Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM node:latest
2+
3+
# update packages
4+
RUN apk update
5+
6+
# create root application folder
7+
WORKDIR /app
8+
9+
# copy configs to /app folder
10+
COPY package*.json ./
11+
COPY tsconfig.json ./
12+
# copy source code to /app/src folder
13+
COPY src /app/src
14+
15+
# check files list
16+
RUN ls -a
17+
18+
RUN npm install
19+
RUN npm run build
20+
21+
EXPOSE 7777
22+
23+
CMD [ "node", "./dist/main.js" ]

README.md

+106-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,107 @@
11
# typescript-backend-template
2-
Typescript+Docker+Eslint+Prettier+Jest+Husky+Commitlint+Ts-node+Vscode
2+
Typescript+Docker+Eslint+Prettier+Jest+Husky+Commitlint+Ts-node+Vscode+CD/CI
3+
4+
Every time you create a project, you have to configure various tools. This will be a waste of our time. We will do this with a template to solve this problem. Congratulations on finding the project template you want.
5+
6+
## How use this template with your project?
7+
click above `Use this template` button, create new fork your github.Then git clone your local host
8+
9+
```
10+
git clone your-github-repo
11+
yarn install
12+
```
13+
14+
## Typescript
15+
[What is TypeScript and why would I use it in place of JavaScript?](https://stackoverflow.com/questions/12694530/what-is-typescript-and-why-would-i-use-it-in-place-of-javascript/35048303#35048303)
16+
- Support for modern JavaScript features
17+
- Advanced type system
18+
- Developer tooling support
19+
- Optionally static typing and type inference
20+
- Enhanced IDE support
21+
- Strict null checks
22+
- JavaScript interoperability
23+
24+
## Eslint
25+
[ESLint](https://eslint.org/) is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code, with the goal of making code more consistent and avoiding bugs. ... ESLint uses an AST to evaluate patterns in code. ESLint is completely pluggable, every single rule is a plugin and you can add more at runtime.
26+
27+
## Jest
28+
[Jest](https://jestjs.io/) is a delightful JavaScript Testing Framework with a focus on simplicity.
29+
30+
Why code testing? Let us start with a few questions:
31+
32+
- How to measure the quality of code
33+
- How to ensure the quality of code
34+
- Are you free to refactor code
35+
- How to guarantee the correctness of refactored code
36+
- Have you confidence to release your untested code
37+
- If you are not sure, you probably need unit testing.
38+
39+
## Prettier
40+
Prettier is an opinionated code formatter with support for:
41+
42+
- JavaScript (including experimental features)
43+
- JSX
44+
- Angular
45+
- Vue
46+
- TypeScript
47+
- CSS, Less, and SCSS
48+
- HTML
49+
- JSON
50+
- GraphQL
51+
- Markdown, including GFM and MDX
52+
- YAML
53+
Why to use Prettier in your project?
54+
- How to ensure the code style in a team?
55+
- [Why Prettier?](https://prettier.io/docs/en/why-prettier.html)
56+
57+
## Husky
58+
Having a good feedback loop is extremely important for developers. A properly configured project has a CI/CD pipeline that ensures the code will not break anything in the application’s logic or codebase itself by running the necessary checks, such as static code analysis and tests. [Husky](https://typicode.github.io/) can help you do this.
59+
60+
## Commitlint
61+
[commitlint](https://commitlint.js.org/) helps your team adhering to a commit convention. By supporting npm-installed configurations it makes sharing of commit conventions easy.
62+
63+
Why Use Conventional Commits?
64+
- Automatically generating CHANGELOGs.
65+
- Automatically determining a semantic version bump (based on the types of commits landed).
66+
- Communicating the nature of changes to teammates, the public, and other stakeholders.
67+
- Triggering build and publish processes.
68+
- Making it easier for people to contribute to your projects, by allowing them to explore a more structured commit history.
69+
70+
## Ts-node
71+
[ts-node](https://typestrong.org/ts-node/docs/) is a TypeScript execution engine and REPL for Node.js.
72+
73+
It JIT transforms TypeScript into JavaScript, enabling you to directly execute TypeScript on Node.js without precompiling. This is accomplished by hooking node's module loading APIs, enabling it to be used seamlessly alongside other Node.js tools and libraries.
74+
75+
- Automatic sourcemaps in stack traces
76+
- Automatic tsconfig.json parsing
77+
- Automatic defaults to match your node version
78+
- Typechecking (optional)
79+
- REPL
80+
- Write standalone scripts
81+
- Native ESM loader
82+
- Use third-party transpilers
83+
- Use custom transformers
84+
- Integrate with test runners, debuggers, and CLI tools
85+
- Compatible with pre-compilation for production
86+
87+
## Vscode
88+
We recommend installing plugins
89+
- [Eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
90+
- [Docker](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker)
91+
- [Jest](https://marketplace.visualstudio.com/items?itemName=Orta.vscode-jest)
92+
- [Jest Runner](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner)
93+
- [Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
94+
95+
## Docker
96+
What can I use Docker for?
97+
- Fast, consistent delivery of your applications
98+
- Responsive deployment and scaling
99+
- Running more workloads on the same hardware
100+
101+
## ts-node-dev
102+
[ts-node-dev](https://github.com/wclr/ts-node-dev) Compiles your TS app and restarts when files are modified.
103+
104+
105+
106+
## CD/CI
107+
GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.

commitlint.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
};

0 commit comments

Comments
 (0)