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

mongoqueue-dev

v0.0.5

Published

mongoqueue npm lib

Downloads

2

Readme

Installation

# Install dependencies
yarn install

# Start the project
npm run nodemon

# Build project env dev
yarn build

Dev guide

  • Typescript ESM
  • Đặt tên class theo tên folder
  • Viêt theo hướng tách module thành lib để re-use. Lưu ý:
    • Dependency Injection
    • Truyền params thông qua constructor, set hoặc function

#MongoQueue reference https://www.mongodb.com/docs/manual/core/index-partial/ https://stackoverflow.com/questions/35178356/create-a-conditional-ttl-in-mongo

Ex: db.email.createIndex( {createdDate: 1}, { expireAfterSeconds: 172800, // 2 days partialFilterExpression: { scheduledDate: 0 } });

Make local package install

tham khảo https://terodox.tech/using-npm-link-for-package-development/ Ví dụ:

  1. Mỗi lib phải có file package.json để mô tả lib
  2. Tới thư mục lib .../partnership/server/modules/auths Chạy npm link Cho kết quả /home/bao/.nvm/versions/node/v12.22.1/lib/node_modules/auths -> /home/bao/Private/Demo/partnership/server/modules/auths
  3. Sử dụng cho project Vào thư mục .../partnership/server Chạy npm link auths Cho kết quả /home/bao/Private/Demo/partnership/server/node_modules/auths -> /home/bao/.nvm/versions/node/v12.22.1/lib/node_modules/auths -> /home/bao/Private/Demo/partnership/server/modules/auths Sửa lại các import import {Auth...} from '../../auths' -> import {Auth} from 'auths'
  4. Xóa liên kết Vào lại thư mục .../partnership/server/modules/auths Chạy lệnh npm unlink Vào lại thư mục .../partnership/server Chạy lệnh npm unlink auths

Unit Test with Jest

jest @types/jest ts-jest supertest

setup npm install --save-dev libname

Add script to package.json

"test": "jest --coverage --passWithNoTests" "test:watch": "jest --watch"

jest.config.ts

import type {Config} from '@jest/types'

// Sync object const config: Config.InitialOptions = { verbose: true, testMatch: [ //cấu hình các thư mục test '/tests//*.test.tsx', '/modules//*.test.ts', ], transform: { '^.+.(ts|tsx|js)$': 'ts-jest', }, } export default config

Run test

npm run test

Kết quả tương tự như sau PASS modules/auths/index.test.ts (5.69 s) test ✓ get getLoginURL from config is not empty (1 ms) ✓ get login URL contructor (342 ms) ✓ get login URL get set (3 ms)

---------------------------|---------|----------|---------|---------|----------------------------------------------------------------------------------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------------------|---------|----------|---------|---------|----------------------------------------------------------------------------------------------- All files | 41.86 | 15.62 | 34.54 | 41.66 |
index.ts | 88.88 | 100 | 66.66 | 87.5 | 14
configs | 76.92 | 32.78 | 45.45 | 76.56 |
config.constant.ts | 100 | 100 | 100 | 100 |
index.ts | 76.56 | 32.78 | 45.45 | 76.19 | 53,74,87,96,107-114,124,128,132,136,140
configs/developments | 100 | 100 | 100 | 100 |
worker.config.ts | 100 | 100 | 100 | 100 |
logs | 24.62 | 0 | 17.24 | 23.11 |
index.ts | 100 | 100 | 100 | 100 |
log.constant.ts | 100 | 100 | 100 | 100 |
log.service.ts | 37.03 | 0 | 20 | 36.36 | 17-25,40-44,48-52,56-60
log.util.ts | 63.63 | 100 | 20 | 100 |
static_log.service.ts | 14.56 | 0 | 5.88 | 13.42 | 31,38-47,59-76,88-107,122-124,132-149,153-170,180-184,192-213,217-218,222-239,245-263,269-320 ---------------------------|---------|----------|---------|---------|----------------------------------------------------------------------------------------------- Test Suites: 1 passed, 1 total Tests: 3 passed, 3 total Snapshots: 0 total Time: 5.941 s Ran all test suites.

#Make npm library reference: https://dev.to/alexeagleson/how-to-create-and-publish-a-react-component-library-2oe#adding-rollup

Step1: install rollup npm install rollup @rollup/plugin-node-resolve @rollup/plugin-typescript @rollup/plugin-commonjs rollup-plugin-dts --save-dev

Step2: add rollup.config.js import resolve from "@rollup/plugin-node-resolve"; import commonjs from "@rollup/plugin-commonjs"; import typescript from "@rollup/plugin-typescript"; import dts from "rollup-plugin-dts";

const packageJson = require("./package.json");

export default [ { input: "src/index.ts", output: [ { file: packageJson.main, format: "cjs", sourcemap: true, }, { file: packageJson.module, format: "esm", sourcemap: true, }, ], plugins: [ resolve(), commonjs(), typescript({ tsconfig: "./tsconfig.json" }), ], }, { input: "dist/esm/types/index.d.ts", output: [{ file: "dist/index.d.ts", format: "esm" }], plugins: [dts()], }, ];

Step3 npm run rollup

Step4 publish git init add .gitignore update package.json { "name": "@YOUR_GITHUB_USERNAME/YOUR_REPOSITORY_NAME", "publishConfig": { "registry": "https://npm.pkg.github.com/YOUR_GITHUB_USERNAME" }, ...
} add root/.npmrc registry=https://registry.npmjs.org/ @YOUR_GITHUB_USERNAME:registry=https://npm.pkg.github.com/ //npm.pkg.github.com/:_authToken=YOUR_AUTH_TOKEN