Skip to content

Commit

Permalink
it works
Browse files Browse the repository at this point in the history
  • Loading branch information
Div9851 committed Sep 10, 2021
1 parent b85dfc7 commit faf3886
Show file tree
Hide file tree
Showing 19 changed files with 544 additions and 181 deletions.
3 changes: 2 additions & 1 deletion initdb/postgres/1-create-users-table.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CREATE TABLE users
(
id TEXT PRIMARY KEY,
name TEXT NOT NULL
name TEXT NOT NULL,
picture TEXT NOT NULL
);
7 changes: 7 additions & 0 deletions initdb/postgres/2-create-questions-table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE questions
(
id SERIAL NOT NULL,
content TEXT,
display_answer TEXT,
answer TEXT
);
6 changes: 0 additions & 6 deletions initdb/postgres/2-create-rooms-table.sql

This file was deleted.

8 changes: 0 additions & 8 deletions initdb/postgres/3-create-room-users-table.sql

This file was deleted.

30 changes: 30 additions & 0 deletions initdb/postgres/3-insert-sample-questions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
INSERT INTO questions (content, display_answer, answer) VALUES ('病気になっても自覚症状が現れにくいことから「沈黙の臓器」とも呼ばれる、胆汁を作るなどの働きを持つ臓器は何でしょう?', '肝臓', 'かんぞう');
INSERT INTO questions (content, display_answer, answer) VALUES ('目黒駅は品川区にありますが、品川駅は何区にあるでしょう?', '港区', 'みなとく');
INSERT INTO questions (content, display_answer, answer) VALUES ('火を神聖視することから「拝火教」とも呼ばれる、アヴェスターを根本経典とする宗教は何でしょう?', 'ゾロアスター教', 'ゾロアスターきょう');
INSERT INTO questions (content, display_answer, answer) VALUES ('日本の中央省庁で、幼稚園を管轄しているのは文部科学省ですが、保育園を管轄しているのは何省でしょう?', '厚生労働省', 'こうせいろうどうしょう');
INSERT INTO questions (content, display_answer, answer) VALUES ('「おい地獄さ行ぐんだで!」という書き出しで始まる、小林多喜二によって書かれたプロレタリア文学の代表的な作品は何でしょう?', '蟹工船', 'かにこうせん');
INSERT INTO questions (content, display_answer, answer) VALUES ('6、28、496のように、自分自身を除く正の約数の和がその数と等しくなるような自然数のことを何というでしょう?', '完全数', 'かんぜんすう');
INSERT INTO questions (content, display_answer, answer) VALUES ('予想だにしない出来事が突然起こる様子を表す「青天の霹靂」の「霹靂」とは何を意味する言葉でしょう?', '', 'かみなり');
INSERT INTO questions (content, display_answer, answer) VALUES ('「あかい」「まるい」「おおきい」「うまい」の頭文字をとって名付けられた、福岡の特産であるイチゴの品種は何でしょう?', 'あまおう', 'あまおう');
INSERT INTO questions (content, display_answer, answer) VALUES ('「なぜ山に登るのか」と聞かれて「そこに山があるから」と答えたことで有名な、イギリスの登山家は誰でしょう?', 'ジョージ・マロリー', 'ジョージマロリー');
INSERT INTO questions (content, display_answer, answer) VALUES ('「音楽の三要素」といえば、リズム、メロディと何でしょう?', 'ハーモニー', 'ハーモニー');
INSERT INTO questions (content, display_answer, answer) VALUES ('一般的なサイコロの目を全て掛けるといくつになるでしょう?', '720', '720');
INSERT INTO questions (content, display_answer, answer) VALUES ('ドイツ音楽における「三大3B」とは、バッハ、ベートヴェンとあと一人は誰でしょう?', 'ヨハネス・ブラームス', 'ブラームス');
INSERT INTO questions (content, display_answer, answer) VALUES ('原子番号で、1番の元素は水素、10番の元素はネオンですが、100番の元素は何でしょう?', 'フェルミウム', 'フェルミウム');
INSERT INTO questions (content, display_answer, answer) VALUES ('文章中で、誤った文字を「誤字」、抜け落ちた文字を「脱字」といいますが、余分に入った不要な文字は何というでしょう?', '衍字', 'えんじ');
INSERT INTO questions (content, display_answer, answer) VALUES ('ことわざ「頭隠して尻隠さず」の由来となった動物は何でしょう?', 'キジ', 'キジ');
INSERT INTO questions (content, display_answer, answer) VALUES ('「どっどど どどうど どどうど どどう」という書き出しで始まる、宮沢賢治の童話は何でしょう?', '風の又三郎', 'かぜのまたさぶろう');
INSERT INTO questions (content, display_answer, answer) VALUES ('コンゴ共和国の首都はブラザヴィルですが、コンゴ民主共和国の首都はどこでしょう?', 'キンシャサ', 'キンシャサ');
INSERT INTO questions (content, display_answer, answer) VALUES ('「朕は国家なり」という言葉で知られる、「太陽王」と呼ばれたフランス・ブルボン朝の国王は誰?', 'ルイ14世', 'ルイ14せい');
INSERT INTO questions (content, display_answer, answer) VALUES ('「超ド級」という言葉の由来になった、イギリスの戦艦は何でしょう?', 'ドレッドノート', 'ドレッドノート');
INSERT INTO questions (content, display_answer, answer) VALUES ('恒温動物において、同じ種でも寒冷な地域に生息するものほど大型になるという法則を何というでしょう?', 'ベルクマンの法則', 'ベルクマンのほうそく');
INSERT INTO questions (content, display_answer, answer) VALUES ('「ホワイトハウス」はアメリカの大統領官邸ですが、「ピンクハウス」と呼ばれるのはどこの国の大統領官邸でしょう?', 'アルゼンチン', 'アルゼンチン');
INSERT INTO questions (content, display_answer, answer) VALUES ('749年、聖武天皇の時代に使用された、日本初の漢字四文字の元号は何でしょう?', '天平感宝', 'てんぴょうかんぽう');
INSERT INTO questions (content, display_answer, answer) VALUES ('世界三大瀑布といえば、ナイアガラの滝、ヴィクトリアの滝とあと1つは何でしょう?', 'イグアスの滝', 'イグアスのたき');
INSERT INTO questions (content, display_answer, answer) VALUES ('あと一画足すと「百」という漢字になることから、数え年で99歳のお祝いのことを何というでしょう?', '白寿', 'はくじゅ');
INSERT INTO questions (content, display_answer, answer) VALUES ('代表作に『田舎教師』や『蒲団』などがある、自然主義を代表する小説家は誰でしょう?', '田山花袋', 'たやまかたい');
INSERT INTO questions (content, display_answer, answer) VALUES ('スロバキアの首都はブラチスラヴァですが、スロベニアの首都はどこでしょう?', 'リュブリャナ', 'リュブリャナ');
INSERT INTO questions (content, display_answer, answer) VALUES ('アニメなどの声優を意味する「C.V.」とは、何という英語の略でしょう?', 'キャラクターボイス', 'キャラクターボイス');
INSERT INTO questions (content, display_answer, answer) VALUES ('五臓六腑の五臓とは、心臓、肝臓、脾臓、腎臓とあと一つは何でしょう?', '', 'はい');
INSERT INTO questions (content, display_answer, answer) VALUES ('宝塚歌劇団に存在する5つの組のうち、設立されたのが最も新しい組は何組でしょう?', '宙組', 'そらぐみ');
INSERT INTO questions (content, display_answer, answer) VALUES ('「仕事をサボる」などと言うときの「サボ」とは何という言葉の略でしょう?', 'サボタージュ', 'サボタージュ');
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"http-status-codes": "^2.1.4",
"ioredis": "^4.27.9",
"jwks-rsa": "^2.0.4",
"pandemonium": "^2.0.0",
"pg": "^8.7.1",
"socket.io": "^4.2.0"
},
Expand Down
20 changes: 11 additions & 9 deletions src/db/redis.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import Redis from "ioredis";
import env from "env";

const redis = new Redis({
host: env.redisHost,
port: env.redisPort,
});
const connect = () => {
const redis = new Redis({
host: env.redisHost,
port: env.redisPort,
});
redis.on("error", (err) => {
console.error(err);
});
return redis;
};

redis.on("error", (err) => {
console.error(err);
});

export default redis;
export { connect };
2 changes: 2 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface Env {
pgDatabase: string;
redisHost: string;
redisPort: number;
corsOrigin: string;
}

dotenv.config();
Expand All @@ -28,6 +29,7 @@ const env: Env = {
pgDatabase: process.env.PG_DB || "",
redisHost: process.env.REDIS_HOST || "localhost",
redisPort: parseInt(process.env.REDIS_PORT || "6379"),
corsOrigin: process.env.CORS_ORIGIN || "",
};

export default env;
Loading

0 comments on commit faf3886

Please sign in to comment.