Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8936

Apex UpでNode.js × expressをAWS Lambda, API Gatewayに速攻デプロイしてみる

$
0
0

はじめに

Node.js × expressのAPIのデプロイ先としてLambdaを使おうと思ったのですが
手取り早くデプロイして試したかったので、Apex Upを使ってみた。今回はその時の備忘録

Upとは

APIや静的ウェブサイトをLambda × API Gatewayにupコマンドでデプロイしてくれるツールです。

使ってみる

Upのインストール

curl -sf https://up.apex.sh/install | sh

プロジェクト作成

mkdir node-up
cd node-up
npm init
entry point: (index.js) app.js # 自分はapp.jsに変更

expressのインストール

npm install express
touch app.js
touch up.json # Upの設定ファイル

app.js

constexpress=require('express')constapp=express()const{PORT=3000}=process.envapp.get('/',(req,res)=>{res.send('Hello World!')})app.listen(PORT);

Upの設定は以下の内容に設定

{"name":"node-up"}

これで設定は完了です。

最後にgit commitします。
git commitしとかないとupしたときにエラーが出てしまいます。

git init
git add .
git commit -m"First commit"

最後にデプロイします。

up

しばらくすると以下のような内容が出てくるのでURLをチェックして表示されればおkです。

stack: complete(19.175s)
endpoint: https://.../staging/

実際の表示
hello-up.png

削除

up stack delete

さいごに

Apex Upを使えば気軽にデプロイできるのでとりあえずデプロイしたいときは重宝しそうです。

参考資料

Up公式
Up GitHub


Viewing all articles
Browse latest Browse all 8936

Trending Articles