Created
January 26, 2024 00:41
-
-
Save ChrisCates/8f983ca34b75cfc9b7e7d66b4a3f7300 to your computer and use it in GitHub Desktop.
Vercel Configuration for Typescript Express Servers
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
import 'colors' | |
import { config } from 'dotenv' | |
import { createServer } from 'http' | |
import morgan from 'morgan' | |
import cors from 'cors' | |
import Express from 'express' | |
import BodyParser from 'body-parser' | |
import { testRoute } from 'api/route/test' | |
config() | |
process.env.TZ = 'America/New_York' | |
export const PORT = Number(process.env.PORT || '4242') | |
export const api = Express() | |
export const server = createServer(api) | |
api.use(cors()) | |
api.use(BodyParser.json()) | |
api.use(BodyParser.urlencoded({ extended: true })) | |
api.use(morgan('tiny')) | |
api.get('/', (req, res) => { | |
return res.status(200).send('OK') | |
}) | |
api.post('/test', testRoute) | |
module.exports = server |
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
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "ES6", | |
"lib": ["ESNext"], | |
"baseUrl": "./", | |
"allowJs": true, | |
"skipLibCheck": true, | |
"strict": false, | |
"forceConsistentCasingInFileNames": true, | |
"noEmit": true, | |
"incremental": true, | |
"esModuleInterop": true, | |
"module": "CommonJS", | |
"moduleResolution": "Node", | |
"allowImportingTsExtensions": true, | |
"resolveJsonModule": true, | |
"isolatedModules": true, | |
"composite": true, | |
"experimentalDecorators": true, | |
"emitDecoratorMetadata": true, | |
"strictPropertyInitialization": false | |
}, | |
"include": ["api/**/*.ts"], | |
"exclude": ["node_modules"] | |
} |
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
{ | |
"version": 2, | |
"builds": [ | |
{ | |
"src": "api/server.ts", | |
"use": "@vercel/node", | |
"config": { "includeFiles": ["api/**"] } | |
} | |
], | |
"routes": [ | |
{ | |
"src": "/(.*)", | |
"dest": "api/server.ts" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment