minsung

Merge branch 'master' of https://bitbucket.org/vel1024/capstone

.env
node_modules
\ No newline at end of file
......
......@@ -9,4 +9,6 @@ COPY prisma ./prisma/
RUN npm install && npx prisma generate
CMD ["npm","run","dev"]
CMD ["npm","start"]
COPY . .
\ No newline at end of file
......
......@@ -1372,6 +1372,11 @@
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw=="
},
"asap": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
"integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
},
"asn1": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
......@@ -1410,6 +1415,14 @@
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.1.tgz",
"integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug=="
},
"axios": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz",
"integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==",
"requires": {
"follow-redirects": "1.5.10"
}
},
"babel-code-frame": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
......@@ -2017,6 +2030,11 @@
"assert-plus": "^1.0.0"
}
},
"dayjs": {
"version": "1.8.25",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.25.tgz",
"integrity": "sha512-Pk36juDfQQGDCgr0Lqd1kw15w3OS6xt21JaLPE3lCfsEf8KrERGwDNwvK1tRjrjqFC0uZBJncT4smZQ4F+uV5g=="
},
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
......@@ -2472,6 +2490,24 @@
"locate-path": "^3.0.0"
}
},
"follow-redirects": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
"requires": {
"debug": "=3.1.0"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
}
}
},
"forever-agent": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
......@@ -3914,6 +3950,11 @@
}
}
},
"pop-iterate": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/pop-iterate/-/pop-iterate-1.0.1.tgz",
"integrity": "sha1-zqz9q0q/NT16DyqqLB/Hs/lBO6M="
},
"prelude-ls": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
......@@ -3963,11 +4004,26 @@
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
},
"q": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/q/-/q-2.0.3.tgz",
"integrity": "sha1-dbjbAlWhpa+C9Yw/Oqoe/sfQ0TQ=",
"requires": {
"asap": "^2.0.0",
"pop-iterate": "^1.0.1",
"weak-map": "^1.0.5"
}
},
"qs": {
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
"integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
},
"querystringify": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz",
"integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA=="
},
"range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
......@@ -4179,6 +4235,11 @@
}
}
},
"requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
},
"resolve": {
"version": "1.15.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz",
......@@ -4198,6 +4259,11 @@
"resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz",
"integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw=="
},
"rootpath": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/rootpath/-/rootpath-0.1.2.tgz",
"integrity": "sha1-Wzeah9ypBum5HWkKWZQ5vvJn6ms="
},
"run-parallel": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz",
......@@ -4219,6 +4285,11 @@
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==",
"optional": true
},
"scmp": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/scmp/-/scmp-2.1.0.tgz",
"integrity": "sha512-o/mRQGk9Rcer/jEEw/yw4mwo3EU/NvYvp577/Btqrym9Qy5/MdWGBqipbALgd2lrdWTJ5/gqDusxfnQBxOxT2Q=="
},
"semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
......@@ -4575,6 +4646,31 @@
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
"integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q="
},
"twilio": {
"version": "3.42.2",
"resolved": "https://registry.npmjs.org/twilio/-/twilio-3.42.2.tgz",
"integrity": "sha512-59vtghp5XZXCAt19Z8mqyVMmJ3ZEEp3/JPrAjVoIbLqiGuIeffM90eXx6TWUXEwVqAdVoihrqUkzVTIlCresDQ==",
"requires": {
"@types/express": "^4.17.3",
"axios": "^0.19.2",
"dayjs": "^1.8.21",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.15",
"q": "2.0.x",
"qs": "^6.9.1",
"rootpath": "^0.1.2",
"scmp": "^2.1.0",
"url-parse": "^1.4.7",
"xmlbuilder": "^13.0.2"
},
"dependencies": {
"qs": {
"version": "6.9.3",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.9.3.tgz",
"integrity": "sha512-EbZYNarm6138UKKq46tdx08Yo/q9ZhFoAXAI1meAFd2GtbRDhbZY2WQSICskT0c5q99aFzLG1D4nvTk9tqfXIw=="
}
}
},
"type-check": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
......@@ -4704,6 +4800,15 @@
"punycode": "^2.1.0"
}
},
"url-parse": {
"version": "1.4.7",
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz",
"integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==",
"requires": {
"querystringify": "^2.1.1",
"requires-port": "^1.0.0"
}
},
"url-parse-lax": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz",
......@@ -4752,6 +4857,11 @@
"extsprintf": "^1.2.0"
}
},
"weak-map": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/weak-map/-/weak-map-1.0.5.tgz",
"integrity": "sha1-eWkVhNmGB/UHC9O3CkDmuyLkAes="
},
"webidl-conversions": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-2.0.1.tgz",
......@@ -4822,6 +4932,11 @@
"integrity": "sha1-TYuPHszTQZqjYgYb7O9RXh5VljU=",
"optional": true
},
"xmlbuilder": {
"version": "13.0.2",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-13.0.2.tgz",
"integrity": "sha512-Eux0i2QdDYKbdbA6AM6xE4m6ZTZr4G4xF9kahI2ukSEMCzwce2eX9WlTI5J3s+NU7hpasFsr8hWIONae7LluAQ=="
},
"yallist": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
......
......@@ -3,7 +3,7 @@
"version": "1.0.0",
"description": "1st semester capstone design project",
"scripts": {
"dev": "nodemon --exec babel-node src/server.js",
"start": "nodemon --exec babel-node src/server.js",
"prisma": "prisma2 studio --experimental"
},
"repository": {
......@@ -22,7 +22,8 @@
"jsonwebtoken": "^8.5.1",
"merge-graphql-schemas": "^1.7.7",
"nodemailer": "^6.4.6",
"nodemailer-sendgrid-transport": "^0.2.0"
"nodemailer-sendgrid-transport": "^0.2.0",
"twilio": "^3.42.2"
},
"devDependencies": {
"@babel/core": "^7.9.0",
......
......@@ -6,4 +6,4 @@ WORKDIR /app
COPY ./ ./prisma/
CMD ["prisma", "studio", "--experimental"]
CMD ["prisma", "studio", "--experimental"]
\ No newline at end of file
......
# Migration `20200424124259-init`
This migration has been generated by sdy at 4/24/2020, 12:42:59 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
CREATE TABLE `chat_schema`.`User` (
`avatarUrl` varchar(191) ,
`bio` varchar(191) ,
`createdAt` datetime DEFAULT CURRENT_TIMESTAMP ,
`email` varchar(191) NOT NULL ,
`emailSecret` varchar(191) ,
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(191) NOT NULL ,
`password` varchar(191) NOT NULL ,
`phoneNumber` int ,
`phoneSecret` varchar(191) ,
PRIMARY KEY (`id`)
)
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
CREATE TABLE `chat_schema`.`Room` (
`id` int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
)
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
CREATE TABLE `chat_schema`.`Category` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(191) DEFAULT '' ,
PRIMARY KEY (`id`)
)
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
CREATE TABLE `chat_schema`.`Message` (
`id` int NOT NULL AUTO_INCREMENT,
`senderId` int NOT NULL ,
`text` varchar(191) DEFAULT '' ,
PRIMARY KEY (`id`)
)
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
CREATE TABLE `chat_schema`.`_RoomToUser` (
`A` int NOT NULL ,
`B` int NOT NULL
)
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
CREATE TABLE `chat_schema`.`_CategoryToRoom` (
`A` int NOT NULL ,
`B` int NOT NULL
)
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
CREATE UNIQUE INDEX `User.email` ON `chat_schema`.`User`(`email`)
CREATE UNIQUE INDEX `_RoomToUser_AB_unique` ON `chat_schema`.`_RoomToUser`(`A`,`B`)
CREATE INDEX `_RoomToUser_B_index` ON `chat_schema`.`_RoomToUser`(`B`)
CREATE UNIQUE INDEX `_CategoryToRoom_AB_unique` ON `chat_schema`.`_CategoryToRoom`(`A`,`B`)
CREATE INDEX `_CategoryToRoom_B_index` ON `chat_schema`.`_CategoryToRoom`(`B`)
ALTER TABLE `chat_schema`.`Message` ADD FOREIGN KEY (`senderId`) REFERENCES `chat_schema`.`User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
ALTER TABLE `chat_schema`.`_RoomToUser` ADD FOREIGN KEY (`A`) REFERENCES `chat_schema`.`Room`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
ALTER TABLE `chat_schema`.`_RoomToUser` ADD FOREIGN KEY (`B`) REFERENCES `chat_schema`.`User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
ALTER TABLE `chat_schema`.`_CategoryToRoom` ADD FOREIGN KEY (`A`) REFERENCES `chat_schema`.`Category`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
ALTER TABLE `chat_schema`.`_CategoryToRoom` ADD FOREIGN KEY (`B`) REFERENCES `chat_schema`.`Room`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
DROP TABLE `chat_schema`.`_categorytoroom`;
DROP TABLE `chat_schema`.`_migration`;
DROP TABLE `chat_schema`.`_roomtouser`;
DROP TABLE `chat_schema`.`category`;
DROP TABLE `chat_schema`.`message`;
DROP TABLE `chat_schema`.`room`;
DROP TABLE `chat_schema`.`test`;
DROP TABLE `chat_schema`.`user`;
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration 20200419160117-init..20200424124259-init
--- datamodel.dml
+++ datamodel.dml
@@ -4,18 +4,20 @@
}
datasource db {
provider = "mysql"
- url = "***"
+ url = env("DATABASE_URL")
}
model User {
id Int @default(autoincrement()) @id
avatarUrl String?
email String @unique
password String
name String
- loginSecret String?
+ phoneNumber Int?
+ emailSecret String?
+ phoneSecret String?
bio String?
rooms Room[] @relation(references: [id])
messages Message[]
createdAt DateTime? @default(now())
```
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-1.1.x"]
}
datasource db {
provider = "mysql"
url = "***"
}
model User {
id Int @default(autoincrement()) @id
avatarUrl String?
email String @unique
password String
name String
phoneNumber Int?
emailSecret String?
phoneSecret String?
bio String?
rooms Room[] @relation(references: [id])
messages Message[]
createdAt DateTime? @default(now())
}
model Room {
id Int @default(autoincrement()) @id
participants User[] @relation(references: [id])
categories Category[] @relation(references: [id])
}
model Category {
id Int @default(autoincrement()) @id
name String? @default("")
rooms Room[] @relation(references: [id])
}
model Message {
id Int @default(autoincrement()) @id
text String? @default("")
sender User @relation(fields: [senderId], references: [id])
senderId Int
}
\ No newline at end of file
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateField",
"model": "User",
"field": "phoneNumber",
"type": "Int",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "User",
"field": "emailSecret",
"type": "String",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "User",
"field": "phoneSecret",
"type": "String",
"arity": "Optional"
},
{
"tag": "DeleteField",
"model": "User",
"field": "loginSecret"
}
]
}
\ No newline at end of file
......@@ -3,4 +3,5 @@
# Prisma Migrate lockfile v1
# Read more about conflict resolution here: TODO
20200419160117-init
\ No newline at end of file
20200419160117-init
20200424124259-init
\ No newline at end of file
......
......@@ -14,6 +14,7 @@ model User {
email String @unique
password String
name String
phoneNumber String? @unique
emailSecret String?
phoneSecret String?
bio String?
......
type Query {
findEmail(secret: String!): User!
findEmail(phoneNumber: String!): User!
}
......
import { prisma } from "../../../utils";
import { prisma, generateSecret } from "../../../utils";
import twilio from "twilio";
export default {
Query: {
findEmail: async (_, args) => {
const { secret } = args;
const { phoneNumber } = args;
const accountSid = process.env.TWILIO_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = new twilio(accountSid, authToken);
const randomWords = generateSecret();
client.messages
.create({
body: `Please enter this word : ${randomWords}`,
to: `${phoneNumber}`,
from: "KhuChat",
})
.then((message) => console.log(message.sid));
const user = await prisma.user.update({
where: {
phoneNumber,
},
data: {
phoneSecret: randomWords,
},
});
return user;
},
},
};
......
......@@ -4,6 +4,7 @@ type User {
name: String
email: String!
password: String
phoneNumber: String
emailSecret: String
phoneSecret: String
bio: String
......
......@@ -20,7 +20,7 @@ services:
ports:
- "5555:5555"
build:
context: back/prisma
context: ./back/prisma
dockerfile: Dockerfile
environment:
MYSQL_URL: ${MYSQL_URL}
......@@ -37,22 +37,22 @@ services:
ports:
- "4000:4000"
build:
context: back
context: ./back
dockerfile: Dockerfile
environment:
MYSQL_URL: ${MYSQL_URL}
FRONTEND_URL: ${FRONTEND_URL}
volumes:
- ./back:/app
- ./back/node_modules:/app/node_modules
- ./back/prisma:/app/prisma
- ./back:/usr/src/app
- ./back/node_modules:/usr/src/app/node_modules
- ./back/prisma:/usr/src/app/prisma
frontend:
container_name: frontend
ports:
- "3000:3000"
tty: "true"
build:
context: front
context: ./front
dockerfile: Dockerfile
command: npm start
environment:
......
FROM node:12.16.2
WORKDIR /usr/src/app
RUN mkdir /app
WORKDIR /app
COPY package*.json ./
......