UNPKG

@excli/express

Version:

A cli tool for creating Express.js applications, supporting both JavaScript and TypeScript.

29 lines (24 loc) 892 B
import cors from "cors"; import helmet from "helmet"; import http from "node:http"; import path from "node:path"; import express from "express"; import process from "node:process"; import type { Request, Response } from "express"; const app = express(); const PORT = process.env.PORT || 3000; const server = http.createServer(app); const client = process.env.CLIENT_ORIGIN || "*"; const staticFiles = path.join(process.cwd(), "public"); app.use(helmet()); app.use(express.static(staticFiles)); app.use(express.json({ limit: "20mb" })); app.use(cors({ origin: client, credentials: true })); app.use(express.urlencoded({ limit: "20mb", extended: true })); app.get("/", (_: Request, res: Response) => { return res.status(200).send("<h1>Thanks for using Excli</h1>"); }); // FIRE IN THE HOLE (() => { server.listen(PORT, () => console.log(`Express: http://localhost:${PORT}`)); })();