2024-09-18 04:14:45 +00:00
|
|
|
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
|
2024-09-18 04:15:21 +00:00
|
|
|
const FormaRouter = require("./routes/basicp1/Forma.routes")
|
|
|
|
app.use("/Forma/Forma", FormaRouter)
|
|
|
|
|
2024-09-18 04:14:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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}`)
|
|
|
|
})
|