-
Notifications
You must be signed in to change notification settings - Fork 2
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
54 changed files
with
1,216 additions
and
790 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
node_modules | ||
.git | ||
.env | ||
logs | ||
.DS_Store | ||
.vscode | ||
.github | ||
.sanity | ||
.turbo | ||
.next | ||
dist | ||
postgres-data | ||
redis-data |
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,36 @@ | ||
FROM node:20-alpine AS base | ||
|
||
RUN npm install -g turbo@2.0.14 | ||
RUN npm install -g pnpm@9.7.1 | ||
|
||
FROM base AS builder | ||
|
||
RUN apk update | ||
RUN apk add --no-cache libc6-compat | ||
|
||
WORKDIR /app | ||
COPY . . | ||
RUN turbo prune @echo-webkom/api --docker | ||
|
||
FROM base AS installer | ||
RUN apk update | ||
RUN apk add --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
COPY --from=builder /app/out/json/ . | ||
RUN pnpm install | ||
|
||
COPY --from=builder /app/out/full/ . | ||
|
||
RUN pnpm turbo build --filter=@echo-webkom/api... | ||
|
||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 hono | ||
USER hono | ||
|
||
COPY --from=installer /app/apps/api/dist ./dist | ||
|
||
CMD node ./dist/index.js |
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,17 @@ | ||
app = "fly-echo-api" | ||
primary_region = "arn" | ||
|
||
[build] | ||
|
||
[http_service] | ||
internal_port = 8000 | ||
force_https = true | ||
auto_stop_machines = "stop" | ||
auto_start_machines = true | ||
min_machines_running = 1 | ||
processes = ["app"] | ||
|
||
[[vm]] | ||
size = "shared-cpu-2x" | ||
memory = "1gb" | ||
cpus = 4 |
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,34 @@ | ||
{ | ||
"name": "@echo-webkom/api", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "pnpm with-env tsx --watch ./src/index.ts", | ||
"build": "pnpm with-env esbuild ./src/index.ts --bundle --platform=node --outfile=dist/index.js", | ||
"start": "node ./dist/index.js", | ||
"typecheck": "pnpm with-env tsc --noEmit", | ||
"clean": "rm -rf dist .turbo node_modules", | ||
"with-env": "dotenv -e ../../.env --" | ||
}, | ||
"dependencies": { | ||
"@echo-webkom/auth": "workspace:*", | ||
"@echo-webkom/db": "workspace:*", | ||
"@echo-webkom/email": "workspace:*", | ||
"@echo-webkom/lib": "workspace:*", | ||
"@echo-webkom/sanity": "workspace:*", | ||
"@hono/node-server": "1.13.0", | ||
"date-fns": "3.6.0", | ||
"drizzle-orm": "0.33.0", | ||
"hono": "4.6.2", | ||
"zod": "3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@echo-webkom/tsconfig": "workspace:*", | ||
"@types/node": "20.16.5", | ||
"dotenv-cli": "7.4.2", | ||
"esbuild": "^0.23.1", | ||
"tsx": "4.19.1", | ||
"typescript": "5.5.4", | ||
"vitest": "2.0.5" | ||
} | ||
} |
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,22 @@ | ||
import { Hono } from "hono"; | ||
import { cors } from "hono/cors"; | ||
import { logger } from "hono/logger"; | ||
|
||
import adminApp from "./services/admin"; | ||
import feedbackApp from "./services/feedback"; | ||
import happeningApp from "./services/happening"; | ||
import healthApp from "./services/health"; | ||
import shoppingApp from "./services/shopping-list"; | ||
|
||
const app = new Hono(); | ||
|
||
app.use(logger()); | ||
app.use(cors()); | ||
|
||
app.route("/", healthApp); | ||
app.route("/", adminApp); | ||
app.route("/", happeningApp); | ||
app.route("/", feedbackApp); | ||
app.route("/", shoppingApp); | ||
|
||
export default app; |
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,15 @@ | ||
import { serve } from "@hono/node-server"; | ||
|
||
import app from "./app"; | ||
|
||
const PORT = 8000; | ||
|
||
serve( | ||
{ | ||
fetch: app.fetch, | ||
port: PORT, | ||
}, | ||
(info) => { | ||
console.log(`Listening on http://localhost:${info.port}`); | ||
}, | ||
); |
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,13 @@ | ||
import { createMiddleware } from "hono/factory"; | ||
|
||
export const admin = () => { | ||
return createMiddleware(async (c, next) => { | ||
const bearerToken = c.req.header("Authorization"); | ||
|
||
if (bearerToken !== "Bearer foobar") { | ||
return c.json({ error: "Unauthorized" }, 401); | ||
} | ||
|
||
return await next(); | ||
}); | ||
}; |
Oops, something went wrong.