Skip to content

Commit 68d76b1

Browse files
committed
upload
0 parents  commit 68d76b1

25 files changed

+2067
-0
lines changed

Server/.gcloudignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file specifies files that are *not* uploaded to Google Cloud
2+
# using gcloud. It follows the same syntax as .gitignore, with the addition of
3+
# "#!include" directives (which insert the entries of the given .gitignore-style
4+
# file at that point).
5+
#
6+
# For more information, run:
7+
# $ gcloud topic gcloudignore
8+
#
9+
.gcloudignore
10+
# If you would like to upload your .git directory, .gitignore file or files
11+
# from your .gitignore file, remove the corresponding line
12+
# below:
13+
.git
14+
.gitignore
15+
16+
# Node.js dependencies:
17+
node_modules/

Server/.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Dependency directories
7+
node_modules/
8+
9+
#보안관련해서..
10+
package-lock.json
11+
firebase-adminsdk.json
12+
.env

Server/app.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
runtime: nodejs16
2+
env: standard
3+
4+
manual_scaling:
5+
instances: 1
6+
resources:
7+
cpu: 1
8+
memory_gb: 0.5
9+
disk_size_gb: 10

Server/package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "backend",
3+
"version": "1.0.0",
4+
"description": "Good-to-Go Backend",
5+
"main": "index.js",
6+
"type": "module",
7+
"scripts": {
8+
"start": "node src",
9+
"dev": "nodemon --watch src/ src/index.js",
10+
"test": "echo \"Error: no test specified\" && exit 1"
11+
},
12+
"author": "",
13+
"license": "ISC",
14+
"dependencies": {
15+
"@google-cloud/storage": "^6.9.4",
16+
"cookie-parser": "^1.4.6",
17+
"cors": "^2.8.5",
18+
"dotenv": "^16.0.3",
19+
"express": "^4.18.2",
20+
"firebase-admin": "^11.5.0",
21+
"firebase-functions": "^4.2.1",
22+
"multer": "^1.4.5-lts.1",
23+
"node-schedule": "^2.1.1",
24+
"node-schedule-tz": "^1.2.1-4",
25+
"uuid": "^9.0.0"
26+
},
27+
"devDependencies": {
28+
"nodemon": "^2.0.20"
29+
}
30+
}

Server/src/config/firebase.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import config from './index.js';
2+
import admin from 'firebase-admin';
3+
import { getFirestore } from 'firebase-admin/firestore';
4+
import { getAuth } from 'firebase-admin/auth';
5+
import { getStorage } from 'firebase-admin/storage';
6+
7+
import serviceAccount from './firebase-adminsdk.json' assert { type: "json" };
8+
9+
const app = admin.initializeApp({
10+
credential: admin.credential.cert(serviceAccount),
11+
storageBucket: config.storageBucket
12+
});
13+
14+
const fbDB = getFirestore(app);
15+
const fbAuth = getAuth(app);
16+
const bucket = getStorage().bucket();
17+
18+
export { fbDB, fbAuth, bucket};

Server/src/config/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import dotenv from "dotenv";
2+
3+
// Set the NODE_ENV to 'development' by default
4+
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
5+
6+
const envFound = dotenv.config();
7+
8+
if (envFound.error) {
9+
// This error should crash whole process
10+
throw new Error(envFound.error);
11+
}
12+
13+
const {
14+
PORT,
15+
COOKIE_SECRET,
16+
STORAGE_BUCKET,
17+
ORIGIN_URL,
18+
} = process.env;
19+
20+
export default {
21+
port: PORT,
22+
cookieSecret: COOKIE_SECRET,
23+
storageBucket:STORAGE_BUCKET,
24+
originUrl: ORIGIN_URL
25+
};

