Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site: Attach Database #2572

Merged
merged 29 commits into from
May 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2b45963
fix: move `shelljs` to dev-deps
lukeed Apr 25, 2019
b2927e2
fix: move `codemirror` to “external” config only
lukeed Apr 25, 2019
d7fdd2c
fix: move `yootils` to “external” config only
lukeed Apr 25, 2019
a516923
chore: bump “sirv” dep
lukeed Apr 25, 2019
b4be051
chore: regenerate pkg-lock
lukeed Apr 25, 2019
083c4d9
chore: add `.env.example` file
lukeed Apr 25, 2019
2eacc35
chore: remove previous dependencies
lukeed Apr 25, 2019
e8adc9c
chore: add users migration
lukeed Apr 26, 2019
d6f0b69
feat: add `db` util w/ pool
lukeed Apr 26, 2019
f22c22c
feat: handle GitHub OAuth directly, thru JWTs
lukeed Apr 26, 2019
fdf7963
fix: hydrate `user` data & update keys
lukeed Apr 26, 2019
5298f8e
fix: add timestamp columns to “users" table
lukeed Apr 26, 2019
f672e6a
feat: save new gists to database
lukeed Apr 26, 2019
a337dd2
feat: find & update gists
lukeed Apr 26, 2019
7cc22eb
fix: update client for new endpoints
lukeed Apr 26, 2019
35485f9
fix: always send { error } shape
lukeed Apr 26, 2019
e3331ac
fix: rename “users.token” => "users.github_token”
lukeed Apr 26, 2019
8fba0ec
chore: include node-fetch as dev-dep
lukeed Apr 26, 2019
6ae893f
fix: remove extra DATABASE_URL key
lukeed Apr 26, 2019
b724a3d
Merge branch 'master' into site/database
lukeed Apr 30, 2019
3732b9c
fix: upload OAuth popup message
lukeed Apr 30, 2019
67d3fb1
chore: regenerate lock file
lukeed Apr 30, 2019
2e6f9c4
merge master -> database
Rich-Harris May 4, 2019
a4f7954
add database entries for new gists, update REPL URLs
Rich-Harris May 4, 2019
fd1b444
implement saving and forking
Rich-Harris May 4, 2019
c3857ab
insert history entry when forking
Rich-Harris May 4, 2019
9795ee8
add logic for relaxed gists
Rich-Harris May 5, 2019
f6fd1e2
remove unnecessary on conflict clause
Rich-Harris May 5, 2019
d654b34
Merge pull request #2680 from sveltejs/site/database-with-fallback
Rich-Harris May 5, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions site/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
NODE_ENV=

PORT=
BASEURL=
DATABASE_URL=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
MAPBOX_ACCESS_TOKEN=

JWT_EXP=30d
JWT_ALG=HS512
JWT_KEY=
25 changes: 25 additions & 0 deletions site/migrations/000-create-users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
exports.up = DB => {
DB.sql(`
create table if not exists users (
id serial primary key,
uid character varying(255) not null unique,
name character varying(255),
username character varying(255) not null,
avatar text,
github_token character varying(255),
created_at timestamp with time zone NOT NULL DEFAULT now(),
updated_at timestamp with time zone
);

create unique index if not exists users_pkey ON users(id int4_ops);
create unique index if not exists users_uid_key ON users(uid text_ops);
`);
};

exports.down = DB => {
DB.sql(`
drop table if exists users cascade;
drop index if exists users_uid_key;
drop index if exists users_pkey;
`);
};
24 changes: 24 additions & 0 deletions site/migrations/001-create-gists.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
exports.up = DB => {
DB.sql(`
create table if not exists gists (
id serial primary key,
uid uuid NOT NULL DEFAULT gen_random_uuid(),
user_id integer REFERENCES users(id) not null,
name character varying(255) not null,
files json not null,
created_at timestamp with time zone NOT NULL DEFAULT now(),
updated_at timestamp with time zone
);

create unique index if not exists gists_pkey ON gists(id int4_ops);
create index if not exists gists_user_id_key ON gists(user_id int4_ops);
`);
};

exports.down = DB => {
DB.sql(`
drop table if exists gists cascade;
drop index if exists gists_user_id_key;
drop index if exists gists_pkey;
`);
};
Loading