UNPKG

jan-artist

Version:

Start a express server with one line of code.

19 lines (17 loc) 551 B
import express from "express"; export default function janStart(port = 3000,routes={}){ const app = express(); app.use(express.json()); if(Object.keys(routes).length === 0){ app.get("/",(req,res)=>res.send("Jan started the server and no routes configured. so,default routes executed.")); } else{ for(const [path,handler] of Object.entries(routes)){ app.get(path,handler); } } app.listen(port,()=>{ console.log(`Server running at http://localhost:${port}`); }) } janStart();