Skip to content

RyosukeDTomita/qiita_auto_update

Repository files navigation

APP NAME

un license

INDEX


ABOUT

AWS Lambda to hit qiita api to update like and stock number.

target qiita article


ENVIRONMENT

  • Node.js v22.11.0
  • Serverless with AWS Lambda
自分用メモなので折りたたんでおく
  • Node.jsのインストール
# 現在のLTS: Jobのv22.11.0を指定
nvm ls-remote 
nvm install v22.11.0
nvm alias default 22 # default変更
  • ライブラリのインストール
npm init -y
npm install --save-dev typescript
npm install --save-dev @types/node
npm install @types/aws-lambda
npm install axios
npm install dotenv
  • tsconfigの設定
npx tsc --init
{
  "compilerOptions": {
    "target": "es2016",
    "module": "commonjs", // node.jsの場合はcommonjsで良さそう
    "moduleResolution": "node",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true, // ファイル名の大文字小文字を厳密にチェック
    "strict": true,
    "skipLibCheck": true, // ライブラリの型チェックをスキップ
    "noEmitOnError": true, // エラーがある場合はコンパイルしない
    "noImplicitAny": true, // 暗黙的なany型の使用を許可しない
  },
  "include": ["qiita-auto-update/handler.ts"],
  "compileOnSave": true
}

[!NOTE] package.jsonのtypeも同じくcommonjsにあわせる必要がある。

  • VSCodeでビルドタスクを.vscode/tasks.jsonの作成(Ctrl + Shift + Bしておくとtsファイル保存時に自動でビルドされる)
  • ACCESS_TOKENを.envファイルから読み込むようにする
    • .envファイルの作成
    • serverless-dotenv-pluginのインストール

PREPARING

  1. set up serverless. See Getting Started
  2. clone this repository

HOW TO USE

  1. prepare QIITA_ACCESS_TOKEN from qiita settings page
  2. create .env file in the root directory and write QIITA_ACCESS_TOKEN and TARGET_URI
cat .env
QIITA_ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TARGET_URI=https://qiita.com/your_account/items/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  1. deploy to aws lambda
cd qiita-auto-update
sls deploy

About

Qiitaのviews,いいね数,ストック数を自動取得して記事を更新するAWS Lambda

Topics

Resources

License

Stars

Watchers

Forks