-
Notifications
You must be signed in to change notification settings - Fork 2
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
마이페이지에서 작성글, 관심목록, 구매목록을 조회하기 위한 미들웨어 추가 #85
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
77bfc24
feat: add a router to search for items sold by individuals
kgpyo 3c31aeb
feat: add buyer, interest filter
kgpyo 5d7470d
chore: add fuzziness option
kgpyo 186ba51
fix: search result priority
kgpyo 560237a
feat: add keyword model for autocomplete
kgpyo e76242e
feat: router setup for keyword search
kgpyo 4bcf435
fix: configure elasticsearch to stop when testing
kgpyo 861698b
fix: fixed 500 error when db connection failed
kgpyo 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import mongoose from 'mongoose'; | ||
|
||
export const dbConnect = () => { | ||
const options = { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true, | ||
keepAlive: false, | ||
}; | ||
let errorMessage; | ||
mongoose.connect(`${process.env.MONGO_URL}`, options, (err) => { | ||
if (err) { | ||
errorMessage = err.toString(); | ||
} | ||
}); | ||
return (req, res, next) => { | ||
if (errorMessage) { | ||
next({ status: 500, message: errorMessage }); | ||
} else { | ||
next(); | ||
} | ||
}; | ||
}; | ||
|
||
export const mongoosasticSettings = (process.env.NODE_ENV === 'test') ? {} : { | ||
hosts: process.env.ELASTICSEARCH, | ||
port: process.env.ESPORT, | ||
bulk: { | ||
size: 100, | ||
delay: 1000, | ||
}, | ||
}; | ||
|
||
export const redisConnection = { | ||
port: 6379, | ||
host: '127.0.0.1', | ||
password: 'test132@', | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// esSearch convert promise | ||
export default async function (query, options) { | ||
return new Promise((resolve, reject) => { | ||
this.esSearch(query, options, (err, result) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(result); | ||
} | ||
}); | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import mongoose from 'mongoose'; | ||
import mongoosastic from 'mongoosastic'; | ||
import promiseSearch from '../common/statics'; | ||
import { mongoosasticSettings } from '../../config'; | ||
|
||
const { Schema } = mongoose; | ||
|
||
const keywordScheme = new Schema({ | ||
word: { | ||
type: String, | ||
required: true, | ||
es_indexed: true, | ||
es_type: 'text', | ||
unique: true, | ||
}, | ||
}); | ||
|
||
keywordScheme.plugin(mongoosastic, mongoosasticSettings); | ||
|
||
keywordScheme.static('search', promiseSearch); | ||
|
||
const Keyword = mongoose.model('Keyword', keywordScheme); | ||
|
||
|
||
module.exports = Keyword; |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,21 @@ | ||
import 'dotenv/config'; | ||
import mongoose from 'mongoose'; | ||
import model from '../model'; | ||
import mock from './20191209.json'; | ||
|
||
const { product } = model; | ||
|
||
mongoose.connect(`${process.env.MONGO_URL}`, { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true, | ||
}); | ||
const { product, keyword } = model; | ||
|
||
(async () => { | ||
try { | ||
const db = await mongoose.connection; | ||
mongoose.connect(`${process.env.MONGO_URL}`, { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true, | ||
}); | ||
await mongoose.connection; | ||
await product.deleteMany({}); | ||
await keyword.deleteMany({}); | ||
await product.create(mock); | ||
db.close(); | ||
} catch (e) { | ||
throw Error(e); | ||
console.log(e); | ||
} | ||
})(); |
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.
구매자는 왜 들어가나요?
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.
구매목록을 조회하기 위함입니다.