sdy
Showing 112 changed files with 0 additions and 1592 deletions
1 -*.xlsx
2 -.env
...\ No newline at end of file ...\ No newline at end of file
1 -# Capstone design
2 -
3 -1st semester capstone design project
4 -
5 -Subject : Making website in order to practice latest web technologies
6 -
7 -sub-subject : making chat site using JS
8 -
9 -# Schedule
10 -
11 -- 4/6 ~ 4/12
12 -- [x] Set development environment
13 -
14 - (tech : react.js, react hooks, styled-components, GraphQL, Prisma, Apollo, AWS, Docker)
15 -
16 -- 4/13 ~ 4/19
17 -- [x] login, sign up (using JWT, sendGrid), Create Docker-compose
18 -
19 -- 4/20 ~ 4/26
20 -- [X] Find ID, PW
21 -
22 -- 4/27 ~ 5/3
23 -- [X] Make chat room (using GraphQL's subscription)
24 -
25 -- 5/4 ~ 5/10
26 -- [X] Mid-term exam, Debugging
27 -
28 -- 5/11 ~ 5/17
29 -- [X] Plan chat category and make code
30 -
31 -- 5/18 ~ 5/24
32 -- [X] Debugging for code created in 6th week's plan
33 -
34 -- 5/25 ~ 5/31
35 -- [X] Plan a matching strategy for random chat
36 -
37 -- 6/1 ~ 6/7
38 -- [X] Make a code based on the matching plan created in 8th week's plan
39 -
40 -- 6/8 ~ 6/14
41 -- [X] Debugging for whole codes in our project, and meeting with mento
1 -{
2 - "presets": ["@babel/preset-env"]
3 -}
1 -node_modules
...\ No newline at end of file ...\ No newline at end of file
1 -# node_modules
2 -node_modules
3 -
4 -.env
5 -
6 -note.txt
7 -linux.txt
...\ No newline at end of file ...\ No newline at end of file
1 -FROM node:12.16.2
2 -RUN npm i -g @prisma/cli
3 -
4 -RUN mkdir /app
5 -WORKDIR /app
6 -
7 -COPY package*.json ./
8 -COPY prisma ./prisma/
9 -
10 -RUN npm install && npx prisma generate
11 -
12 -CMD ["npm","start"]
13 -
14 -COPY . .
...\ No newline at end of file ...\ No newline at end of file
1 -# Capstone design
2 -
3 -1st semester capstone design project
4 -
5 -Subject : Making website in order to practice latest web technologies
6 -
7 -sub-subject : making chat site using JS
8 -
9 -# Schedule
10 -
11 -- 4/6 ~ 4/12
12 -- [x] Set development environment
13 -
14 - (tech : react.js, react hooks, styled-components, GraphQL, Prisma, Apollo, AWS, Docker)
15 -
16 -- 4/13 ~ 4/19
17 -- [x] login, sign up (using JWT, sendGrid), Create Docker-compose
18 -
19 -- 4/20 ~ 4/26
20 -- [ ] Find ID, PW
21 -
22 -- 4/27 ~ 5/3
23 -- [ ] Make chat room (using GraphQL's subscription)
24 -
25 -- 5/4 ~ 5/10
26 -- [ ] Mid-term exam, Debugging
27 -
28 -- 5/11 ~ 5/17
29 -- [ ] Plan chat category and make code
30 -
31 -- 5/18 ~ 5/24
32 -- [ ] Debugging for code created in 6th week's plan
33 -
34 -- 5/25 ~ 5/31
35 -- [ ] Plan a matching strategy for random chat
36 -
37 -- 6/1 ~ 6/7
38 -- [ ] Make a code based on the matching plan created in 8th week's plan
39 -
40 -- 6/8 ~ 6/14
41 -- [ ] Debugging for whole codes in our project
42 -
43 -- 6/15 ~ 6/21
44 -- [ ] Deploy project in AWS amplify
45 -
46 -- 6/22 ~ 6/26
47 -- [ ] Final exam, review project
1 -{
2 - "ext": "js graphql"
3 -}
This diff could not be displayed because it is too large.
1 -{
2 - "name": "capstone-back",
3 - "version": "1.0.0",
4 - "description": "1st semester capstone design project",
5 - "scripts": {
6 - "start": "nodemon --exec babel-node src/server.js",
7 - "prisma": "prisma2 studio --experimental"
8 - },
9 - "repository": {
10 - "type": "git",
11 - "url": "git+https://vel1024@bitbucket.org/vel1024/capstone2.git"
12 - },
13 - "author": "sdy, kms",
14 - "license": "ISC",
15 - "homepage": "https://bitbucket.org/vel1024/capstone2#readme",
16 - "dependencies": {
17 - "@prisma/client": "^2.0.0-beta.2",
18 - "bcryptjs": "^2.4.3",
19 - "dotenv": "^8.2.0",
20 - "graphql-tools": "^4.0.7",
21 - "graphql-yoga": "^1.18.3",
22 - "jsonwebtoken": "^8.5.1",
23 - "merge-graphql-schemas": "^1.7.7",
24 - "nodemailer": "^6.4.6",
25 - "nodemailer-sendgrid-transport": "^0.2.0",
26 - "twilio": "^3.42.2"
27 - },
28 - "devDependencies": {
29 - "@babel/core": "^7.9.0",
30 - "@babel/node": "^7.8.7",
31 - "@babel/preset-env": "^7.9.0",
32 - "@prisma/cli": "^2.0.0-beta.2",
33 - "morgan": "^1.10.0",
34 - "nodemon": "^2.0.2"
35 - }
36 -}
1 -FROM node:12.16.2
2 -RUN npm i -g @prisma/cli
3 -
4 -RUN mkdir /app
5 -WORKDIR /app
6 -
7 -COPY ./ ./prisma/
8 -
9 -CMD ["prisma", "studio", "--experimental"]
...\ No newline at end of file ...\ No newline at end of file
1 -# Migration `20200419160117-init`
2 -
3 -This migration has been generated by sdy at 4/19/2020, 4:01:17 PM.
4 -You can check out the [state of the schema](./schema.prisma) after the migration.
5 -
6 -## Database Steps
7 -
8 -```sql
9 -CREATE TABLE `chat_schema`.`User` (
10 - `avatarUrl` varchar(191) ,
11 - `bio` varchar(191) ,
12 - `createdAt` datetime DEFAULT CURRENT_TIMESTAMP ,
13 - `email` varchar(191) NOT NULL ,
14 - `id` int NOT NULL AUTO_INCREMENT,
15 - `loginSecret` varchar(191) ,
16 - `name` varchar(191) NOT NULL ,
17 - `password` varchar(191) NOT NULL ,
18 - PRIMARY KEY (`id`)
19 -)
20 -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
21 -
22 -CREATE TABLE `chat_schema`.`Room` (
23 - `id` int NOT NULL AUTO_INCREMENT,
24 - PRIMARY KEY (`id`)
25 -)
26 -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
27 -
28 -CREATE TABLE `chat_schema`.`Category` (
29 - `id` int NOT NULL AUTO_INCREMENT,
30 - `name` varchar(191) DEFAULT '' ,
31 - PRIMARY KEY (`id`)
32 -)
33 -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
34 -
35 -CREATE TABLE `chat_schema`.`Message` (
36 - `id` int NOT NULL AUTO_INCREMENT,
37 - `senderId` int NOT NULL ,
38 - `text` varchar(191) DEFAULT '' ,
39 - PRIMARY KEY (`id`)
40 -)
41 -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
42 -
43 -CREATE TABLE `chat_schema`.`_RoomToUser` (
44 - `A` int NOT NULL ,
45 - `B` int NOT NULL
46 -)
47 -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
48 -
49 -CREATE TABLE `chat_schema`.`_CategoryToRoom` (
50 - `A` int NOT NULL ,
51 - `B` int NOT NULL
52 -)
53 -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
54 -
55 -CREATE UNIQUE INDEX `User.email` ON `chat_schema`.`User`(`email`)
56 -
57 -CREATE UNIQUE INDEX `_RoomToUser_AB_unique` ON `chat_schema`.`_RoomToUser`(`A`,`B`)
58 -
59 -CREATE INDEX `_RoomToUser_B_index` ON `chat_schema`.`_RoomToUser`(`B`)
60 -
61 -CREATE UNIQUE INDEX `_CategoryToRoom_AB_unique` ON `chat_schema`.`_CategoryToRoom`(`A`,`B`)
62 -
63 -CREATE INDEX `_CategoryToRoom_B_index` ON `chat_schema`.`_CategoryToRoom`(`B`)
64 -
65 -ALTER TABLE `chat_schema`.`Message` ADD FOREIGN KEY (`senderId`) REFERENCES `chat_schema`.`User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
66 -
67 -ALTER TABLE `chat_schema`.`_RoomToUser` ADD FOREIGN KEY (`A`) REFERENCES `chat_schema`.`Room`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
68 -
69 -ALTER TABLE `chat_schema`.`_RoomToUser` ADD FOREIGN KEY (`B`) REFERENCES `chat_schema`.`User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
70 -
71 -ALTER TABLE `chat_schema`.`_CategoryToRoom` ADD FOREIGN KEY (`A`) REFERENCES `chat_schema`.`Category`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
72 -
73 -ALTER TABLE `chat_schema`.`_CategoryToRoom` ADD FOREIGN KEY (`B`) REFERENCES `chat_schema`.`Room`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
74 -
75 -DROP TABLE `chat_schema`.`_migration`;
76 -
77 -DROP TABLE `chat_schema`.`test`;
78 -```
79 -
80 -## Changes
81 -
82 -```diff
83 -diff --git schema.prisma schema.prisma
84 -migration ..20200419160117-init
85 ---- datamodel.dml
86 -+++ datamodel.dml
87 -@@ -1,0 +1,41 @@
88 -+generator client {
89 -+ provider = "prisma-client-js"
90 -+ binaryTargets = ["native", "debian-openssl-1.1.x"]
91 -+}
92 -+
93 -+datasource db {
94 -+ provider = "mysql"
95 -+ url = env("DATABASE_URL")
96 -+}
97 -+
98 -+model User {
99 -+ id Int @default(autoincrement()) @id
100 -+ avatarUrl String?
101 -+ email String @unique
102 -+ password String
103 -+ name String
104 -+ loginSecret String?
105 -+ bio String?
106 -+ rooms Room[] @relation(references: [id])
107 -+ messages Message[]
108 -+ createdAt DateTime? @default(now())
109 -+}
110 -+
111 -+model Room {
112 -+ id Int @default(autoincrement()) @id
113 -+ participants User[] @relation(references: [id])
114 -+ categories Category[] @relation(references: [id])
115 -+}
116 -+
117 -+model Category {
118 -+ id Int @default(autoincrement()) @id
119 -+ name String? @default("")
120 -+ rooms Room[] @relation(references: [id])
121 -+}
122 -+
123 -+model Message {
124 -+ id Int @default(autoincrement()) @id
125 -+ text String? @default("")
126 -+ sender User @relation(fields: [senderId], references: [id])
127 -+ senderId Int
128 -+}
129 -```
130 -
131 -
1 -generator client {
2 - provider = "prisma-client-js"
3 - binaryTargets = ["native", "debian-openssl-1.1.x"]
4 -}
5 -
6 -datasource db {
7 - provider = "mysql"
8 - url = "***"
9 -}
10 -
11 -model User {
12 - id Int @default(autoincrement()) @id
13 - avatarUrl String?
14 - email String @unique
15 - password String
16 - name String
17 - loginSecret String?
18 - bio String?
19 - rooms Room[] @relation(references: [id])
20 - messages Message[]
21 - createdAt DateTime? @default(now())
22 -}
23 -
24 -model Room {
25 - id Int @default(autoincrement()) @id
26 - participants User[] @relation(references: [id])
27 - categories Category[] @relation(references: [id])
28 -}
29 -
30 -model Category {
31 - id Int @default(autoincrement()) @id
32 - name String? @default("")
33 - rooms Room[] @relation(references: [id])
34 -}
35 -
36 -model Message {
37 - id Int @default(autoincrement()) @id
38 - text String? @default("")
39 - sender User @relation(fields: [senderId], references: [id])
40 - senderId Int
41 -}
...\ No newline at end of file ...\ No newline at end of file
1 -# Migration `20200424124259-init`
2 -
3 -This migration has been generated by sdy at 4/24/2020, 12:42:59 PM.
4 -You can check out the [state of the schema](./schema.prisma) after the migration.
5 -
6 -## Database Steps
7 -
8 -```sql
9 -CREATE TABLE `chat_schema`.`User` (
10 - `avatarUrl` varchar(191) ,
11 - `bio` varchar(191) ,
12 - `createdAt` datetime DEFAULT CURRENT_TIMESTAMP ,
13 - `email` varchar(191) NOT NULL ,
14 - `emailSecret` varchar(191) ,
15 - `id` int NOT NULL AUTO_INCREMENT,
16 - `name` varchar(191) NOT NULL ,
17 - `password` varchar(191) NOT NULL ,
18 - `phoneNumber` int ,
19 - `phoneSecret` varchar(191) ,
20 - PRIMARY KEY (`id`)
21 -)
22 -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
23 -
24 -CREATE TABLE `chat_schema`.`Room` (
25 - `id` int NOT NULL AUTO_INCREMENT,
26 - PRIMARY KEY (`id`)
27 -)
28 -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
29 -
30 -CREATE TABLE `chat_schema`.`Category` (
31 - `id` int NOT NULL AUTO_INCREMENT,
32 - `name` varchar(191) DEFAULT '' ,
33 - PRIMARY KEY (`id`)
34 -)
35 -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
36 -
37 -CREATE TABLE `chat_schema`.`Message` (
38 - `id` int NOT NULL AUTO_INCREMENT,
39 - `senderId` int NOT NULL ,
40 - `text` varchar(191) DEFAULT '' ,
41 - PRIMARY KEY (`id`)
42 -)
43 -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
44 -
45 -CREATE TABLE `chat_schema`.`_RoomToUser` (
46 - `A` int NOT NULL ,
47 - `B` int NOT NULL
48 -)
49 -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
50 -
51 -CREATE TABLE `chat_schema`.`_CategoryToRoom` (
52 - `A` int NOT NULL ,
53 - `B` int NOT NULL
54 -)
55 -DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
56 -
57 -CREATE UNIQUE INDEX `User.email` ON `chat_schema`.`User`(`email`)
58 -
59 -CREATE UNIQUE INDEX `_RoomToUser_AB_unique` ON `chat_schema`.`_RoomToUser`(`A`,`B`)
60 -
61 -CREATE INDEX `_RoomToUser_B_index` ON `chat_schema`.`_RoomToUser`(`B`)
62 -
63 -CREATE UNIQUE INDEX `_CategoryToRoom_AB_unique` ON `chat_schema`.`_CategoryToRoom`(`A`,`B`)
64 -
65 -CREATE INDEX `_CategoryToRoom_B_index` ON `chat_schema`.`_CategoryToRoom`(`B`)
66 -
67 -ALTER TABLE `chat_schema`.`Message` ADD FOREIGN KEY (`senderId`) REFERENCES `chat_schema`.`User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
68 -
69 -ALTER TABLE `chat_schema`.`_RoomToUser` ADD FOREIGN KEY (`A`) REFERENCES `chat_schema`.`Room`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
70 -
71 -ALTER TABLE `chat_schema`.`_RoomToUser` ADD FOREIGN KEY (`B`) REFERENCES `chat_schema`.`User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
72 -
73 -ALTER TABLE `chat_schema`.`_CategoryToRoom` ADD FOREIGN KEY (`A`) REFERENCES `chat_schema`.`Category`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
74 -
75 -ALTER TABLE `chat_schema`.`_CategoryToRoom` ADD FOREIGN KEY (`B`) REFERENCES `chat_schema`.`Room`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
76 -
77 -DROP TABLE `chat_schema`.`_categorytoroom`;
78 -
79 -DROP TABLE `chat_schema`.`_migration`;
80 -
81 -DROP TABLE `chat_schema`.`_roomtouser`;
82 -
83 -DROP TABLE `chat_schema`.`category`;
84 -
85 -DROP TABLE `chat_schema`.`message`;
86 -
87 -DROP TABLE `chat_schema`.`room`;
88 -
89 -DROP TABLE `chat_schema`.`test`;
90 -
91 -DROP TABLE `chat_schema`.`user`;
92 -```
93 -
94 -## Changes
95 -
96 -```diff
97 -diff --git schema.prisma schema.prisma
98 -migration 20200419160117-init..20200424124259-init
99 ---- datamodel.dml
100 -+++ datamodel.dml
101 -@@ -4,18 +4,20 @@
102 - }
103 - datasource db {
104 - provider = "mysql"
105 -- url = "***"
106 -+ url = env("DATABASE_URL")
107 - }
108 - model User {
109 - id Int @default(autoincrement()) @id
110 - avatarUrl String?
111 - email String @unique
112 - password String
113 - name String
114 -- loginSecret String?
115 -+ phoneNumber Int?
116 -+ emailSecret String?
117 -+ phoneSecret String?
118 - bio String?
119 - rooms Room[] @relation(references: [id])
120 - messages Message[]
121 - createdAt DateTime? @default(now())
122 -```
123 -
124 -
1 -generator client {
2 - provider = "prisma-client-js"
3 - binaryTargets = ["native", "debian-openssl-1.1.x"]
4 -}
5 -
6 -datasource db {
7 - provider = "mysql"
8 - url = "***"
9 -}
10 -
11 -model User {
12 - id Int @default(autoincrement()) @id
13 - avatarUrl String?
14 - email String @unique
15 - password String
16 - name String
17 - phoneNumber Int?
18 - emailSecret String?
19 - phoneSecret String?
20 - bio String?
21 - rooms Room[] @relation(references: [id])
22 - messages Message[]
23 - createdAt DateTime? @default(now())
24 -}
25 -
26 -model Room {
27 - id Int @default(autoincrement()) @id
28 - participants User[] @relation(references: [id])
29 - categories Category[] @relation(references: [id])
30 -}
31 -
32 -model Category {
33 - id Int @default(autoincrement()) @id
34 - name String? @default("")
35 - rooms Room[] @relation(references: [id])
36 -}
37 -
38 -model Message {
39 - id Int @default(autoincrement()) @id
40 - text String? @default("")
41 - sender User @relation(fields: [senderId], references: [id])
42 - senderId Int
43 -}
...\ No newline at end of file ...\ No newline at end of file
1 -{
2 - "version": "0.3.14-fixed",
3 - "steps": [
4 - {
5 - "tag": "CreateField",
6 - "model": "User",
7 - "field": "phoneNumber",
8 - "type": "Int",
9 - "arity": "Optional"
10 - },
11 - {
12 - "tag": "CreateField",
13 - "model": "User",
14 - "field": "emailSecret",
15 - "type": "String",
16 - "arity": "Optional"
17 - },
18 - {
19 - "tag": "CreateField",
20 - "model": "User",
21 - "field": "phoneSecret",
22 - "type": "String",
23 - "arity": "Optional"
24 - },
25 - {
26 - "tag": "DeleteField",
27 - "model": "User",
28 - "field": "loginSecret"
29 - }
30 - ]
31 -}
...\ No newline at end of file ...\ No newline at end of file
1 -# IF THERE'S A GIT CONFLICT IN THIS FILE, DON'T SOLVE IT MANUALLY!
2 -# INSTEAD EXECUTE `prisma migrate fix`
3 -# Prisma Migrate lockfile v1
4 -# Read more about conflict resolution here: TODO
5 -
6 -20200419160117-init
7 -20200424124259-init
...\ No newline at end of file ...\ No newline at end of file
1 -generator client {
2 - provider = "prisma-client-js"
3 - binaryTargets = ["native", "debian-openssl-1.1.x"]
4 -}
5 -
6 -datasource db {
7 - provider = "mysql"
8 - url = env("DATABASE_URL")
9 -}
10 -
11 -model User {
12 - id Int @default(autoincrement()) @id
13 - avatarUrl String?
14 - email String @unique
15 - password String
16 - name String
17 - phoneNumber String? @unique
18 - emailSecret String?
19 - phoneSecret String?
20 - bio String?
21 - rooms Room[] @relation(references: [id])
22 - messages Message[]
23 - createdAt DateTime? @default(now())
24 -}
25 -
26 -model Room {
27 - id Int @default(autoincrement()) @id
28 - participants User[] @relation(references: [id])
29 - categories Category[] @relation(references: [id])
30 -}
31 -
32 -model Category {
33 - id Int @default(autoincrement()) @id
34 - name String? @default("")
35 - rooms Room[] @relation(references: [id])
36 -}
37 -
38 -model Message {
39 - id Int @default(autoincrement()) @id
40 - text String? @default("")
41 - sender User @relation(fields: [senderId], references: [id])
42 - senderId Int
43 -}
...\ No newline at end of file ...\ No newline at end of file
1 -type Mutation {
2 - addCategory(name: String): Category!
3 -}
1 -import { prisma } from "../../../utils";
2 -
3 -export default {
4 - Mutation: {
5 - addCategory: async (_, args) => {
6 - const { name } = args;
7 - },
8 - },
9 -};
1 -type Mutation {
2 - deleteCategory(id: String!): Boolean!
3 -}
1 -import { prisma } from "../../../utils";
2 -
3 -export default {
4 - Mutation: {
5 - deleteCategory: async (_, args) => {
6 - const { id } = args;
7 - },
8 - },
9 -};
1 -type Mutation {
2 - editCategory(id: String!): Category!
3 -}
1 -import { prisma } from "../../../utils";
2 -
3 -export default {
4 - Mutation: {
5 - editCategory: async (_, args) => {
6 - const { id } = args;
7 - },
8 - },
9 -};
1 -type Subscription {
2 - sendMessage(message: String!): Message!
3 -}
1 -import { prisma } from "../../../utils";
2 -
3 -export default {
4 - Subscription: {
5 - sendMessage: async (_, args) => {
6 - const { message } = args;
7 - },
8 - },
9 -};
1 -type Mutation {
2 - exitRoom(roomId: String!): Boolean!
3 -}
1 -import { prisma } from "../../../utils";
2 -
3 -export default {
4 - Mutation: {
5 - exitRoom: async (_, args) => {
6 - const { roomId } = args;
7 - },
8 - },
9 -};
1 -type Query {
2 - seeRoom(id: String!): Room!
3 -}
1 -import { prisma } from "../../../utils";
2 -
3 -export default {
4 - Query: {
5 - seeRoom: async (_, args) => {
6 - const { id } = args;
7 - },
8 - },
9 -};
1 -type Query {
2 - TestQL(text: String!): String!
3 -}
1 -export default {
2 - Query: {
3 - TestQL: async (_, args) => {
4 - const { text } = args;
5 - return text;
6 - },
7 - },
8 -};
1 -type Mutation {
2 - createAccount(
3 - name: String!
4 - email: String!
5 - password: String!
6 - bio: String
7 - avatarUrl: String
8 - ): AuthPayload!
9 -}
1 -import { prisma, generateToken } from "../../../utils";
2 -import bcrypt from "bcryptjs";
3 -
4 -export default {
5 - Mutation: {
6 - createAccount: async (_, args) => {
7 - const { name, password, email, bio = "", avatarUrl = "" } = args;
8 - const encryptPw = await bcrypt.hash(password, 10);
9 - const user = await prisma.user.create({
10 - data: {
11 - name,
12 - email,
13 - bio,
14 - avatarUrl,
15 - password: encryptPw,
16 - },
17 - });
18 - const token = generateToken(user.id);
19 - return { token, user };
20 - },
21 - },
22 -};
1 -type Mutation {
2 - editProfile(
3 - name: String
4 - email: String
5 - bio: String
6 - avatarUrl: String
7 - ): User!
8 -}
1 -import { prisma } from "../../../utils";
2 -
3 -export default {
4 - Mutation: {
5 - editProfile: async (_, args, { request }) => {},
6 - },
7 -};
1 -type Query {
2 - findEmail(phoneNumber: String!): User!
3 -}
1 -import { prisma, generateSecret } from "../../../utils";
2 -import twilio from "twilio";
3 -
4 -export default {
5 - Query: {
6 - findEmail: async (_, args) => {
7 - const { phoneNumber } = args;
8 - const accountSid = process.env.TWILIO_SID;
9 - const authToken = process.env.TWILIO_AUTH_TOKEN;
10 - const client = new twilio(accountSid, authToken);
11 - const randomWords = generateSecret();
12 - client.messages
13 - .create({
14 - body: `Please enter this word : ${randomWords}`,
15 - to: `${phoneNumber}`,
16 - from: "KhuChat",
17 - })
18 - .then((message) => console.log(message.sid));
19 -
20 - const user = await prisma.user.update({
21 - where: {
22 - phoneNumber,
23 - },
24 - data: {
25 - phoneSecret: randomWords,
26 - },
27 - });
28 - return user;
29 - },
30 - },
31 -};
1 -type Mutation {
2 - login(email: String!, password: String!): AuthPayload
3 -}
1 -import { prisma } from "../../../utils";
2 -import bcrypt from "bcryptjs";
3 -import jwt from "jsonwebtoken";
4 -
5 -export default {
6 - Mutation: {
7 - login: async (_, args) => {
8 - const { email, password } = args;
9 - const user = await prisma.user.findOne({
10 - where: {
11 - email,
12 - },
13 - });
14 - let vaild;
15 - if (user) {
16 - vaild = await bcrypt.compare(password, user.password);
17 - }
18 - if (!user || !vaild) {
19 - throw new Error("Not vaild email or password");
20 - }
21 - const token = jwt.sign({ id: user.id }, process.env.JWT_SECRET);
22 - return { token, user };
23 - },
24 - },
25 -};
1 -type Mutation {
2 - requestEmailSecret(email: String!): Boolean!
3 -}
1 -import { prisma, generateSecret, sendSecretMail } from "../../../utils";
2 -import bcrypt from "bcryptjs";
3 -
4 -export default {
5 - Mutation: {
6 - requestEmailSecret: async (_, args) => {
7 - const { email } = args;
8 - const emailSecret = generateSecret();
9 - const encryptSecret = await bcrypt.hash(emailSecret, 10);
10 - try {
11 - await sendSecretMail(email, emailSecret);
12 - await prisma.user.update({
13 - where: {
14 - email,
15 - },
16 - data: {
17 - emailSecret: encryptSecret,
18 - },
19 - });
20 - return true;
21 - } catch (error) {
22 - console.log(error);
23 - return false;
24 - }
25 - },
26 - },
27 -};
1 -type Mutation {
2 - resetPassword(
3 - secret: String!
4 - email: String!
5 - passwordOne: String!
6 - passwordTwo: String!
7 - ): User!
8 -}
1 -import { prisma } from "../../../utils";
2 -import bcrypt from "bcryptjs";
3 -
4 -export default {
5 - Mutation: {
6 - resetPassword: async (_, args) => {
7 - const { secret, email, passwordOne, passwordTwo } = args;
8 - const user = await prisma.user.findOne({
9 - where: {
10 - email,
11 - },
12 - });
13 - const encryptSecret = await bcrypt.hash(user.emailSecret, 10);
14 - if (encryptSecret !== secret) {
15 - throw new Error(
16 - "not vaild secret value!, input another value or resend email"
17 - );
18 - } else {
19 - if (passwordOne !== passwordTwo) {
20 - // For check new password is right, the two things must be same.
21 - throw new Error("the two password don't match each other, try again");
22 - } else {
23 - await prisma.user.update({
24 - where: {
25 - email,
26 - },
27 - data: {
28 - emailSecret: "",
29 - password: passwordOne,
30 - },
31 - });
32 - }
33 - return user;
34 - }
35 - },
36 - },
37 -};
1 -type Query {
2 - searchUser(name: String!): [User!]!
3 -}
1 -import { prisma } from "../../../utils";
2 -
3 -export default {
4 - Query: {
5 - searchUser: async (_, args) => {
6 - const { name } = args;
7 - const user = await prisma.user.findOne({});
8 - },
9 - },
10 -};
1 -type Query {
2 - seeProfile(id: String!): User!
3 -}
1 -import { prisma } from "../../../utils";
2 -
3 -export default {
4 - Query: {
5 - seeProfile: async (_, args) => {
6 - const { id } = args;
7 - },
8 - },
9 -};
1 -type User {
2 - id: ID!
3 - avatarUrl: String
4 - name: String
5 - email: String!
6 - password: String
7 - phoneNumber: String
8 - emailSecret: String
9 - phoneSecret: String
10 - bio: String
11 - rooms: [Room]
12 - createdAt: String
13 - messages: [Message]
14 -}
15 -
16 -type Room {
17 - id: ID!
18 - participants: [User]
19 - categories: [Category]
20 -}
21 -
22 -type Category {
23 - id: ID!
24 - name: String
25 - rooms: [Room]
26 -}
27 -
28 -type Message {
29 - id: ID!
30 - text: String
31 - sender: User
32 -}
33 -
34 -type AuthPayload {
35 - token: String
36 - user: User
37 -}
1 -import path from "path";
2 -import { makeExecutableSchema } from "graphql-tools";
3 -import { fileLoader, mergeResolvers, mergeTypes } from "merge-graphql-schemas";
4 -
5 -const allTypes = fileLoader(path.join(__dirname, "api/**/*.graphql"));
6 -const allResolvers = fileLoader(path.join(__dirname, "api/**/*.js"));
7 -
8 -const schema = makeExecutableSchema({
9 - typeDefs: mergeTypes(allTypes),
10 - resolvers: mergeResolvers(allResolvers),
11 -});
12 -
13 -export default schema;
1 -import dotenv from "dotenv";
2 -dotenv.config();
3 -import { GraphQLServer } from "graphql-yoga";
4 -import morgan from "morgan";
5 -import schema from "./schema";
6 -import { prisma } from "./utils";
7 -
8 -const PORT = process.env.PORT;
9 -
10 -const server = new GraphQLServer({
11 - schema,
12 - context: (request) => {
13 - return {
14 - ...request,
15 - prisma,
16 - };
17 - },
18 -});
19 -
20 -server.express.use(morgan("dev"));
21 -
22 -server.start(() => console.log(`server is running : http://localhost:${PORT}`));
1 -import { PrismaClient } from "@prisma/client";
2 -import { nouns, adjectives } from "./words";
3 -import jwt from "jsonwebtoken";
4 -import nodemailer from "nodemailer";
5 -import sgTransport from "nodemailer-sendgrid-transport";
6 -
7 -export const prisma = new PrismaClient();
8 -
9 -export const getUserId = (context) => {
10 - const Authorization = context.request.get("Authorization");
11 - if (Authorization) {
12 - const token = Authorization.replace("Bearer ", "");
13 - const { userId } = jwt.verify(token, process.env.JWT_SECRET);
14 - return userId;
15 - }
16 - throw new Error("There is no vaild user");
17 -};
18 -
19 -export const generateSecret = () => {
20 - const randomNumber = Math.floor(Math.random() * adjectives.length);
21 - return `${adjectives[randomNumber]} ${nouns[randomNumber]}`;
22 -};
23 -
24 -const sendEmail = (email) => {
25 - const options = {
26 - auth: {
27 - api_user: process.env.SENDGRID_USERNAME,
28 - api_password: process.env.SENDGRID_PASSWORD,
29 - },
30 - };
31 - const client = nodemailer.createTransport(sgTransport(options));
32 - return client.sendMail(email);
33 -};
34 -
35 -export const sendSecretMail = (address, emailSecret, value) => {
36 - const email = {
37 - from: "vel1024@khu.ac.kr",
38 - to: address,
39 - subject: `Authentication key for forgotten ${value}`,
40 - html: `Hello, This is khuchat, authentication key is <b>${emailSecret}</b>, copy and paste it, Thanks.`,
41 - };
42 - return sendEmail(email);
43 -};
44 -
45 -export const generateToken = (id) => jwt.sign({ id }, process.env.JWT_SECRET);
1 -export const adjectives = [
2 - "languid",
3 - "expensive",
4 - "careful",
5 - "feeble",
6 - "inconclusive",
7 - "damp",
8 - "obscene",
9 - "optimal",
10 - "learned",
11 - "measly",
12 - "silent",
13 - "absurd",
14 - "hypnotic",
15 - "smart",
16 - "horrible",
17 - "deep",
18 - "grotesque",
19 - "rigid",
20 - "sweltering",
21 - "quirky",
22 - "pointless",
23 - "spiffy",
24 - "cheap",
25 - "psychotic",
26 - "possible",
27 - "burly",
28 - "huge",
29 - "tranquil",
30 - "impolite",
31 - "clear",
32 - "groovy",
33 - "royal",
34 - "envious",
35 - "voracious",
36 - "substantial",
37 - "gusty",
38 - "absorbing",
39 - "wealthy",
40 - "fancy",
41 - "ultra",
42 - "giant",
43 - "harmonious",
44 - "nauseating",
45 - "literate",
46 - "friendly",
47 - "panicky",
48 - "utopian",
49 - "happy",
50 - "gaudy",
51 - "direful",
52 - "descriptive",
53 - "better",
54 - "ambiguous",
55 - "momentous",
56 - "obsequious",
57 - "secret",
58 - "clever",
59 - "far",
60 - "temporary",
61 - "unable",
62 - "normal",
63 - "imported",
64 - "three",
65 - "five",
66 - "petite",
67 - "natural",
68 - "early",
69 - "profuse",
70 - "flimsy",
71 - "bustling",
72 - "scrawny",
73 - "present",
74 - "gruesome",
75 - "cut",
76 - "fantastic",
77 - "grandiose",
78 - "second-hand",
79 - "noiseless",
80 - "craven",
81 - "grubby",
82 - "vengeful",
83 - "tiny",
84 - "wiry",
85 - "auspicious",
86 - "dull",
87 - "quiet",
88 - "terrific",
89 - "furry",
90 - "crooked",
91 - "wholesale",
92 - "panoramic",
93 - "forgetful",
94 - "gamy",
95 - "victorious",
96 - "special",
97 - "neighborly",
98 - "useful",
99 - "chubby",
100 - "probable",
101 - "abnormal",
102 -];
103 -
104 -export const nouns = [
105 - "rat",
106 - "start",
107 - "icicle",
108 - "hobbies",
109 - "books",
110 - "dress",
111 - "board",
112 - "scale",
113 - "cattle",
114 - "quince",
115 - "cabbage",
116 - "chance",
117 - "attack",
118 - "linen",
119 - "swing",
120 - "skin",
121 - "channel",
122 - "discovery",
123 - "window",
124 - "watch",
125 - "collar",
126 - "creature",
127 - "fall",
128 - "rod",
129 - "skirt",
130 - "trousers",
131 - "guitar",
132 - "pest",
133 - "middle",
134 - "holiday",
135 - "invention",
136 - "pump",
137 - "morning",
138 - "reaction",
139 - "wash",
140 - "cloth",
141 - "hydrant",
142 - "committee",
143 - "meeting",
144 - "star",
145 - "pigs",
146 - "bikes",
147 - "plant",
148 - "stomach",
149 - "transport",
150 - "hole",
151 - "library",
152 - "tank",
153 - "hands",
154 - "offer",
155 - "slip",
156 - "chicken",
157 - "sand",
158 - "wilderness",
159 - "sweater",
160 - "frogs",
161 - "basket",
162 - "flesh",
163 - "cook",
164 - "girl",
165 - "queen",
166 - "nut",
167 - "force",
168 - "laborer",
169 - "basin",
170 - "lumber",
171 - "mine",
172 - "mountain",
173 - "insect",
174 - "store",
175 - "experience",
176 - "credit",
177 - "meat",
178 - "taste",
179 - "iron",
180 - "regret",
181 - "sleep",
182 - "notebook",
183 - "powder",
184 - "fuel",
185 - "lace",
186 - "volleyball",
187 - "look",
188 - "ticket",
189 - "place",
190 - "digestion",
191 - "point",
192 - "crook",
193 - "train",
194 - "judge",
195 - "time",
196 - "truck",
197 - "record",
198 - "sheet",
199 - "join",
200 - "achiever",
201 - "spring",
202 - "death",
203 - "potato",
204 - "liquid",
205 -];
This diff is collapsed. Click to expand it.
1 -version: "3.7"
2 -services:
3 - mysql:
4 - image: mysql:8.0.19
5 - container_name: mysql
6 - ports:
7 - - 3306:3306
8 - restart: always
9 - environment:
10 - MYSQL_DATABASE: prisma
11 - MYSQL_ROOT_PASSWORD: prisma
12 - volumes:
13 - - /var/lib/mysql
14 - prisma:
15 - links:
16 - - mysql
17 - depends_on:
18 - - mysql
19 - container_name: prisma
20 - ports:
21 - - "5555:5555"
22 - build:
23 - context: ./back/prisma
24 - dockerfile: Dockerfile
25 - environment:
26 - MYSQL_URL: ${MYSQL_URL}
27 - MYSQL_DATABASE: prisma
28 - MYSQL_ROOT_PASSWORD: prisma
29 - volumes:
30 - - /app/prisma
31 - backend:
32 - links:
33 - - mysql
34 - depends_on:
35 - - mysql
36 - container_name: backend
37 - ports:
38 - - "4000:4000"
39 - build:
40 - context: ./back
41 - dockerfile: Dockerfile
42 - environment:
43 - MYSQL_URL: ${MYSQL_URL}
44 - FRONTEND_URL: ${FRONTEND_URL}
45 - volumes:
46 - - ./back:/usr/src/app
47 - - ./back/node_modules:/usr/src/app/node_modules
48 - - ./back/prisma:/usr/src/app/prisma
49 - frontend:
50 - container_name: frontend
51 - ports:
52 - - "3000:3000"
53 - tty: "true"
54 - build:
55 - context: ./front
56 - dockerfile: Dockerfile
57 - command: npm start
58 - environment:
59 - - NODE_ENV=development
60 - - CHOKIDAR_USEPOLLING=true
61 - - BACKEND_URL=${BACKEND_URL}
62 - volumes:
63 - - ./front:/usr/src/app
1 -node_modules
...\ No newline at end of file ...\ No newline at end of file
1 -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 -
3 -# dependencies
4 -/node_modules
5 -/.pnp
6 -.pnp.js
7 -
8 -# testing
9 -/coverage
10 -
11 -# production
12 -/build
13 -
14 -# misc
15 -.DS_Store
16 -.env.local
17 -.env.development.local
18 -.env.test.local
19 -.env.production.local
20 -
21 -npm-debug.log*
22 -yarn-debug.log*
23 -yarn-error.log*
1 -FROM node:12.16.2
2 -
3 -RUN mkdir /app
4 -WORKDIR /app
5 -
6 -COPY package*.json ./
7 -
8 -RUN npm install
9 -
10 -COPY . .
...\ No newline at end of file ...\ No newline at end of file
1 -# Capstone design
2 -
3 -1st semester capstone design project
4 -
5 -Subject : Making website in order to practice web tech
6 -
7 -sub-subject : making chat site using JS
...\ No newline at end of file ...\ No newline at end of file
This diff could not be displayed because it is too large.
1 -{
2 - "name": "capstone-front",
3 - "version": "0.1.0",
4 - "private": true,
5 - "dependencies": {
6 - "@testing-library/jest-dom": "^4.2.4",
7 - "@testing-library/react": "^9.3.2",
8 - "@testing-library/user-event": "^7.1.2",
9 - "apollo-boost": "^0.4.7",
10 - "core-js": "^3.6.5",
11 - "graphql": "^15.0.0",
12 - "react": "^16.13.1",
13 - "react-apollo-hooks": "^0.5.0",
14 - "react-dom": "^16.13.1",
15 - "react-hooks": "^1.0.1",
16 - "react-router": "^5.1.2",
17 - "react-router-dom": "^5.1.2",
18 - "react-scripts": "3.4.1",
19 - "react-toastify": "^5.5.0",
20 - "styled-components": "^5.1.0",
21 - "styled-reset": "^4.1.3"
22 - },
23 - "scripts": {
24 - "start": "react-scripts start",
25 - "build": "react-scripts build",
26 - "test": "react-scripts test",
27 - "eject": "react-scripts eject"
28 - },
29 - "eslintConfig": {
30 - "extends": "react-app"
31 - },
32 - "browserslist": {
33 - "production": [
34 - ">0.2%",
35 - "not dead",
36 - "not op_mini all"
37 - ],
38 - "development": [
39 - "last 1 chrome version",
40 - "last 1 firefox version",
41 - "last 1 safari version"
42 - ]
43 - }
44 -}
No preview for this file type
1 -<!DOCTYPE html>
2 -<html lang="en">
3 - <head>
4 - <meta charset="utf-8" />
5 - <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6 - <meta name="viewport" content="width=device-width, initial-scale=1" />
7 - <meta name="theme-color" content="#000000" />
8 - <meta
9 - name="description"
10 - content="Web site created using create-react-app"
11 - />
12 - <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13 - <!--
14 - manifest.json provides metadata used when your web app is installed on a
15 - user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16 - -->
17 - <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18 - <!--
19 - Notice the use of %PUBLIC_URL% in the tags above.
20 - It will be replaced with the URL of the `public` folder during the build.
21 - Only files inside the `public` folder can be referenced from the HTML.
22 -
23 - Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24 - work correctly both with client-side routing and a non-root public URL.
25 - Learn how to configure a non-root public URL by running `npm run build`.
26 - -->
27 - <title>React App</title>
28 - </head>
29 - <body>
30 - <noscript>You need to enable JavaScript to run this app.</noscript>
31 - <div id="root"></div>
32 - <!--
33 - This HTML file is a template.
34 - If you open it directly in the browser, you will see an empty page.
35 -
36 - You can add webfonts, meta tags, or analytics to this file.
37 - The build step will place the bundled scripts into the <body> tag.
38 -
39 - To begin the development, run `npm start` or `yarn start`.
40 - To create a production bundle, use `npm run build` or `yarn build`.
41 - -->
42 - </body>
43 -</html>
1 -{
2 - "short_name": "React App",
3 - "name": "Create React App Sample",
4 - "icons": [
5 - {
6 - "src": "favicon.ico",
7 - "sizes": "64x64 32x32 24x24 16x16",
8 - "type": "image/x-icon"
9 - },
10 - {
11 - "src": "logo192.png",
12 - "type": "image/png",
13 - "sizes": "192x192"
14 - },
15 - {
16 - "src": "logo512.png",
17 - "type": "image/png",
18 - "sizes": "512x512"
19 - }
20 - ],
21 - "start_url": ".",
22 - "display": "standalone",
23 - "theme_color": "#000000",
24 - "background_color": "#ffffff"
25 -}
1 -# https://www.robotstxt.org/robotstxt.html
2 -User-agent: *
3 -Disallow:
1 -import ApolloClient from "apollo-boost";
2 -import { defaults, resolvers } from "./ClientState";
3 -
4 -export default new ApolloClient({
5 - uri: "http://localhost:4000",
6 - clientState: {
7 - defaults,
8 - resolvers,
9 - },
10 -});
1 -export const defaults = {};
2 -
3 -export const resolvers = {};
1 -import React from "react";
2 -import GlobalStyles from "../Styles/GlobalStyles";
3 -import Header from "./Header";
4 -import Image from "./Image";
5 -import Grid from "./Grid";
6 -
7 -export default () => {
8 - return (
9 - <>
10 - <GlobalStyles />
11 - <Header />
12 - <Image />
13 - <Grid />
14 - </>
15 - );
16 -};
1 -import React from "react";
2 -import Styled from "styled-components";
3 -
4 -const Article = Styled.div`
5 - width: 70%;
6 - justify-content: center;
7 - align-items: center;
8 - text-align: center;
9 - margin-top: 10px;
10 - border-top: 1px solid black;
11 -`;
12 -
13 -export default () => {
14 - return (
15 - <Article>
16 - <h1>Article Title</h1>
17 - </Article>
18 - );
19 -};
1 -import React from "react";
2 -import Styled from "styled-components";
3 -import MenuList from "./MenuList";
4 -import Article from "./Article";
5 -
6 -const Grid = Styled.div`
7 - width: 100%;
8 - display: flex;
9 -`;
10 -
11 -export default () => {
12 - return (
13 - <Grid>
14 - <MenuList />
15 - <Article />
16 - </Grid>
17 - );
18 -};
1 -import React from "react";
2 -import Styled from "styled-components";
3 -
4 -const Header = Styled.div`
5 - width: 100%;
6 - display: flex;
7 - justify-content: center;
8 - margin: 10px 0px;
9 - font-size: 25px;
10 -`;
11 -
12 -export default () => {
13 - return (
14 - <Header>
15 - <h1>KHU Chatting service</h1>
16 - </Header>
17 - );
18 -};
1 -import React from "react";
2 -import Styled from "styled-components";
3 -
4 -const Image = Styled.div`
5 - width: 100%;
6 - margin: 20px 0px;
7 - display: flex;
8 - justify-content: center;
9 -`;
10 -
11 -export default () => {
12 - return (
13 - <Image>
14 - <img src="" alt="sample"></img>
15 - </Image>
16 - );
17 -};
1 -import React from "react";
2 -import Styled from "styled-components";
3 -
4 -const MenuBox = Styled.div`
5 - width: 30%;
6 - display: flex;
7 - justify-content: center;
8 - align-items: center;
9 - margin-top: 10px;
10 - border-top: 1px solid black;
11 - border-right: 1px solid black;
12 -`;
13 -
14 -const MenuList = Styled.ol`
15 -`;
16 -
17 -const MenuItem = Styled.li`
18 -`;
19 -
20 -const Link = Styled.a`
21 -`;
22 -
23 -export default () => {
24 - return (
25 - <MenuBox>
26 - <MenuList>
27 - <MenuItem>
28 - <Link href="">1. What is KHU Chat?</Link>
29 - </MenuItem>
30 - </MenuList>
31 - </MenuBox>
32 - );
33 -};
1 -export default {
2 - bgColor: "white",
3 -};
1 -import { createGlobalStyle } from "styled-components";
2 -import reset from "styled-reset";
3 -
4 -export default createGlobalStyle`
5 - ${reset}
6 - * {
7 - box-sizing: border-box;
8 - }
9 -`;
1 -import React from "react";
2 -import ReactDOM from "react-dom";
3 -import App from "./Components/App";
4 -import { ApolloProvider } from "react-apollo-hooks";
5 -import Client from "./Apollo/Client";
6 -
7 -ReactDOM.render(
8 - <ApolloProvider client={Client}>
9 - <App />
10 - </ApolloProvider>,
11 - document.getElementById("root")
12 -);
This diff could not be displayed because it is too large.
1 -{
2 - "name": "capstone",
3 - "version": "1.0.0",
4 - "description": "",
5 - "scripts": {
6 - "start": "docker-compose up",
7 - "build": "docker-compose build",
8 - "stop": "docker-compose down",
9 - "clean": "docker system prune -af",
10 - "clean:volumes": "docker volume prune -f",
11 - "seed": "docker exec -it prisma npm run seed",
12 - "reset:db": "docker-compose rm -fv mysql"
13 - },
14 - "author": {
15 - "name": "sdy, kms",
16 - "email": "vel1024@khu.ac.kr"
17 - },
18 - "license": "ISC"
19 -}