Includes: API (Express/TypeScript), Astro site, Python workers, document generators, FCC compliance tools, Canada CRTC formation, Ansible infrastructure, and deployment scripts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
66 lines
2.3 KiB
TypeScript
66 lines
2.3 KiB
TypeScript
import { Router } from "express";
|
|
import { pgHealthy } from "../db.js";
|
|
import { cadToUsdCents, getFxInfo } from "../fx.js";
|
|
|
|
const router = Router();
|
|
|
|
router.get("/api/v1/status", async (_req, res) => {
|
|
const db = await pgHealthy();
|
|
const status = db ? "ok" : "degraded";
|
|
res.status(db ? 200 : 503).json({
|
|
status,
|
|
version: "0.1.0",
|
|
service: "performancewest-api",
|
|
db: db ? "connected" : "unreachable",
|
|
timestamp: new Date().toISOString(),
|
|
});
|
|
});
|
|
|
|
/**
|
|
* GET /api/v1/fx/ca-provinces
|
|
*
|
|
* Returns Canadian province incorporation fees in both CAD and USD.
|
|
* USD = CAD converted at Bank of Canada daily rate + 10% buffer, rounded up to nearest dollar.
|
|
* Used by the formation order page to populate the province dropdown.
|
|
*/
|
|
const CA_PROVINCES_CAD: Array<{ code: string; name: string; feeCad: number; annualCad: number }> = [
|
|
{ code: "BC", name: "British Columbia", feeCad: 35000, annualCad: 4200 },
|
|
{ code: "AB", name: "Alberta", feeCad: 27500, annualCad: 2000 },
|
|
{ code: "ON", name: "Ontario", feeCad: 36000, annualCad: 0 },
|
|
{ code: "QC", name: "Quebec", feeCad: 37900, annualCad: 8800 },
|
|
{ code: "MB", name: "Manitoba", feeCad: 35000, annualCad: 0 },
|
|
{ code: "SK", name: "Saskatchewan", feeCad: 26600, annualCad: 0 },
|
|
{ code: "NS", name: "Nova Scotia", feeCad: 42682, annualCad: 11400 },
|
|
{ code: "NB", name: "New Brunswick", feeCad: 26200, annualCad: 6700 },
|
|
{ code: "PE", name: "Prince Edward Island", feeCad: 31000, annualCad: 0 },
|
|
{ code: "NL", name: "Newfoundland and Labrador", feeCad: 30000, annualCad: 2500 },
|
|
];
|
|
|
|
router.get("/api/v1/fx/ca-provinces", async (_req, res) => {
|
|
try {
|
|
const fxInfo = await getFxInfo();
|
|
const provinces = await Promise.all(
|
|
CA_PROVINCES_CAD.map(async (p) => ({
|
|
code: p.code,
|
|
name: p.name,
|
|
feeCad: p.feeCad,
|
|
feeUsd: await cadToUsdCents(p.feeCad),
|
|
annualCad: p.annualCad,
|
|
annualUsd: p.annualCad > 0 ? await cadToUsdCents(p.annualCad) : 0,
|
|
})),
|
|
);
|
|
res.json({
|
|
provinces,
|
|
fx: {
|
|
cadUsdRate: fxInfo.rate,
|
|
bufferPct: 10,
|
|
fetchedAt: fxInfo.fetchedAt,
|
|
},
|
|
});
|
|
} catch (err) {
|
|
console.error("[fx] ca-provinces error:", err);
|
|
res.status(500).json({ error: "Failed to fetch exchange rates" });
|
|
}
|
|
});
|
|
|
|
export default router;
|