Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions api/discovery.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//discovery.js
export default function handler(req, res) {
const handler = async (req, res) => {
if (req.method !== 'GET') {
return res.status(405).json({ error: 'Method not allowed' });
}
Expand All @@ -23,7 +23,7 @@ export default function handler(req, res) {
required: false
}
],
endpoint: `${baseUrl}/tools/greeting`,
endpoint: `/tools/greeting`,
http_method: "POST"
},
{
Expand All @@ -37,16 +37,17 @@ export default function handler(req, res) {
required: false
}
],
endpoint: `${baseUrl}/tools/todays-date`,
endpoint: `/tools/todays-date`,
http_method: "POST"
},
{
name: "rick-roll",
description: "Rick rolls the user",
parameters: [],
endpoint: `${baseUrl}/tools/rick-roll`,
endpoint: `/tools/rick-roll`,
http_method: "POST"
}
];
res.status(200).json({ functions });
}
module.exports = handler;
14 changes: 14 additions & 0 deletions api/hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const handler = async (req, res) => {
try {
const { name = 'World' } = req.query;
res.status(200).json({
message: `Hello, ${name}!`,
timestamp: new Date().toISOString(),
method: req.method
});
} catch (error) {
res.status(500).json({ error: 'Internal Server Error' });
}
};

module.exports = handler;
5 changes: 0 additions & 5 deletions api/test.js

This file was deleted.

3 changes: 2 additions & 1 deletion api/tools/greeting.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// api/tools/greeting.js
export default function handler(req, res) {
const handler = async (req, res) => {
if (req.method !== 'POST') {
return res.status(405).json({ error: 'Method not allowed' });
}
Expand Down Expand Up @@ -30,3 +30,4 @@ export default function handler(req, res) {
res.status(500).json({ error: 'Internal server error' });
}
}
module.exports = handler;
3 changes: 2 additions & 1 deletion api/tools/rick-roll.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// api/tools/rick-roll.js
export default function handler(req, res) {
const handler = async (req, res) => {
if (req.method !== 'POST') {
return res.status(405).json({ error: 'Method not allowed' });
}
Expand All @@ -25,3 +25,4 @@ export default function handler(req, res) {
res.status(500).json({ error: 'Internal server error' });
}
}
module.exports = handler;
3 changes: 2 additions & 1 deletion api/tools/todays-date.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// api/tools/todays-date.js
export default function handler(req, res) {
const handler = async (req, res) => {
if (req.method !== 'POST') {
return res.status(405).json({ error: 'Method not allowed' });
}
Expand Down Expand Up @@ -39,3 +39,4 @@ export default function handler(req, res) {
res.status(500).json({ error: 'Internal server error' });
}
}
module.exports = handler;
17 changes: 0 additions & 17 deletions package.json

This file was deleted.

31 changes: 27 additions & 4 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"version": 2,
"builds": [
{ "src": "*.html", "use": "@vercel/static" },
{ "src": "*.py", "use": "@vercel/python" },
{ "src": "*.js", "use": "@vercel/node" }
{
"src": "api/**/*.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/api/([^/]+)",
"methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
"dest": "/api/$1.js"
},
{
"src": "/api/([^/]+).*",
"methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
"dest": "/api/$1.js"
},
{
"src": "/api/tools/([^/]+)",
"methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
"dest": "/api/tools/$1.js"
},
{
"src": "/api/tools/([^/]+).*",
"methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
"dest": "/api/tools/$1.js"
}
]
}