Skip to content

Commit

Permalink
Merge branch 'main' into 55-feat-add-activitypub
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvasandani authored Mar 6, 2024
2 parents f4a35ab + 4349235 commit 0cdf419
Show file tree
Hide file tree
Showing 9 changed files with 874 additions and 42 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ _gemini/
node_modules/
dist/
.DS_Store

# Local Netlify folder
.netlify
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
18
23 changes: 19 additions & 4 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@
for = "/.well-known/webfinger"
[headers.values]
Content-Type = "application/jrd+json"
[[redirects]]
from = "/hello"
to = "/.netlify/functions/hello"
status = 200

[functions]
external_node_modules = ["express"]
node_bundler = "esbuild"

[[redirects]]
force = true
from = "/api/*"
status = 200
to = "/.netlify/functions/api/:splat"

# Redirects and headers are GLOBAL for all builds – they do not get scoped to
# contexts no matter where you define them in the file.
# For context-specific rules, use _headers or _redirects files, which are
# applied on a PER-DEPLOY basis.

# REDIRECT and HEADERS examples

Expand All @@ -36,7 +55,3 @@
# X-XSS-Protection = "1; mode=block"
# Content-Security-Policy = "frame-ancestors https://www.facebook.com"

# Redirects and headers are GLOBAL for all builds – they do not get scoped to
# contexts no matter where you define them in the file.
# For context-specific rules, use _headers or _redirects files, which are
# applied on a PER-DEPLOY basis.
33 changes: 33 additions & 0 deletions netlify/functions/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import express, { Router, Request, Response } from "express";
import serverless from "serverless-http";
import os from "os";

const api = express();

const router = Router();
router.get("/hello", (req, res) => res.send("Hello World!"));

// Echo route
router.get("/echo", (req: Request, res: Response) => {
const echo = {
path: req.path,
headers: req.headers,
method: req.method,
body: req.body,
cookies: req.cookies,
hostname: req.hostname,
ip: req.ip,
protocol: req.protocol,
query: req.query,
subdomains: req.subdomains,
os: {
hostname: os.hostname()
},
};

res.json(echo);
});

api.use("/api/", router);

export const handler = serverless(api);
5 changes: 5 additions & 0 deletions netlify/functions/hello/hello.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { Context } from "@netlify/functions"

export default async (req: Request, context: Context) => {
return new Response("Hello, world!")
}
Loading

0 comments on commit 0cdf419

Please sign in to comment.