diff --git a/app/models/page.js b/app/models/page.js new file mode 100644 index 0000000..705fb82 --- /dev/null +++ b/app/models/page.js @@ -0,0 +1,29 @@ +// page.js +// Copyright (C) 2021 Digital Telepresence, LLC +// License: Apache-2.0 + +'use strict'; + +const mongoose = require('mongoose'); +const Schema = mongoose.Schema; + +const PAGE_STATUS_LIST = ['draft','published','archived']; + +const PageSchema = new Schema({ + title: { type: String, required: true }, + slug: { type: String, required: true, lowercase: true, unique: true }, + image: { + header: { type: Schema.ObjectId, ref: 'Image' }, + icon: { type: Schema.ObjectId, ref: 'Image' }, + }, + content: { type: String, required: true, select: false }, + status: { type: String, enum: PAGE_STATUS_LIST, default: 'draft', index: true }, + menu: { + icon: { type: String, required: true }, + label: { type: String, required: true }, + order: { type: Number, default: 0, required: true }, + parent: { type: Schema.ObjectId, index: 1, ref: 'Page' }, + }, +}); + +module.exports = mongoose.model('Page', PageSchema); \ No newline at end of file diff --git a/app/models/post.js b/app/models/post.js new file mode 100644 index 0000000..750ec45 --- /dev/null +++ b/app/models/post.js @@ -0,0 +1,36 @@ +// post.js +// Copyright (C) 2021 Digital Telepresence, LLC +// License: Apache-2.0 + +'use strict'; + +const path = require('path'); +const mongoose = require('mongoose'); + +const Schema = mongoose.Schema; + +const { + ResourceStats, + ResourceStatsDefaults, +} = require(path.join(__dirname, 'lib', 'resource-stats.js')); + +const POST_STATUS_LIST = ['draft','published','archived']; + +const PostSchema = new Schema({ + created: { type: Date, default: Date.now, required: true, index: -1 }, + updated: { type: Date }, + author: { type: Schema.ObjectId, required: true, index: 1, ref: 'User' }, + image: { type: Schema.ObjectId, ref: 'Image' }, + title: { type: String, required: true }, + slug: { type: String, required: true, lowercase: true, unique: true }, + summary: { type: String, required: true }, + content: { type: String, required: true, select: false }, + status: { type: String, enum: POST_STATUS_LIST, default: 'draft', index: true }, + stats: { type: ResourceStats, default: ResourceStatsDefaults, required: true }, + flags: { + enableComments: { type: Boolean, default: true, index: true }, + isFeatured: { type: Boolean, default: false, index: true }, + }, +}); + +module.exports = mongoose.model('Post', PostSchema); \ No newline at end of file diff --git a/app/services/session.js b/app/services/session.js index aafc4f6..7c6f226 100644 --- a/app/services/session.js +++ b/app/services/session.js @@ -1,5 +1,5 @@ // session.js -// Copyright (C) 2022 DTP Technologies, LLC +// Copyright (C) 2021 Digital Telepresence, LLC // License: Apache-2.0 'use strict'; diff --git a/config/limiter.js b/config/limiter.js index 350e855..f1d3d1a 100644 --- a/config/limiter.js +++ b/config/limiter.js @@ -1,5 +1,5 @@ // limiter.js -// Copyright (C) 2022 DTP Technologies, LLC +// Copyright (C) 2021 Digital Telepresence, LLC // License: Apache-2.0 'use strict'; @@ -70,6 +70,38 @@ module.exports = { }, }, + /* + * CryptoExchangeController + */ + cryptoExchange: { + getRateGraph: { + total: 10, + expire: ONE_MINUTE, + message: 'You are loading exchange rate graphs too quickly', + }, + getCurrentRates: { + total: 10, + expire: ONE_MINUTE, + message: 'You are loading cryptocurrency exchange rates too quickly', + }, + }, + + /* + * DashboardController + */ + dashboard: { + getEpisodeView: { + total: 15, + expire: ONE_MINUTE, + message: 'You are loading the dashboard episode view too quickly', + }, + getHome: { + total: 15, + expire: ONE_MINUTE, + message: 'You are loading the publisher dashboard too quickly', + }, + }, + /* * EmailController */ @@ -127,6 +159,54 @@ module.exports = { } }, + /* + * NewsletterController + */ + newsletter: { + getView: { + total: 5, + expire: ONE_MINUTE, + message: 'You are reading newsletters too quickly', + }, + getIndex: { + total: 60, + expire: ONE_MINUTE, + message: 'You are fetching newsletters too quickly', + }, + }, + + /* + * PageController + */ + page: { + getView: { + total: 5, + expire: ONE_MINUTE, + message: 'You are reading pages too quickly', + }, + }, + + /* + * PostController + */ + post: { + getComments: { + total: 20, + expire: ONE_MINUTE, + message: 'You are reading comments too quickly', + }, + getView: { + total: 5, + expire: ONE_MINUTE, + message: 'You are reading posts too quickly', + }, + getIndex: { + total: 60, + expire: ONE_MINUTE, + message: 'You are refreshing too quickly', + }, + }, + /* * UserController */ @@ -178,4 +258,4 @@ module.exports = { expire: ONE_MINUTE, message: 'You are loading these pages too quickly', }, -}; \ No newline at end of file +};