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

@mahdi.js/macore

v0.0.7

Published

macore is a nodejs core using typescript and express

Downloads

4

Readme

Description (V 0.0.7)

Macore is a framework for building easy , fast and MultiLangual Node.js server-side applications. It uses modern JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming) , DP (Design Patterns)

Table Of Macore Features

Quick Start

  • 1 - Install This nodejs Module From npm using : npm i --save @mahdi.js/macore
  • 2 - Create Your start.js|ts With Below Code :
  //TypeScript : 
  import App from 'macore'
  App(port)

  //javascript :
  const App = require('macore')
  App(port)

  // Also You Can Config view+session+cookie !
  App(
    port , 
    host , 
    viewConfig ,  // config OR {} OR Null(if you not need view)
    sessionConfig , // config OR {} OR Null(if you not need session)
    cookieConfig , // config OR {} OR Null(if you not need cookie)
    true // MongoConnection => true OR false ,
    MultiLingualConfig // config OR Null (if you not need i18Next[MultiLingual])
  ) 
  • 3 - Your Macore App Configured !

Router

  //const app = new App(port , host , ...)
  app.route("/" , Request_Methods.GET , (req:Request , res:Response , next:NextFunction) => {res.send("Hello Macore")})

Validation

Macore Validator is Using class-validator 1-Create Your dto(data transfer object) file , Example : Signin.dto.ts

  import { IsString, Length } from 'class-validator';
  export default class SigninDto {
      @IsString()
      public name!: string;
  }

2-Set This Dto To Your app as a midleware

  app.route("/" , Request_Methods.POST , MacoreValidator(SignInDto) , Controller)
  
  /*
    * also you can pass your callback url if you are using view
    * this will be rediredct to callbackUrl
  */
  app.route("/" , Request_Methods.POST , MacoreValidator(SignInDto , "/home") , Controller)

Utilities

This is Really Can Help You in any projects

Note: you can cancel several requests with the same cancel token.

ApiService

Send Any Request Using axios inside this package

    import {ApiService} from '@mahdi.js/macore'
    const apiInstance = new ApiService("https://jsonplaceholder.typicode.com/")
    await apiInstance.callService("todos/1" , Request_Methods.GET)
    
    //Also You Can Send Type of your Request & Response in Typescript
    await apiInstance.callService<RequestInterface , ResponseInterface>("todos/1" , Request_Methods.GET) 

chalk

console.log With Fucking Great TextColors!

You Can Read Document Inside chalk

  import {ch} from '@mahdi.js/macore'
  console.log(ch.red("Hello With Red Color"))

MultiLingual

Create MultiLingual Server-side App Easssssyyyy 1 - Config : this example for an english + spanish Server-side app

  new App(... , {
    lng : "en" ,
    fallbackLng : "en" ,
    preload : ["en" , "es"] ,
    saveMissing : false ,
    load : "languageOnly" ,
    resources : {
      en : {translation : {"greeting" : "Hello {{name}}" , 
      es : {translation : {"greeting" : "Hallo {{name}}  "}}
    }
  })

2 - Use it Using app.t Function

  app.t(
    "greeting" ,
    "en" , //This Lang
    {name : "Mahdi"}   // For pass Value Of {{name}}
  )

Also You Can Use it as Middleware or something else For Example , This is Your Middleware

  function (req , res , next) {
    this.app.changeLanguage(req.query.lang || "en")
  }

ORM

In This Version You Just Can Use MongoORM in the future we use typeORM :)

1 - Create a File For Your Model , Example : User.ts

  import {MongoBaseRepository} from "@mahdi.js/macore/utils/mongo";
  import {CustomSchemaDefinition} from "@mahdi.js/macore/types/mongo";
  
  export interface IUsers {
    name : string
  }
  
  class User extends MongoBaseRepository<IUsers>{

    definition(): CustomSchemaDefinition<IUsers> {
        return {
            name : {type : String , required : true}
        };
    }

    protected initiateIndexes(): void {}
    protected initiatePlugins(): void {}

  }

  export default new User("users")

2- End! , Use EveryWhere :)

    const users = await User.find({})