Skip to content

Commit 1d0da9d

Browse files
lukeedRich-Harris
authored andcommitted
Use database for REPL, update URL structure (sveltejs#2572)
* fix: move `shelljs` to dev-deps * fix: move `codemirror` to “external” config only * fix: move `yootils` to “external” config only * chore: bump “sirv” dep * chore: regenerate pkg-lock * chore: add `.env.example` file * chore: remove previous dependencies * chore: add users migration * feat: add `db` util w/ pool * feat: handle GitHub OAuth directly, thru JWTs * fix: hydrate `user` data & update keys * fix: add timestamp columns to “users" table * feat: save new gists to database * feat: find & update gists * fix: update client for new endpoints * fix: always send { error } shape * fix: rename “users.token” => "users.github_token” * chore: include node-fetch as dev-dep * fix: remove extra DATABASE_URL key * fix: upload OAuth popup message * chore: regenerate lock file * add database entries for new gists, update REPL URLs * implement saving and forking * insert history entry when forking * add logic for relaxed gists * remove unnecessary on conflict clause
1 parent 5263354 commit 1d0da9d

24 files changed

+1057
-778
lines changed

site/.env.example

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
NODE_ENV=
2+
3+
PORT=
4+
BASEURL=
5+
DATABASE_URL=
6+
GITHUB_CLIENT_ID=
7+
GITHUB_CLIENT_SECRET=
8+
MAPBOX_ACCESS_TOKEN=
9+
10+
JWT_EXP=30d
11+
JWT_ALG=HS512
12+
JWT_KEY=

site/migrations/000-create-users.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
exports.up = DB => {
2+
DB.sql(`
3+
create table if not exists users (
4+
id serial primary key,
5+
uid character varying(255) not null unique,
6+
name character varying(255),
7+
username character varying(255) not null,
8+
avatar text,
9+
github_token character varying(255),
10+
created_at timestamp with time zone NOT NULL DEFAULT now(),
11+
updated_at timestamp with time zone
12+
);
13+
14+
create unique index if not exists users_pkey ON users(id int4_ops);
15+
create unique index if not exists users_uid_key ON users(uid text_ops);
16+
`);
17+
};
18+
19+
exports.down = DB => {
20+
DB.sql(`
21+
drop table if exists users cascade;
22+
drop index if exists users_uid_key;
23+
drop index if exists users_pkey;
24+
`);
25+
};

site/migrations/001-create-gists.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
exports.up = DB => {
2+
DB.sql(`
3+
create table if not exists gists (
4+
id serial primary key,
5+
uid uuid NOT NULL DEFAULT gen_random_uuid(),
6+
user_id integer REFERENCES users(id) not null,
7+
name character varying(255) not null,
8+
files json not null,
9+
created_at timestamp with time zone NOT NULL DEFAULT now(),
10+
updated_at timestamp with time zone
11+
);
12+
13+
create unique index if not exists gists_pkey ON gists(id int4_ops);
14+
create index if not exists gists_user_id_key ON gists(user_id int4_ops);
15+
`);
16+
};
17+
18+
exports.down = DB => {
19+
DB.sql(`
20+
drop table if exists gists cascade;
21+
drop index if exists gists_user_id_key;
22+
drop index if exists gists_pkey;
23+
`);
24+
};

0 commit comments

Comments
 (0)