Merge branch 'julius-dev' of Software_Engineering_I/greenvironment-server into develop

pull/1/head
Trivernis 5 years ago committed by Gitea
commit 8f142b78fb

41
package-lock.json generated

@ -2552,7 +2552,8 @@
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"aproba": { "aproba": {
"version": "1.2.0", "version": "1.2.0",
@ -2573,12 +2574,14 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -2593,17 +2596,20 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -2720,7 +2726,8 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -2732,6 +2739,7 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -2746,6 +2754,7 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@ -2753,12 +2762,14 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.3.5", "version": "2.3.5",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.2", "safe-buffer": "^5.1.2",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -2777,6 +2788,7 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -2857,7 +2869,8 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -2869,6 +2882,7 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -2954,7 +2968,8 @@
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.1.2",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"safer-buffer": { "safer-buffer": {
"version": "2.1.2", "version": "2.1.2",
@ -2990,6 +3005,7 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -3009,6 +3025,7 @@
"version": "3.0.1", "version": "3.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
@ -3052,12 +3069,14 @@
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"yallist": { "yallist": {
"version": "3.0.3", "version": "3.0.3",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
} }
} }
}, },

@ -20,7 +20,7 @@ export class MemoryCache extends EventEmitter {
* @param key * @param key
*/ */
public hashKey(key: string): string { public hashKey(key: string): string {
const hash = crypto.createHash("md5"); const hash = crypto.createHash("sha1");
const data = hash.update(key, "utf8"); const data = hash.update(key, "utf8");
return data.digest("hex"); return data.digest("hex");
} }

@ -49,16 +49,15 @@ DO $$ BEGIN
END$$; END$$;
-- create tables -- create tables
DO $$ BEGIN
CREATE TABLE IF NOT EXISTS "user_sessions" ( CREATE TABLE IF NOT EXISTS "user_sessions" (
"sid" varchar NOT NULL, "sid" varchar NOT NULL,
"sess" json NOT NULL, "sess" json NOT NULL,
"expire" timestamp(6) NOT NULL, "expire" timestamp(6) NOT NULL,
PRIMARY KEY ("sid") NOT DEFERRABLE INITIALLY IMMEDIATE PRIMARY KEY ("sid") NOT DEFERRABLE INITIALLY IMMEDIATE
) WITH (OIDS=FALSE); ) WITH (OIDS=FALSE);
CREATE TABLE IF NOT EXISTS users ( CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
name varchar(128) NOT NULL, name varchar(128) NOT NULL,
handle varchar(128) UNIQUE NOT NULL, handle varchar(128) UNIQUE NOT NULL,
@ -66,9 +65,9 @@ DO $$ BEGIN
email varchar(128) UNIQUE NOT NULL, email varchar(128) UNIQUE NOT NULL,
greenpoints INTEGER DEFAULT 0, greenpoints INTEGER DEFAULT 0,
joined_at TIMESTAMP DEFAULT now() joined_at TIMESTAMP DEFAULT now()
); );
CREATE TABLE IF NOT EXISTS posts ( CREATE TABLE IF NOT EXISTS posts (
id BIGSERIAL PRIMARY KEY, id BIGSERIAL PRIMARY KEY,
upvotes INTEGER DEFAULT 0, upvotes INTEGER DEFAULT 0,
downvotes INTEGER DEFAULT 0, downvotes INTEGER DEFAULT 0,
@ -76,56 +75,54 @@ DO $$ BEGIN
content text, content text,
author SERIAL REFERENCES users (id) ON DELETE CASCADE, author SERIAL REFERENCES users (id) ON DELETE CASCADE,
type posttype NOT NULL DEFAULT 'MISC' type posttype NOT NULL DEFAULT 'MISC'
); );
CREATE TABLE IF NOT EXISTS votes ( CREATE TABLE IF NOT EXISTS votes (
user_id SERIAL REFERENCES users (id) ON DELETE CASCADE, user_id SERIAL REFERENCES users (id) ON DELETE CASCADE,
item_id BIGSERIAL REFERENCES posts (id) ON DELETE CASCADE, item_id BIGSERIAL REFERENCES posts (id) ON DELETE CASCADE,
vote_type votetype DEFAULT 'DOWNVOTE', vote_type votetype DEFAULT 'DOWNVOTE',
PRIMARY KEY (user_id, item_id) PRIMARY KEY (user_id, item_id)
); );
CREATE TABLE IF NOT EXISTS events ( CREATE TABLE IF NOT EXISTS events (
id BIGSERIAL PRIMARY KEY, id BIGSERIAL PRIMARY KEY,
time TIMESTAMP, time TIMESTAMP,
owner SERIAL REFERENCES users (id) owner SERIAL REFERENCES users (id)
); );
CREATE TABLE IF NOT EXISTS event_members ( CREATE TABLE IF NOT EXISTS event_members (
event BIGSERIAL REFERENCES events (id), event BIGSERIAL REFERENCES events (id),
member SERIAL REFERENCES users (id), member SERIAL REFERENCES users (id),
PRIMARY KEY (event, member) PRIMARY KEY (event, member)
); );
CREATE TABLE IF NOT EXISTS chats ( CREATE TABLE IF NOT EXISTS chats (
id BIGSERIAL PRIMARY KEY id BIGSERIAL PRIMARY KEY
); );
CREATE TABLE IF NOT EXISTS chat_messages ( CREATE TABLE IF NOT EXISTS chat_messages (
chat BIGSERIAL REFERENCES chats (id) ON DELETE CASCADE, chat BIGSERIAL REFERENCES chats (id) ON DELETE CASCADE,
author SERIAL REFERENCES users (id) ON DELETE SET NULL, author SERIAL REFERENCES users (id) ON DELETE SET NULL,
content VARCHAR(1024) NOT NULL, content VARCHAR(1024) NOT NULL,
created_at TIMESTAMP DEFAULT now(), created_at TIMESTAMP DEFAULT now(),
PRIMARY KEY (chat, author, created_at) PRIMARY KEY (chat, author, created_at)
); );
CREATE TABLE IF NOT EXISTS chat_members ( CREATE TABLE IF NOT EXISTS chat_members (
chat BIGSERIAL REFERENCES chats (id) ON DELETE CASCADE, chat BIGSERIAL REFERENCES chats (id) ON DELETE CASCADE,
member SERIAL REFERENCES users (id) ON DELETE CASCADE, member SERIAL REFERENCES users (id) ON DELETE CASCADE,
PRIMARY KEY (chat, member) PRIMARY KEY (chat, member)
); );
CREATE TABLE IF NOT EXISTS user_friends ( CREATE TABLE IF NOT EXISTS user_friends (
user_id SERIAL REFERENCES users (id) ON DELETE CASCADE, user_id SERIAL REFERENCES users (id) ON DELETE CASCADE,
friend_id SERIAL REFERENCES users (id) ON DELETE CASCADE, friend_id SERIAL REFERENCES users (id) ON DELETE CASCADE,
PRIMARY KEY (user_id, friend_id) PRIMARY KEY (user_id, friend_id)
); );
CREATE TABLE IF NOT EXISTS requests ( CREATE TABLE IF NOT EXISTS requests (
sender SERIAL REFERENCES users (id) ON DELETE CASCADE, sender SERIAL REFERENCES users (id) ON DELETE CASCADE,
receiver SERIAL REFERENCES users (id) ON DELETE CASCADE, receiver SERIAL REFERENCES users (id) ON DELETE CASCADE,
type requesttype DEFAULT 'FRIENDREQUEST', type requesttype DEFAULT 'FRIENDREQUEST',
PRIMARY KEY (sender, receiver, type) PRIMARY KEY (sender, receiver, type)
); );
END $$;

Loading…
Cancel
Save