Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/issue 62 #63

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
package-lock.json
node_modules/**/package.json
package.json
project/
node_modules/
node_modules/**/*.json
*.json
body-parser/
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
*/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# COLLUSIC

#### 온라인 프로듀싱 협업 프로젝트
#### 온라인 프로듀싱 협업 프로젝트!

프로듀싱하는데 협업을 하고 싶다?

Expand All @@ -10,8 +10,6 @@

"작곡가"들을 위한 온라인 프로듀싱 협업 서비스🎤🎶🎸🎹



#### 프로젝트 규칙

Collusic 프로젝트를 처음 접하시는 같이 개발하는 개발자에게 전합니다. 이 규칙은 서로의 코드를 더 잘 이해할 수 있게 정해진 규칙입니다. 때문에 언제든지 모든 개발자가 동의한다면 변경이 가능합니다. 규칙을 준수하여 서로의 발전을 도와줍시다.
Expand All @@ -28,8 +26,6 @@ Collusic 프로젝트를 처음 접하시는 같이 개발하는 개발자에게
8. 컴포넌트를 제외한 함수의 이름은 동작의 의미가 담겨 있어야 합니다.
9. 컴포넌트 코드가 들어간 파일의 확장자는 jsx를 사용합니다.



##### 코딩컨벤션

else 사용을 최대한 자제합니다.
Expand All @@ -48,8 +44,6 @@ else 사용을 최대한 자제합니다.

게터/세터 속성 사용을 금지합니다.



규칙1, 2, 3, 5, 6, 9

https://developerfarm.wordpress.com/2012/02/03/object_calisthenics_summary/
Expand Down
2 changes: 2 additions & 0 deletions backend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
COOKIE_SECRET=cookiesecret
NODE_ENV=test
74 changes: 74 additions & 0 deletions backend/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const express = require("express");
const cookieParser = require("cookie-parser");
const morgan = require("morgan");
const path = require("path");
const session = require("express-session");
const nunjucks = require("nunjucks");
const dotenv = require("dotenv");
const passport = require("passport");
dotenv.config();
const pageRouter = require("./routes/page");
const authRouter = require("./routes/auth");
const postRouter = require("./routes/post");
const { sequelize } = require("./models");
const passportConfig = require("./passport");
const cors = require("cors");

const app = express();
passportConfig();
app.set("port", process.env.PORT || 8001);
app.set("view engine", "html");
nunjucks.configure("views", {
express: app,
watch: true,
});
sequelize
.sync({ force: false }) //sequelize가 초기화 될 때 DB에 필요한 테이블 생성
.then(() => {
console.log("데이터베이스 연결 성공");
})
.catch((err) => {
console.error(err);
});

app.use(morgan("dev"));
app.use(express.static(path.join(__dirname, "public")));
app.use("/img", express.static(path.join(__dirname, "uploads")));
app.use(cors());

app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cookieParser(process.env.COOKIE_SECRET));
app.use(
session({
resave: false,
saveUninitialized: false,
secret: process.env.COOKIE_SECRET,
cookie: {
httpOnly: true,
secure: false,
},
})
);
app.use(passport.initialize());
app.use(passport.session());
app.use("/", pageRouter);
app.use("/auth", authRouter);
app.use("/post", postRouter);

app.use((req, res, next) => {
const error = new Error(`${req.method} ${req.url} 라우터가 없습니다.`);
error.status = 404;
next(error);
});

app.use((err, req, res, next) => {
res.locals.message = err.message;
res.locals.error = process.env.NODE_ENV !== "production" ? err : {};
res.status(err.status || 500);
res.render("error");
});

app.listen(app.get("port"), () => {
console.log(app.get("port"), "번 포트에서 대기중");
});
23 changes: 23 additions & 0 deletions backend/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"development": {
"username": "root",
"password": "daaeda",
"database": "collusic",
"host": "127.0.0.1",
"dialect": "mysql"
},
"test": {
"username": "collusic",
"password": "collusic3717",
"database": "collusic",
"host": "54.180.156.26",
"dialect": "mysql"
},
"production": {
"username": "root",
"password": null,
"database": "database_production",
"host": "127.0.0.1",
"dialect": "mysql"
}
}
52 changes: 52 additions & 0 deletions backend/controllers/contributeProjects/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const router = require("express");
const {
isLoggedIn,
isNotLoggedIn,
upload_commit,
} = require("../../routes/middlewares");
const { Post, User,Comment } = require("../../models");
//field값

