Create: Backend branch
This commit is contained in:
parent
f91febf919
commit
76ac0c292c
260 changed files with 10 additions and 12964 deletions
44
models/database/ads.model.js
Normal file
44
models/database/ads.model.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
userId: String,
|
||||
title: String,
|
||||
images: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
interests: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
comment: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
views: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
isVisible: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
isActive: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
schema.method("toJSON", function() {
|
||||
const { __v, _id, ...object } = this.toObject();
|
||||
object.id = _id;
|
||||
return object;
|
||||
});
|
||||
|
||||
return mongoose.model("ads", schema);
|
||||
};
|
||||
24
models/database/playlists.model.js
Normal file
24
models/database/playlists.model.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
userId: String,
|
||||
videoIds: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
name: String,
|
||||
isActive: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
schema.method("toJSON", function() {
|
||||
const { __v, _id, ...object } = this.toObject();
|
||||
object.id = _id;
|
||||
return object;
|
||||
});
|
||||
|
||||
return mongoose.model("playlists", schema);
|
||||
};
|
||||
48
models/database/users.model.js
Normal file
48
models/database/users.model.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
const roles = require("../objects/role.model");
|
||||
|
||||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
email: String,
|
||||
hashPass: String, // WARNING: We don't want to send back the hashPass
|
||||
login: String,
|
||||
role: {
|
||||
type: Object,
|
||||
default: roles.User
|
||||
},
|
||||
company: String,
|
||||
profileImageUrl: {
|
||||
type: String,
|
||||
default: "https://www.handiclubnimois.fr/wp-content/uploads/2020/10/blank-profile-picture-973460_1280.png"
|
||||
},
|
||||
dateOfBirth: {
|
||||
type: Date,
|
||||
default: null
|
||||
},
|
||||
gender: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
interests: {
|
||||
type: Array,
|
||||
default: null
|
||||
},
|
||||
isActive: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
lastConnexion: {
|
||||
type: Date,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
schema.method("toJSON", function() {
|
||||
const { __v, _id, ...object } = this.toObject();
|
||||
object.id = _id;
|
||||
return object;
|
||||
});
|
||||
|
||||
return mongoose.model("users", schema);
|
||||
};
|
||||
29
models/database/videos.model.js
Normal file
29
models/database/videos.model.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
userId: String,
|
||||
videoId: String,
|
||||
source: String,
|
||||
interest: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
watchedDates: {
|
||||
type: Array,
|
||||
default: null
|
||||
},
|
||||
isActive: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
schema.method("toJSON", function() {
|
||||
const { __v, _id, ...object } = this.toObject();
|
||||
object.id = _id;
|
||||
return object;
|
||||
});
|
||||
|
||||
return mongoose.model("videos", schema);
|
||||
};
|
||||
19
models/mongodb.model.js
Normal file
19
models/mongodb.model.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
const dbConfig = require("../config/mongodb.config");
|
||||
const mongoose = require("mongoose");
|
||||
mongoose.Promise = global.Promise;
|
||||
|
||||
const db = {};
|
||||
db.mongoose = mongoose;
|
||||
|
||||
if(typeof process.env.NODE_ENV !== 'undefined' && process.env.NODE_ENV === 'production'){
|
||||
db.url = dbConfig.prodUrl;
|
||||
} else {
|
||||
db.url = dbConfig.devUrl;
|
||||
}
|
||||
|
||||
db.users = require("./database/users.model")(mongoose);
|
||||
db.playlists = require("./database/playlists.model")(mongoose);
|
||||
db.videos = require("./database/videos.model")(mongoose);
|
||||
db.ads = require("./database/ads.model")(mongoose);
|
||||
|
||||
module.exports = db;
|
||||
10
models/objects/image.model.js
Normal file
10
models/objects/image.model.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
class Image {
|
||||
constructor(base64, url, description, type){
|
||||
this.base64 = base64;
|
||||
this.url = url;
|
||||
this.description = description;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Image;
|
||||
22
models/objects/role.model.js
Normal file
22
models/objects/role.model.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
module.exports = {
|
||||
User: {
|
||||
name: "user",
|
||||
permission: 0,
|
||||
isAccepted: true
|
||||
},
|
||||
Advertiser: {
|
||||
name: "advertiser",
|
||||
permission: 5,
|
||||
isAccepted: false
|
||||
},
|
||||
Admin: {
|
||||
name: "admin",
|
||||
permission: 10,
|
||||
isAccepted: false
|
||||
},
|
||||
SuperAdmin: {
|
||||
name: "superAdmin",
|
||||
permission: 1000,
|
||||
isAccepted: true
|
||||
}
|
||||
};
|
||||
157
models/objects/video.categories.model.js
Normal file
157
models/objects/video.categories.model.js
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
const {youtube, dailymotion} = require('../../config/host.config');
|
||||
module.exports = [
|
||||
{
|
||||
id: 0,
|
||||
interest: "Actualités",
|
||||
categories: [
|
||||
{id: "news", name: "News", source: dailymotion.name},
|
||||
{id: "25", name: "News & Politics", source: youtube.name},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
interest: "Animaux",
|
||||
categories: [
|
||||
{id: "animals", name: "animaux", source: dailymotion.name},
|
||||
{id: "15", name: "Pets & Animals", source: youtube.name},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
interest: "Arts",
|
||||
categories: [
|
||||
{id: "creation", name: "Art", source: dailymotion.name},
|
||||
{id: "", name: "", source: youtube.name},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
interest: "Autos",
|
||||
categories: [
|
||||
{id: "auto", name: "Auto-Moto", source: dailymotion.name},
|
||||
{id: "2", name: "Autos & Vehicles", source: youtube.name},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
interest: "Divertissements",
|
||||
categories: [
|
||||
{id: "tv", name: "TV", source: dailymotion.name},
|
||||
{id: "fun", name: "Humour & Divertissement", source: dailymotion.name},
|
||||
{id: "webcam", name: "Webcam", source: dailymotion.name},
|
||||
{id: "23", name: "Comedy", source: youtube.name},
|
||||
{id: "24", name: "Entertainment", source: youtube.name},
|
||||
{id: "43", name: "Shows", source: youtube.name}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
interest: "Éducation",
|
||||
categories: [
|
||||
{id: "school", name: "Éducation", source: dailymotion.name},
|
||||
{id: "27", name: "Education", source: youtube.name}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
interest: "Événements",
|
||||
categories: [
|
||||
{id: "", name: "", source: dailymotion.name},
|
||||
{id: "19", name: "Travel & Events", source: youtube.name},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
interest: "Films",
|
||||
categories: [
|
||||
{id: "shortfilms", name: "Cinéma", source: dailymotion.name},
|
||||
{id: "1", name: "Film & Animation", source: youtube.name},
|
||||
{id: "18", name: "Short Movies", source: youtube.name},
|
||||
{id: "30", name: "Movies", source: youtube.name},
|
||||
{id: "31", name: "Anime/Animation", source: youtube.name},
|
||||
{id: "32", name: "Action/Adventure", source: youtube.name},
|
||||
{id: "33", name: "Comedy", source: youtube.name},
|
||||
{id: "35", name: "Documentary", source: youtube.name},
|
||||
{id: "36", name: "Drama", source: youtube.name},
|
||||
{id: "39", name: "Horror", source: youtube.name},
|
||||
{id: "40", name: "Sci-Fi/Fantasy", source: youtube.name},
|
||||
{id: "41", name: "Thriller", source: youtube.name},
|
||||
{id: "42", name: "Shorts", source: youtube.name},
|
||||
{id: "44", name: "Trailers", source: youtube.name}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
interest: "Jeux vidéo",
|
||||
categories: [
|
||||
{id: "videogames", name: "Jeux vidéo", source: dailymotion.name},
|
||||
{id: "20", name: "Gaming", source: youtube.name},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
interest: "Kids",
|
||||
categories: [
|
||||
{id: "kids", name: "Kids", source: dailymotion.name},
|
||||
{id: "", name: "", source: youtube.name},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
interest: "Modes de vie",
|
||||
categories: [
|
||||
{id: "lifestyle", name: "Lifestyle & Tutoriels", source: dailymotion.name},
|
||||
{id: "26", name: "Howto & Style", source: youtube.name},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
interest: "Musiques",
|
||||
categories: [
|
||||
{id: "music", name: "Musique", source: dailymotion.name},
|
||||
{id: "10", name: "Music", source: youtube.name},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
interest: "People",
|
||||
categories: [
|
||||
{id: "people", name: "Amis & Famille", source: dailymotion.name},
|
||||
{id: "21", name: "Videoblogging", source: youtube.name},
|
||||
{id: "22", name: "People & Blogs", source: youtube.name},
|
||||
{id: "37", name: "Family", source: youtube.name},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 13,
|
||||
interest: "Science et Technologie",
|
||||
categories: [
|
||||
{id: "tech", name: "Tech", source: dailymotion.name},
|
||||
{id: "28", name: "Science & Technology", source: youtube.name},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 14,
|
||||
interest: "Sports",
|
||||
categories: [
|
||||
{id: "sport", name: "Sport", source: dailymotion.name},
|
||||
{id: "17", name: "Sports", source: youtube.name},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 15,
|
||||
interest: "Voyages",
|
||||
categories: [
|
||||
{id: "travel", name: "Voyages", source: dailymotion.name},
|
||||
{id: "38", name: "Foreign", source: youtube.name},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 16,
|
||||
interest: "Autres",
|
||||
categories: [
|
||||
{id: "29", name: "Nonprofits & Activism", source: youtube.name},
|
||||
{id: "33", name: "Classics", source: youtube.name}
|
||||
]
|
||||
}
|
||||
];
|
||||
Reference in a new issue