Better limits

This commit is contained in:
Akif9748 2022-09-17 20:25:19 +03:00
parent 5a05737f8b
commit 87be28c71f
9 changed files with 23 additions and 18 deletions

View file

@ -1,11 +1,13 @@
const mongoose = require("mongoose") const mongoose = require("mongoose");
const cache = require("./cache") const cache = require("./cache");
const { limits } = require("../config.json");
const schema = new mongoose.Schema({ const schema = new mongoose.Schema({
id: { type: String, unique: true }, id: { type: String, unique: true },
author: Object, author: Object,
threadID: String, threadID: String,
authorID: String, authorID: String,
content: { type: String, maxlength: 1024 }, content: { type: String, maxlength: limits.message },
time: { type: Date, default: Date.now }, time: { type: Date, default: Date.now },
deleted: { type: Boolean, default: false }, deleted: { type: Boolean, default: false },
edited: { type: Boolean, default: false }, edited: { type: Boolean, default: false },

View file

@ -1,7 +1,8 @@
const mongoose = require("mongoose") const mongoose = require("mongoose")
const { limits } = require("../config.json");
const schema = new mongoose.Schema({ const schema = new mongoose.Schema({
username: { type: String, unique: true, maxlength: 25 }, username: { type: String, unique: true, maxlength: limits.names },
password: String, password: String,
id: { type: String, unique: true } id: { type: String, unique: true }
}); });

View file

@ -1,6 +1,8 @@
const mongoose = require("mongoose"); const mongoose = require("mongoose");
const cache = require("./cache") const cache = require("./cache")
const MessageModel = require("./Message"); const MessageModel = require("./Message");
const { limits } = require("../config.json");
const schema = new mongoose.Schema({ const schema = new mongoose.Schema({
id: { type: String, unique: true }, id: { type: String, unique: true },
@ -8,7 +10,7 @@ const schema = new mongoose.Schema({
authorID: String, authorID: String,
author: Object, author: Object,
title: { type: String, maxlength: 128 }, title: { type: String, maxlength: limits.title },
time: { type: Date, default: Date.now }, time: { type: Date, default: Date.now },
deleted: { type: Boolean, default: false }, deleted: { type: Boolean, default: false },
edited: { type: Boolean, default: false }, edited: { type: Boolean, default: false },

View file

@ -1,14 +1,14 @@
const mongoose = require("mongoose") const mongoose = require("mongoose")
const { def_theme } = require("../config.json"); const { def_theme, limits } = require("../config.json");
const schema = new mongoose.Schema({ const schema = new mongoose.Schema({
id: { type: String, unique: true }, id: { type: String, unique: true },
discordID: { type: String, unique: true }, discordID: { type: String, unique: true },
name: { type: String, maxlength: 25 }, name: { type: String, maxlength: limits.names },
avatar: { type: String, default: "/images/avatars/default.jpg" }, avatar: { type: String, default: "/images/avatars/default.jpg" },
time: { type: Date, default: Date.now }, time: { type: Date, default: Date.now },
deleted: { type: Boolean, default: false }, deleted: { type: Boolean, default: false },
edited: { type: Boolean, default: false }, edited: { type: Boolean, default: false },
about: { type: String, default: "", maxlength: 256 }, about: { type: String, default: "", maxlength: limits.desp },
admin: { type: Boolean, default: false }, admin: { type: Boolean, default: false },
theme: { type: String, default: def_theme }, theme: { type: String, default: def_theme },
lastSeen: { type: Date, default: Date.now, select: false }, lastSeen: { type: Date, default: Date.now, select: false },

View file

@ -9,9 +9,9 @@
<form> <form>
<h2 class="title" style="align-self: baseline;">Name:</h2> <h2 class="title" style="align-self: baseline;">Name:</h2>
<input name="name" class="input" required maxlength="25"></input> <input name="name" class="input" required ></input>
<h2 class="title" style="align-self: baseline;">Description:</h2> <h2 class="title" style="align-self: baseline;">Description:</h2>
<textarea rows="4" cols="50" name="desp" maxlength="256" class="input" required></textarea> <textarea rows="4" cols="50" name="desp" class="input" required></textarea>
<button class="btn-primary" style="width:100%" type="submit">Create Category!</button> <button class="btn-primary" style="width:100%" type="submit">Create Category!</button>
</form> </form>

View file

@ -11,9 +11,9 @@
<form> <form>
<h2 class="title" style="align-self: baseline;">Title:</h2> <h2 class="title" style="align-self: baseline;">Title:</h2>
<input name="title" maxlength="128" class="input" required></input> <input name="title" class="input" required></input>
<h2 class="title" style="align-self: baseline;">Content:</h2> <h2 class="title" style="align-self: baseline;">Content:</h2>
<textarea rows="4" cols="50" maxlength="1024" name="content" class="input" required></textarea> <textarea rows="4" cols="50" name="content" class="input" required></textarea>
<h2 class="title" style="align-self: baseline;">Category:</h2> <h2 class="title" style="align-self: baseline;">Category:</h2>
<select name="category"> <select name="category">

View file

@ -14,9 +14,9 @@
<form action="/register" method="post"> <form action="/register" method="post">
<input type="text" name="username" maxlength="25" placeholder="Username" class="input" required> <input type="text" name="username" placeholder="Username" class="input" required>
<input type="password" name="password" maxlength="25" placeholder="Password" class="input" required> <input type="password" name="password" placeholder="Password" class="input" required>
<textarea class="input" name="about" rows="4" maxlength="256" placeholder="About you... You can use markdown"></textarea> <textarea class="input" name="about" rows="4" placeholder="About you... You can use markdown"></textarea>
<input type="submit" class="btn-primary" style="width:100%;" value="Register"> <input type="submit" class="btn-primary" style="width:100%;" value="Register">
</form> </form>

View file

@ -109,7 +109,7 @@
<div class="message" id="send-div"> <div class="message" id="send-div">
<form id="send" style="width:100%"> <form id="send" style="width:100%">
<textarea rows="4" maxlength="1024" name="content" required></textarea> <textarea rows="4" name="content" required></textarea>
<input name="threadID" type="hidden" value="<%= thread.id %>"></input> <input name="threadID" type="hidden" value="<%= thread.id %>"></input>
<input name="page" type="hidden" value="<%= page %>"></input> <input name="page" type="hidden" value="<%= page %>"></input>
<button class="btn-primary">Send!</button> <button class="btn-primary">Send!</button>

View file

@ -30,9 +30,9 @@
<h1 class="title" style="text-align:center;">Edit <a class="see" href="/users/<%= member.id %>"><%= member.name %></a></h1> <h1 class="title" style="text-align:center;">Edit <a class="see" href="/users/<%= member.id %>"><%= member.name %></a></h1>
<div class="content"> <div class="content">
<form id="form" class="see" style="box-shadow:none"> <form id="form" class="see" style="box-shadow:none">
<input type="text" name="name" maxlength="25" placeholder="<%=member.name%>" class="input" > <input type="text" name="name" placeholder="<%=member.name%>" class="input" >
<textarea class="input" name="about" maxlength="256" rows="4" cols="60" name="content" placeholder="<%=member.about%>"></textarea> <textarea class="input" name="about" rows="4" cols="60" name="content" placeholder="<%=member.about%>"></textarea>
<% if (user?.admin){ %> <% if (user?.admin){ %>
Is Admin? <input id='admin' type='checkbox' value='true' name='admin' <%=member.admin ? "checked": ""%>> Is Admin? <input id='admin' type='checkbox' value='true' name='admin' <%=member.admin ? "checked": ""%>>
<input id='adminHidden' type='hidden' value='false' name='admin'> <input id='adminHidden' type='hidden' value='false' name='admin'>