Skip to content

Commit

Permalink
Merge pull request #36 from anthonypena97/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
anthonypena97 committed Aug 9, 2021
2 parents f671d83 + dd1ae23 commit aa6cb63
Show file tree
Hide file tree
Showing 35 changed files with 2,485 additions and 295 deletions.
120 changes: 0 additions & 120 deletions app.js

This file was deleted.

16 changes: 8 additions & 8 deletions config/connections.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require('dotenv').config();

// import the Sequelize constructor from the library
const Sequelize = require('sequelize');

const sequelize = process.env.JAWSDB_URL ?
new Sequelize(process.env.JAWSDB_URL) :
new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PW, {
require('dotenv').config();

const sequelize = process.env.JAWSDB_URL
? new Sequelize(process.env.JAWSDB_URL)
: new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PW, {
host: 'localhost',
dialect: 'mysql',
dialectOptions: {
decimalNumbers: true,
},
port: 3306
});


module.exports = sequelize;
31 changes: 0 additions & 31 deletions index.html

This file was deleted.

30 changes: 30 additions & 0 deletions models/Playlist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { Model, DataTypes, INTEGER } = require('sequelize');
const sequelize = require('../config/connections');

class Playlist extends Model { }

Playlist.init({
id: {
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true,
autoIncrement: true,
},
playlist_name: {
type: DataTypes.STRING,
allowNull: false,
},
playlist_artwork: {
type: DataTypes.STRING,
allowNull: false
}
},
{
sequelize,
timestamps: false,
freezeTableName: true,
underscored: true,
modelName: 'playlist'
});

module.exports = Playlist;
38 changes: 38 additions & 0 deletions models/Songs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const { Model, DataTypes, INTEGER } = require('sequelize');
const sequelize = require('../config/connections');
const Playlist = require('./Playlist');

class Songs extends Model { }

Songs.init({
id: {
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true,
autoIncrement: true,
},
song_title: {
type: DataTypes.STRING,
allowNull: false,
},
artist: {
type: DataTypes.STRING,
allowNull: false,
},
playlist_id: {
type: DataTypes.INTEGER,
references: {
model: 'playlist',
key: 'id'
}
}
},
{
sequelize,
timestamps: false,
freezeTableName: true,
underscored: true,
modelName: 'songs',
})

module.exports = Songs
60 changes: 60 additions & 0 deletions models/UserLogin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const { Model, DataTypes, INTEGER } = require('sequelize');
const sequelize = require('../config/connections')
const bcrypt = require('bcrypt');
// const { beforeUpdate, beforeCreate } = require('./Playlist');
// const { Hooks } = require('sequelize/types/lib/hooks');

class UserLogin extends Model {
checksPassword(loginPw) {
return bcrypt.compareSync(loginPw, this.password)
}
checksToken(tokenKey) {
return bcrypt.compareSync(tokenKey, this.token_for_user)
}
}

UserLogin.init({
id: {
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true,
autoIncrement: true
},
username: {
type: DataTypes.STRING,
allowNull: false

},
password: {
type: DataTypes.STRING,
allowNull: false
},
token_for_user: {
type: DataTypes.STRING,
allowNull: false
},

},
// {
// hooks: {
// async beforeCreate(newUserPw) {
// newUserPw.password = await bcrypt.hash(newUserPw.password, 10);
// return newUserPw;
// },
// async beforeUpdate(updateUserPw) {
// updateUserPw.password = await bcrypt.hash(updateUserPw.password, 10);
// return updateUserPw;
// }
// },
// },
{

sequelize,
timestamps: false,
freezeTableName: true,
underscored: true,
modelName: 'user_login'

})

module.exports = UserLogin
14 changes: 6 additions & 8 deletions models/index.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
const Playlist = require('./playlist')
const PlaylistSongs = require('./songs')
const Playlist = require('./Playlist')
const Songs = require('./Songs')
const UserLogin = require('./UserLogin')


PlaylistSongs.belongsTo(Playlist, {
Songs.belongsTo(Playlist, {
foreignKey: 'playlist_id'
})


Playlist.hasMany(PlaylistSongs, {
Playlist.hasMany(Songs, {
foreignKey: 'playlist_id'
})


module.exports = {
Playlist,
PlaylistSongs
};
module.exports = { Playlist, Songs, UserLogin };
23 changes: 0 additions & 23 deletions models/playlist.js

This file was deleted.

Loading

0 comments on commit aa6cb63

Please sign in to comment.