Skip to content

Instantly share code, notes, and snippets.

@mxro
Created February 20, 2021 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxro/cb7c1264cf66c4e310e56f693d98ad9c to your computer and use it in GitHub Desktop.
Save mxro/cb7c1264cf66c4e310e56f693d98ad9c to your computer and use it in GitHub Desktop.
A simple Express.js server
import express from 'express';
import cors from 'cors';
import helmet from 'helmet';
import { rootHandler } from './root';
export const app: express.Application = express();
app.use(helmet());
if (process.env.CORS) {
console.info(`Starting server with CORS domain: ${process.env.CORS}`);
app.use(cors({ origin: process.env.CORS, credentials: true }));
}
app.use(express.json());
app.get('/', rootHandler);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment