Skip to content

Latest commit

 

History

History
94 lines (73 loc) · 2.01 KB

README.md

File metadata and controls

94 lines (73 loc) · 2.01 KB

ChatGPT node server

fastify + typescript + json-schema-to-ts + eslint + prettier


development

yarn build 
yarn start

production

# docker image # at this folder
docker-compose build

# docker container  # at deploy folder
docker-compose up chatgpt_server

set up

init

npm init -y
npm i fastify
npm i -D typescript @types/node

...
npx tsc --init

...
[json-schema-to-ts](https://www.npmjs.com/package/json-schema-to-ts)
npm i -D json-schema-to-ts

...
# tsconfig.json
"baseUrl": "./",
"paths": {
  "@/*": ["src/*"]
}

eslint
eslint-plugin-simple-import-sort
prettier
eslint-config-prettier

# https://eslint.org/docs/latest/use/getting-started
npm init @eslint/config
npm init @eslint/config -- --config semistandard

...
# https://github.com/lydell/eslint-plugin-simple-import-sort/
npm install --save-dev eslint-plugin-simple-import-sort

...
# https://prettier.io/docs/en/install.html
npm install --save-dev --save-exact prettier


...
# [配置关闭 eslint 与 pretter 冲突的规则](https://github.com/prettier/eslint-config-prettier#installation)
npm install --save-dev eslint-config-prettier

...
# [如果出现 prettier 不符合代码会报 eslint 错误](https://github.com/prettier/eslint-config-prettier#installation)
npm install --save-dev eslint-config-prettier

...
# .vscode/settings.json
{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode"
}

...
# package.json
  "scripts": {
    ...
    "_lint": "eslint \"src/**/*.{js,json,md,ts}\"",
    "_lint:fix": "eslint --fix \"src/**/*.{js,json,md,ts}\"",
    "_prettier": "prettier --write \"src/**/*.{js,json,md,ts}\""
  }