-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactor/Lambda #21
Open
tanonkim
wants to merge
5
commits into
master
Choose a base branch
from
refactor/lambda
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Refactor/Lambda #21
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c0f5ecc
Refactor : Fix app.js -> index.js
tanonkim c3b30a9
Feature : Add engines 20 -> 18 && install serverless-https
tanonkim f731900
Refactor : Add CircularReplacer
tanonkim 78f91a0
Refactor : Fix minor
tanonkim e040f5b
Refactor : Fix .env
tanonkim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
PORT=YOUR_POTR_NUMBER | ||
# DB | ||
DB_CONNECTION = DB_CONNECTION | ||
DB_USERNAME = DB_USERNAME | ||
DB_PASSWORD = DB_PASSWORD | ||
DB_LOGGING = DB_LOGGING | ||
|
||
DB_CONNECTION=CONNECTION | ||
DB_HOST=HOST | ||
DB_USERNAME=USERNAME | ||
DB_PASSWORD=PASSWORD | ||
DB_DATABASE=DATABASENAME | ||
DB_PORT=PROT | ||
DB_LOGGING=LOGGING | ||
DB_HOST = DB_HOST | ||
DB_DATABASE = DB_DATABASE | ||
DB_PORT = DB_PORT | ||
DATABASE_URL = DATABASE_URL | ||
|
||
DATABASE_URL=URL | ||
|
||
SECRET_KEY=SECRET_KEY | ||
PORT = PORT | ||
SECRET_KEY = SECRET_KEY | ||
|
||
# AWS-S3 | ||
AWS_ACCESS_KEY_ID=AWS_ACCESS_KEY_ID | ||
AWS_SECRET_ACCESS_KEY=AWS_SECRET_ACCESS_KEY | ||
AWS_S3_REGION=AWS_S3_REGION | ||
AWS_S3_BUCKET_NAME=AWS_S3_BUCKET_NAME | ||
AWS_ACCESS_KEY_ID = AWS_ACCESS_KEY_ID | ||
AWS_SECRET_ACCESS_KEY = AWS_SECRET_ACCESS_KEY | ||
S3_REGION = S3_REGION | ||
BUCKET_NAME = BUCKET_NAME | ||
|
||
API_ENDPOINT=API_ENDPOINT | ||
META_DATA_URL = META_DATA_URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
const serverless = require("serverless-http"); // Lambda | ||
|
||
const dotenv = require("dotenv"); | ||
|
||
const express = require("express"); | ||
|
@@ -10,31 +12,37 @@ const dataSource = require("./models/appDataSource"); | |
const routes = require("./routes"); | ||
const baseResponse = require("./utils/baseResponse"); | ||
|
||
dataSource | ||
.initialize() | ||
.then(() => { | ||
const initializeDataSource = async () => { | ||
try { | ||
await dataSource.initialize(); | ||
console.log("Data Source has been initialized!"); | ||
}) | ||
.catch((error) => { | ||
console.err(`Initialize Error ${error}`); | ||
}); | ||
} catch (error) { | ||
console.error(`Initialize Error: ${error}`); | ||
} | ||
}; | ||
|
||
// 데이터 소스를 즉시 초기화하려는 경우 여기서 호출 | ||
initializeDataSource(); | ||
|
||
const app = express(); | ||
|
||
app.use(express.json()); | ||
app.use(cors()); | ||
app.use(morgan("dev")); | ||
app.use(routes); | ||
app.use(baseResponse); | ||
|
||
app.get("/ping", (req, res) => { | ||
return res.status(200).json({ message: "pong" }); | ||
}); | ||
// app.get("/", (req, res) => { | ||
// return res.status(200).json({ message: "Welcome to the API" }); | ||
// }); | ||
|
||
const PORT = process.env.PORT; | ||
|
||
const start = async () => { | ||
app.listen(PORT, () => console.log(`server is listening on ${PORT}`)); | ||
}; | ||
|
||
start(); | ||
start(); | ||
|
||
module.exports.handler = serverless(app); | ||
Comment on lines
+47
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. module.exports.handler = serverless(app); AWS Lambda와 같은 서버리스 환경에서 Express.js 애플리케이션을 실행하기 위해 필요해요!
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app.js
에서index.js
로 변경하였습니다.app.js
로 사용해도 상관없는데, 그냥 핸들러의 default가 index이기에 바꿨습니다.app.js
로 사용하면app.handler
로 수정하면 돼요!