now.sh で Koa + TypeScript
2019/11/10 13:19:032020/06/03 00:53:20
now.json
の用に設定ファイルをルートディレクトリに要求する。 now.json
{
"version": 2,
"name": "tobiuo",
"routes": [{
"src": "/(.*)",
"dest": "src/index.ts"
}],
"builds": [{
"src": "src/**/*.ts",
"use": "@now/node@canary",
"config": {
"maxLambdaSize": "25mb"
}
}, {
"src": "src/**/*.pug",
"use": "@now/static"
}],
"env": {
"IS_NOW": "true",
"ENDPOINT": "@tobiuo-endpoint",
"SECRET_KEY": "@tobiuo-secret-key",
"BRANCA_KEY": "@tobiuo-branca-key",
"CLIENT_ID": "@tobiuo-client-id",
"CLIENT_SECRET": "@tobiuo-secret"
}
}
package.json
での build などの記述を要求しない。 @now/node@canary
でデプロイするように指定し、routes に dist ではなく ts ファイルに対し直接 dest を指定する。 index.ts
より抜粋してみる。 index.ts
const run = async () {
const port = process.env.PORT || 5000
app.listen(port, () => {
console.log(`started on http://localhost:${port}`)
})
}
run()
Generated from
now.sh で Koa + TypeScript