Skip to content

Commit

Permalink
๐ŸŽจ ํ™˜๊ฒฝ ๋ถ„๋ฆฌ
Browse files Browse the repository at this point in the history
  • Loading branch information
jjikky committed Jun 29, 2024
1 parent 04dc393 commit bcf6efb
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const express = require('express');
const conf = require('./src/common/config/index');
const expressLoader = require('./src/common/modules/express');
const initDB = require('./src/common/modules/mongodb');
const { START_MESSAGE } = require('./src/common/constants/express');

const app = express();

Expand All @@ -10,7 +11,7 @@ const initServer = async () => {

await initDB();
app.listen(conf.port, () => {
console.log(`app listening on http://localhost:${conf.port}`);
console.log(START_MESSAGE);
});
};

Expand Down
34 changes: 34 additions & 0 deletions src/common/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,38 @@ const conf = {
kakaoRestApiKey: process.env.KAKAO_REST_API_KEY,
};

switch (process.env.NODE_ENV) {
case 'production':
conf.cookieInAccessTokenOptions = {
httpOnly: false,
maxAge: 10 * 60 * 1000,
sameSite: 'Lax',
secure: true,
};
conf.cookieInRefreshTokenOptions = {
httpOnly: true,
maxAge: 10 * 60 * 1000,
sameSite: 'Lax',
secure: true,
};
conf.envMode = 'prod';
break;
case 'development':
conf.cookieInAccessTokenOptions = {
httpOnly: false,
maxAge: 10 * 60 * 1000,
sameSite: 'Lax',
};
conf.cookieInRefreshTokenOptions = {
httpOnly: true,
maxAge: 10 * 60 * 1000,
sameSite: 'Lax',
};
1;
conf.envMode = 'dev';
break;
default:
console.error('NODE_ENV is not set correctly. It should be either production or development');
}

module.exports = conf;
1 change: 1 addition & 0 deletions src/common/constants/error-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const ErrorMessage = Object.freeze({
LOGIN_ERROR: '๋กœ๊ทธ์ธ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค.',
KAKAO_LOGIN_ERROR: '์นด์นด์˜ค ๋กœ๊ทธ์ธ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค.',
NO_REFRESH_TOKEN: 'refresh token์ด ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.',
REFRESH_TOKEN_ERROR: 'refresh token ๊ฒ€์ฆ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค.',
});

module.exports = ErrorMessage;
13 changes: 13 additions & 0 deletions src/common/constants/express.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const conf = require('../config');

const mode = {
dev: 'development',
prod: 'production',
};

exports.START_MESSAGE = `
================================================================
MURAKANO API Server has been started at localhost:${conf.port}
Mode : ${mode[conf.envMode]}
================================================================
`;

0 comments on commit bcf6efb

Please sign in to comment.