Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamlined the routes in index.js by defining common API prefixes. #6 #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import './config/Auth.js';
import passport from 'passport';
import sessionMiddleware from './middleware/sessionMiddleware.js';
import { isAuth } from './middleware/isAuth.js';
// Import Router
import userRouter from './routes/User.js';
import movieRouter from './routes/Movie.js';
import theaterRouter from './routes/Theater.js';
import screenRouter from './routes/Screen.js';
import bookingRouter from './routes/Booking.js';

const app = express();

Expand All @@ -18,18 +24,13 @@ app.use(sessionMiddleware);
app.use(passport.initialize());
app.use(passport.session());

// Import Router
import userRouter from './routes/User.js';
import movieRouter from './routes/Movie.js';
import theaterRouter from './routes/Theater.js';
import screenRouter from './routes/Screen.js';
import bookingRouter from './routes/Booking.js';

app.use('/api/', userRouter);
app.use('/api/', movieRouter);
app.use('/api/', theaterRouter);
app.use('/api/', screenRouter);
app.use('/api/', bookingRouter);

app.use('/api/user', userRouter);
app.use('/api/movie', movieRouter);
app.use('/api/theater', theaterRouter);
app.use('/api/screen', screenRouter);
app.use('/api/booking', bookingRouter);

app.get('/', isAuth, (req, res) => {
res.send('Ticket Booking Website');
Expand Down