Be happy, take a happic:
맀μΌμ μΆμ΅μ΄ λμ νλ³΅μ΄ λμ΄, ν΄ν½
μ ν¬λ ν΄ν½μ λλ€SOPT 30th APP JAM
νλ‘μ νΈ κΈ°κ° : 2022.07.02 ~ 2022.07.23
μΆν λ¦΄λ¦¬μ¦ μμ
μ΄μμ° | κΉλμ¬ | μ μ‘κ²½ |
dltjdn | ehdwoKIM | ssong915 |
-
main: λ°°ν¬λ₯Ό μν λΈλμΉ ( μ΅μ’ λ³Έ )
-
develop: κΈ°λ₯ κ°λ°μ΄ μλ£λ μ½λλ€μ΄ λͺ¨μ΄λ κ³³ ( κ²μ¦λ κ³³μ΄μ κ²μ¦ν κ³³ )
-
feature: κΈ°λ₯ κ°λ°μ μν λΈλμΉ ( feature/λ³ΈμΈμ΄λ¦/κΈ°λ₯λͺ )
- [ADD] : μλ‘μ΄ κΈ°λ₯ ꡬν
- [FEAT] : ADD μ΄μΈμ λΆμμ μΈ μ½λ μΆκ°, λΌμ΄λΈλ¬λ¦¬ μΆκ°, μλ‘μ΄ νμΌ μμ± μ
- [CHORE]: μ½λ μμ , λ΄λΆ νμΌ μμ
- [FIX] : λ²κ·Έ, μ€λ₯ ν΄κ²°
- [DEL] : μΈλͺ¨μλ μ½λ μμ
- [DOCS] : READMEλ WIKI λ±μ λ¬Έμ κ°μ
- [MOVE] : νλ‘μ νΈ λ΄ νμΌμ΄λ μ½λμ μ΄λ
- [RENAME] : νμΌ μ΄λ¦μ λ³κ²½
- [STYLE] : μ½λκ° μλ μ€νμΌ λ³κ²½μ νλ κ²½μ°
λͺ λͺ κ·μΉ (Naming Conventions)
- μ΄λ¦μΌλ‘λΆν° μλκ° μ½νμ§ μ μκ² μ΄λ€.
- μ€λΈμ νΈ, ν¨μ, κ·Έλ¦¬κ³ μΈμ€ν΄μ€μλ
camelCase
λ₯Ό μ¬μ©νλ€. - ν΄λμ€λ constructorμλ
PascalCase
λ₯Ό μ¬μ©νλ€. - ν¨μ μ΄λ¦μ λμ¬ + λͺ
μ¬ ννλ‘ μμ±νλ€.
ex)postUserInformation()
- μ½μ΄ μ¬μ©μ μ΅λν μ§μνλ€.
- μ΄λ¦μ λ€ λ¨μ΄ μ΄μμ΄ λ€μ΄κ°λ©΄ νμκ³Ό μμλ₯Ό κ±°μΉ ν μ¬μ©νλ€.
- λ°μ΄ν°λ² μ΄μ€ λͺ μ μμ΄ μλ¬Έμλ‘ κ΅¬μ±νλ€.
λΈλ‘ (Blocks)
- 볡μνμ λΈλ‘μλ μ€κ΄νΈ({})λ₯Ό μ¬μ©νλ€.
- 볡μν λΈλ‘μ if μ else λ₯Ό μ΄μ©νλ κ²½μ° else λ if λΈλ‘ λμ μ€κ΄νΈ( } )μ κ°μ νμ μμΉμν¨λ€.
μ½λ©νΈ (Comments)
- 볡μνμ μ½λ©νΈλ
/** ... */
λ₯Ό μ¬μ©νλ€. - λ¨μΌ νμ μ½λ©νΈμλ
//
μ μ¬μ©νκ³ μ½λ©νΈλ₯Ό μΆκ°νκ³ μΆμ μ½λμ μλΆμ λ°°μΉνλ€. κ·Έλ¦¬κ³ μ½λ©νΈμ μμ λΉ νμ λ£λλ€.
λ¬Έμμ΄ (Strings)
- λ¬Έμμ΄μλ μ±ν¬μΏΌνΈ
''
λ₯Ό μ¬μ©νλ€.. - νλ‘κ·Έλ¨μμ λ¬Έμμ΄μ μμ±νλ κ²½μ°λ λ¬Έμμ΄ μ°κ²°μ΄ μλ
template strings
λ₯Ό μ΄μ©νλ€.
ν¨μ (Functions)
- νμ΄ν ν¨μλ₯Ό μ¬μ©νλ€.
var arr1 = [1, 2, 3];
var pow1 = arr.map(function (x) { // ES5 Not Good
return x * x;
});
const arr2 = [1, 2, 3];
const pow2 = arr.map(x => x * x); // ES6 Good
- λΉλκΈ° ν¨μ μ¬μ© μ Promiseν¨μμ μ¬μ©μ μ§μνκ³ async, await λ₯Ό μ¬μ©νλλ‘ νλ€.
쑰건μκ³Ό λ±κ°μ (Comparsion Operators & Equality)
==
μ΄λ!=
보λ€===
μ!==
μ μ¬μ©νλ€.- λ¨μΆνμ μ¬μ©νλ€.
- λΉλκΈ° ν¨μλ₯Ό μ¬μ©ν λ
Promise
ν¨μμ μ¬μ©μ μ§μνκ³async, await
λ₯Ό μ°λλ‘ νλ€.
π¦ config
β π index.ts
π¦ controllers
β£ π index.ts
π¦ interfaces
β π film
β β π FilmInfo.ts
β π keyword
β π KeywordInfo.ts
β π user
β π UserInfo.ts
π¦ loaders
β π db.ts
π¦ middlewares
β π auth.ts
π¦ models
β£ π Film.ts
β£ π Keyword.ts
β π User.ts
π¦ modules
β π util.ts
β π statusCode.ts
β π responseMessage.ts
π¦ routes
β£ π index.ts
π¦ services
β£ π index.ts
Char
const CharSchema = new mongoose.Schema({
characterId: {
type: Number,
required: true,
},
characterName: {
type: String,
required: true,
},
});
File
const FileSchema = new mongoose.Schema(
{
link: {
type: String,
required: true,
},
fileName: {
type: String,
required: true,
},
},
{
timestamps: true, // createdAt, updatedAt μλκΈ°λ‘
}
);
User
const UserSchema = new mongoose.Schema({
name: {
type: String,
required: true,
},
social: {
type: String,
required: true,
unique: true,
},
socialId: {
type: String,
required: true,
unique: true,
},
email: {
type: String,
required: true,
unique: true,
},
characterId: {
type: Number,
required: true,
},
characterName: {
type: String,
required: true,
},
growthRate: {
type: Number,
required: true,
default: 0,
},
level: {
type: Number,
required: true,
default: 1,
},
film: [
{
type: mongoose.Types.ObjectId,
ref: 'Film',
},
],
count: {
type: Number,
required: true,
default: 0,
},
fcmToken: {
type: String,
required: true,
unique: true,
},
refreshToken: {
type: String,
required: true,
unique: true,
},
});
Film
const FilmSchema = new mongoose.Schema(
{
writer: {
type: mongoose.Types.ObjectId,
required: true,
ref: 'User',
},
photo: {
type: String,
required: true,
},
thumbnail: {
type: String,
},
keyword: [
{
type: mongoose.Types.ObjectId,
required: true,
ref: 'Keyword',
},
],
year: {
type: Number,
required: true,
},
month: {
type: Number,
required: true,
},
},
{
timestamps: true, // createdAt, updatedAt μλκΈ°λ‘
}
);
Keyword
const KeywordSchema = new mongoose.Schema(
{
writer: {
type: mongoose.Types.ObjectId,
required: true,
ref: 'User',
},
category: {
type: String,
required: true,
},
content: {
type: String,
required: true,
},
year: {
type: Number,
required: true,
},
month: {
type: Number,
required: true,
},
count: {
type: Number,
required: true,
default: 0,
},
},
{
timestamps: true, // createdAt, updatedAt μλκΈ°λ‘
}
);
{
"name": "node-typescript-init",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "nodemon",
"build": "tsc",
"start:dev": "node dist/index.js",
"test": "mocha -r ts-node/register src/test/daily.spec.ts"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/chai": "^4.3.1",
"@types/express": "^4.17.13",
"@types/jsonwebtoken": "^8.5.8",
"@types/mocha": "^9.1.1",
"@types/mongoose": "^5.11.97",
"@types/multer": "^1.4.7",
"@types/multer-s3": "^2.7.12",
"@types/node": "^17.0.25",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^5.30.5",
"@typescript-eslint/parser": "^5.30.5",
"chai": "^4.3.6",
"eslint": "^8.19.0",
"mocha": "^10.0.0",
"nodemon": "^2.0.15",
"prettier": "^2.7.1",
"supertest": "^6.2.4",
"ts-node": "^10.7.0",
"typescript": "^4.6.3"
},
"dependencies": {
"aws-sdk": "^2.1143.0",
"axios": "^0.27.2",
"bcryptjs": "^2.4.3",
"bucket": "^0.0.1",
"dayjs": "^1.11.3",
"dotenv": "^16.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"express": "^4.18.1",
"express-validator": "^6.14.2",
"firebase-admin": "^11.0.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^6.3.1",
"multer": "^1.4.4",
"multer-s3": "^2.10.0",
"node-schedule": "^2.1.0",
"winston": "^3.8.1"
}
}
- κ°λ° νκ²½ : Typescript, Express(Node.js)
- λ°μ΄ν°λ² μ΄μ€ : MongoDB, AWS S3
- μλ² νκ²½ : AWS EC2, PM2