prod124njac/prod124njac-back-b/authsec_node/Backend/app.js

55 lines
1.1 KiB
JavaScript

global.__rootdir = __dirname
require("dotenv").config()
const express = require("express")
const app = express()
const bodyParser = require("body-parser")
const router = require("./routes/cns.router")
const userRouter = require("./routes/user.routes")
const cors = require("cors")
app.use(express.json())
// Set the base path from the .env file
const basePath = process.env.BASE_PATH || "/"
app.base = basePath
// app.use("/api/tables/v1", router)
// app.use("/api/users/v1", userRouter)
// app.use("", router)
// app.use("", userRouter)
app.use(
cors({
origin: "*",
})
)
router.use(function (req, res, next) {
console.log("%s %s %s", req.method, req.url, req.path)
next()
})
app.use(`${basePath}`, router)
app.use(`${basePath}`, userRouter)
app.use(bodyParser.json())
// buildercomponents
const FormaRouter = require("./routes/basicp1/Forma.routes")
app.use("/Forma/Forma", FormaRouter)
const port = process.env.PORT || 9292
app.get(`${basePath}/test`, (req, res) => {
res.json({
success: 1,
message: "This is hello from auth backend",
})
})
app.listen(port, () => {
console.log(`Server is up and running on port ${port}`)
})