npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

Iโ€™ve always been into building performant and accessible sites, but lately Iโ€™ve been taking it extremely seriously. So much so that Iโ€™ve been building a tool to help me optimize and monitor the sites that I build to make sure that Iโ€™m making an attempt to offer the best experience to those who visit them. If youโ€™re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, ๐Ÿ‘‹, Iโ€™m Ryan Hefnerย  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If youโ€™re interested in other things Iโ€™m working on, follow me on Twitter or check out the open source projects Iโ€™ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soonโ€“ish.

Open Software & Tools

This site wouldnโ€™t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you ๐Ÿ™

ยฉ 2024 โ€“ย Pkg Stats / Ryan Hefner

@jetvil/cm-api

v0.2.1

Published

๐Ÿ“š Content management API for integrating with NodeJS(express) and Prisma ORM

Downloads

4

Readme

@jetvil/cm-api

Bundle size Versionย  Downloadsย  GitHubย  GitHub Repo starsย  GitHub issuesย 

๐Ÿ“š Content management API for integrating with NodeJS Express(backend) and Prisma(ORM)

Features

  • ๐Ÿš€ Easy to use: Easy to install in your project.
  • โœ… ES6+ && TS: TypeScript and ES6+ support(JS).
  • ๐Ÿ“ฆ Required dependencies: You don't need what you won't use: express and prisma.
  • ๐Ÿ’ต Free: It's free and always will be, the beauty of open source.

Getting Started

Installation

To use this package, install using npm, yarn or pnpm๐Ÿ“ฅ:

# npm
npm install @jetvil/cm-api
# yarn
yarn add @jetvil/cm-api
# pnpm
pnpm install @jetvil/cm-api

Usage

const express = require("express");
const { PrismaClient } = require("@prisma/client");
const jetvil = require("@jetvil/cm-api");

// prisma with eg. postgresql and schemas: "user" and "post"
const prisma = new PrismaClient(); // Prisma ORM, you must have it installed and generated.
const app = express();
const jetvil = jetvil();

app.use(express.json()); // for parsing application/json.

jetvil.setClient(prisma); // Set prisma client here or pass it in the router() method.
const router = jetvil.router(); // Empty by default, you can configure it by passing an object.

app.use("/api", router);

app.listen(3000, () => {
  console.log("Server is running on port 3000");
});
// Routes such as /user and /post will be available at /api/user and /api/post

Configuration

You can configure the router by passing an object to the router() method.

By doing so you can adjust the routes to your needs.

const jetvil = require("@jetvil/cm-api");

const jetvil = jetvil();

const router = jetvil.router({
  client: prisma, // Prisma ORM, you must have it installed and generated.
  global: {
    schemas: ["user", "post", "profile"], // if specified, only these schemas will be available.
    methods: ["get", "post", "put", "delete", "fake"], // if specified, only these methods will be available, 'fake' will not be used.
    middleware: [
      {
        methods: ["get"], // Method to which the middleware will be applied.
        schemas: ["user"], // Schema to which the middleware will be applied.
        handler: (req, res, next) => {
          // Middleware function.
          next();
        },
      },
    ],
  },
  config: {
    // note how the schema is the key and the value is an object with the schema config.
    // these are overrides for the global config on a per schema basis.
    user: {
      methods: ["get", "post", "put"], // note how the delete method is not included.
      actions: ["read", "create", "update", "delete"], // these actions determine what the user can do with the schema.
      // for example, if the user has the 'read' action, he can only read the schema.
      // when the 'filter' action is included, the user can filter the schema on the schema.

      middleware: [
        // this middleware will override the global middleware for the user schema.
        {
          handler: (_req, _res, next) => {
            console.log("Middleware applied to user schema!");
            next();
          },
        },
      ],
    },
  },
  verbose: true, // If true, the router will log the routes it generates.
});

Documentation

For more information, please check out the documentation๐Ÿ“–.

Contributing

Found a bug๐ŸฆŸ? or want to suggest a new feature๐Ÿ†•? or just want to help๐Ÿ†˜?

Feel free to open an issue or a pull request.

Contributions are always welcome!๐ŸŽ‰

  • Fork the project here.
  • Create a new branch like this: git checkout -b feature/featureName.
  • Commit your changes to your branch: git commit -m 'Create AwesomeFeature'โš™๏ธ.
  • Push your branch: git push origin feature/featureName.
  • Open a pull request on the dev branch here๐Ÿ”ƒ.

๐Ÿ“’Note: Make sure to add tests for your changes โœ….