-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
69dd4e4
commit c9e65bc
Showing
8 changed files
with
2,665 additions
and
5,672 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { generateNewCode } from "../../src/pages/api/generate"; | ||
import { GenerateMessage } from "../../src/types"; | ||
import { Handler, HandlerEvent } from "@netlify/functions"; | ||
|
||
/** | ||
* Netlify function specific code, can be ignored in local development. | ||
*/ | ||
|
||
const handler: Handler = async (event: HandlerEvent) => { | ||
if (event.httpMethod !== 'POST') { | ||
return { statusCode: 405, body: `Method ${event.httpMethod} Not Allowed` }; | ||
} | ||
if (!event.body) { | ||
return { statusCode: 405, body: 'Missing body' }; | ||
} | ||
try { | ||
const message = JSON.parse(event.body) as GenerateMessage; | ||
const response = await generateNewCode(message); | ||
return { | ||
statusCode: 200, | ||
body: JSON.stringify(response) | ||
}; | ||
} catch (e) { | ||
console.error(e); | ||
return { | ||
statusCode: 500, | ||
body: JSON.stringify({ | ||
error: 'There was an error generating the models' | ||
}) | ||
}; | ||
} | ||
} | ||
export { handler as default }; |
Large diffs are not rendered by default.
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
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.