forked from lukePeavey/quotable
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add function to jest to auto-refresh when test files changed. * Add API for getting a quote by its ID. * Change 'sample' folder to 'samples' and update gitignore and contributing files. * Add web API for getting list of 'tags'. * Remove duplicate web API in 'routes' for getting a quote by its ID. * Rename 'samples' folder back to 'sample'.
- Loading branch information
1 parent
08002ac
commit d8a2e1e
Showing
10 changed files
with
148 additions
and
12 deletions.
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 |
---|---|---|
|
@@ -8,8 +8,8 @@ | |
|
||
docs/ | ||
private/ | ||
data/ | ||
!data/samples | ||
data/* | ||
!data/sample | ||
|
||
# misc | ||
.DS_Store | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
[ | ||
{ | ||
"_id": "lmOF86Cv", | ||
"name": "famous-quotes" | ||
}, | ||
{ | ||
"_id": "7HjmNmOIE", | ||
"name": "life" | ||
}, | ||
{ | ||
"_id": "ZY0PgehL1", | ||
"name": "friendship" | ||
}, | ||
{ | ||
"_id": "rYJgbbjOK", | ||
"name": "science" | ||
}, | ||
{ | ||
"_id": "ZBOfkMBWc", | ||
"name": "technology" | ||
}, | ||
{ | ||
"_id": "M97I8NOsF", | ||
"name": "inspirational" | ||
}, | ||
{ | ||
"_id": "PnbpDlRlC", | ||
"name": "motivational" | ||
}, | ||
{ | ||
"_id": "637eDKoGB", | ||
"name": "literature" | ||
}, | ||
{ | ||
"_id": "fqgdQmYNk", | ||
"name": "art" | ||
}, | ||
{ | ||
"_id": "BPCApygPx", | ||
"name": "business" | ||
}, | ||
{ | ||
"_id": "CkRvna8Tz", | ||
"name": "love" | ||
}, | ||
{ | ||
"_id": "AK9UKVnIm", | ||
"name": "success" | ||
}, | ||
{ | ||
"_id": "GADjjdrcd", | ||
"name": "religion" | ||
}, | ||
{ | ||
"_id": "8mV7Dhqt3", | ||
"name": "social-justice" | ||
} | ||
] |
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,17 @@ | ||
const Tags = require('../../models/Tags') | ||
|
||
/** | ||
* Get list of tags from the database. | ||
*/ | ||
module.exports = async function listTags(req, res, next) { | ||
try { | ||
const results = await Tags.find({}).select('name') | ||
|
||
res.status(200).json({ | ||
count: results.length, | ||
results, | ||
}) | ||
} catch (error) { | ||
return next(error) | ||
} | ||
} |
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 @@ | ||
const { Schema, model } = require('mongoose') | ||
const shortid = require('shortid') | ||
|
||
const TagSchema = new Schema({ | ||
_id: { type: String, default: shortid.generate }, | ||
name: { type: String, required: true }, | ||
}) | ||
|
||
// To support full text search | ||
TagSchema.index({ name: 'text' }) | ||
|
||
module.exports = model('Tag', TagSchema) |
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,4 +1,5 @@ | ||
const Quotes = require('./Quotes') | ||
const Authors = require('./Authors') | ||
const Tags = require('./Tags') | ||
|
||
module.exports = { Quotes, Authors } | ||
module.exports = { Quotes, Authors, Tags } |
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