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

FER REYES WDFT APR 2021 #1606

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
14 changes: 14 additions & 0 deletions models/Celebrity.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const mongoose = require('mongoose');
const {
Schema,
model
} = mongoose;

const celebritySchema = new Schema({
name: String,
occupation: String,
catchPhrase: String,

});

module.exports = model('Celebrity', celebritySchema);
14 changes: 14 additions & 0 deletions models/Movies.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const mongoose = require('mongoose');
const {
Schema,
model
} = mongoose;

const celebritySchema = new Schema({
title: String,
genre: String,
plot: String,

});

module.exports = model('Movies', celebritySchema);
22 changes: 5 additions & 17 deletions starter-code/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require('dotenv').config();

const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const express = require('express');
Expand All @@ -11,48 +10,37 @@ const path = require('path');


mongoose
.connect('mongodb://localhost/starter-code', {useNewUrlParser: true})
.connect('mongodb://localhost/starter-code2', {
useNewUrlParser: true
})
.then(x => {
console.log(`Connected to Mongo! Database name: "${x.connections[0].name}"`)
})
.catch(err => {
console.error('Error connecting to mongo', err)
});

const app_name = require('./package.json').name;
const debug = require('debug')(`${app_name}:${path.basename(__filename).split('.')[0]}`);

const app = express();

// Middleware Setup
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());

// Express View engine setup

app.use(require('node-sass-middleware')({
app.use(require('node-sass-middleware-5')({
src: path.join(__dirname, 'public'),
dest: path.join(__dirname, 'public'),
sourceMap: true
}));


app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');
app.use(express.static(path.join(__dirname, 'public')));
app.use(favicon(path.join(__dirname, 'public', 'images', 'favicon.ico')));



// default value for title local
app.locals.title = 'Express - Generated with IronGenerator';



const index = require('./routes/index');
app.use('/', index);


module.exports = app;
module.exports = app;
39 changes: 39 additions & 0 deletions starter-code/bin/seed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const mongoose = require('mongoose');
const Movies = require('../models/Movies.model');

const DB_NAME = 'starter-code2';

mongoose.connect(`mongodb://localhost/${DB_NAME}`, {
useCreateIndex: true,
useNewUrlParser: true,
useUnifiedTopology: true
});

const celebrity = [{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const celebrity = [{
const movies = [{

title: 'Salvenme!',
genre: 'Terror',
plot: 'ya no quiero mas lab',

},
{
title: 'la risa!',
genre: 'de risa',
plot: 'para reir',

},
{
title: 'la accion!',
genre: 'de accion',
plot: 'para dormir',

},
];

Movies.create(celebrity)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Movies.create(celebrity)
Movies.create(movies)

.then(booksFromDB => {
console.log(`Created ${booksFromDB.length} celebrity`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(`Created ${booksFromDB.length} celebrity`);
console.log(`Created ${booksFromDB.length} movies`);


// Once created, close the DB connection
mongoose.connection.close();
})
.catch(err => console.log(`An error occurred while creating books from the DB: ${err}`));
13 changes: 13 additions & 0 deletions starter-code/public/stylesheets/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
body {
padding: 50px;
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
}

a {
color: #00B7FF;
}

.layout {
display: flex;
justify-content: space-between;
}
Loading