Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kt3k/now-deno-example

A demo application of now-deno and deno-postgres.
https://github.com/kt3k/now-deno-example

deno deno-postgres now-deno zeit-now

Last synced: 3 months ago
JSON representation

A demo application of now-deno and deno-postgres.

Awesome Lists containing this project

README

        

# now-deno-demo

Very simple BBS written in Deno, running on Zeit [Now][].

# Architecture

- Runs on Zeit [Now][], which means each endpoint runs as a serverless function.
- Written in [Deno][].
- Stores the data in Postgres DB.
- Single Page App, written in vanilla JS.

# How to run this demo

You need postgres DB instance to run this demo. You can get a free instance from generous database hosting services such as AWS RDS, ElephantSQL, etc.

You need [Now][] and need to set the following information in `now secrets`

```
now secrets add pguser
now secrets add pgpassword
now secrets add pghost
now secrets add pgdatabase
now secrets add pgport
```

You need to create a database in your postgres DB:

```sql
CREATE DATABASE bbs ENCODING 'UTF-8';
```

You need to create the following table:

```sql
CREATE TABLE posts(
id SERIAL PRIMARY KEY,
name VARCHAR(255),
body TEXT,
created_at TIMESTAMP NOT NULL DEFAULT NOW()
);
```

I recommend you insert some of rows before starting:

```sql
INSERT INTO posts (name, body) VALUES ('alice', 'hi');
INSERT INTO posts (name, body) VALUES ('alice', 'anyone here?');
INSERT INTO posts (name, body) VALUES ('bob', 'hey');
INSERT INTO posts (name, body) VALUES ('bob', 'anyone?');
```

Then hit the command `now` and that should run this app in your now account.

# License

MIT

[Now]: https://github.com/zeit/now
[Deno]: https://deno.land/