-
Notifications
You must be signed in to change notification settings - Fork 1
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
7 changed files
with
63 additions
and
20 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 was deleted.
Oops, something went wrong.
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,8 @@ | ||
/** | ||
* This route will return all of the data on the server. | ||
*/ | ||
import { NextResponse } from "next/server"; | ||
|
||
export async function GET() { | ||
return NextResponse.json({message: "The pull route is not yet finished!"}); | ||
} |
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,31 @@ | ||
/** | ||
* This route allows the client to send data with the server | ||
*/ | ||
import { existsSync, mkdirSync, writeFile } from "fs"; | ||
import { NextRequest, NextResponse } from "next/server"; | ||
|
||
export async function GET() { | ||
return NextResponse.json({ "error_message": "You cannot GET this api route!" }); | ||
} | ||
|
||
export async function POST( | ||
req: NextRequest | ||
) { | ||
const dataDir = "./turbo-data/"; | ||
|
||
if (!existsSync(dataDir)) { | ||
mkdirSync(dataDir); | ||
} | ||
|
||
if (req.body == null) { | ||
return NextResponse.json({ "error_message": "You must send some data!" }); | ||
} | ||
|
||
//TODO: check if data is blank but not null, e.g. {} or [] | ||
|
||
const fileName = "data-" + btoa(new Date().toISOString()) + ".json"; | ||
writeFile(fileName, await req.json(), () => { }); | ||
|
||
|
||
return NextResponse.json({ "fileName": fileName }); | ||
} |
This file was deleted.
Oops, something went wrong.
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