Generic api for any entity
This commit is contained in:
22
web/lib/models/bookmarks.js
Normal file
22
web/lib/models/bookmarks.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import Ajv from "ajv";
|
||||
import addFormats from "ajv-formats";
|
||||
|
||||
const ajv = new Ajv();
|
||||
addFormats(ajv);
|
||||
|
||||
const validateId = ajv.compile({
|
||||
type: "string",
|
||||
minLength: 1,
|
||||
maxLength: 10,
|
||||
});
|
||||
|
||||
const validatePostBody = ajv.compile({
|
||||
type: "object",
|
||||
properties: {
|
||||
title: { type: "string" },
|
||||
url: { type: "string", format: "uri" },
|
||||
},
|
||||
required: ["title", "url"],
|
||||
});
|
||||
|
||||
export { validateId, validatePostBody };
|
||||
3
web/lib/models/index.js
Normal file
3
web/lib/models/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export default {
|
||||
bookmarks: require("./bookmarks"),
|
||||
};
|
||||
Reference in New Issue
Block a user