16 lines
No EOL
563 B
TypeScript
16 lines
No EOL
563 B
TypeScript
import fsPromises from 'fs/promises'
|
|
import path from 'path'
|
|
|
|
export default async function MapApi(req: any, res: any) {
|
|
const { map } = req.query
|
|
try {
|
|
// get Empire and Game name first to create an EmpireData object
|
|
const filePathMap = path.join(process.cwd(), '/public/images/'+map+'/info.json');
|
|
const jsonMapData = await fsPromises.readFile(filePathMap);
|
|
res.status(200).send(jsonMapData.toString())
|
|
}
|
|
catch (error) {
|
|
console.log(error)
|
|
res.status(500).json({error: 'Error reading data'})
|
|
}
|
|
} |