diff --git a/.gitignore b/.gitignore deleted file mode 100644 index c245e51..0000000 --- a/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -node_modules -dist -coverage -.awcache -test-report.* -junit.xml -*.log -*.orig -package-lock.json -yarn.lock -.awcache -public diff --git a/README.md b/README.md deleted file mode 100644 index 2540dfc..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# code-paster \ No newline at end of file diff --git a/back/.babelrc b/back/.babelrc deleted file mode 100644 index e3dc914..0000000 --- a/back/.babelrc +++ /dev/null @@ -1,17 +0,0 @@ -{ - "presets": [ - "@babel/preset-env", - "@babel/preset-typescript", - [ - { - "env": { - "development": { - "sourceMaps": true, - "retainLines": true - } - } - } - ] - ], - "plugins": ["@babel/plugin-proposal-optional-chaining"] -} diff --git a/back/.editorconfig b/back/.editorconfig deleted file mode 100644 index c6c8b36..0000000 --- a/back/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true diff --git a/back/.env b/back/.env deleted file mode 100644 index 984663d..0000000 --- a/back/.env +++ /dev/null @@ -1,2 +0,0 @@ -NODE_ENV=development -PORT=8081 diff --git a/back/.gitignore b/back/.gitignore deleted file mode 100644 index 84aa3b7..0000000 --- a/back/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -node_modules -dist -coverage -.awcache -test-report.* -junit.xml -*.log -*.orig -package-lock.json -yarn.lock -.awcache -public - diff --git a/back/.prettierrc b/back/.prettierrc deleted file mode 100644 index 099f1b2..0000000 --- a/back/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "singleQuote": true, - "trailingComma": "es5", - "endOfLine": "lf" -} diff --git a/back/.vscode/launch.json b/back/.vscode/launch.json deleted file mode 100644 index 3da094b..0000000 --- a/back/.vscode/launch.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Launch Program", - "program": "${workspaceFolder}/dist/index.js", - "preLaunchTask": "build", - "runtimeExecutable": null, - "runtimeArgs": ["--nolazy"], - "env": { - "NODE_ENV": "development" - }, - "console": "internalConsole", - "sourceMaps": true, - "outFiles": ["${workspaceRoot}/**/*.js"] - } - ] -} diff --git a/back/.vscode/tasks.json b/back/.vscode/tasks.json deleted file mode 100644 index be05538..0000000 --- a/back/.vscode/tasks.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": "2.0.0", - "command": "npm", - "type": "shell", - "tasks": [ - { - "label": "build", - "args": ["run", "build:dev"], - "group": "build" - } - ] -} diff --git a/back/README.md b/back/README.md deleted file mode 100644 index bc1bc35..0000000 --- a/back/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Scaffolding Express Typescript - -## Steps - -- Run install - -```bash -npm install -``` - -- Create `.env` file with same `.env.example` value. - -- Run development start: - -```bash -npm start -``` - -- Run debug start: - -```bash -npm run start:debug -``` - -- And run .vscode/launch.json diff --git a/back/package.json b/back/package.json deleted file mode 100644 index c4ca9cb..0000000 --- a/back/package.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "name": "scaffolding-express-typescript", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "start": "run-p -l type-check:watch start:dev", - "start:dev": "nodemon --exec babel-node --extensions \".ts\" src/index.ts", - "start:debug": "run-p -l type-check:watch \"start:dev -- --inspect-brk\"", - "start:prod": "node ./dist/index.js", - "build": "run-p -l type-check build:prod", - "build:prod": "npm run clean && babel src -d dist --ignore=\"./src/test-runners\" --extensions \".ts\"", - "build:dev": "npm run clean && babel src -d dist --ignore=\"./src/test-runners\" --extensions \".ts\" --source-maps", - "type-check": "tsc --noEmit", - "type-check:watch": "npm run type-check -- --watch", - "clean": "rimraf dist" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Lemoncode/scaffolding-express-typescript.git" - }, - "keywords": [], - "author": "", - "license": "ISC", - "bugs": { - "url": "https://github.com/Lemoncode/scaffolding-express-typescript/issues" - }, - "homepage": "https://github.com/Lemoncode/scaffolding-express-typescript#readme", - "devDependencies": { - "@babel/cli": "^7.10.5", - "@babel/core": "^7.11.1", - "@babel/node": "^7.10.5", - "@babel/plugin-proposal-optional-chaining": "^7.11.0", - "@babel/preset-env": "^7.11.0", - "@babel/preset-typescript": "^7.10.4", - "@types/cors": "^2.8.7", - "@types/express": "^4.17.7", - "@types/socket.io": "^2.1.10", - "cross-env": "^7.0.2", - "nodemon": "^2.0.4", - "npm-run-all": "^4.1.5", - "rimraf": "^3.0.2", - "typescript": "^3.9.7" - }, - "dependencies": { - "body-parser": "^1.19.0", - "cors": "^2.8.5", - "dotenv": "^8.2.0", - "express": "^4.17.1", - "regenerator-runtime": "^0.13.7", - "socket.io": "^2.3.0" - } -} diff --git a/back/src/api.ts b/back/src/api.ts deleted file mode 100644 index d83e3d5..0000000 --- a/back/src/api.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Router } from 'express'; -import { generateNewRoomName, generateNewTrainerToken } from './business'; - -export const api = Router(); - -api.get('/create-room', async (req, res) => { - const roomName = generateNewRoomName(); - const trainerToken = generateNewTrainerToken(); - res.send({ room: roomName, trainerToken: trainerToken }); -}); - -api.post('/enroll-room', async (req, res) => { - // TODO: ensure parameter is informed - const roomName = req.body.name; - - res.send({ error: roomName }); -}); diff --git a/back/src/app.ts b/back/src/app.ts deleted file mode 100644 index 593a5eb..0000000 --- a/back/src/app.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { createApp } from './express.server'; -import { envConstants } from './env.constants'; -import { api } from './api'; -import cors from 'cors'; -import SocketIOClient, { Socket } from 'socket.io'; -import { - processInputMessage, - InputMessageTypes, - processOutputMessageCollection, - Action, - SocketInfo, -} from './messages'; - -const app = createApp(); - -let http = require('http').Server(app); -// set up socket.io and bind it to our -// http server. -let io: SocketIOClient.Socket = require('socket.io')(http); - -//options for cors midddleware -const options: cors.CorsOptions = { - allowedHeaders: [ - 'Origin', - 'X-Requested-With', - 'Content-Type', - 'Accept', - 'X-Access-Token', - ], - credentials: true, - methods: 'GET,HEAD,OPTIONS,PUT,PATCH,POST,DELETE', - // IMPORTANT LIMIT HERE YOUR CLIENT APPS DOMAINS - origin: '*', - preflightContinue: false, -}; - -app.use(cors(options)); -app.use('/api', api); - -app.listen(envConstants.PORT, () => { - console.log(`Server ready at http://localhost:${envConstants.PORT}/api`); -}); - -// whenever a user connects on port 3000 via -// a websocket, log that a user has connected -io.on('connection', function (socket: Socket) { - // WATCH OUT !! Reconnect is not implemented - // In the connection input processing, we should - // check if connectionId matches with userId and RoomId - // if not reject, if it's accepted send connection - // reestablished - const { room, trainertoken } = socket.handshake.query; - console.log(`room request: ${room}`); - console.log(`trainer token: ${trainertoken}`); - console.log('*** Session ID:', socket.conn.id); - - let outputMessageCollection: Action[] = []; - const socketInfo: SocketInfo = { - socket: socket, - io, - connectionId: socket.conn.id, - }; - - // TODO encapuslate this to processInputMessage - if (trainertoken) { - outputMessageCollection = processInputMessage(socketInfo, { - type: InputMessageTypes.ESTABLISH_CONNECTION_TRAINER, - payload: { - room, - trainertoken, - }, - }); - } else { - outputMessageCollection = processInputMessage(socketInfo, { - type: InputMessageTypes.ESTABLISH_CONNECTION_STUDENT, - payload: { - room, - }, - }); - } - - processOutputMessageCollection(socketInfo, outputMessageCollection); - - socket.on('message', function (message: any) { - console.log(message); - if (message && message.type) { - const outputMessageCollection: Action[] = processInputMessage( - socketInfo, - message - ); - - processOutputMessageCollection(socketInfo, outputMessageCollection); - } - }); -}); - -const server = http.listen(3001, function () { - console.log('listening on *:3001'); -}); diff --git a/back/src/business/index.ts b/back/src/business/index.ts deleted file mode 100644 index 09926a2..0000000 --- a/back/src/business/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './room-name-generator.business'; diff --git a/back/src/business/room-name-generator.business.ts b/back/src/business/room-name-generator.business.ts deleted file mode 100644 index 6114f65..0000000 --- a/back/src/business/room-name-generator.business.ts +++ /dev/null @@ -1,62 +0,0 @@ -const baseNames = [ - 'FISTRO', - 'PECADOR', - 'PRADERA', - 'NOPUEDOR', - 'JARL', - 'REACT', - 'CURRY', - 'HOOKS', - 'KETCHUP', - 'TURING', - 'ALAN', - 'CHUCK', - 'NORRIS', - 'DELAWARE', - 'MALAGA', - 'PALO', - 'VALLEY', - 'LEMON', -]; - -const baseTrainerTokens = [ - 'son_goku', - 'vegeta', - 'bardock', - 'king_vegeta', - 'nappa', - 'toma', - 'selypar', - 'gine', - 'bulma', - 'piccolo', - 'krilin', - 'freezer', -]; - -const generateRandomNumberRange = (min: number, max: number) => { - return Math.floor(Math.random() * max) + min; -}; - -// TODO Unit test this - -const chooseRandomStringFromArray = (valueCollection: string[]) => { - const maxNumber = valueCollection.length - 1; - const randomNumber = generateRandomNumberRange(0, maxNumber); - - return valueCollection[randomNumber]; -}; - -const generateRandomRoomSuffix = (): string => { - const randomNumber = generateRandomNumberRange(0, 9999); - - return randomNumber.toString(); -}; - -export const generateNewRoomName = () => - `${chooseRandomStringFromArray(baseNames)}-${generateRandomRoomSuffix()}`; - -export const generateNewTrainerToken = () => - `${chooseRandomStringFromArray( - baseTrainerTokens - )}-${generateRandomRoomSuffix()}`; diff --git a/back/src/env.constants.ts b/back/src/env.constants.ts deleted file mode 100644 index 57848e6..0000000 --- a/back/src/env.constants.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const envConstants = { - NODE_ENV: process.env.NODE_ENV, - PORT: process.env.PORT, -}; diff --git a/back/src/express.server.ts b/back/src/express.server.ts deleted file mode 100644 index 44dfe63..0000000 --- a/back/src/express.server.ts +++ /dev/null @@ -1,10 +0,0 @@ -import express from 'express'; -import bodyParser from 'body-parser'; - -export const createApp = () => { - const app = express(); - - app.use(bodyParser.urlencoded({ extended: false })); - app.use(bodyParser.json()); - return app; -}; diff --git a/back/src/index.ts b/back/src/index.ts deleted file mode 100644 index 403ca45..0000000 --- a/back/src/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import 'regenerator-runtime/runtime'; -import { config } from 'dotenv'; - -config(); -require('./app'); diff --git a/back/src/messages/consts.ts b/back/src/messages/consts.ts deleted file mode 100644 index b90f969..0000000 --- a/back/src/messages/consts.ts +++ /dev/null @@ -1,23 +0,0 @@ -export const InputMessageTypes = { - ESTABLISH_CONNECTION_TRAINER: 'ESTABLISH_CONNECTION_TRAINER', - ESTABLISH_CONNECTION_STUDENT: 'ESTABLISH_CONNECTION_STUDENT', - TRAINER_APPEND_TEXT: 'TRAINER_APPEND_TEXT', - TRAINER_SET_FULL_TEXT: 'TRAINER_SET_FULL_TEXT' -}; - -export const OutputMessageTypes = { - CONNECTION_ESTABLISHED_TRAINER: 'CONNECTION_ESTABLISHED_TRAINER', - CONNECTION_ESTABLISHED_STUDENT: 'CONNECTION_ESTABLISHED_STUDENT', - ERROR_MULTI_TRAINER_NOT_IMPLEMENTED_YET: - 'ERROR_MULTI_TRAINER_NOT_IMPLEMENTED_YET', - APPEND_TEXT: 'APPEND_TEXT', - REPLACE_FULL_TEXT: 'REPLACE_FULL_TEXT' -}; - -export const SocketMessageTypes = {}; - -export const ErrorCodes = {}; - -export const SocketOuputMessageLiteral = { - MESSAGE: 'message', -}; diff --git a/back/src/messages/index.ts b/back/src/messages/index.ts deleted file mode 100644 index 54b55a6..0000000 --- a/back/src/messages/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './consts'; -export * from './input-processor'; -export * from './output-processor'; -export * from './model'; diff --git a/back/src/messages/input-processor.ts b/back/src/messages/input-processor.ts deleted file mode 100644 index 196ff8c..0000000 --- a/back/src/messages/input-processor.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { InputMessageTypes, OutputMessageTypes } from './consts'; -import { - Action, - InputEstablishConnectionMaster, - InputEstablishConnectionPlayer, - SocketInfo, -} from './model'; -import { - isTrainerUser, - getRoomFromConnectionId, - isExistingConnection, - isRoomAvailable, - addNewUser, -} from '../storage'; -import { processOuputMessage } from './output-processor'; - -export const processInputMessage = ( - socketInfo: SocketInfo, - action: Action -): Action[] => { - let outputActionCollection: Action[] = []; - switch (action.type) { - case InputMessageTypes.ESTABLISH_CONNECTION_TRAINER: - const payloadECT: InputEstablishConnectionMaster = action.payload; - outputActionCollection = handleEstablishConnectionTrainer( - socketInfo, - payloadECT.room, - payloadECT.trainertoken - ); - break; - case InputMessageTypes.ESTABLISH_CONNECTION_STUDENT: - const payloadECS: InputEstablishConnectionMaster = action.payload; - outputActionCollection = handleEstablishConnectionStudent( - socketInfo, - payloadECS.room - ); - break; - case InputMessageTypes.TRAINER_APPEND_TEXT: - outputActionCollection = handleTrainerAppendText( - socketInfo, - action.payload - ); - break; - case InputMessageTypes.TRAINER_SET_FULL_TEXT: - outputActionCollection = handleSetTrainerFullText( - socketInfo, - action.payload - ); - break; - } - - return outputActionCollection; -}; - -const handleSetTrainerFullText = (socketInfo: SocketInfo, text: string) => { - if (!isTrainerUser(socketInfo.connectionId)) { - return []; - } - - return [{ type: OutputMessageTypes.REPLACE_FULL_TEXT, payload: text }]; -}; - -const handleTrainerAppendText = (socketInfo: SocketInfo, text: string) => { - if (!isTrainerUser(socketInfo.connectionId)) { - return []; - } - - return [{ type: OutputMessageTypes.APPEND_TEXT, payload: text }]; -}; - -const handleEstablishConnectionStudent = ( - socketInfo: SocketInfo, - room: string -) => { - if (!room) { - // Ignore - return []; - } - - if (isRoomAvailable(room) || !isExistingConnection(socketInfo.connectionId)) { - addNewUser(socketInfo.connectionId, { - room, - trainerToken: '', - isTrainer: false, - }); - socketInfo.socket.join(room); - } - return [{ type: OutputMessageTypes.CONNECTION_ESTABLISHED_STUDENT }]; -}; - -const handleEstablishConnectionTrainer = ( - socketInfo: SocketInfo, - room: string, - trainerToken: string -): Action[] => { - if (!trainerToken || !room) { - // Ignore - return []; - } - - if (isRoomAvailable(room) || !isExistingConnection(socketInfo.connectionId)) { - addNewUser(socketInfo.connectionId, { - room, - trainerToken, - isTrainer: !!trainerToken, - }); - socketInfo.socket.join(room); - } - return [{ type: OutputMessageTypes.CONNECTION_ESTABLISHED_TRAINER }]; -}; diff --git a/back/src/messages/model.ts b/back/src/messages/model.ts deleted file mode 100644 index c110f49..0000000 --- a/back/src/messages/model.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Socket } from 'socket.io'; - -export type MessageType = 'message' | 'error'; - -export interface SocketInfo { - socket: Socket; - io: Socket; - connectionId: string; -} - -export interface Action { - type: string; - payload?: any; - messageType?: MessageType; -} - -export interface InputEstablishConnectionMaster { - room: string; - trainertoken: string; -} - -export interface InputEstablishConnectionPlayer { - nickname: string; - room: string; -} diff --git a/back/src/messages/output-processor.ts b/back/src/messages/output-processor.ts deleted file mode 100644 index 82804b4..0000000 --- a/back/src/messages/output-processor.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { - OutputMessageTypes, - ErrorCodes, - SocketMessageTypes, - SocketOuputMessageLiteral, -} from './consts'; -import { Action, SocketInfo } from './model'; -import { isTrainerUser, getRoomFromConnectionId } from '../storage'; -import * as SocketIOClient from 'socket.io'; -import { ResponseBase, responseType } from './response'; - -export const processOutputMessageCollection = ( - socketInfo: SocketInfo, - actionCollection: Action[] -) => { - if (actionCollection) { - // TODO: Error handling - actionCollection.forEach((action) => - processOuputMessage(socketInfo, action) - ); - } -}; - -export const processOuputMessage = (socketInfo: SocketInfo, action: Action) => { - const { connectionId, io, socket } = socketInfo; - const isMaster = isTrainerUser(connectionId); - const room = getRoomFromConnectionId(connectionId); - - switch (action.type) { - case OutputMessageTypes.CONNECTION_ESTABLISHED_TRAINER: - handleNotifyConnectionEstablishedTrainer(socketInfo, connectionId); - break; - case OutputMessageTypes.CONNECTION_ESTABLISHED_STUDENT: - handleNotifyConnectionEstablishedStudent(socketInfo, connectionId); - break; - case OutputMessageTypes.APPEND_TEXT: - handleAppendText(socketInfo, action.payload); - case OutputMessageTypes.REPLACE_FULL_TEXT: - handleReplaceFullText(socketInfo, action.payload); - } -}; - -const handleReplaceFullText = (socketInfo: SocketInfo, text: string) => { - const room = getRoomFromConnectionId(socketInfo.connectionId); - socketInfo.io.in(room).emit(SocketOuputMessageLiteral.MESSAGE, { - type: responseType.REPLACE_FULL_TEXT, - payload: text, - }); -}; - -const handleAppendText = (socketInfo: SocketInfo, text: string) => { - const room = getRoomFromConnectionId(socketInfo.connectionId); - socketInfo.io.in(room).emit(SocketOuputMessageLiteral.MESSAGE, { - type: responseType.APPEND_TEXT, - payload: text, - }); -}; - -const handleNotifyConnectionEstablishedTrainer = ( - socketInfo: SocketInfo, - connectionId: string -) => { - const room = getRoomFromConnectionId(socketInfo.connectionId); - const response: ResponseBase = { type: responseType.CONNECTION_ACK }; - socketInfo.socket.in(room).emit(SocketOuputMessageLiteral.MESSAGE, response); -}; - -// Right now same as trainer, this could change in the future -const handleNotifyConnectionEstablishedStudent = ( - socketInfo: SocketInfo, - connectionId: string -) => { - const room = getRoomFromConnectionId(socketInfo.connectionId); - const response: ResponseBase = { type: responseType.CONNECTION_ACK }; - socketInfo.socket.in(room).emit(SocketOuputMessageLiteral.MESSAGE, response); -}; diff --git a/back/src/messages/response.ts b/back/src/messages/response.ts deleted file mode 100644 index c19c247..0000000 --- a/back/src/messages/response.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const responseType = { - CONNECTION_ACK: 'CONNECTION_ACK', - APPEND_TEXT: 'APPEND_TEXT', - REPLACE_FULL_TEXT: 'REPLACE_FULL_TEXT', -}; - -export interface ResponseBase { - type: string; - payload?: any; -} diff --git a/back/src/storage/index.ts b/back/src/storage/index.ts deleted file mode 100644 index 1ae27f4..0000000 --- a/back/src/storage/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './session'; diff --git a/back/src/storage/session.ts b/back/src/storage/session.ts deleted file mode 100644 index 790e94d..0000000 --- a/back/src/storage/session.ts +++ /dev/null @@ -1,51 +0,0 @@ -// This is just a demo approach, storing in memory session Info -// Another way to identify users: https://stackoverflow.com/questions/6979992/how-to-get-session-id-of-socket-io-client-in-client - -interface ConnectSessionInfo { - room: string; - trainerToken: string; - isTrainer: boolean; -} - -interface UserSession extends ConnectSessionInfo { - connectionId: string; -} - -let userCollectionSession: UserSession[] = []; - -export const isRoomAvailable = (room: string) => - !userCollectionSession.find((session) => session.room === room); - -export const addNewUser = ( - connectionId: string, - { room, trainerToken, isTrainer }: ConnectSessionInfo -) => { - userCollectionSession = [ - ...userCollectionSession, - { - connectionId, - room, - trainerToken, - isTrainer, - }, - ]; -}; - -export const isTrainerUser = (connectionId: string) => { - const session = userCollectionSession.find( - (session) => session.connectionId === connectionId && session.isTrainer - ); - return session; -}; - -export const isExistingConnection = (connectionId: string) => - userCollectionSession.findIndex( - (session) => session.connectionId === connectionId - ) !== -1; - -export const getRoomFromConnectionId = (connectionId: string) => { - const session = userCollectionSession.find( - (session) => session.connectionId === connectionId - ); - return session ? session.room : ''; -}; diff --git a/back/tsconfig.json b/back/tsconfig.json deleted file mode 100644 index 0ef78f2..0000000 --- a/back/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "compilerOptions": { - "target": "es6", - "module": "es6", - "moduleResolution": "node", - "declaration": false, - "noImplicitAny": false, - "sourceMap": true, - "noLib": false, - "allowJs": true, - "suppressImplicitAnyIndexErrors": true, - "skipLibCheck": true, - "esModuleInterop": true, - "baseUrl": "./src" - }, - "include": ["src/**/*"] -} diff --git a/front/.babelrc b/front/.babelrc deleted file mode 100644 index 885ff9e..0000000 --- a/front/.babelrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "presets": [ - "@babel/preset-env", - "@babel/preset-typescript", - "@babel/preset-react" - ], - "plugins": ["react-hot-loader/babel", "emotion"] -} diff --git a/front/.editorconfig b/front/.editorconfig deleted file mode 100644 index c6c8b36..0000000 --- a/front/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true diff --git a/front/.gitignore b/front/.gitignore deleted file mode 100644 index c245e51..0000000 --- a/front/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -node_modules -dist -coverage -.awcache -test-report.* -junit.xml -*.log -*.orig -package-lock.json -yarn.lock -.awcache -public diff --git a/front/.prettierrc b/front/.prettierrc deleted file mode 100644 index 099f1b2..0000000 --- a/front/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "singleQuote": true, - "trailingComma": "es5", - "endOfLine": "lf" -} diff --git a/front/.vscode/settings.json b/front/.vscode/settings.json deleted file mode 100644 index ad92582..0000000 --- a/front/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "editor.formatOnSave": true -} diff --git a/front/LICENSE b/front/LICENSE deleted file mode 100644 index 56d4579..0000000 --- a/front/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Lemoncode - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/front/config/test/jest.js b/front/config/test/jest.js deleted file mode 100644 index d33e89f..0000000 --- a/front/config/test/jest.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - rootDir: '../../', - preset: 'ts-jest', - restoreMocks: true, - moduleDirectories: ['/src', 'node_modules'], - setupFilesAfterEnv: ['/config/test/setup.ts'], -}; diff --git a/front/config/test/setup.ts b/front/config/test/setup.ts deleted file mode 100644 index 22c352d..0000000 --- a/front/config/test/setup.ts +++ /dev/null @@ -1,2 +0,0 @@ -import '@testing-library/jest-dom'; -import '@testing-library/jest-dom/extend-expect'; diff --git a/front/config/webpack/analyze.js b/front/config/webpack/analyze.js deleted file mode 100644 index bce0cf3..0000000 --- a/front/config/webpack/analyze.js +++ /dev/null @@ -1,7 +0,0 @@ -const merge = require('webpack-merge'); -const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); -const config = require('./prod'); - -module.exports = merge(config, { - plugins: [new BundleAnalyzerPlugin()], -}); diff --git a/front/config/webpack/base.js b/front/config/webpack/base.js deleted file mode 100644 index 92ae41c..0000000 --- a/front/config/webpack/base.js +++ /dev/null @@ -1,52 +0,0 @@ -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const merge = require('webpack-merge'); -const helpers = require('./helpers'); - -module.exports = merge( - {}, - { - context: helpers.resolveFromRootPath('src'), - resolve: { - alias: { - layout: helpers.resolveFromRootPath('src/layout'), - core: helpers.resolveFromRootPath('src/core'), - scenes: helpers.resolveFromRootPath('src/scenes'), - pods: helpers.resolveFromRootPath('src/pods'), - 'common-app': helpers.resolveFromRootPath('src/common-app'), - }, - extensions: ['.js', '.ts', '.tsx'], - }, - entry: { - app: ['regenerator-runtime/runtime', './index.tsx'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - exclude: /node_modules/, - loader: 'babel-loader', - }, - ], - }, - optimization: { - runtimeChunk: 'single', - splitChunks: { - cacheGroups: { - vendor: { - chunks: 'all', - name: 'vendor', - test: /[\\/]node_modules[\\/]/, - enforce: true, - }, - }, - }, - }, - plugins: [ - new HtmlWebpackPlugin({ - favicon: 'assets/favicon.ico', - filename: 'index.html', - template: 'index.html', - }), - ], - } -); diff --git a/front/config/webpack/dev.js b/front/config/webpack/dev.js deleted file mode 100644 index a6514f8..0000000 --- a/front/config/webpack/dev.js +++ /dev/null @@ -1,52 +0,0 @@ -const merge = require('webpack-merge'); -const Dotenv = require('dotenv-webpack'); -const base = require('./base'); -const helpers = require('./helpers'); - -const hotReloadingEntries = ['react-hot-loader/patch']; - -module.exports = merge.strategy({ - entry: 'prepend', -})(base, { - mode: 'development', - devtool: 'inline-source-map', - resolve: { - alias: { - 'react-dom': '@hot-loader/react-dom', - }, - }, - entry: { - app: hotReloadingEntries, - }, - output: { - path: helpers.resolveFromRootPath('dist'), - filename: '[name].js', - }, - devServer: { - inline: true, - host: 'localhost', - port: 8080, - stats: 'minimal', - hot: true, - }, - plugins: [ - new Dotenv({ - path: 'dev.env', - }), - ], - module: { - rules: [ - { - test: /\.(png|jpg|gif|svg)$/, - loader: 'file-loader', - options: { - name: 'img/[name].[ext]', - }, - }, - { - test: /\.css$/, - use: ['style-loader', 'css-loader'], - }, - ], - }, -}); diff --git a/front/config/webpack/helpers.js b/front/config/webpack/helpers.js deleted file mode 100644 index 3a187bd..0000000 --- a/front/config/webpack/helpers.js +++ /dev/null @@ -1,5 +0,0 @@ -const path = require('path'); - -const rootPath = path.resolve(__dirname, '../../'); - -exports.resolveFromRootPath = (...args) => path.join(rootPath, ...args); diff --git a/front/config/webpack/prod.js b/front/config/webpack/prod.js deleted file mode 100644 index a49ff45..0000000 --- a/front/config/webpack/prod.js +++ /dev/null @@ -1,37 +0,0 @@ -const merge = require('webpack-merge'); -const Dotenv = require('dotenv-webpack'); -const base = require('./base'); -const helpers = require('./helpers'); -const MiniCssExtractPlugin = require('mini-css-extract-plugin'); - -module.exports = merge(base, { - mode: 'production', - output: { - path: helpers.resolveFromRootPath('dist'), - filename: './js/[name].[chunkhash].js', - }, - module: { - rules: [ - { - test: /\.(png|jpg|gif|svg)$/, - loader: 'file-loader', - options: { - name: './images/[name].[ext]?[hash]', - }, - }, - { - test: /\.css$/, - use: [MiniCssExtractPlugin.loader, 'css-loader'], - }, - ], - }, - plugins: [ - new Dotenv({ - path: 'prod.env', - }), - new MiniCssExtractPlugin({ - filename: './css/[chunkhash].[name].css', - chunkFilename: '[chunkhash].[id].css', - }), - ], -}); diff --git a/front/dev.env b/front/dev.env deleted file mode 100644 index 0033ebb..0000000 --- a/front/dev.env +++ /dev/null @@ -1,2 +0,0 @@ -NODE_ENV=development -GRAPHQL_URL=http://localhost:8081/graphql/employee diff --git a/front/global.types.d.ts b/front/global.types.d.ts deleted file mode 100644 index e2937d4..0000000 --- a/front/global.types.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module '*.png'; diff --git a/front/package.json b/front/package.json deleted file mode 100644 index c2bcd1b..0000000 --- a/front/package.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "name": "planning-poker", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "start": "run-p -l type-check:watch start:dev", - "start:dev": "webpack-dev-server --config ./config/webpack/dev.js", - "build": "run-p -l type-check build:prod", - "build:prod": "npm run clean && webpack --config ./config/webpack/prod.js", - "analyze": "npm run clean && npm run type-check && webpack --config ./config/webpack/analyze.js", - "type-check": "tsc --noEmit", - "type-check:watch": "npm run type-check -- --watch", - "test": "jest -c ./config/test/jest.js --verbose", - "test:watch": "npm run test -- --watchAll -i", - "clean": "rimraf dist", - "prettier": "prettier {config,src}/**/*{.js,.jsx,.ts,.tsx}", - "prettier:fix": "npm run prettier -- --fix" - }, - "repository": { - "type": "git" - }, - "author": "Lemoncode", - "license": "MIT", - "homepage": "", - "dependencies": { - "@emotion/core": "^10.0.35", - "@material-ui/core": "^4.10.1", - "@material-ui/icons": "^4.9.1", - "axios": "^0.19.2", - "emotion": "^10.0.27", - "lodash.merge": "^4.6.2", - "react": "^16.12.0", - "react-dom": "^16.12.0", - "react-hot-loader": "^4.12.18", - "react-router-dom": "^5.2.0", - "regenerator-runtime": "^0.13.3", - "socket.io": "^2.3.0" - }, - "devDependencies": { - "@babel/cli": "^7.7.4", - "@babel/core": "^7.7.4", - "@babel/preset-env": "^7.7.4", - "@babel/preset-react": "^7.7.4", - "@babel/preset-typescript": "^7.7.4", - "@hot-loader/react-dom": "^16.11.0", - "@testing-library/jest-dom": "^4.2.4", - "@testing-library/react": "^9.3.2", - "@testing-library/react-hooks": "^3.2.1", - "@types/jest": "^24.0.23", - "@types/react": "^16.9.13", - "@types/react-dom": "^16.9.4", - "@types/react-router-dom": "^5.1.5", - "@types/socket.io": "^2.1.10", - "@typescript-eslint/eslint-plugin": "^2.9.0", - "@typescript-eslint/parser": "^2.9.0", - "babel-loader": "^8.0.6", - "babel-plugin-emotion": "^10.0.23", - "css-loader": "^3.2.0", - "dotenv-webpack": "^1.7.0", - "eslint": "^6.7.1", - "eslint-config-prettier": "^6.7.0", - "eslint-plugin-prettier": "^3.1.1", - "eslint-plugin-react": "^7.16.0", - "file-loader": "^5.0.2", - "html-webpack-plugin": "^3.2.0", - "jest": "^24.9.0", - "lint-staged": "^9.5.0", - "mini-css-extract-plugin": "^0.8.0", - "npm-run-all": "^4.1.5", - "prettier": "^1.19.1", - "pretty-quick": "^2.0.1", - "react-test-renderer": "^16.12.0", - "rimraf": "^3.0.0", - "style-loader": "^1.0.1", - "ts-jest": "^24.2.0", - "typescript": "^3.7.2", - "url-loader": "^3.0.0", - "webpack": "^4.41.2", - "webpack-bundle-analyzer": "^3.6.0", - "webpack-cli": "^3.3.10", - "webpack-dev-server": "^3.9.0", - "webpack-merge": "^4.2.2" - } -} diff --git a/front/prod.env b/front/prod.env deleted file mode 100644 index 624e793..0000000 --- a/front/prod.env +++ /dev/null @@ -1,2 +0,0 @@ -NODE_ENV=production -GRAPHQL_URL=/graphql/employee diff --git a/front/src/app.tsx b/front/src/app.tsx deleted file mode 100644 index 0c200f7..0000000 --- a/front/src/app.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; -import { hot } from 'react-hot-loader/root'; -import { RouterComponent } from 'core/router'; - -const App: React.FunctionComponent = () => { - return ; -}; - -export default hot(App); diff --git a/front/src/assets/favicon.ico b/front/src/assets/favicon.ico deleted file mode 100644 index cda3300..0000000 Binary files a/front/src/assets/favicon.ico and /dev/null differ diff --git a/front/src/assets/favicon.png b/front/src/assets/favicon.png deleted file mode 100644 index 07cb1a7..0000000 Binary files a/front/src/assets/favicon.png and /dev/null differ diff --git a/front/src/assets/fondo-desktop.jpg b/front/src/assets/fondo-desktop.jpg deleted file mode 100644 index 51f8d1a..0000000 Binary files a/front/src/assets/fondo-desktop.jpg and /dev/null differ diff --git a/front/src/assets/fondo-movil.jpg b/front/src/assets/fondo-movil.jpg deleted file mode 100644 index ba070fb..0000000 Binary files a/front/src/assets/fondo-movil.jpg and /dev/null differ diff --git a/front/src/assets/fondo-tablet.jpg b/front/src/assets/fondo-tablet.jpg deleted file mode 100644 index a411eac..0000000 Binary files a/front/src/assets/fondo-tablet.jpg and /dev/null differ diff --git a/front/src/assets/l-red.png b/front/src/assets/l-red.png deleted file mode 100644 index 9778379..0000000 Binary files a/front/src/assets/l-red.png and /dev/null differ diff --git a/front/src/assets/l-white.png b/front/src/assets/l-white.png deleted file mode 100644 index 51b416b..0000000 Binary files a/front/src/assets/l-white.png and /dev/null differ diff --git a/front/src/assets/logo-lemon.png b/front/src/assets/logo-lemon.png deleted file mode 100644 index d0fe6ce..0000000 Binary files a/front/src/assets/logo-lemon.png and /dev/null differ diff --git a/front/src/assets/logo.png b/front/src/assets/logo.png deleted file mode 100644 index c0dafa8..0000000 Binary files a/front/src/assets/logo.png and /dev/null differ diff --git a/front/src/assets/m-red.png b/front/src/assets/m-red.png deleted file mode 100644 index 5fbe960..0000000 Binary files a/front/src/assets/m-red.png and /dev/null differ diff --git a/front/src/assets/m-white.png b/front/src/assets/m-white.png deleted file mode 100644 index 1c7d4a3..0000000 Binary files a/front/src/assets/m-white.png and /dev/null differ diff --git a/front/src/assets/s-red.png b/front/src/assets/s-red.png deleted file mode 100644 index cc05623..0000000 Binary files a/front/src/assets/s-red.png and /dev/null differ diff --git a/front/src/assets/s-white.png b/front/src/assets/s-white.png deleted file mode 100644 index 36d75d9..0000000 Binary files a/front/src/assets/s-white.png and /dev/null differ diff --git a/front/src/assets/xl-red.png b/front/src/assets/xl-red.png deleted file mode 100644 index 74820bf..0000000 Binary files a/front/src/assets/xl-red.png and /dev/null differ diff --git a/front/src/assets/xl-white.png b/front/src/assets/xl-white.png deleted file mode 100644 index e075335..0000000 Binary files a/front/src/assets/xl-white.png and /dev/null differ diff --git a/front/src/assets/xs-red.png b/front/src/assets/xs-red.png deleted file mode 100644 index 7b8bfcb..0000000 Binary files a/front/src/assets/xs-red.png and /dev/null differ diff --git a/front/src/assets/xs-white.png b/front/src/assets/xs-white.png deleted file mode 100644 index 7fdb432..0000000 Binary files a/front/src/assets/xs-white.png and /dev/null differ diff --git a/front/src/assets/xxl-red.png b/front/src/assets/xxl-red.png deleted file mode 100644 index e9964c9..0000000 Binary files a/front/src/assets/xxl-red.png and /dev/null differ diff --git a/front/src/assets/xxl-white.png b/front/src/assets/xxl-white.png deleted file mode 100644 index 7702e2c..0000000 Binary files a/front/src/assets/xxl-white.png and /dev/null differ diff --git a/front/src/common-app/index.ts b/front/src/common-app/index.ts deleted file mode 100644 index e69de29..0000000 diff --git a/front/src/core/api.ts b/front/src/core/api.ts deleted file mode 100644 index bd8a20c..0000000 --- a/front/src/core/api.ts +++ /dev/null @@ -1,22 +0,0 @@ -import * as ioClient from 'socket.io-client'; -import { baseSocketUrl } from './const'; -import SocketIOClient, { Socket } from 'socket.io'; - -export interface ConnectionSetup { - room: string; - trainertoken: string; -} - -export const createSocket = (connectionSetup: ConnectionSetup): Socket => { - const { room, trainertoken } = connectionSetup; - const socketParams = { - url: baseSocketUrl, - options: { - query: { room, trainertoken }, - timeout: 60000, - }, - }; - - // TODO Add channel (room) - return ioClient(baseSocketUrl, socketParams.options); -}; diff --git a/front/src/core/const.ts b/front/src/core/const.ts deleted file mode 100644 index 77014d3..0000000 --- a/front/src/core/const.ts +++ /dev/null @@ -1,18 +0,0 @@ -// TODO: Add env variables -export const baseSocketUrl = 'http://localhost:3001'; - -export const baseApiUrl = 'http://localhost:8080'; - -export const SocketOuputMessageLiteral = { - MESSAGE: 'message', -}; - -export const SocketEmitMessageTypes = { - TRAINER_APPEND_TEXT: 'TRAINER_APPEND_TEXT', // Master creates a user story -}; - -export const SocketReceiveMessageTypes = { - CONNECTION_ACK: 'CONNECTION_ACK', - APPEND_TEXT: 'APPEND_TEXT', - REPLACE_FULL_TEXT: 'REPLACE_FULL_TEXT', -}; diff --git a/front/src/core/index.ts b/front/src/core/index.ts deleted file mode 100644 index 57b12ff..0000000 --- a/front/src/core/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './api'; -export * from './const'; -export * from './use-log.hook'; diff --git a/front/src/core/router/index.ts b/front/src/core/router/index.ts deleted file mode 100644 index e6abe80..0000000 --- a/front/src/core/router/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './router.component'; -export { routes } from './routes'; diff --git a/front/src/core/router/router.component.tsx b/front/src/core/router/router.component.tsx deleted file mode 100644 index 2aafe6a..0000000 --- a/front/src/core/router/router.component.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react'; -import { HashRouter as Router, Switch, Route } from 'react-router-dom'; -import { switchRoutes } from './routes'; -import { CreateSessionScene, TrainerScene, StudentScene } from 'scenes'; - -export const RouterComponent: React.FunctionComponent = () => { - return ( - - - - - - - - ); -}; diff --git a/front/src/core/router/routes.ts b/front/src/core/router/routes.ts deleted file mode 100644 index c391144..0000000 --- a/front/src/core/router/routes.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { generatePath } from 'react-router-dom'; - -interface SwitchRoutes { - root: string; - student: string; - trainer: string; -} - -export const switchRoutes: SwitchRoutes = { - root: '/', - student: '/student/:room', - trainer: '/trainer/:room/:token', -}; - -interface Routes extends Omit { - student: (room: string) => string; - trainer: (room: string, token: string) => string; -} - -export const routes: Routes = { - ...switchRoutes, - student: room => generatePath(switchRoutes.student, { room }), - trainer: (room, token) => generatePath(switchRoutes.trainer, { room, token }), -}; diff --git a/front/src/core/use-log.hook.ts b/front/src/core/use-log.hook.ts deleted file mode 100644 index 26c4da7..0000000 --- a/front/src/core/use-log.hook.ts +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; - -export const useLog = () => { - const [log, internalSetLog] = React.useState(''); - const logRef = React.useRef(''); - - const appendToLog = (value: string) => { - const newText = `${logRef.current}\n${value} `; - internalSetLog(newText); - logRef.current = newText; - }; - - return { log, appendToLog, logRef }; -}; diff --git a/front/src/index.html b/front/src/index.html deleted file mode 100644 index 65e1605..0000000 --- a/front/src/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - T-Shirt Planning Poker - Lemoncode - - - - - -
- - diff --git a/front/src/index.tsx b/front/src/index.tsx deleted file mode 100644 index 6688070..0000000 --- a/front/src/index.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import { StylesProvider } from '@material-ui/styles'; -import App from './app'; - -ReactDOM.render( - <> - - - - , - document.getElementById('root') -); diff --git a/front/src/layout/index.ts b/front/src/layout/index.ts deleted file mode 100644 index e69de29..0000000 diff --git a/front/src/pods/create-session/components/test-runner-trainer.api.ts b/front/src/pods/create-session/components/test-runner-trainer.api.ts deleted file mode 100644 index 35daefe..0000000 --- a/front/src/pods/create-session/components/test-runner-trainer.api.ts +++ /dev/null @@ -1,17 +0,0 @@ -import Axios from 'axios'; - -const baseApiUrl = 'http://localhost:8081'; - -const getRoomUrl = `${baseApiUrl}/api/create-room`; - -interface SessionInfo { - room: string; - trainerToken: string; -} - -export const createRoom = async (): Promise => { - // TODO Error handling - const result = await Axios.get(getRoomUrl); - - return result.data; -}; diff --git a/front/src/pods/create-session/create-session.component.tsx b/front/src/pods/create-session/create-session.component.tsx deleted file mode 100644 index af0dff4..0000000 --- a/front/src/pods/create-session/create-session.component.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react'; -import * as classes from './create-session.styles'; -// Material UI ~ components -import Button from '@material-ui/core/Button'; - -interface Props { - handleCreateSession: () => void; -} - -export const CreateSessionComponent: React.FunctionComponent = props => { - const { handleCreateSession } = props; - const { mainContainer, createSessionBtn } = classes; - - return ( - <> -
- -
- - ); -}; diff --git a/front/src/pods/create-session/create-session.container.tsx b/front/src/pods/create-session/create-session.container.tsx deleted file mode 100644 index 8277410..0000000 --- a/front/src/pods/create-session/create-session.container.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import React from 'react'; -import { useHistory } from 'react-router-dom'; -import { routes } from 'core/router'; -import { CreateSessionComponent } from './create-session.component'; -import { createRoom } from './components/test-runner-trainer.api'; - -export const CreateSessionContainer: React.FunctionComponent = () => { - const history = useHistory(); - - const handleCreateSession = async (): Promise => { - const response = await createRoom(); - const trainerUrl = routes.trainer(response.room, response.trainerToken); - history.push(trainerUrl); - }; - - return ( - <> - - - ); -}; diff --git a/front/src/pods/create-session/create-session.styles.ts b/front/src/pods/create-session/create-session.styles.ts deleted file mode 100644 index 1655aeb..0000000 --- a/front/src/pods/create-session/create-session.styles.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { css } from 'emotion'; - -export const mainContainer = css` - margin: 0; - padding: 0; - position: relative; - width: 100%; - height: calc(100vh - 16px); -`; - -export const createSessionBtn = css` - padding: 20px 30px; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); -`; diff --git a/front/src/pods/create-session/index.ts b/front/src/pods/create-session/index.ts deleted file mode 100644 index ff22322..0000000 --- a/front/src/pods/create-session/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './create-session.container'; diff --git a/front/src/pods/student/index.ts b/front/src/pods/student/index.ts deleted file mode 100644 index fe0bef1..0000000 --- a/front/src/pods/student/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './student.container'; diff --git a/front/src/pods/student/student.component.tsx b/front/src/pods/student/student.component.tsx deleted file mode 100644 index 60ecd50..0000000 --- a/front/src/pods/student/student.component.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import React from 'react'; -import * as classes from './student.styles'; -// Material UI ~ components -import TextareaAutosize from '@material-ui/core/TextareaAutosize'; -import Typography from '@material-ui/core/Typography'; - -interface Props { - room: string; - log: string; -} - -export const StudentComponent: React.FC = props => { - const { room, log } = props; - const { mainContainer, sessionName, studentBoard, labelTextarea } = classes; - - return ( -
- - Session name: {room} - - - -
- ); -}; diff --git a/front/src/pods/student/student.container.tsx b/front/src/pods/student/student.container.tsx deleted file mode 100644 index 1a3f9c9..0000000 --- a/front/src/pods/student/student.container.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import * as React from 'react'; -import { useParams } from 'react-router-dom'; -import { - createSocket, - SocketOuputMessageLiteral, - SocketEmitMessageTypes, - SocketReceiveMessageTypes, -} from 'core'; -import { useLog } from 'core'; -import { StudentComponent } from './student.component'; - -interface Params { - room: string; -} - -export const PlayerContainer = () => { - const { room } = useParams(); - const { log, appendToLog } = useLog(); - const [socket, setSocket] = React.useState(null); - - const handleConnection = () => { - // Connect to socket - const localSocket = createSocket({ - room: room, - trainertoken: '', - }); - - setSocket(localSocket); - - localSocket.on(SocketOuputMessageLiteral.MESSAGE, msg => { - console.log(msg); - - if (msg.type) { - const { type, payload } = msg; - - switch (type) { - case SocketReceiveMessageTypes.APPEND_TEXT: - appendToLog(payload); - break; - } - } - }); - }; - - React.useEffect(() => { - handleConnection(); - }, []); - - return ( - <> - - - ); -}; diff --git a/front/src/pods/student/student.styles.ts b/front/src/pods/student/student.styles.ts deleted file mode 100644 index 2f10490..0000000 --- a/front/src/pods/student/student.styles.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { css } from 'emotion'; - -export const mainContainer = css` - width: 60%; - margin: 40px auto 0 auto; -`; - -export const studentBoard = css` - box-sizing: border-box; - width: 100%; - margin-top: 10px; - padding: 5px; - font-family: 'Roboto', sans-serif; - resize: none; -`; - -export const labelTextarea = css` - font-family: 'Roboto', sans-serif; -`; - -export const sessionName = css` - margin-bottom: 20px; -`; diff --git a/front/src/pods/trainer/components/header.component.tsx b/front/src/pods/trainer/components/header.component.tsx deleted file mode 100644 index dd21de9..0000000 --- a/front/src/pods/trainer/components/header.component.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import React from 'react'; -import * as classes from './header.styles'; -// Material UI ~ components -import TextField from '@material-ui/core/TextField'; -import FileCopyOutlinedIcon from '@material-ui/icons/FileCopyOutlined'; - -interface Props { - currentTrainerUrl: string; - currentStudentUrl: string; -} - -export const HeaderComponent: React.FC = props => { - const { currentStudentUrl, currentTrainerUrl } = props; - const { headerContainer } = classes; - - return ( -
- - -
- ); -}; - -// CopyField Component - - - - - - - - - - - - - - - - -interface CopyFieldProps { - labelName: string; - inputId: string; - urlLink: string; -} - -export const CopyFieldComponent: React.FC = props => { - const { labelName, inputId, urlLink } = props; - const { inputField, label, inputIconContainer, textArea, copyIcon } = classes; - return ( -
- -
- - navigator.clipboard.writeText(urlLink)} - /> -
-
- ); -}; diff --git a/front/src/pods/trainer/components/header.styles.ts b/front/src/pods/trainer/components/header.styles.ts deleted file mode 100644 index 5ad96b2..0000000 --- a/front/src/pods/trainer/components/header.styles.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { css } from 'emotion'; - -export const headerContainer = css` - width: 100%; - margin-bottom: 60px; -`; - -export const inputField = css` - display: flex; - justify-content: space-between; - align-items: center; - margin-bottom: 20px; -`; - -export const label = css` - font-family: 'Roboto', sans-serif; -`; - -export const inputIconContainer = css` - display: flex; - justify-content: space-between; - align-items: center; - width: 80%; -`; - -export const textArea = css` - width: 90%; -`; - -export const copyIcon = css` - font-size: 30px; - &:hover { - color: #ccc; - } - &:active { - color: red; - } -`; diff --git a/front/src/pods/trainer/components/new-text.component.tsx b/front/src/pods/trainer/components/new-text.component.tsx deleted file mode 100644 index fffa061..0000000 --- a/front/src/pods/trainer/components/new-text.component.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import React from 'react'; -import * as classes from './new-text.styles'; -// Material UI ~ components -import Button from '@material-ui/core/Button'; -import TextareaAutosize from '@material-ui/core/TextareaAutosize'; - -interface Props { - handleAppendTrainerText: (trainerText: string) => void; -} - -export const NewTextComponent: React.FC = props => { - const { handleAppendTrainerText } = props; - const [trainerText, setTrainerText] = React.useState(''); - const { newTextContainer, labelTextarea, editTextArea, sendBtn } = classes; - - const handleAppendTrainerTextInternal = (): void => { - handleAppendTrainerText(trainerText); - setTrainerText(''); - }; - - return ( -
- - setTrainerText(e.target.value)} - value={trainerText} - /> - -
- ); -}; diff --git a/front/src/pods/trainer/components/new-text.styles.ts b/front/src/pods/trainer/components/new-text.styles.ts deleted file mode 100644 index 0d470d5..0000000 --- a/front/src/pods/trainer/components/new-text.styles.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { css } from 'emotion'; - -export const newTextContainer = css` - width: 100%; - margin-bottom: 40px; -`; - -export const labelTextarea = css` - font-family: 'Roboto', sans-serif; -`; - -export const editTextArea = css` - box-sizing: border-box; - width: 100%; - margin-bottom: 10px; - margin-top: 10px; - padding: 5px; - font-family: 'Roboto', sans-serif; - resize: none; -`; - -export const sendBtn = css` - width: 100%; -`; diff --git a/front/src/pods/trainer/components/session.component.tsx b/front/src/pods/trainer/components/session.component.tsx deleted file mode 100644 index 1c30faa..0000000 --- a/front/src/pods/trainer/components/session.component.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react'; -import * as classes from './session.styles'; -// Material UI ~ components -import TextareaAutosize from '@material-ui/core/TextareaAutosize'; - -interface Props { - log: string; -} - -export const SessionComponent: React.FC = props => { - const { log } = props; - const { labelTextarea, studentBoard } = classes; - - return ( -
- - -
- ); -}; diff --git a/front/src/pods/trainer/components/session.styles.ts b/front/src/pods/trainer/components/session.styles.ts deleted file mode 100644 index 973498c..0000000 --- a/front/src/pods/trainer/components/session.styles.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { css } from 'emotion'; - -export const studentBoard = css` - box-sizing: border-box; - width: 100%; - margin-top: 10px; - padding: 5px; - font-family: 'Roboto', sans-serif; - resize: none; -`; - -export const labelTextarea = css` - font-family: 'Roboto', sans-serif; -`; diff --git a/front/src/pods/trainer/index.ts b/front/src/pods/trainer/index.ts deleted file mode 100644 index d570827..0000000 --- a/front/src/pods/trainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './trainer.container'; diff --git a/front/src/pods/trainer/trainer.component.tsx b/front/src/pods/trainer/trainer.component.tsx deleted file mode 100644 index 30dd181..0000000 --- a/front/src/pods/trainer/trainer.component.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import * as React from 'react'; -import * as classes from './trainer.styles'; -import { HeaderComponent } from './components/header.component'; -import { NewTextComponent } from './components/new-text.component'; -import { SessionComponent } from './components/session.component'; - -interface Props { - handleAppendTrainerText: (trainerText: string) => void; - currentTrainerUrl: string; - currentStudentUrl: string; - log: string; -} - -export const TrainerComponent: React.FC = props => { - const { - handleAppendTrainerText, - currentTrainerUrl, - currentStudentUrl, - log, - } = props; - - const { mainContainer } = classes; - - return ( - <> -
- - - -
- - ); -}; diff --git a/front/src/pods/trainer/trainer.container.tsx b/front/src/pods/trainer/trainer.container.tsx deleted file mode 100644 index e25cac3..0000000 --- a/front/src/pods/trainer/trainer.container.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import * as React from 'react'; -import { useParams } from 'react-router'; -import { baseApiUrl } from 'core/const'; -import { routes } from 'core/router/routes'; -import { - createSocket, - SocketOuputMessageLiteral, - SocketEmitMessageTypes, - SocketReceiveMessageTypes, -} from 'core'; -import { useLog } from 'core'; -import { TrainerComponent } from './trainer.component'; - -interface Params { - token: string; - room: string; -} - -export const TrainerContainer = () => { - const { token, room } = useParams(); - const { log, appendToLog } = useLog(); - const [socket, setSocket] = React.useState(null); - const [currentTrainerUrl, setCurrentTrainerUrl] = React.useState(''); - const [currentStudentUrl, setCurrentStudentUrl] = React.useState(''); - - const handleConnection = () => { - // Connect to socket - const localSocket = createSocket({ - room: room, - trainertoken: token, - }); - - setSocket(localSocket); - - localSocket.on(SocketOuputMessageLiteral.MESSAGE, msg => { - console.log(msg); - - if (msg.type) { - const { type, payload } = msg; - - switch (type) { - case SocketReceiveMessageTypes.APPEND_TEXT: - appendToLog(payload); - break; - } - } - }); - }; - - React.useEffect(() => { - setCurrentTrainerUrl(`${baseApiUrl}/#${routes.trainer(room, token)}`); - setCurrentStudentUrl(`${baseApiUrl}/#${routes.student(room)}`); - handleConnection(); - }, []); - - const handleAppendTrainerText = (trainerText: string): void => { - socket.emit(SocketOuputMessageLiteral.MESSAGE, { - type: SocketEmitMessageTypes.TRAINER_APPEND_TEXT, - payload: trainerText, - }); - }; - - return ( - - ); -}; diff --git a/front/src/pods/trainer/trainer.styles.ts b/front/src/pods/trainer/trainer.styles.ts deleted file mode 100644 index cd0b8b2..0000000 --- a/front/src/pods/trainer/trainer.styles.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { css } from 'emotion'; - -export const mainContainer = css` - width: 60%; - margin: 40px auto 0 auto; -`; diff --git a/front/src/scenes/create-session.scene.tsx b/front/src/scenes/create-session.scene.tsx deleted file mode 100644 index 4f539cc..0000000 --- a/front/src/scenes/create-session.scene.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import React from 'react'; -import { CreateSessionContainer } from 'pods/create-session'; - -export const CreateSessionScene: React.FC = () => { - return ; -}; diff --git a/front/src/scenes/index.ts b/front/src/scenes/index.ts deleted file mode 100644 index b845dee..0000000 --- a/front/src/scenes/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './create-session.scene'; -export * from './trainer.scene'; -export * from './student.scene'; diff --git a/front/src/scenes/student.scene.tsx b/front/src/scenes/student.scene.tsx deleted file mode 100644 index 9c5cf23..0000000 --- a/front/src/scenes/student.scene.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import * as React from 'react'; -import { PlayerContainer } from 'pods/student'; - -export const StudentScene = () => { - return ; -}; diff --git a/front/src/scenes/trainer.scene.tsx b/front/src/scenes/trainer.scene.tsx deleted file mode 100644 index e57ace4..0000000 --- a/front/src/scenes/trainer.scene.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; -import { CreateSessionContainer } from 'pods/create-session'; -import { TrainerContainer } from 'pods/trainer'; - -export const TrainerScene: React.FC = () => { - return ; -}; diff --git a/front/tsconfig.json b/front/tsconfig.json deleted file mode 100644 index 4b16519..0000000 --- a/front/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "target": "es6", - "module": "es6", - "moduleResolution": "node", - "declaration": false, - "noImplicitAny": false, - "sourceMap": true, - "jsx": "react", - "noLib": false, - "allowJs": true, - "suppressImplicitAnyIndexErrors": true, - "skipLibCheck": true, - "esModuleInterop": true, - "baseUrl": "./src/", - "paths": { - "layout": ["layout"], - "core": ["core"], - "scenes": ["scenes"], - "pods": ["pods"], - "common-app": ["common-app"] - } - }, - "include": ["./src/**/*", "./config/test/setup.ts", "./global.types.d.ts"] -} diff --git a/img/code-paster.png b/img/code-paster.png new file mode 100644 index 0000000..56faae1 Binary files /dev/null and b/img/code-paster.png differ diff --git a/img/coming-soon-tag.png b/img/coming-soon-tag.png new file mode 100644 index 0000000..a13e28a Binary files /dev/null and b/img/coming-soon-tag.png differ diff --git a/img/coming-soon.png b/img/coming-soon.png new file mode 100644 index 0000000..41e35a9 Binary files /dev/null and b/img/coming-soon.png differ diff --git a/img/logo-lemon.png b/img/logo-lemon.png new file mode 100644 index 0000000..e406846 Binary files /dev/null and b/img/logo-lemon.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..e275dd4 --- /dev/null +++ b/index.html @@ -0,0 +1,33 @@ + + + + + + Code Paster + + + + +
+
+
+
+ lemoncode-logo +
+

presents

+
+ code-paster-logo + coming-soon-text +
+
+
+
+ + diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..0087a57 --- /dev/null +++ b/styles.css @@ -0,0 +1,257 @@ +*, +*::before, +*::after { + margin: 0; + padding: 0; + box-sizing: inherit; +} + +html { + box-sizing: border-box; + font-size: 62.4%; + font-family: "Merriweather", serif; + background-color: #fef9ee; +} + +body { + margin: 1rem; + padding: 1rem; + font-size: 1.6rem; + height: calc(100vh - 2rem); + background-color: lightblue; + color: #181818; +} + +img { + max-width: 100%; +} + +h1 { + font-family: inherit; + text-transform: uppercase; + font-weight: 300; + text-align: center; +} + +.container { + width: 100%; + height: 100%; + padding: 1rem; +} + +.container-1 { + background-color: #fffea6; +} + +.container-2 { + background-color: #242417; +} + +.container-3 { + background-color: #fef9ee; +} + +.flex-container { + display: flex; + flex-direction: column; + justify-content: space-between; + align-items: center; + padding: 2rem 2rem 4rem 2rem; +} + +.img-container { + width: 70%; + padding: 1rem; + border-radius: 1rem; + background-color: white; + -webkit-box-shadow: 6px 6px 15px -4px rgba(41, 41, 41, 0.6); + -moz-box-shadow: 6px 6px 15px -4px rgba(41, 41, 41, 0.6); + box-shadow: 6px 6px 15px -4px rgba(41, 41, 41, 0.6); +} + +.lemon-img-container { + padding: 1rem; +} + +.code-img-container { + position: relative; +} + +.presents-text { + font-size: 2rem; + letter-spacing: 1px; + font-style: italic; + font-weight: 400; + color: #242417; +} + +.coming-soon-img { + position: absolute; + width: 80%; + bottom: -2rem; + right: -3.3rem; +} + +@media only screen and (min-width: 350px) { + .coming-soon-img { + bottom: -2.5rem; + } +} + +@media only screen and (min-width: 370px) { + .coming-soon-img { + bottom: -3rem; + } +} + +@media only screen and (min-width: 410px) { + .flex-container { + padding: 2rem 2rem 5rem 2rem; + } + .coming-soon-img { + bottom: -3.5rem; + } +} + +@media only screen and (min-width: 440px) { + .coming-soon-img { + bottom: -4rem; + } +} + +@media only screen and (min-width: 480px) { + .flex-container { + padding: 2rem 2rem 6rem 2rem; + } + .coming-soon-img { + bottom: -4.5rem; + } +} + +@media only screen and (min-width: 520px) { + .img-container { + padding: 2rem; + width: 60%; + } +} + +@media only screen and (min-width: 650px) { + .img-container { + width: 55%; + } +} + +@media only screen and (min-width: 720px) { + .img-container { + width: 50%; + } +} + +@media only screen and (min-width: 800px) { + .img-container { + width: 45%; + } +} + +@media only screen and (min-width: 870px) { + .img-container { + width: 40%; + } +} + +@media only screen and (min-width: 930px) { + body { + margin: 2rem; + padding: 2rem; + height: calc(100vh - 4rem); + } + .container { + padding: 2rem; + } + .flex-container { + flex-direction: row; + padding: 4rem; + } + .img-container { + padding: 2rem; + width: 33.3%; + } + .lemon-img-container { + padding: 1rem 2rem; + } + .presents-text { + font-size: 2.6rem; + } + .coming-soon-img { + bottom: -3.5rem; + right: -2rem; + } +} + +@media only screen and (min-width: 1030px) { + .coming-soon-img { + bottom: -4rem; + } +} + +@media only screen and (min-width: 1090px) { + .coming-soon-img { + bottom: -4.5rem; + } +} + +@media only screen and (min-width: 1180px) { + .coming-soon-img { + bottom: -5rem; + } +} + +@media only screen and (min-width: 1250px) { + .coming-soon-img { + bottom: -5.5rem; + right: -2.5rem; + } + .flex-container { + flex-direction: row; + padding: 5rem; + } +} + +@media only screen and (min-width: 1340px) { + .coming-soon-img { + bottom: -6rem; + } +} + +@media only screen and (min-width: 1440px) { + .coming-soon-img { + bottom: -6.5rem; + } +} + +@media only screen and (min-width: 1550px) { + .coming-soon-img { + bottom: -7rem; + } + .presents-text { + font-size: 2.8rem; + } +} + +@media only screen and (min-width: 1700px) { + .coming-soon-img { + bottom: -8rem; + } + .presents-text { + font-size: 2.9rem; + } +} + +@media only screen and (min-width: 1900px) { + .coming-soon-img { + bottom: -9rem; + } + .presents-text { + font-size: 3rem; + } +}