add the rest of basic stringList fields

master
Kit Kasune 1 year ago
parent 6546e0f719
commit 33b07db58d
  1. 16
      api/ani/v1/routes/series/edits.js
  2. 8
      db/ani/series.js

@ -41,10 +41,13 @@ module.exports = (app, router) => {
}
catch {return res.status(500).send("There was an error trying to update your synopsis. Please try again.");}
})
.get(app.auth.tokenPass, app.auth.permsPass('series-approve'), async (req, res) => { //working
.get(app.auth.tokenPass, app.auth.permsPass('series-approve'), async (req, res) => {
const series = await Anime.findOne({id: req.params.id.toLowerCase()});
if (!series || (series && !series.meta.completed && req.unauthorized)) {return res.status(400).send("A series with that ID doesn't exist!");}
return res.send({synopsis: series.synopsis.synopsis, by: series.synopsis.by});
})
.get(app.auth.tokenPass, app.auth.permsPass('series-approve'), async (req, res) => {
});
[ //?SINGLE STRING FIELDS
@ -58,11 +61,14 @@ module.exports = (app, router) => {
[ //?STRING LIST FIELDS
['tags', 'tag', x => x.match(/^[a-z-]+$/) && x.length < 25], //TODO set list length limits
['genres', 'genre', x => x.match(/^[a-zA-Z- ]+$/) && x.length < 25],
['stream-at', 'location', x => x.match(/^[\w- ]+$/) && x.length < 40] //TODO doc cheeky field
['stream-at', 'location', x => x.match(/^[\w- ]+$/) && x.length < 25], //TODO doc cheeky field
['alt-names', 'name', x => x.match(/^[\w\-!?.:; ]+$/gm) && x.length < 150],
['publishers', 'publisher', x => x.match(/^[\w\-!?.:; ]+$/gm) && x.length < 150],
['studios', 'studio', x => x.match(/^[\w\-!?.:; ]+$/gm) && x.length < 150]
].forEach(x => edits.list(...x)); //it's just that shrimple
//router.use('/:id/altnames', app.auth.tokenPass, app.auth.permsPass('series-approve'))
//air, completed, nsfw, externalLinks, videos, art, ratings, rating, watchers, likes, reviews, seasons, characters, related
//dependent fields can be modified string lists into number lists; seasons stored purely by numerical ID
// /ani/v1/series/code-geass --> /ep-1 /episode-1 /ep1 /1 /e1 -> seasons/1/episodes/1/
};

@ -79,10 +79,10 @@ module.exports = (connection) => connection.model('series', new Schema({
reviews: {type: [{ //full review vs rating
user: String,
ratings: {
plot: Number,
characters: Number,
soundtrack: Number,
animation: Number
plot: {type: Number, min: 1, max: 5, required: true},
characters: {type: Number, min: 1, max: 5, required: true},
soundtrack: {type: Number, min: 1, max: 5, required: true},
animation: {type: Number, min: 1, max: 5, required: true}
},
comments: {type: String, maxLength: 2000}
}], default: () => ([])

Loading…
Cancel
Save