Creating App.js for Node Application
In this post we will setup app.js file to make app running first write below code below -> import express from "express" import cors from "cors" import morgan from "morgan" const app = express () app. use ( cors ()) app. use ( express . json ()) app. use ( morgan("dev") ) app. get ( '/' , ( req , res ) => { res . json ({message: "CMS Backend API Running." }) }) export default app and save express.json() — JSON body parse karta hai cors() — frontend (Next.js) ko API call karne deta hai morgan("dev") — console me request logs dikhata hai Base route / — test karne ke liye ready hai
Comments
Post a Comment