Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
delete output log
Browse files Browse the repository at this point in the history
  • Loading branch information
gms-hi-oda committed Sep 7, 2019
1 parent 2f3b2d0 commit 35f43a7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 30 deletions.
6 changes: 3 additions & 3 deletions conf/my.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
[mysqld]
bind-address = 0.0.0.0
# スロークエリの設定
slow_query_log = 1
long_query_time = 0
slow_query_log_file = /var/log/mysql/slow.log
# slow_query_log = 1
# long_query_time = 0
# slow_query_log_file = /var/log/mysql/slow.log
4 changes: 2 additions & 2 deletions conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ http {
"\truntime:$upstream_http_x_runtime"
"\tapptime:$upstream_response_time"
"\tvhost:$host"; # alp用のlog format
access_log /var/log/nginx/access.log ltsv;
# access_log off; # 不要になったらOFFにする
# access_log /var/log/nginx/access.log ltsv;
access_log off; # 不要になったらOFFにする
include /etc/nginx/mime.types;
default_type application/octet-stream;

Expand Down
25 changes: 0 additions & 25 deletions webapp/nodejs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,6 @@ async function postItemEdit(req: FastifyRequest, reply: FastifyReply<ServerRespo
}

async function postBuy(req: FastifyRequest, reply: FastifyReply<ServerResponse>) {
console.time("post buy: postBuy");

const csrfToken = req.body.csrf_token;

Expand All @@ -1032,17 +1031,14 @@ async function postBuy(req: FastifyRequest, reply: FastifyReply<ServerResponse>)
}

const db = await getDBConnection();
console.time("post buy: getLoginUser");
const buyer = await getLoginUser(req, db);
console.timeEnd("post buy: getLoginUser");

if (buyer === null) {
replyError(reply, "no session", 404);
await db.release();
return;
}

console.time("post buy: postBuy select data");
await db.beginTransaction();

let targetItem: Item | null = null;
Expand All @@ -1062,15 +1058,13 @@ async function postBuy(req: FastifyRequest, reply: FastifyReply<ServerResponse>)
}

if (targetItem.status !== ItemStatusOnSale) {
console.log('item is not for sale');
replyError(reply, "item is not for sale", 403);
await db.rollback();
await db.release();
return;
}

if (targetItem.seller_id === buyer.id) {
console.log('自分の商品は買えません');
replyError(reply, "自分の商品は買えません", 403);
await db.rollback();
await db.release();
Expand All @@ -1091,19 +1085,15 @@ async function postBuy(req: FastifyRequest, reply: FastifyReply<ServerResponse>)
await db.release();
return;
}
console.timeEnd("post buy: postBuy select data");

console.time("post buy: getCategoryByID");
const category = await getCategoryByID(db, targetItem.category_id);
if (category === null) {
replyError(reply, "category id error", 500);
await db.rollback();
await db.release();
return;
}
console.timeEnd("post buy: getCategoryByID");

console.time("post buy: insert data");
const [result] = await db.query(
"INSERT INTO `transaction_evidences` (`seller_id`, `buyer_id`, `status`, `item_id`, `item_name`, `item_price`, `item_description`,`item_category_id`,`item_root_category_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
[
Expand All @@ -1130,11 +1120,9 @@ async function postBuy(req: FastifyRequest, reply: FastifyReply<ServerResponse>)
targetItem.id,
]
)
console.timeEnd("post buy: insert data");


try {
console.time("post buy: paymentToken");

const promises = [];

Expand Down Expand Up @@ -1176,9 +1164,7 @@ async function postBuy(req: FastifyRequest, reply: FastifyReply<ServerResponse>)
return;
}

console.timeEnd("post buy: paymentToken");

console.time("post buy: insert shippiing");

await db.query(
"INSERT INTO `shippings` (`transaction_evidence_id`, `status`, `item_name`, `item_id`, `reserve_id`, `reserve_time`, `to_address`, `to_name`, `from_address`, `from_name`, `img_binary`) VALUES (?,?,?,?,?,?,?,?,?,?,?)",
Expand All @@ -1196,7 +1182,6 @@ async function postBuy(req: FastifyRequest, reply: FastifyReply<ServerResponse>)
"",
]
);
console.timeEnd("post buy: insert shippiing");

} catch (e) {
replyError(reply, "payment service is failed", 500)
Expand All @@ -1214,7 +1199,6 @@ async function postBuy(req: FastifyRequest, reply: FastifyReply<ServerResponse>)
await db.commit();
await db.release();

console.timeEnd("post buy: postBuy");

reply.code(200)
.type("application/json;charset=utf-8")
Expand All @@ -1232,41 +1216,35 @@ async function postSell(req: FastifyRequest, reply: FastifyReply<ServerResponse>
const categoryIdStr = req.body.category_id;

if (csrfToken !== req.cookies.csrf_token) {
console.log("csrf token error");
replyError(reply, "csrf token error", 422);
return;
}

const categoryId: number = parseInt(categoryIdStr, 10);
if (isNaN(categoryId) || categoryId < 0) {
console.log("category id error");
replyError(reply, "category id error", 400);
return;
}

const price: number = parseInt(priceStr, 10);
if (isNaN(price) || price < 0) {
console.log("price error");
replyError(reply, "price error", 400);
return;
}

if (price < ItemMinPrice || price > ItemMaxPrice) {
console.log(ItemPriceErrMsg);
replyError(reply, ItemPriceErrMsg, 400);
return;
}

if (name === null || name === "" || description === null || description === "" || price === 0 || categoryId === 0) {
console.log("all parameters are required");
replyError(reply, "all parameters are required", 400);
}

const db = await getDBConnection();

const category = await getCategoryByID(db, categoryId);
if (category === null || category.parent_id === 0) {
console.log("Incorrect category ID");
replyError(reply, "Incorrect category ID", 400);
await db.release();
return;
Expand All @@ -1275,15 +1253,13 @@ async function postSell(req: FastifyRequest, reply: FastifyReply<ServerResponse>
const user = await getLoginUser(req, db);

if (user === null) {
console.log("no session");
replyError(reply, "no session", 404);
await db.release();
return;
}

let ext = path.extname(req.body.image[0].filename);
if (![".jpg", ".jpeg", ".png", ".gif"].includes(ext)) {
console.log("unsupported image format error");
replyError(reply, "unsupported image format error", 400);
await db.release();
return;
Expand All @@ -1309,7 +1285,6 @@ async function postSell(req: FastifyRequest, reply: FastifyReply<ServerResponse>
}

if (seller === null) {
console.log("user not found");
replyError(reply, "user not found", 404);
await db.rollback();
await db.release();
Expand Down

0 comments on commit 35f43a7

Please sign in to comment.