임지영

프로젝트 폴더 추가

Showing 49 changed files with 1319 additions and 0 deletions
1 +# image-editor
2 +Online Image Editor
1 +module.exports = {
2 + env: {
3 + browser: true,
4 + commonjs: true,
5 + es2021: true,
6 + node: true,
7 + },
8 + extends: [
9 + 'airbnb-base',
10 + ],
11 + parserOptions: {
12 + ecmaVersion: 12,
13 + },
14 + rules: {
15 + },
16 +};
1 +# dependencies
2 +/node_modules
3 +config
4 +.env
1 +const express = require('express');
2 +const path = require('path');
3 +const session = require('express-session');
4 +const cors = require('cors');
5 +const logger = require('morgan');
6 +const passport = require('passport');
7 +const { sequelize } = require('./models');
8 +const passportConfig = require('./modules/passport');
9 +const router = require('./routes');
10 +
11 +const app = express();
12 +sequelize.sync();
13 +
14 +app.use(logger('dev'));
15 +app.use(express.json());
16 +app.use(express.urlencoded({ extended: false }));
17 +app.use(express.static(path.join(__dirname, 'public')));
18 +app.use(session({ secret: 'keyboard cat' }));
19 +app.use(passport.initialize());
20 +app.use(passport.session());
21 +app.use(cors({
22 + origin: 'http://localhost:3000',
23 + credentials: true,
24 +}));
25 +
26 +passportConfig();
27 +
28 +app.use('/', router);
29 +
30 +module.exports = app;
1 +#!/usr/bin/env node
2 +
3 +/**
4 + * Module dependencies.
5 + */
6 +
7 +const app = require('../app');
8 +const debug = require('debug')('backend:server');
9 +const http = require('http');
10 +
11 +/**
12 + * Get port from environment and store in Express.
13 + */
14 +
15 +const port = normalizePort(process.env.PORT || '9000');
16 +app.set('port', port);
17 +
18 +/**
19 + * Create HTTP server.
20 + */
21 +
22 +const server = http.createServer(app);
23 +
24 +/**
25 + * Listen on provided port, on all network interfaces.
26 + */
27 +
28 +server.listen(port);
29 +server.on('error', onError);
30 +server.on('listening', onListening);
31 +
32 +/**
33 + * Normalize a port into a number, string, or false.
34 + */
35 +
36 +function normalizePort(val) {
37 + const port = parseInt(val, 10);
38 +
39 + if (isNaN(port)) {
40 + // named pipe
41 + return val;
42 + }
43 +
44 + if (port >= 0) {
45 + // port number
46 + return port;
47 + }
48 +
49 + return false;
50 +}
51 +
52 +/**
53 + * Event listener for HTTP server "error" event.
54 + */
55 +
56 +function onError(error) {
57 + if (error.syscall !== 'listen') {
58 + throw error;
59 + }
60 +
61 + const bind = typeof port === 'string'
62 + ? `Pipe ${port}`
63 + : `Port ${port}`;
64 +
65 + // handle specific listen errors with friendly messages
66 + switch (error.code) {
67 + case 'EACCES':
68 + console.error(`${bind} requires elevated privileges`);
69 + process.exit(1);
70 + break;
71 + case 'EADDRINUSE':
72 + console.error(`${bind} is already in use`);
73 + process.exit(1);
74 + break;
75 + default:
76 + throw error;
77 + }
78 +}
79 +
80 +/**
81 + * Event listener for HTTP server "listening" event.
82 + */
83 +
84 +function onListening() {
85 + const addr = server.address();
86 + const bind = typeof addr === 'string'
87 + ? `pipe ${addr}`
88 + : `port ${addr.port}`;
89 + debug(`Listening on ${bind}`);
90 +}
1 +module.exports = (sequelize, DataType) => sequelize.define('project', {
2 + id: {
3 + type: DataType.INTEGER,
4 + autoIncrement: true,
5 + primaryKey: true,
6 + unique: true,
7 + },
8 + name: {
9 + type: DataType.STRING(50),
10 + allowNull: false,
11 + unique: true,
12 + },
13 + imageUrl: {
14 + type: DataType.STRING,
15 + allowNull: false,
16 + },
17 +});
1 +module.exports = (sequelize, DataType) => sequelize.define('user', {
2 + id: {
3 + type: DataType.INTEGER,
4 + autoIncrement: true,
5 + primaryKey: true,
6 + unique: true,
7 + },
8 + email: {
9 + type: DataType.STRING,
10 + allowNull: false,
11 + unique: true,
12 + },
13 + name: {
14 + type: DataType.STRING(20),
15 + allowNull: false,
16 + },
17 + password: {
18 + type: DataType.STRING,
19 + allowNull: true,
20 + },
21 + loginType: {
22 + type: DataType.STRING,
23 + allowNull: false,
24 + defaultValue: 'local',
25 + },
26 +});
1 +const Sequelize = require('sequelize');
2 +
3 +const env = process.env.NODE_ENV || 'development';
4 +const config = require('../config/config.json')[env];
5 +
6 +const db = {};
7 +
8 +const sequelize = new Sequelize(config.database, config.username, config.password, config);
9 +
10 +db.sequelize = sequelize;
11 +db.Sequelize = Sequelize;
12 +
13 +db.User = require('./User')(sequelize, Sequelize);
14 +db.Project = require('./Project')(sequelize, Sequelize);
15 +
16 +db.User.hasMany(db.Project);
17 +db.Project.belongsTo(db.User);
18 +
19 +module.exports = db;
1 +const passport = require('passport');
2 +const LocalStrategy = require('passport-local').Strategy;
3 +const bcrypt = require('bcrypt');
4 +
5 +const { User } = require('../models');
6 +
7 +module.exports = () => {
8 + passport.serializeUser((user, done) => {
9 + done(null, user.id);
10 + });
11 +
12 + passport.deserializeUser(async (id, done) => {
13 + try {
14 + const user = await User.findOne({ where: { id } });
15 + done(null, user);
16 + } catch (err) {
17 + done(err);
18 + }
19 + });
20 +
21 + passport.use(new LocalStrategy({
22 + usernameField: 'email',
23 + passwordField: 'password',
24 + },
25 + async (email, password, done) => {
26 + try {
27 + const user = await User.findOne({ where: { email } });
28 + if (!user) {
29 + return done(null, false, { message: 'Incorrect email.' });
30 + }
31 + const isSamePassword = await bcrypt.compare(password, user.password);
32 + if (!isSamePassword) {
33 + return done(null, false, { message: 'Incorrect password.' });
34 + }
35 + return done(null, user);
36 + } catch (err) {
37 + return done(err);
38 + }
39 + }));
40 +};
This diff is collapsed. Click to expand it.
1 +{
2 + "name": "backend",
3 + "version": "0.0.0",
4 + "private": true,
5 + "scripts": {
6 + "start": "node ./bin/www",
7 + "lint": "eslint . --fix"
8 + },
9 + "dependencies": {
10 + "bcrypt": "^5.0.0",
11 + "cookie-parser": "~1.4.4",
12 + "cors": "^2.8.5",
13 + "debug": "~2.6.9",
14 + "dotenv": "^8.2.0",
15 + "express": "~4.16.1",
16 + "express-session": "^1.17.1",
17 + "morgan": "~1.9.1",
18 + "mysql2": "^2.2.5",
19 + "passport": "^0.4.1",
20 + "passport-local": "^1.0.0",
21 + "sequelize": "^6.3.5"
22 + },
23 + "devDependencies": {
24 + "eslint": "^7.11.0",
25 + "eslint-config-airbnb-base": "^14.2.0",
26 + "eslint-plugin-import": "^2.22.1"
27 + }
28 +}
1 +<html>
2 +
3 +<head>
4 + <title>Express</title>
5 + <link rel="stylesheet" href="/stylesheets/style.css">
6 +</head>
7 +
8 +<body>
9 + <h1>Express</h1>
10 + <p>Welcome to Express</p>
11 +</body>
12 +
13 +</html>
1 +body {
2 + padding: 50px;
3 + font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
4 +}
5 +
6 +a {
7 + color: #00B7FF;
8 +}
1 +const bcrypt = require('bcrypt');
2 +const passport = require('passport');
3 +const { User } = require('../../models');
4 +
5 +exports.signup = async (req, res, next) => {
6 + const { email, name, password } = req.body;
7 + try {
8 + const existUser = await User.findOne({ where: { email } });
9 + if (existUser) {
10 + res.status(409).json({ ok: false, message: 'already exists' });
11 + return;
12 + }
13 + const hash = await bcrypt.hash(password, 10);
14 + await User.create({ email, password: hash, name });
15 + res.json({ ok: true });
16 + } catch (err) {
17 + next(err);
18 + }
19 +};
20 +
21 +exports.login = (req, res, next) => {
22 + passport.authenticate('local', (err, user, info) => {
23 + if (err) return next(err);
24 + if (!user) return res.status(401).json({ ok: false, ...info });
25 + req.logIn(user, (loginErr) => {
26 + if (loginErr) next(loginErr);
27 + res.json({ ok: true, user: req.user });
28 + });
29 + })(req, res, next);
30 +};
1 +const express = require('express');
2 +const authCtrl = require('./authController');
3 +
4 +const auth = express.Router();
5 +
6 +auth.post('/signup', authCtrl.signup);
7 +auth.post('/login', authCtrl.login);
8 +
9 +module.exports = auth;
1 +const express = require('express');
2 +const authRouter = require('./auth');
3 +const projectRouter = require('./project');
4 +
5 +const router = express.Router();
6 +
7 +router.use('/auth', authRouter);
8 +router.use('/projects', projectRouter);
9 +
10 +module.exports = router;
1 +const express = require('express');
2 +const projectCtrl = require('./projectController');
3 +
4 +const router = express.Router();
5 +
6 +router.get('/', projectCtrl.list);
7 +
8 +module.exports = router;
1 +const { Project } = require('../../models');
2 +
3 +exports.list = async (req, res, next) => {
4 + try {
5 + const { id: userId } = req.user;
6 + const projects = await Project.findAll({ where: { userId } });
7 + res.json({ ok: true, projects });
8 + } catch (err) {
9 + next(err);
10 + }
11 +};
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 +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 +
3 +## Available Scripts
4 +
5 +In the project directory, you can run:
6 +
7 +### `yarn start`
8 +
9 +Runs the app in the development mode.<br />
10 +Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 +
12 +The page will reload if you make edits.<br />
13 +You will also see any lint errors in the console.
14 +
15 +### `yarn test`
16 +
17 +Launches the test runner in the interactive watch mode.<br />
18 +See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 +
20 +### `yarn build`
21 +
22 +Builds the app for production to the `build` folder.<br />
23 +It correctly bundles React in production mode and optimizes the build for the best performance.
24 +
25 +The build is minified and the filenames include the hashes.<br />
26 +Your app is ready to be deployed!
27 +
28 +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 +
30 +### `yarn eject`
31 +
32 +**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 +
34 +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 +
36 +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 +
38 +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 +
40 +## Learn More
41 +
42 +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 +
44 +To learn React, check out the [React documentation](https://reactjs.org/).
45 +
46 +### Code Splitting
47 +
48 +This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 +
50 +### Analyzing the Bundle Size
51 +
52 +This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 +
54 +### Making a Progressive Web App
55 +
56 +This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 +
58 +### Advanced Configuration
59 +
60 +This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 +
62 +### Deployment
63 +
64 +This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 +
66 +### `yarn build` fails to minify
67 +
68 +This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
This diff could not be displayed because it is too large.
1 +{
2 + "name": "frontend",
3 + "version": "0.1.0",
4 + "private": true,
5 + "dependencies": {
6 + "@material-ui/core": "^4.11.0",
7 + "@testing-library/jest-dom": "^4.2.4",
8 + "@testing-library/react": "^9.3.2",
9 + "@testing-library/user-event": "^7.1.2",
10 + "@toast-ui/react-image-editor": "^1.2.0",
11 + "axios": "^0.21.0",
12 + "react": "^16.13.1",
13 + "react-dom": "^16.13.1",
14 + "react-router-dom": "^5.2.0",
15 + "react-scripts": "3.4.3"
16 + },
17 + "scripts": {
18 + "start": "react-scripts start",
19 + "build": "react-scripts build",
20 + "test": "react-scripts test",
21 + "eject": "react-scripts eject"
22 + },
23 + "eslintConfig": {
24 + "extends": "react-app"
25 + },
26 + "browserslist": {
27 + "production": [
28 + ">0.2%",
29 + "not dead",
30 + "not op_mini all"
31 + ],
32 + "development": [
33 + "last 1 chrome version",
34 + "last 1 firefox version",
35 + "last 1 safari version"
36 + ]
37 + }
38 +}
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 React, { createContext, useState} from 'react';
2 +import Routes from './routes';
3 +import HeaderContainer from './container/common/HeaderContainer';
4 +import { HashRouter as Router } from 'react-router-dom';
5 +import userContext from './utils/context';
6 +
7 +function App() {
8 + const [state, setState] = useState({
9 + userName: '',
10 + editingImageUrl: '',
11 + });
12 + const contextProps = {
13 + data: state,
14 + setData: setState,
15 + };
16 +
17 + return (
18 + <Router>
19 + <userContext.Provider value={contextProps}>
20 + <HeaderContainer/>
21 + <Routes />
22 + </userContext.Provider>
23 + </Router>
24 + );
25 +}
26 +
27 +export default App;
1 +import React from 'react';
2 +import { makeStyles } from '@material-ui/core/styles';
3 +import Card from '@material-ui/core/Card';
4 +import CardActionArea from '@material-ui/core/CardActionArea';
5 +import CardActions from '@material-ui/core/CardActions';
6 +import CardContent from '@material-ui/core/CardContent';
7 +import CardMedia from '@material-ui/core/CardMedia';
8 +import Button from '@material-ui/core/Button';
9 +import Typography from '@material-ui/core/Typography';
10 +
11 +const useStyles = makeStyles({
12 + root: {
13 + maxWidth: 345,
14 + margin: 10,
15 + },
16 + media: {
17 + height: 140,
18 + },
19 +});
20 +
21 +const MediaCard = (props) => {
22 + const classes = useStyles();
23 + const { title, imageUrl, onClick } = props;
24 +
25 + return (
26 + <Card className={classes.root} onClick={onClick}>
27 + <CardActionArea>
28 + <CardMedia
29 + className={classes.media}
30 + image={imageUrl}
31 + title="Contemplative Reptile"
32 + />
33 + <CardContent>
34 + <Typography gutterBottom variant="h6">
35 + {title}
36 + </Typography>
37 + </CardContent>
38 + </CardActionArea>
39 + </Card>
40 + );
41 +}
42 +
43 +export default MediaCard;
1 +import React from "react";
2 +import { makeStyles } from "@material-ui/core/styles";
3 +import Card from "@material-ui/core/Card";
4 +import CardActionArea from "@material-ui/core/CardActionArea";
5 +import CardActions from "@material-ui/core/CardActions";
6 +import CardContent from "@material-ui/core/CardContent";
7 +import CardMedia from "@material-ui/core/CardMedia";
8 +import Button from "@material-ui/core/Button";
9 +import Typography from "@material-ui/core/Typography";
10 +import { Link } from "react-router-dom";
11 +
12 +const useStyles = makeStyles({
13 + root: {
14 + maxWidth: 345,
15 + margin: 10,
16 + },
17 + media: {
18 + height: 140,
19 + },
20 +});
21 +
22 +const NewCard = (props) => {
23 + const classes = useStyles();
24 +
25 + return (
26 + <Link to="/editor">
27 + <Card className={classes.root}>
28 + <CardContent>
29 + <Typography> + 새로운 프로젝트 생성</Typography>
30 + </CardContent>
31 + </Card>
32 + </Link>
33 + );
34 +};
35 +
36 +export default NewCard;
1 +import React from 'react';
2 +import { PropTypes } from 'prop-types';
3 +import { Link as RouterLink } from 'react-router-dom';
4 +import { makeStyles, useTheme } from '@material-ui/core/styles';
5 +import Link from '@material-ui/core/Link';
6 +import Button from '@material-ui/core/Button';
7 +import { pathUri } from '../../constants/path';
8 +
9 +const useStyles = makeStyles((theme) => ({
10 + header: {
11 + display: 'flex',
12 + justifyContent: 'space-between',
13 + alignItems: 'center',
14 + height: '60px',
15 + padding: `0 ${theme.spacing(3)}px`,
16 + backgroundColor: 'whitesmoke',
17 + },
18 +}));
19 +
20 +const Header = (props) => {
21 + const classes = useStyles();
22 + //const theme = useTheme();
23 + const { userName, handlelogout } = props;
24 +
25 + return (
26 + <header className={classes.header}>
27 + <div> Image Editor </div>
28 + <div>
29 + {
30 + userName !== ''
31 + ? <Button onClick={handlelogout}>{userName}</Button>
32 + : <Link component={RouterLink} to={pathUri.signin}>Sign in</Link>
33 + }
34 + </div>
35 + </header>
36 + );
37 + };
38 +
39 +// Header.propTypes = {
40 +// data: PropTypes.object,
41 +// handlelogout: PropTypes.func,
42 +// };
43 +
44 + export default Header;
...\ No newline at end of file ...\ No newline at end of file
1 +import React from 'react';
2 +import { PropTypes } from 'prop-types';
3 +import TextField from '@material-ui/core/TextField';
4 +import Button from '@material-ui/core/Button';
5 +import Grid from '@material-ui/core/Grid';
6 +
7 +const FormField = (props) => {
8 + const {
9 + loginState, login, guestLogin
10 + } = props;
11 +
12 + const [state, setState] = React.useState({
13 + loginState,
14 + userName: '',
15 + email: '',
16 + password: '',
17 + confirmPassword: '',
18 + });
19 +
20 + const handleChange = (event) => {
21 + const { name } = event.target;
22 + const value = event.target.value;
23 + setState({ ...state, [name]: value });
24 + };
25 +
26 + return (
27 + <>
28 + <Grid
29 + container
30 + spacing={3}
31 + direction="column"
32 + justify="center"
33 + alignItems="center"
34 + >
35 + <Grid item xs={12}>
36 + Image Editor
37 + </Grid>
38 +
39 + {(!state.loginState)
40 + && (
41 + <Grid item xs={12}>
42 + <TextField
43 + required
44 + id="userName"
45 + label="Name"
46 + variant="filled"
47 + name="userName"
48 + onChange={handleChange}
49 + />
50 + </Grid>
51 + )}
52 +
53 + <Grid item xs={12}>
54 + <TextField
55 + required
56 + id="email"
57 + label="Email"
58 + variant="filled"
59 + name="email"
60 + onChange={handleChange}
61 + />
62 + </Grid>
63 +
64 + <Grid item xs={12}>
65 + <TextField
66 + required
67 + id="password"
68 + label="Password"
69 + type="password"
70 + autoComplete="current-password"
71 + variant="filled"
72 + name="password"
73 + onChange={handleChange}
74 + />
75 + </Grid>
76 +
77 + {(!state.loginState)
78 + && (
79 + <Grid item xs={12}>
80 + <TextField
81 + required
82 + id="confirmPassword"
83 + label="confirmPassword"
84 + type="password"
85 + variant="filled"
86 + name="confirmPassword"
87 + onChange={handleChange}
88 + />
89 + </Grid>
90 + )}
91 +
92 + <Grid item xs={12}>
93 + <Button
94 + variant="contained"
95 + color="primary"
96 + onClick={(e) => { login(state); }}
97 + >
98 + {state.loginState ? 'Sign in' : 'Sign up'}
99 + </Button>
100 + </Grid>
101 + <Grid item xs={12}>
102 + <Button onClick={guestLogin}>
103 + Sign in as a guest
104 + </Button>
105 + </Grid>
106 + </Grid>
107 + </>
108 + );
109 +};
110 +
111 +
112 +// FormField.propTypes = {
113 +// login: PropTypes.bool.isRequired,
114 +// onChange: PropTypes.func,
115 +// onSubmit: PropTypes.func,
116 +// remember: PropTypes.bool,
117 +// };
118 +
119 +export default FormField;
...\ No newline at end of file ...\ No newline at end of file
1 +export const pathUri = {
2 + home: '/',
3 + signin: '/signin',
4 + signup: '/signup',
5 + board: '/board',
6 + editor: '/editor',
7 +};
...\ No newline at end of file ...\ No newline at end of file
1 +import React, { useContext } from 'react';
2 +import Header from '../../components/common/Header';
3 +import userContext from '../../utils/context';
4 +
5 +const HeaderContainer = (props) => {
6 + const { data } = useContext(userContext);
7 +
8 + return (
9 + <Header userName={data.userName}/>
10 + );
11 + };
12 +
13 + export default HeaderContainer;
...\ No newline at end of file ...\ No newline at end of file
1 +import React, { useContext, useEffect } from "react";
2 +import "tui-image-editor/dist/tui-image-editor.css";
3 +import ImageEditor from "@toast-ui/react-image-editor";
4 +import userContext from "../../utils/context";
5 +import whitetheme from "../../utils/theme";
6 +
7 +const ImageEditorContainer = () => {
8 + const editorRef = React.createRef();
9 + const { data, setData } = useContext(userContext);
10 + const { editingImageUrl } = data;
11 + const sampleImageUrl =
12 + "https://kr.object.ncloudstorage.com/image-editor/sample.jpg";
13 +
14 + return (
15 + <ImageEditor
16 + ref={editorRef}
17 + includeUI={{
18 + loadImage: {
19 + path: editingImageUrl ? editingImageUrl : sampleImageUrl,
20 + name: "image",
21 + },
22 + theme: whitetheme,
23 + menu: [
24 + "crop",
25 + "flip",
26 + "rotate",
27 + "draw",
28 + "shape",
29 + "icon",
30 + "text",
31 + "mask",
32 + "filter",
33 + ],
34 + initMenu: "filter",
35 + uiSize: {
36 + width: "100%",
37 + height: "800px",
38 + },
39 + menuBarPosition: "bottom",
40 + }}
41 + cssMaxHeight={500}
42 + cssMaxWidth={700}
43 + selectionStyle={{
44 + cornerSize: 20,
45 + rotatingPointOffset: 70,
46 + }}
47 + usageStatistics={true}
48 + />
49 + );
50 +};
51 +
52 +export default ImageEditorContainer;
1 +import React, { useContext } from 'react';
2 +import { withRouter } from 'react-router-dom';
3 +import { SignApi } from '../../utils/api';
4 +import userContext from '../../utils/context';
5 +import FormField from '../../components/signin/FormField';
6 +import { pathUri } from '../../constants/path';
7 +
8 +const SignInContainer = (props) => {
9 + const { history } = props;
10 + const { data, setData } = useContext(userContext);
11 +
12 + const login = async (state) => {
13 + const data = {
14 + email: state.email,
15 + password: state.password,
16 + };
17 + try {
18 + const { user } = await SignApi('http://localhost:9000/auth/login', { data });
19 + handleSuccess(user);
20 + } catch(err) {
21 + console.log(err);
22 + }
23 + }
24 +
25 + const guestLogin = () => {
26 + history.push(pathUri.editor);
27 + }
28 +
29 + const handleSuccess = (user) => {
30 + setData({
31 + ...data, userName: user.name
32 + })
33 + history.push(pathUri.board);
34 + };
35 +
36 + return (
37 + <>
38 + <FormField
39 + loginState={true}
40 + login={login}
41 + guestLogin={guestLogin}
42 + />
43 + </>
44 + );
45 +};
46 +
47 +export default withRouter(SignInContainer);
...\ No newline at end of file ...\ No newline at end of file
1 +import React from 'react';
2 +import ReactDOM from 'react-dom';
3 +import App from './App';
4 +import * as serviceWorker from './serviceWorker';
5 +
6 +ReactDOM.render(
7 + <React.StrictMode>
8 + <App />
9 + </React.StrictMode>,
10 + document.getElementById('root')
11 +);
12 +
13 +// If you want your app to work offline and load faster, you can change
14 +// unregister() to register() below. Note this comes with some pitfalls.
15 +// Learn more about service workers: https://bit.ly/CRA-PWA
16 +serviceWorker.unregister();
1 +import React, { useState, useEffect, useContext } from "react";
2 +import { SignApi } from "../utils/api";
3 +import { useHistory } from "react-router-dom";
4 +import Container from "@material-ui/core/Container";
5 +import MediaCard from "../components/board/Card";
6 +import NewCard from "../components/board/NewCard";
7 +import { makeStyles } from "@material-ui/core/styles";
8 +import userContext from "../utils/context";
9 +
10 +const useStyles = makeStyles((theme) => ({
11 + container: {
12 + display: "grid",
13 + gridTemplateColumns: "1fr 1fr 1fr 1fr",
14 + background: "white",
15 + marginTop: "40px",
16 + },
17 +}));
18 +
19 +const Board = () => {
20 + const classes = useStyles();
21 + const [projects, setProjects] = useState([]);
22 + const { data, setData } = useContext(userContext);
23 + const history = useHistory();
24 +
25 + const handleClick = (imageUrl) => {
26 + history.push("editor");
27 + setData({ ...data, editingImageUrl: imageUrl });
28 + };
29 +
30 + const getInitialData = async () => {
31 + const { projects } = await SignApi("http://localhost:9000/projects", {
32 + method: "GET",
33 + });
34 + setProjects(projects);
35 + };
36 +
37 + useEffect(() => {
38 + getInitialData();
39 + }, []);
40 +
41 + return (
42 + <Container maxWidth="lg" className={classes.container}>
43 + <NewCard />
44 + {projects.map(({ id, name, imageUrl }) => (
45 + <MediaCard
46 + key={id}
47 + title={name}
48 + imageUrl={imageUrl}
49 + onClick={() => handleClick(imageUrl)}
50 + />
51 + ))}
52 + </Container>
53 + );
54 +};
55 +
56 +export default Board;
1 +import React from 'react';
2 +import ImageEditorContainer from '../container/editor/ImageEditorContainer';
3 +
4 +const Editor = () => {
5 + return (
6 + <ImageEditorContainer />
7 + );
8 +};
9 +
10 +export default Editor;
...\ No newline at end of file ...\ No newline at end of file
1 +import React from 'react';
2 +import Container from '@material-ui/core/Container';
3 +import SignInContainer from '../container/signin/SignInContainer';
4 +import { makeStyles } from "@material-ui/core/styles"
5 +
6 +const useStyles = makeStyles((theme) => ({
7 + container: {
8 + background: 'white',
9 + marginTop: '40px',
10 + },
11 +}))
12 +
13 +const SignIn = () => {
14 + const classes = useStyles()
15 + return (
16 + <Container maxWidth="lg" className={classes.container}>
17 + <SignInContainer/>
18 + </Container>
19 + );
20 +};
21 +
22 +export default SignIn;
...\ No newline at end of file ...\ No newline at end of file
1 +import React from 'react';
2 +import { Switch, Route, Redirect } from 'react-router-dom';
3 +import Editor from './pages/Editor';
4 +import SignIn from './pages/SignIn';
5 +import Board from './pages/Board';
6 +import { pathUri } from './constants/path';
7 +
8 +const routes = () => (
9 + <Switch>
10 + <Route path={pathUri.home} component={SignIn} exact />
11 + <Route path={pathUri.signin} component={SignIn} />
12 + <Route path={pathUri.board} component={Board} />
13 + <Route path={pathUri.editor} component={Editor} />
14 + <Route component={() => <Redirect to={pathUri.home} />} />
15 + </Switch>
16 +);
17 +
18 +export default routes;
...\ No newline at end of file ...\ No newline at end of file
1 +// This optional code is used to register a service worker.
2 +// register() is not called by default.
3 +
4 +// This lets the app load faster on subsequent visits in production, and gives
5 +// it offline capabilities. However, it also means that developers (and users)
6 +// will only see deployed updates on subsequent visits to a page, after all the
7 +// existing tabs open on the page have been closed, since previously cached
8 +// resources are updated in the background.
9 +
10 +// To learn more about the benefits of this model and instructions on how to
11 +// opt-in, read https://bit.ly/CRA-PWA
12 +
13 +const isLocalhost = Boolean(
14 + window.location.hostname === 'localhost' ||
15 + // [::1] is the IPv6 localhost address.
16 + window.location.hostname === '[::1]' ||
17 + // 127.0.0.0/8 are considered localhost for IPv4.
18 + window.location.hostname.match(
19 + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20 + )
21 +);
22 +
23 +export function register(config) {
24 + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
25 + // The URL constructor is available in all browsers that support SW.
26 + const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
27 + if (publicUrl.origin !== window.location.origin) {
28 + // Our service worker won't work if PUBLIC_URL is on a different origin
29 + // from what our page is served on. This might happen if a CDN is used to
30 + // serve assets; see https://github.com/facebook/create-react-app/issues/2374
31 + return;
32 + }
33 +
34 + window.addEventListener('load', () => {
35 + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
36 +
37 + if (isLocalhost) {
38 + // This is running on localhost. Let's check if a service worker still exists or not.
39 + checkValidServiceWorker(swUrl, config);
40 +
41 + // Add some additional logging to localhost, pointing developers to the
42 + // service worker/PWA documentation.
43 + navigator.serviceWorker.ready.then(() => {
44 + console.log(
45 + 'This web app is being served cache-first by a service ' +
46 + 'worker. To learn more, visit https://bit.ly/CRA-PWA'
47 + );
48 + });
49 + } else {
50 + // Is not localhost. Just register service worker
51 + registerValidSW(swUrl, config);
52 + }
53 + });
54 + }
55 +}
56 +
57 +function registerValidSW(swUrl, config) {
58 + navigator.serviceWorker
59 + .register(swUrl)
60 + .then(registration => {
61 + registration.onupdatefound = () => {
62 + const installingWorker = registration.installing;
63 + if (installingWorker == null) {
64 + return;
65 + }
66 + installingWorker.onstatechange = () => {
67 + if (installingWorker.state === 'installed') {
68 + if (navigator.serviceWorker.controller) {
69 + // At this point, the updated precached content has been fetched,
70 + // but the previous service worker will still serve the older
71 + // content until all client tabs are closed.
72 + console.log(
73 + 'New content is available and will be used when all ' +
74 + 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
75 + );
76 +
77 + // Execute callback
78 + if (config && config.onUpdate) {
79 + config.onUpdate(registration);
80 + }
81 + } else {
82 + // At this point, everything has been precached.
83 + // It's the perfect time to display a
84 + // "Content is cached for offline use." message.
85 + console.log('Content is cached for offline use.');
86 +
87 + // Execute callback
88 + if (config && config.onSuccess) {
89 + config.onSuccess(registration);
90 + }
91 + }
92 + }
93 + };
94 + };
95 + })
96 + .catch(error => {
97 + console.error('Error during service worker registration:', error);
98 + });
99 +}
100 +
101 +function checkValidServiceWorker(swUrl, config) {
102 + // Check if the service worker can be found. If it can't reload the page.
103 + fetch(swUrl, {
104 + headers: { 'Service-Worker': 'script' },
105 + })
106 + .then(response => {
107 + // Ensure service worker exists, and that we really are getting a JS file.
108 + const contentType = response.headers.get('content-type');
109 + if (
110 + response.status === 404 ||
111 + (contentType != null && contentType.indexOf('javascript') === -1)
112 + ) {
113 + // No service worker found. Probably a different app. Reload the page.
114 + navigator.serviceWorker.ready.then(registration => {
115 + registration.unregister().then(() => {
116 + window.location.reload();
117 + });
118 + });
119 + } else {
120 + // Service worker found. Proceed as normal.
121 + registerValidSW(swUrl, config);
122 + }
123 + })
124 + .catch(() => {
125 + console.log(
126 + 'No internet connection found. App is running in offline mode.'
127 + );
128 + });
129 +}
130 +
131 +export function unregister() {
132 + if ('serviceWorker' in navigator) {
133 + navigator.serviceWorker.ready
134 + .then(registration => {
135 + registration.unregister();
136 + })
137 + .catch(error => {
138 + console.error(error.message);
139 + });
140 + }
141 +}
1 +// jest-dom adds custom jest matchers for asserting on DOM nodes.
2 +// allows you to do things like:
3 +// expect(element).toHaveTextContent(/react/i)
4 +// learn more: https://github.com/testing-library/jest-dom
5 +import '@testing-library/jest-dom/extend-expect';
1 +import axios from 'axios';
2 +
3 +export const requestOptions = {
4 + baseURL: 'http://localhost:3000/',
5 + method: 'POST',
6 + withCredentials: true,
7 + headers: {
8 + 'Content-Type': 'application/json',
9 + },
10 +};
11 +
12 +export const SignApi = (url, option) => {
13 + const options = { ...requestOptions, ...option };
14 + return new Promise((resolve, reject) => {
15 + axios(url, options)
16 + .then((response) => resolve(response.data))
17 + .catch((error) => reject(error));
18 + });
19 +};
...\ No newline at end of file ...\ No newline at end of file
1 +import React from 'react';
2 +
3 +const userContext = React.createContext(null); // Create a context object
4 +
5 +export default userContext;
...\ No newline at end of file ...\ No newline at end of file
1 +const whiteTheme = {
2 + "common.bi.image": "https://imgur.com/EaA2e9g.png",
3 + "common.bisize.width": "251px",
4 + "common.bisize.height": "21px",
5 + "common.backgroundImage": "./img/bg.png",
6 + "common.backgroundColor": "#fff",
7 + "common.border": "1px solid #c1c1c1",
8 +
9 + // header
10 + "header.backgroundImage": "none",
11 + "header.backgroundColor": "transparent",
12 + "header.border": "0px",
13 +
14 + // load button
15 + "loadButton.backgroundColor": "#fff",
16 + "loadButton.border": "1px solid #ddd",
17 + "loadButton.color": "#C799DC",
18 + "loadButton.fontFamily": "'Noto Sans', sans-serif",
19 + "loadButton.fontSize": "12px",
20 +
21 + // download button
22 + "downloadButton.backgroundColor": "#C799DC",
23 + "downloadButton.border": "1px solid #C799DC",
24 + "downloadButton.color": "#fff",
25 + "downloadButton.fontFamily": "'Noto Sans', sans-serif",
26 + "downloadButton.fontSize": "12px",
27 +
28 + // main icons
29 + "menu.normalIcon.color": "#8a8a8a",
30 + "menu.activeIcon.color": "#555555",
31 + "menu.disabledIcon.color": "#434343",
32 + "menu.hoverIcon.color": "#e9e9e9",
33 + "menu.iconSize.width": "24px",
34 + "menu.iconSize.height": "24px",
35 +
36 + // submenu icons
37 + "submenu.normalIcon.color": "#8a8a8a",
38 + "submenu.activeIcon.color": "#555555",
39 + "submenu.iconSize.width": "32px",
40 + "submenu.iconSize.height": "32px",
41 +
42 + // submenu primary color
43 + "submenu.backgroundColor": "transparent",
44 + "submenu.partition.color": "#e5e5e5",
45 +
46 + // submenu labels
47 + "submenu.normalLabel.color": "#858585",
48 + "submenu.normalLabel.fontWeight": "normal",
49 + "submenu.activeLabel.color": "#000",
50 + "submenu.activeLabel.fontWeight": "normal",
51 +
52 + // checkbox style
53 + "checkbox.border": "1px solid #ccc",
54 + "checkbox.backgroundColor": "#fff",
55 +
56 + // rango style
57 + "range.pointer.color": "#333",
58 + "range.bar.color": "#ccc",
59 + "range.subbar.color": "#606060",
60 +
61 + "range.disabledPointer.color": "#d3d3d3",
62 + "range.disabledBar.color": "rgba(85,85,85,0.06)",
63 + "range.disabledSubbar.color": "rgba(51,51,51,0.2)",
64 +
65 + "range.value.color": "#000",
66 + "range.value.fontWeight": "normal",
67 + "range.value.fontSize": "11px",
68 + "range.value.border": "0",
69 + "range.value.backgroundColor": "#f5f5f5",
70 + "range.title.color": "#000",
71 + "range.title.fontWeight": "lighter",
72 +
73 + // colorpicker style
74 + "colorpicker.button.border": "0px",
75 + "colorpicker.title.color": "#000",
76 +};
77 +
78 +export default whiteTheme;
This diff could not be displayed because it is too large.