const createContriProjectAPI = async (req, res) => {
let id = req.params.id;
const commentpost = await Comment.create({
c_description: req.body.description,
c_audioFile: req.file.filename,
c_lyrics_text: req.body.lyrics_text,
pid: id,
selected_status:false
});
if (!commentpost) {
res.status(400).json({
success: false,
});
} else {
res.status(200).json({
success: true,
commentpost: commentpost,
});
}
};

/*
const createContributeProjectAPI = async (req, res, next) => {
try { // 기여작 생성 쿼리
const createcontributeproject = await Comment.create({
c_description: req.body.description,
c_audioFile: req.file.filename,
c_lyrics_text: req.body.lyrics_text,
});
res.status(200).json({
createcontributeproject,
});
} catch (err) {
console.log(err);
console.log(req.file);
res.status(400).json({ message: err });
}
};
*/

module.exports = {
createContriProjectAPI: createContriProjectAPI,
};
36 changes: 36 additions & 0 deletions backend/controllers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// const express = require("express");
// const router = express.Router();

// const userInformationAPI = (req, res) => {
// try {
// const myinfo = await User.findOne({
// attributes: ["email", "introduce"],
// where: {
// email: req.user.email,
// },
// });
// res.status(200).json({
// email: myinfo,
// });
// } catch (err) {
// res.status(400).json({
// error: err,
// });
// }
// };

const createContributeProjectAPI = (req, res) => {};
const readRequestProjectsAPI = (req, res) => {};
const readContributeProjectsAPI = (req, res) => {
if (!id) {
res.status(400).json({ error: "you don't send requestProject Id!" });
}

res.status(200).json({ contributeProject: projects });
};
module.exports = {
userInformationAPI,
createContributeProjectAPI,
readRequestProjectsAPI,
readContributeProjectsAPI,
};
28 changes: 28 additions & 0 deletions backend/controllers/mypage/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const express = require("express");
const router = express.Router();
const { isLoggedIn, isNotLoggedIn } = require("../../routes/middlewares");
const { Post, User } = require("../../models");
//field값
const readMyPageAPI = async (req, res, next) => {
try {
const myinfo = await User.findOne({
attributes: ["email", "introduce"],
where: {
email: req.user.email,
},
});
res.status(200).json({
email: myinfo,
});
// const postinfo = await Post.findAll({
// attributes: ["title", "field"],
// });
} catch (err) {
res.status(400).json({ error: err });
}
};
// isLoggedIn 미들웨어 어디다 넣지..?

module.exports = {
readMyPageAPI: readMyPageAPI,
};
35 changes: 35 additions & 0 deletions backend/controllers/requestProjects/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const router = require("express");
const {
isLoggedIn,
isNotLoggedIn,
upload,
} = require("../../routes/middlewares");
const { Post, User } = require("../../models");
//field값

const createProjectAPI = async (req, res) => {
const post = await Post.create({
title: req.body.title,
description: req.body.description,
genre: req.body.genre,
mood: req.body.mood,
lyrics_text: req.body.lyrics_text,
audioFile: req.file.originalname,
music_field: req.body.music_field,
lyrics_field: req.body.lyrics_field,
instrument_field: req.body.instrument_field,
});
if (!post) {
res.status(400).json({
success: false,
});
} else {
res.status(200).json({
success: true,
post: post,
});
}
};
module.exports = {
createProjectAPI: createProjectAPI,
};
2 changes: 2 additions & 0 deletions backend/controllers/user/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// const express = require("express");
// const router = express.Router();
44 changes: 44 additions & 0 deletions backend/models/comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const Sequelize = require("sequelize");

module.exports = class Comment extends Sequelize.Model {
static init(sequelize) {
return super.init(
{
c_description: {
type: Sequelize.TEXT,
allowNull: false,
},
c_audioFile: {
type: Sequelize.STRING(140),
allowNull: false,
},
c_lyrics_text: {
type: Sequelize.TEXT,
allowNull: true,
},
selected_status: {
type: Sequelize.BOOLEAN,
allowNull: true,
},
},
{
sequelize,
timestamps: true,
underscored: false,
modelName: "Comment",
tableName: "comment",
paranoid: false,
charset: "utf8mb4",
collate: "utf8mb4_general_ci",
}
);
}

static associate(db) {
db.Comment.belongsTo(db.Post, { foreignKey: "pid", sourceKey: "id" });
db.Comment.belongsTo(db.User, { foreignKey: "uid", sourceKey: "id" });
}
};
//requestid 외래키
//uid 외래키
//constraint uid foreign key uid references user.uid on delete cascade on update cascade
Loading