-
Notifications
You must be signed in to change notification settings - Fork 57
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
9383f88
commit 5bd0c63
Showing
39 changed files
with
2,361 additions
and
1,989 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
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,4 @@ | ||
import Clue from '@/models/Clue'; | ||
import Clue from '../../models/Clue.js'; | ||
|
||
let clueCountCache = { | ||
count: 0, | ||
|
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
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,53 @@ | ||
import { getServerSession } from "../../components/auth/serverAuth.js"; | ||
import officialCountryMaps from "../../public/officialCountryMaps.json" with { type: "json" }; | ||
import Map from "../../models/Map.js"; | ||
import User from "../../models/User.js"; | ||
import msToTime from "../../components/msToTime.js"; | ||
|
||
export default async function handler(req, res) { | ||
const slug = req.query.slug; | ||
console.log("Getting map data for", slug); | ||
const session = await getServerSession(req); | ||
|
||
// Check if map is an official country map | ||
const cntryMap = Object.values(officialCountryMaps).find(map => map.slug === slug); | ||
if (cntryMap) { | ||
return res.json({ | ||
mapData: { | ||
...cntryMap, | ||
description_short: cntryMap.shortDescription, | ||
description_long: cntryMap.longDescription, | ||
created_by: "WorldGuessr", | ||
in_review: false, | ||
rejected: false | ||
} | ||
}); | ||
} | ||
|
||
// If map is not official, check user-created maps | ||
const map = await Map.findOne({ slug }) | ||
.select({ 'data': { $slice: 10 } }) // Slice the data to limit to 10 items | ||
.lean(); | ||
|
||
if (!map) { | ||
return res.status(404).json({ message: 'Map not found' }); | ||
} | ||
|
||
const authorId = map.created_by; | ||
const authorUser = await User.findById(authorId).lean(); | ||
const authorSecret = authorUser?.secret; | ||
const staff = session?.token?.staff; | ||
|
||
const isCreatorOrStaff = session && (authorSecret === session?.token?.secret || staff); | ||
|
||
if (!map.accepted && !isCreatorOrStaff) { | ||
return res.status(404).json({ message: 'Map not accepted or no permission to view' }); | ||
} | ||
|
||
map.created_by = authorUser?.username; | ||
map.created_at = msToTime(Date.now() - map.created_at); | ||
|
||
return res.json({ | ||
mapData: map | ||
}); | ||
} |
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
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,5 @@ | ||
export function getServerSession(req, res, authOptions) { | ||
console.log("Getting server session"); | ||
|
||
return null; | ||
} |
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.