afrocrud
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

AfroCrud

CircleCI NPM Vesion NPM Downloads

Usage

Mongoose model file:

const NoteModelSchema = new mongoose.Schema({
    text: {
      type: String
    },
    title:{
      type: String,
      default: "Untitled"
    }
  }, {timestamps: true});

export const Notes = mongoose.model("Notes", NoteModelSchema);

Joi schema file:

export const NoteJoiSchema = Joi.object({
    title: Joi.string().allow("").default("Untitled"),
    text: Joi.string().min(3).default("Foo")
  });

Create routes:

import { AfroCrud } from "afrocrud";
import { Notes } from "./notes.model.js";
import { NoteJoiSchema } from "./notes.schema.js";

const notesRoutes = new AfroCrud(Notes, NoteJoiSchema);
app.use("/notes", notesRoutes.router);

/afrocrud/

    Package Sidebar

    Install

    npm i afrocrud

    Weekly Downloads

    1

    Version

    0.0.3

    License

    ISC

    Unpacked Size

    51 kB

    Total Files

    18

    Last publish

    Collaborators

    • digitalkelvin