Server/src/controllers/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export { default as userController } from "./userController.js";
2+
export { default as restrtController } from "./restrtController.js";
3+
export { default as orderController } from "./orderController.js";
4+
export { default as reviewController } from "./reviewController.js";
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import express from 'express';
2+
import { orderService } from "../service/index.js";
3+
4+
/**
5+
* @route GET /order/:id
6+
* @desc get order data by order Id
7+
* @access Private
8+
*/
9+
const getOrderById = async (req, res) => {
10+
const { id } = req.params;
11+
try {
12+
const getOrderById = await orderService.getOrderById(id);
13+
return res.status(200).json({
14+
status: 200,
15+
success: true,
16+
message: "주문 정보 읽기 성공",
17+
data: getOrderById,
18+
});
19+
}catch (error){
20+
console.log(error);
21+
res.status(400).json({
22+
status: 400,
23+
success: false,
24+
message: error.message,
25+
});
26+
}
27+
};
28+
29+
/**
30+
* @route POST /order
31+
* @desc post order
32+
* @access Private
33+
*/
34+
const postOrder = async (req, res) => {
35+
const data = req.body;
36+
try {
37+
const postOrder = await orderService.postOrder(data);
38+
return res.status(200).json({
39+
status: 200,
40+
success: true,
41+
message: "주문 전송 성공",
42+
data: postOrder,
43+
});
44+
}catch (error){
45+
console.log(error);
46+
res.status(400).json({
47+
status: 400,
48+
success: false,
49+
message: error.message,
50+
});
51+
}
52+
};
53+
54+
/**
55+
* @route GET /order/user/{id}
56+
* @desc get order LIst data by user Id
57+
* @access Private
58+
*/
59+
const getOrderListByUserId = async (req, res) => {
60+
const { id } = req.params;
61+
try {
62+
const getOrderListByUserId = await orderService.getOrderListByUserId(id);
63+
return res.status(200).json({
64+
status: 200,
65+
success: true,
66+
message: "사용자별 주문 리스트 읽기 성공",
67+
data: getOrderListByUserId,
68+
});
69+
}catch (error){
70+
console.log(error);
71+
res.status(400).json({
72+
status: 400,
73+
success: false,
74+
message: error.message,
75+
});
76+
}
77+
};
78+
79+
/**
80+
* @route GET /order/user/{id}
81+
* @desc get order LIst data by user Id
82+
* @access Private
83+
*/
84+
const getOrderListByUserIdWithPage = async (req, res) => {
85+
const { id } = req.params;
86+
try {
87+
const page = req.query.page;
88+
const size = req.query.size;
89+
const packed = req.query.packed;
90+
//쿼리 값이 없으면
91+
if((page == undefined) || (size == undefined) ){
92+
const getOrderListByUserId = await orderService.getOrderListByUserId(id);
93+
return res.status(200).json({
94+
status: 200,
95+
success: true,
96+
message: "사용자별 주문 리스트 전체 읽기 성공",
97+
data: getOrderListByUserId,
98+
});
99+
}
100+
101+
//쿼리 값이 있으면
102+
if (page < 1) { //0이하면 에러
103+
return res.status(400).json({
104+
status: 400,
105+
success: false,
106+
message: '잘못된 요청. 페이지는 1 이상부터 가능',
107+
});
108+
}
109+
if ((packed != undefined) && (packed != 1)) {
110+
return res.status(400).json({
111+
status: 400,
112+
success: false,
113+
message: '잘못된 요청. packed는 1 혹은 undifined 값만을 가짐',
114+
});
115+
}
116+
const getOrderListByUserIdWithPage = await orderService.getOrderListByUserIdWithPage(id, page, size, packed);
117+
return res.status(200).json({
118+
status: 200,
119+
success: true,
120+
message: "페이지 형태로 사용자별 주문 리스트 읽기 성공",
121+
data: getOrderListByUserIdWithPage,
122+
});
123+
}catch (error){
124+
console.log(error);
125+
res.status(400).json({
126+
status: 400,
127+
success: false,
128+
message: error.message,
129+
});
130+
}
131+
};
132+
133+
export default {
134+
getOrderById,
135+
postOrder,
136+
getOrderListByUserIdWithPage
137+
};

0 commit comments

Comments
 (0)