Skip to content

Commit

Permalink
Merge pull request #16 from scienmanas/web-update
Browse files Browse the repository at this point in the history
Configure Backend
  • Loading branch information
scienmanas authored Aug 10, 2024
2 parents 1a83892 + 4384228 commit 370fc76
Show file tree
Hide file tree
Showing 4 changed files with 581 additions and 18 deletions.
Empty file.
21 changes: 11 additions & 10 deletions Website/Backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import cors from "cors";
import { config } from "dotenv";
import { connectToDB } from "./config/db";
// Routes import
import certificatesRoute from './routes/certificate.ts';
import authRoute from './routes/auth.ts';

import certificatesRoute from "./routes/certificate.ts";
import authRoute from "./routes/auth.ts";

// Load the env
config();
Expand All @@ -15,21 +14,22 @@ connectToDB();

// configure app
const app: Express = express();
const PORT: string = process.env.PORT || '5000';
const PORT: string = process.env.PORT || "5000";

// CORS configuration
const corsConfiguration = {
origin: ["*"],
optionSucessStatus: 200
}
origin: ["https://certimailer.xyz"],
// origin: ["*"],
optionSucessStatus: 200,
};

// middleware to use import routes and enable cors
app.use(express.json());
app.use(cors(corsConfiguration))
app.use(cors(corsConfiguration));

// Routes
app.use('/api/certificate', certificatesRoute)
app.use('/api/auth', authRoute)
app.use("/api/certificate", certificatesRoute);
app.use("/api/auth", authRoute);

// Landing endpoint
app.get("/", (req: Request, res: Response) => {
Expand All @@ -38,5 +38,6 @@ app.get("/", (req: Request, res: Response) => {

// Listening at
app.listen(PORT, () => {
console.log(`Server active at port: ${PORT}`);
console.log(`Server active at: http://localhost:${PORT}`);
});
Loading

0 comments on commit 370fc76

Please sign in to comment.