-
Home Page: https://node-ts-server-in-vercel.andy770921.vercel.app/
-
About Page: https://node-ts-server-in-vercel.andy770921.vercel.app/about
-
API: https://node-ts-server-in-vercel.andy770921.vercel.app/api
import express from 'express';
const app = express();
app.get('/api', (req, res) => res.status(200).json({ data: 'api' }));
const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Server running on ${port}, http://localhost:${port}`));
MONGO_DB_URL=mongodb+srv://[account]:[password]@[cluster_name].4xneo.gcp.mongodb.net/[db_name]
- Example:
MONGO_DB_URL=mongodb+srv://myAccount:[email protected]/node-auth
-
npm install
-
npm run start
: compile TypeScript to JavaScript and start running local server -
npm run lint
: check lint manually
-
npm run build
: compilesrc/app.ts
todist/app.js
-
Deploy to Vercel: Vercel takes
src/app.ts
and compiles TypeScript to JavaScript automatically for deployment. Detail settings are in the filevercel.json
.