-
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
Showing
5 changed files
with
73 additions
and
77 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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
# testing | ||
/coverage | ||
/temp | ||
/data | ||
|
||
# next.js | ||
/.next/ | ||
|
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 |
---|---|---|
@@ -1,75 +1,59 @@ | ||
// import type { NextApiRequest, NextApiResponse } from "next"; | ||
// import { readFileSync } from "fs"; | ||
// // import { readFileSync } from "fs"; | ||
|
||
type dataType = { | ||
duraction: number, | ||
text: string, | ||
locale: string, | ||
language: string | ||
} | ||
type errorType = { | ||
error: string | ||
} | ||
// type dataType = { | ||
// duraction: number, | ||
// text: string, | ||
// locale: string, | ||
// language: string | ||
// } | ||
// type errorType = { | ||
// error: string | ||
// } | ||
|
||
// const text = "data/text.json"; | ||
|
||
// export const config = { | ||
// runtime: 'edge', | ||
// } | ||
|
||
// export default async function handler(req: NextApiRequest, res: NextApiResponse){ | ||
// if(req.method === "POST"){ | ||
// const time = req.query?.t; | ||
// const language = req.query?.l; | ||
|
||
// export default async function handler(request: Request){ | ||
// if(!await checkAuth(request)){ | ||
// return new Response(JSON.stringify({ error: "Unauthorized request!" }), { | ||
// status: 401, | ||
// headers: apiHeaders, | ||
// if(time && language){ | ||
// try{ | ||
// // const readData = readFileSync(text, 'utf8'); | ||
// // const data = JSON.parse(readData); | ||
// const data = { | ||
// data: | ||
// [ | ||
// "lorem ipsum dolor sit amet, consect lorem ipsum dolor sit amet, consect", | ||
// "afkjh asoh aosh ofa oiash oha fm dolor sit amet, consect", | ||
// "g3 2oig fadgfe fqw qw qw qwf qw fqw fct", | ||
// "la fiaosjhf oisah fohnqwoih fqw fq" | ||
// ] | ||
// }; | ||
// const ranText: string = data?.data[Math.floor(Math.random() * data.data.length)]; | ||
|
||
// if(!ranText) return res.status(500).json({ error: "Something went wrong with parsing the text!" }); | ||
// return res.status(200).json({ | ||
// duraction: Number(time), | ||
// text: ranText, | ||
// locale: language as string, | ||
// language: language === "en-us" ? "english" : "english" as string | ||
// }) | ||
// }catch(err: any){ | ||
// return res.status(500).json({ | ||
// error: err?.message || "Something went wrong with parsing the text!" | ||
// }) | ||
// } | ||
// }else{ | ||
// return res.status(404).json({ | ||
// error: "Didn't provide data!" | ||
// }) | ||
// } | ||
// }else{ | ||
// return res.status(400).json({ | ||
// error: "Bad request" | ||
// }) | ||
// } | ||
// req: NextApiRequest, res: NextApiResponse | ||
export default async function handler(request: Request){ | ||
return new Response(JSON.stringify({ error: "testing" }), { | ||
status: 401, | ||
}) | ||
|
||
// if(req.method === "POST"){ | ||
// const time = req.query?.t; | ||
// const language = req.query?.l; | ||
|
||
// if(time && language){ | ||
// try{ | ||
// // const readData = readFileSync(text, 'utf8'); | ||
// // const data = JSON.parse(readData); | ||
// const data = { | ||
// data: | ||
// [ | ||
// "lorem ipsum dolor sit amet, consect lorem ipsum dolor sit amet, consect", | ||
// "afkjh asoh aosh ofa oiash oha fm dolor sit amet, consect", | ||
// "g3 2oig fadgfe fqw qw qw qwf qw fqw fct", | ||
// "la fiaosjhf oisah fohnqwoih fqw fq" | ||
// ] | ||
// }; | ||
// const ranText: string = data?.data[Math.floor(Math.random() * data.data.length)]; | ||
|
||
// if(!ranText) return res.status(500).json({ error: "Something went wrong with parsing the text!" }); | ||
// return res.status(200).json({ | ||
// duraction: Number(time), | ||
// text: ranText, | ||
// locale: language as string, | ||
// language: language === "en-us" ? "english" : "english" as string | ||
// }) | ||
// }catch(err: any){ | ||
// return res.status(500).json({ | ||
// error: err?.message || "Something went wrong with parsing the text!" | ||
// }) | ||
// } | ||
// }else{ | ||
// return res.status(404).json({ | ||
// error: "Didn't provide data!" | ||
// }) | ||
// } | ||
// }else{ | ||
// return res.status(400).json({ | ||
// error: "Bad request" | ||
// }) | ||
// } | ||
} | ||
// } |
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