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

@muhammedadel/madmin

v1.4.0

Published

- Muhammed Admin package => first step to make framework to node.js # About - this package use to make easy admin panal by only model name and routes guard.

Downloads

2

Readme

MAdmin

  • Muhammed Admin package => first step to make framework to node.js

About

  • this package use to make easy admin panal by only model name and routes guard.

important to

  • app.use(express.json()); or app.use(bodyParser.json())
  • app.use(express.urlencoded()); or app.use(bodyParser.urlencoded())
  • you must but user in req.user becuase i use req.user.role

Package componenets

  • Controller
  • guardAppRoutes
  • Catalog
  • Action, ==> model
  • Role, ==> mode
  • adminAccountSchema, ==> schema for user account to define role refer to Role Model

explain logic

  • every Role have array of acctions
  • action is { url: { type: String, required: true }, ===> '*' for all routes type: { type: String, enum: ['all', 'get', 'post', 'put', 'delete', 'patch', 'head', 'options', 'trace'] } }
  • action foucs on specfic method on certien route
  • you must put in your user schema the following
  • role: { type: mongoose.Schema.Types.ObjectId, ref: 'Role', required: true }

Depndencies

  • mongodb ( mongoose )
  • express

Features

  • the controller create routes with impelementaion from model [get all [Catalog class used here], get by id, create, create many , delete, delete many, update by id ]
  • Catalog class make catalog and pagination
  • validator for rules
  • Router Guard by action

Controller (Model, options, rules)

  • mongoose model
  • options = { prefix: 'hidden', // default 'admin' ==> localhost:3000/admin notAllowedMethods: ['getAll'], urlTitleForMany: 'tests', default table name ===> localhost:3000/tests urlTitleForOne: 'test', default Model name hiddenFields: ['_id', '__v'], ===> projection of mongodb

Controller.app()

immutableFields: ['marks']  ===> to prevent edit on this field <br />
isAuth: isAuthFuntion ==> give me refrence for your is authentication function becuase i want to check if user are logged in or not by your function <br />

};

  • rules = { name: 'minLen:1|maxLen:255|required|string', year: 'minLen:1|maxLen:3|required||number|max:2023|min:1963', active: 'boolean', gender: 'enum:male,female', };

    const pagination = new Catalog(this.Model, { page, pageSize }, filters, sortBy, this.projection());

Catalog (Model, paginationOption, filters, sortBy, projection)

  • mongoose model
  • paginationOption = { page: 1, pageSize: 10 // [5, 10, 25, 50, 100] }
  • filters = { name: 'mohamed' // insenstive case and use regex for searcing }
  • sortBy = 'name' for asc '-name' for desc

guardAppRoutes

  • use this function to guard your routes by role id
  • usage => guardAppRoutes(req.user.roleId)

guardMiddleware (roleId)

  • use this middleware to gaurd specic route

guardByReq

  • use this middleware without pass roleId becuase i take it from req.user.role

appRouter (prefix='admin')

  • usage app.use(appRouter());
  • this middleware give you endpoints for actions and roles

- role endpoints

- Get => prefix/roles/:id ===> get specifc role
- Get => prefix/roles/  ===> get all roles
- Put => prefix/roles/  ===> update role
- delete => prefix/roles/:id  ===> delete role
- post => prefix/roles/:id/clone-actions  ===> to clone actions from role id to another and you can add custom actions 

- actions endpoints

- Get => prefix/actionss/:id ===> get specifc actions
- Get => prefix/actionss/  ===> get all actionss
- Put => prefix/actionss/  ===> update actions
- delete => prefix/actionss/:id  ===> delete actions