Generic api for any entity

This commit is contained in:
2022-08-12 08:57:36 -05:00
parent d1495df5a1
commit f65ae56f74
5 changed files with 118 additions and 84 deletions

View 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
View File

@@ -0,0 +1,3 @@
export default {
bookmarks: require("./bookmarks"),
};