Skip to content

Commit d85b86b

Browse files
committed
fix: actual deployment
1 parent 6b9ad87 commit d85b86b

File tree

10 files changed

+120
-12
lines changed

10 files changed

+120
-12
lines changed

.env.example

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
# Database connection string
2-
DATABASE_URL=postgresql://user:password@localhost:5432/database_name
1+
# PORT=6111
2+
NODE_ENV=production
3+
4+
# -- Database connection options
5+
DB_HOST=localhost
6+
# DB_PORT=5432
7+
DB_USER=postgres
8+
DB_PASS=password
9+
# DB_NAME=url_shortener
10+

.github/copilot-instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# pnet.work AI Coding Instructions
1+
# polinet.cc AI Coding Instructions
22

33
## Project Overview
44

5-
pnet.work is a specialized URL shortener for the polinetwork.org domain ecosystem. It uses Next.js 15 with App Router, PostgreSQL, and follows a contract-first API design pattern using ts-rest.
5+
polinet.cc is a specialized URL shortener for the polinetwork.org domain ecosystem. It uses Next.js 15 with App Router, PostgreSQL, and follows a contract-first API design pattern using ts-rest.
66

77
## Architecture Patterns
88

next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { NextConfig } from "next"
22

33
const nextConfig: NextConfig = {
44
output: "standalone",
5-
/* config options here */
5+
transpilePackages: ["@t3-oss/env-nextjs", "@t3-oss/env-core"],
66
}
77

88
export default nextConfig

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@radix-ui/react-label": "^2.1.7",
2323
"@radix-ui/react-slot": "^1.2.3",
2424
"@scalar/api-reference-react": "^0.7.42",
25+
"@t3-oss/env-nextjs": "^0.13.8",
2526
"@ts-rest/core": "3.52.1",
2627
"@ts-rest/next": "3.52.1",
2728
"@ts-rest/open-api": "3.52.1",

pnpm-lock.yaml

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/openapi.json/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import { contract } from "@/lib/contract"
1616

1717
const openapiDocument = generateOpenApi(contract, {
1818
info: {
19-
title: "pnet.work API",
19+
title: "polinet.cc API",
2020
version: "1.0.0",
2121
description: "PoliNetwork's Short URLs - Service API",
2222
},
23-
servers: [{ url: "https://pnet.work/api" }],
23+
servers: [{ url: "https://polinet.cc/api" }],
2424
components: {
2525
securitySchemes: {
2626
CloudflareID: {

src/components/dashboard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,19 @@ export function Dashboard() {
140140
<TableCell>
141141
<div className="flex items-center gap-2">
142142
<a
143-
href={`https://pnet.work/${url.short_code}`}
143+
href={`https://polinet.cc/${url.short_code}`}
144144
target="_blank"
145145
rel="noopener noreferrer"
146146
className="text-blue-600 hover:underline font-mono"
147147
>
148-
pnet.work/{url.short_code}
148+
polinet.cc/{url.short_code}
149149
</a>
150150
<Button
151151
variant="ghost"
152152
size="sm"
153153
onClick={() =>
154154
copyToClipboard(
155-
`https://pnet.work/${url.short_code}`
155+
`https://polinet.cc/${url.short_code}`
156156
)
157157
}
158158
>

src/components/edit-url-dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export function EditUrlDialog({
8484
<DialogTitle>Edit Short URL</DialogTitle>
8585
<DialogDescription>
8686
Update the destination URL for{" "}
87-
{url ? `pnet.work/${url.short_code}` : "this short URL"}.
87+
{url ? `polinet.cc/${url.short_code}` : "this short URL"}.
8888
</DialogDescription>
8989
</DialogHeader>
9090
<form onSubmit={handleSubmit}>

src/env.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { createEnv } from "@t3-oss/env-nextjs"
2+
import { z } from "zod"
3+
4+
const PORT = 6111
5+
6+
// coerce is needed for non-string values, because k8s supports only string env
7+
export const env = createEnv({
8+
server: {
9+
PORT: z.coerce.number().min(1).max(65535).default(PORT),
10+
NODE_ENV: z.enum(["development", "production"]).default("development"),
11+
// PUBLIC_URL: z.string().default(`https://polinet.cc`),
12+
// LOG_LEVEL: z.string().default("DEBUG"),
13+
14+
DB_HOST: z.string().min(1),
15+
DB_PORT: z.coerce.number().min(1).max(65535).default(5432),
16+
DB_USER: z.string().min(1),
17+
DB_PASS: z.string().min(1),
18+
DB_NAME: z.string().min(3).default("url_shortener"),
19+
},
20+
21+
runtimeEnv: {
22+
PORT: process.env.PORT,
23+
DB_HOST: process.env.DB_HOST,
24+
DB_PORT: process.env.DB_PORT,
25+
DB_USER: process.env.DB_USER,
26+
DB_PASS: process.env.DB_PASS,
27+
DB_NAME: process.env.DB_NAME,
28+
NODE_ENV: process.env.NODE_ENV,
29+
},
30+
31+
/**
32+
* By default, this library will feed the environment variables directly to
33+
* the Zod validator.
34+
*
35+
* This means that if you have an empty string for a value that is supposed
36+
* to be a number (e.g. `PORT=` in a ".env" file), Zod will incorrectly flag
37+
* it as a type mismatch violation. Additionally, if you have an empty string
38+
* for a value that is supposed to be a string with a default value (e.g.
39+
* `DOMAIN=` in an ".env" file), the default value will never be applied.
40+
*
41+
* In order to solve these issues, we recommend that all new projects
42+
* explicitly specify this option as true.
43+
*/
44+
emptyStringAsUndefined: true,
45+
})

src/lib/db.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import { Pool } from "pg"
22
import z from "zod"
3+
import { env } from "@/env"
34

45
let pool: Pool | null = null
56

67
export function getPool(): Pool {
78
if (!pool) {
89
pool = new Pool({
9-
connectionString: process.env.DATABASE_URL,
10+
host: env.DB_HOST,
11+
port: env.DB_PORT,
12+
user: env.DB_USER,
13+
password: env.DB_PASS,
14+
database: env.DB_NAME,
1015
})
1116
}
1217
return pool

0 commit comments

Comments
 (0)