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
27 changes: 27 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Dependency/Build Directories
node_modules
npm-debug.log
.npm

# Project Files
.git
.gitignore
.dockerignore
Dockerfile
fly.toml # Fly.io configuration file

# Environment/Configuration Files
.env
.DS_Store
*.log

# Development/Testing files and directories (adjust as needed)
test
tests
docs
coverage
tmp
*~
# Any files generated during development or testing, e.g.:
dist
build
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SUPABASE_SERVICE_KEY=sb_secret_OsAmmAu1NZQhxnU8Q4nFAg_l53arJP4
SUPABASE_URL=https://pvfwwwovnyylktrsfqkn.supabase.co
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Stage 1: Build the Application
# We use node:22 as the base for building and installing dependencies.
FROM node:22 AS build

# Set the working directory inside the container
WORKDIR /usr/src/app

# Copy package.json and package-lock.json first to leverage Docker caching.
# If these files don't change, subsequent builds can skip 'npm install'.
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy the rest of the application source code
COPY . .

# Stage 2: Create the Final Production Image
# We use node:22 as the runtime image with all the necessary tools.
FROM node:22

# Set the working directory
WORKDIR /usr/src/app

# Copy the node_modules and built application files from the 'build' stage
COPY --from=build /usr/src/app/node_modules ./node_modules
COPY --from=build /usr/src/app/package*.json ./
COPY --from=build /usr/src/app .

# Expose the port your app runs on
ENV PORT=8080
EXPOSE $PORT

# Run the application using the non-root user (recommended for security)
USER node

# Define the command to start your application
CMD [ "node", "index.js" ]
65 changes: 8 additions & 57 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,12 @@
const express = require("express");
const app = express();
const port = process.env.PORT || 3001;
import express from "express";
import listingsRouter from "./routes/listings.js";

app.get("/", (req, res) => res.type('html').send(html));
const app = express();
app.use(express.json());

const server = app.listen(port, () => console.log(`Example app listening on port ${port}!`));
app.use("/listings", listingsRouter);

server.keepAliveTimeout = 120 * 1000;
server.headersTimeout = 120 * 1000;
app.get("/", (req, res) => res.send("Marketplace API running"));

const html = `
<!DOCTYPE html>
<html>
<head>
<title>Hello from Render!</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.browser.min.js"></script>
<script>
setTimeout(() => {
confetti({
particleCount: 100,
spread: 70,
origin: { y: 0.6 },
disableForReducedMotion: true
});
}, 500);
</script>
<style>
@import url("https://p.typekit.net/p.css?s=1&k=vnd5zic&ht=tk&f=39475.39476.39477.39478.39479.39480.39481.39482&a=18673890&app=typekit&e=css");
@font-face {
font-family: "neo-sans";
src: url("https://use.typekit.net/af/00ac0a/00000000000000003b9b2033/27/l?primer=7cdcb44be4a7db8877ffa5c0007b8dd865b3bbc383831fe2ea177f62257a9191&fvd=n7&v=3") format("woff2"), url("https://use.typekit.net/af/00ac0a/00000000000000003b9b2033/27/d?primer=7cdcb44be4a7db8877ffa5c0007b8dd865b3bbc383831fe2ea177f62257a9191&fvd=n7&v=3") format("woff"), url("https://use.typekit.net/af/00ac0a/00000000000000003b9b2033/27/a?primer=7cdcb44be4a7db8877ffa5c0007b8dd865b3bbc383831fe2ea177f62257a9191&fvd=n7&v=3") format("opentype");
font-style: normal;
font-weight: 700;
}
html {
font-family: neo-sans;
font-weight: 700;
font-size: calc(62rem / 16);
}
body {
background: white;
}
section {
border-radius: 1em;
padding: 1em;
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<section>
Hello from Render!
</section>
</body>
</html>
`
const PORT = process.env.PORT || 3000;
app.listen(PORT, "0.0.0.0", () => console.log(`Server running on ${PORT}`));
23 changes: 23 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# fly.toml app configuration file generated for flog-it on 2025-12-14T22:05:26Z
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'flog-it'
primary_region = 'syd'

[build]

[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
memory_mb = 1024
14 changes: 14 additions & 0 deletions middleware/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// middleware/auth.js
import { supabase } from "../utils/supabaseClient.js";

export async function authenticate(req, res, next) {
const authHeader = req.headers.authorization;
if (!authHeader) return res.status(401).json({ error: "Missing auth header" });

const token = authHeader.replace("Bearer ", "");
const { data: { user }, error } = await supabase.auth.getUser(token);

if (error || !user) return res.status(401).json({ error: "Invalid token" });
req.user = user;
next();
}
Loading