Skip to content

Commit

Permalink
Migrate to Vercel first
Browse files Browse the repository at this point in the history
MongoDB and Cloudflare Workers are not playing well at the moment
  • Loading branch information
ruchernchong committed May 1, 2024
1 parent 6095a4f commit fc85b4b
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ node_modules

# local env files
.env*.local
.vercel
2 changes: 1 addition & 1 deletion src/config/db.ts → api/config/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const connectToDatabase = async (): Promise<mongodb.Db> => {
}

const client = await MongoClient.connect(process.env.MONGODB_URI);
cachedDb = await client.db("main");
cachedDb = client.db("main");

return cachedDb;
};
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
"type": "module",
"scripts": {
"dev": "sst dev --stage development",
"build": "sst build",
"deploy": "sst deploy",
"remove": "sst remove",
"console": "sst console",
"start": "vercel dev",
"deploy": "vercel",
"typecheck": "tsc --noEmit"
},
"dependencies": {
Expand Down
9 changes: 8 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"compilerOptions": {
"lib": ["esnext"],
"types": ["@cloudflare/workers-types"]
"types": ["@cloudflare/workers-types"],
// TODO: For temporary Vercel deployment; remove after migrated successfully to CF Workers
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"esModuleInterop": true,
"skipLibCheck": true,
"strict": false
}
}
9 changes: 9 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"regions": ["sin1"],
"rewrites": [
{
"source": "/api/(.*)",
"destination": "/api"
}
]
}

0 comments on commit fc85b4b

Please sign in to comment.