【问题标题】:How do I deploy my Deno application to heroku which uses a postgresql database?如何将我的 Deno 应用程序部署到使用 postgresql 数据库的 heroku?
【发布时间】:2021-03-23 16:16:33
【问题描述】:

我有一个想要部署到 heroku 的应用程序。我已经在 heroku 中创建了应用程序并添加了 deno buildpack。我还使用 psql 设置了数据库并创建了表。现在唯一的问题是我不知道如何编写或使用 .env 文件,以便 Deno 应用程序可以访问正确的数据库凭据。

【问题讨论】:

标签: postgresql heroku deno oak


【解决方案1】:

https://deno.land/x/dotenv@v2.0.0
这个扩展会帮助你。

如果你想在 Deno 中使用 env:

import "https://deno.land/x/dotenv/load.ts";

console.log(Deno.env.get('GREETING'));

另一种方式:

// app.ts
import { config } from "https://deno.land/x/dotenv/mod.ts";

console.log(config());

【讨论】:

    猜你喜欢
    • 2021-06-26
    • 2013-05-31
    • 1970-01-01
    • 2016-06-02
    • 2014-05-27
    • 2016-07-16
    • 2020-08-22
    • 2017-11-03
    • 2015-01-28
    相关资源
    最近更新 更多