smc_cet_otherincome_backend/server.js
suseendhiran17 edfd6bb08c susee:log
2023-07-19 16:06:32 +05:30

76 lines
1.9 KiB
JavaScript

require('dotenv').config();
const express = require('express')
const app = express();
const path = require('path');
const Sentry = require('@sentry/node');
Sentry.init({ dsn: "https://examplePublicKey@o0.ingest.sentry.io/0" });
app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.errorHandler());
app.use(function onError(err, req, res, next) {
// The error id is attached to `res.sentry` to be returned
// and optionally displayed to the user for support.
res.statusCode = 500;
res.end(res.sentry + "\n");
});
//it is used to clear cache
app.use(function(req, res, next) {
res.set("Cache-Control", "no-cache, no-store, must-revalidate, max-age=0")
res.set("Pragma", "no-cache")
res.set("Expires", 0)
next()
})
const {logMsg} = require('./app/services/logger.js');
app.set('views', path.join(__dirname, 'app\\views'));
app.set('view engine', 'ejs');
const swaggerJsdoc = require('swagger-jsdoc');
const swaggerUi = require('swagger-ui-express');
const options = {
definition: {
openapi: '3.0.0',
info: {
title: 'Smc_cet_OtherIncome',
version: '1.0.0',
},
},
apis: ['./app/routes/routes.js'], // files containing annotations as above
};
const swaggerDocument = swaggerJsdoc(options);
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
/**
* @openapi
* /:
* get:
* description: Welcome to swagger-jsdoc!
* responses:
* 200:
* description: Returns a mysterious string.
*/
app.get("/", (req, res) => {
res.json({ message: "Welcome to the application." });
logMsg.info("Server Sent A Welcome to the application!");
});
app.use(express.json())
app.use(express.urlencoded({ extended: true }));
require("./app/routes/routes.js")(app);
const PORT_NUMBER = process.env.SERVER_PORT
app.listen({ port: PORT_NUMBER }, async () => {
console.log('Server up on http://localhost:'+PORT_NUMBER)
//await sequelize.authenticate()
})