Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
PORT=3000
PORT=3000
MONGODB_URI="mongodb+srv://irshadmdk99:[email protected]/lab-express-cinema"
4 changes: 4 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ app.locals.title = `${capitalized(projectName)}- Generated with Ironlauncher`;
const index = require('./routes/index');
app.use('/', index);

// Import and use the movies route
const moviesRoutes = require('./routes/movies');
app.use('/movies', moviesRoutes);

// ❗ To handle errors. Routes that don't exist or errors that you handle in specific routes
require('./error-handling')(app);

Expand Down
8 changes: 3 additions & 5 deletions db/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// ℹ️ package responsible to make the connection with mongodb
// https://www.npmjs.com/package/mongoose
const mongoose = require("mongoose");

// ℹ️ Sets the MongoDB URI for our app to have access to it.
// If no env has been set, we dynamically set it to whatever the folder name was upon the creation of the app
mongoose.set('strictQuery', true);

const MONGO_URI = process.env.MONGODB_URI || "mongodb://localhost/lab-express-cinema";
const MONGO_URI =
process.env.MONGODB_URI

mongoose
.connect(MONGO_URI)
Expand Down
15 changes: 15 additions & 0 deletions models/Movie.Model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const mongoose = require('mongoose');
const { Schema } = mongoose;

const movieSchema = new Schema({
title: { type: String, required: true },
director: { type: String, required: true },
stars: [String],
image: String,
description: String,
showtimes: [String],
});

const Movie = mongoose.model('Movie', movieSchema);

module.exports = Movie;
Loading