Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
olawuwo-abideen committed Feb 21, 2025
1 parent 308d1f2 commit 72b49b6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"name": "fintechapp",
"version": "1.0.0",
"description": "Backend a banking app",
"main": "index.ts",
"main": "index.js",

"scripts": {
"start": "nodemon index.ts",
"build": "npm install && npm install mysql2",
"postinstall": "npm install mysql2"
},
"start": "node dist/index.js",
"dev": "nodemon --exec ts-node-dev src/index.js",
"build": "tsc && cp -r src/template dist/",
"postinstall": "npm run build"
}
,
"author": "",
"license": "ISC",
"devDependencies": {
Expand Down
23 changes: 8 additions & 15 deletions index.ts → src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import express, { Request, Response,NextFunction } from 'express';
import dotenv from 'dotenv';
dotenv.config();
import cors from 'cors';
import DbInitialize from './src/database/init';
import UserRouter from './src/routers/userRouter';
import AccountRouter from './src/routers/accountRouter';
import TransactionRouter from './src/routers/transactionRouter';
import AdminRouter from "./src/routers/adminRouter";
import DbInitialize from './database/init';
import UserRouter from './routers/userRouter';
import AccountRouter from './routers/accountRouter';
import TransactionRouter from './routers/transactionRouter';
import AdminRouter from "./routers/adminRouter";
// import helmet from 'helmet';
import compression from 'compression';
import cookieParser from 'cookie-parser';
Expand All @@ -19,11 +19,11 @@ import bodyParser from "body-parser";
import swaggerUI from "swagger-ui-express";
import swaggerJsDoc from "swagger-jsdoc";

const routersPath = path.join(__dirname, "./src/routers"); // ✅ Get full path
const routersPath = path.join(__dirname, "routers");
console.log("Resolved Routers Path:", routersPath);

if (fs.existsSync(routersPath)) {
const files = fs.readdirSync(routersPath).filter(file => file.endsWith(".ts")); // ✅ Get only .js files
const files = fs.readdirSync(routersPath).filter(file => file.endsWith(".js"));
console.log("Swagger Detected Files:", files);
} else {
console.error("Routers directory not found!");
Expand Down Expand Up @@ -77,17 +77,10 @@ const options = {
},
],
},
// apis: ["./dist/routers/*.js"],
// apis: [path.join(__dirname, "routers/*.js")],

apis: ["./src/routers/*.ts"]
// This is to call all the file
// apis: ["src/**/*.ts"]
apis: ["./dist/routers/*.js"]
};

const specs = swaggerJsDoc(options);
// app.use("/api-docs", swaggerUI.serve, swaggerUI.setup(specs));


app.get("/", (req: Request, res: Response) => {
res.redirect(301, "/api-docs/");
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

"outDir": "./dist",
"rootDir": "./",
"rootDir": "./src",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
/* Language and Environment */
Expand Down
9 changes: 7 additions & 2 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@



{
"version": 2,
"buildCommand": "npm run build",
"builds": [
{
"src": "index.ts",
"src": "dist/**/*.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "index.ts"
"dest": "dist/main.js"
}
]
}

0 comments on commit 72b49b6

Please sign in to comment.