https://github.com/ryosukedtomita/qiita_auto_update
Qiitaのviews,いいね数,ストック数を自動取得して記事を更新するAWS Lambda
https://github.com/ryosukedtomita/qiita_auto_update
aws-lambda nodejs qiita-apiv2 serverless-framework
Last synced: 5 months ago
JSON representation
Qiitaのviews,いいね数,ストック数を自動取得して記事を更新するAWS Lambda
- Host: GitHub
- URL: https://github.com/ryosukedtomita/qiita_auto_update
- Owner: RyosukeDTomita
- License: unlicense
- Created: 2024-12-25T21:03:43.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-01-20T03:01:59.000Z (6 months ago)
- Last Synced: 2025-01-20T04:18:31.185Z (6 months ago)
- Topics: aws-lambda, nodejs, qiita-apiv2, serverless-framework
- Language: JavaScript
- Homepage: https://qiita.com/sigma_devsecops/items/59af6d7f45397217ddd2
- Size: 169 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# APP NAME

## INDEX
- [ABOUT](#about)
- [ENVIRONMENT](#environment)
- [PREPARING](#preparing)
- [HOW TO USE](#how-to-use)---
## ABOUT
AWS Lambda to hit qiita api to update like and stock number.
[target qiita article](https://qiita.com/sigma_devsecops/items/59af6d7f45397217ddd2)
---
## ENVIRONMENT
- Node.js v22.11.0
- Serverless with AWS Lambda自分用メモなので折りたたんでおく
- Node.jsのインストール
```shell
# 現在のLTS: Jobのv22.11.0を指定
nvm ls-remote
nvm install v22.11.0
nvm alias default 22 # default変更
```- ライブラリのインストール
```shell
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の設定
```shell
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](https://www.serverless.com/framework/docs/getting-started)
2. clone this repository---
## HOW TO USE
1. prepare QIITA_ACCESS_TOKEN from [qiita settings page](https://qiita.com/settings/applications)
2. create `.env` file in the root directory and write `QIITA_ACCESS_TOKEN` and `TARGET_URI````shell
cat .env
QIITA_ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TARGET_URI=https://qiita.com/your_account/items/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```3. deploy to aws lambda
```shell
cd qiita-auto-update
sls deploy
```---