-
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.
- Loading branch information
1 parent
89cc279
commit d6691b3
Showing
3 changed files
with
77 additions
and
1 deletion.
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,7 +8,6 @@ function getGoodBySlug(slug) { | |
); | ||
} | ||
|
||
|
||
module.exports = { | ||
getGoodBySlug | ||
} |
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,75 @@ | ||
const express = require('express') | ||
|
||
const Database = require('../../database/newclient'); | ||
const router = express.Router(); | ||
|
||
async function getAllCocktailsSlug() { | ||
return Database.collection('cocktails') | ||
.find({}, { slug: 1 }) | ||
.toArray(); | ||
} | ||
|
||
async function getAllToolsSlug() { | ||
return Database.collection('tools') | ||
.find({}, { slug: 1 }) | ||
.toArray(); | ||
} | ||
|
||
async function getAllGoodsSlug() { | ||
return Database.collection('goods') | ||
.find({}, { slug: 1 }) | ||
.toArray(); | ||
} | ||
|
||
async function getAllGlasswareSlug() { | ||
return Database.collection('glassware') | ||
.find({}, { slug: 1 }) | ||
.toArray(); | ||
} | ||
|
||
async function getAllTagsSlug() { | ||
return Database.collection('tags') | ||
.find({}, { slug: 1 }) | ||
.toArray(); | ||
} | ||
|
||
async function getAllTastesSlug() { | ||
return Database.collection('tastes') | ||
.find({}, { slug: 1 }) | ||
.toArray(); | ||
} | ||
|
||
async function getAllAlcoholVolumeSlug() { | ||
return Database.collection('alcoholVolumes') | ||
.find({}, { slug: 1 }) | ||
.toArray(); | ||
} | ||
|
||
router.get('/api/sitemap', async (req, res) => { | ||
const cocktails = (await getAllCocktailsSlug()).map((cocktail) => `cocktails/${cocktail.slug}`); | ||
const goods = (await getAllGoodsSlug()).map((good) => `goods/${good.slug}`); | ||
const tools = (await getAllToolsSlug()).map((tool) => `tools/${tool.slug}`); | ||
const glassware = (await getAllGlasswareSlug()).map((glass) => `glassware/${glass.slug}`); | ||
const tagsFilter = (await getAllTagsSlug()).map((tag) => `tags=${tag.slug}`); | ||
const goodsFilter = (await getAllGoodsSlug()).map((good) => `goods=${good.slug}`); | ||
const toolsFilter = (await getAllToolsSlug()).map((tool) => `tools=${tool.slug}`); | ||
const tastsFilter = (await getAllTastesSlug()).map((tag) => `taste=${tag.slug}`); | ||
const alcoholVolumeFilter = (await getAllAlcoholVolumeSlug()).map((tag) => `alcohol-volume=${tag.slug}`); | ||
const glasswareFilter = (await getAllGlasswareSlug()).map((glass) => `glassware=${glass.slug}`); | ||
|
||
|
||
const urls = cocktails | ||
.concat(goods) | ||
.concat(tools) | ||
.concat(glassware) | ||
.concat(tagsFilter) | ||
.concat(goodsFilter) | ||
.concat(toolsFilter) | ||
.concat(tastsFilter) | ||
.concat(alcoholVolumeFilter) | ||
.concat(glasswareFilter); | ||
|
||
return res.status(200).send(urls); | ||
}); | ||
|
||
module.exports = router; |
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