Skip to content

Alesion30/obniz-node-template

Repository files navigation

Node.ts + obniz

参考記事:

環境構築

  1. git clone https://github.com/Alesion30/obniz-node-template.git
  2. cd obniz-node-template
  3. rm -rf .git
  4. yarn install
  5. touch .env
  6. .envの値をセットする
OBNIZ_ID=(obniz上に表示されているID)
  1. yarn dev or yarn build && yarn start

1からプロジェクトを作成する手順

  1. yarn init
  2. yarn add obniz express
  3. yarn add -D typescript @types/node @types/express ts-node dotenv tsconfig-paths
  4. touch tsconfig.json
{
  "compilerOptions": {
    "sourceMap": true,
    "esModuleInterop": true,
    "baseUrl": "./",
    "paths": {
      "@/*": ["src/*"]
    },
    "outDir": "dist",
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "lib": ["es2018", "dom"]
  }
}
  1. touch .env
OBNIZ_ID=(obniz上に表示されているID)
  1. yarn add -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin prettier eslint-config-prettier
  2. touch tsconfig.eslint.json
{
  "extends": "./tsconfig.json",
  "include": [
    "src/**/*.ts",
    ".eslintrc.js"
  ],
  "exclude": [
    "node_modules",
    "dist"
  ]
}
  1. touch .eslintrc.js
module.exports = {
  root: true,
  env: {
    es6: true,
    node: true,
  },
  parser: '@typescript-eslint/parser',
  parserOptions: {
    sourceType: 'module',
    ecmaVersion: 2020,
    tsconfigRootDir: __dirname,
    project: ['./tsconfig.eslint.json']
  },
  plugins: [
    '@typescript-eslint',
  ],
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:@typescript-eslint/recommended-requiring-type-checking',
    'prettier',
    'prettier/@typescript-eslint',
  ],
  rules: {
  },
};
  1. touch .eslintignore
.eslintrc.js
  1. echo "{}"> .prettierrc.json
  2. touch .prettierignore
node_modules
  1. npmスクリプトの設定
"scripts": {
  "start": "ts-node --files -r tsconfig-paths/register src/main.ts",
  "lint": "eslint --ext .js,.ts .",
  "format": "prettier --write \"*.{js,ts,json}\" && prettier --write \"src/**/*.{js,ts,json}\""
},

About

Node.ts + obniz + Express テンプレート

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors