@experteam-mx/ngx-services

中文文档
22.0.0发布于 2026/11/07TypeScriptES Module近 30 天下载 2675

Angular common services for Experteam apps

原始使用文档
文档目录5 节
  1. Standalone setup (Angular v20+)
  2. NgModule compatibility
  3. Build
  4. Publish
  5. Test

@experteam-mx/ngx-services

Common Angular services used across Experteam applications.

Standalone setup (Angular v20+)

Use provideNgxServices(environment) in your ApplicationConfig.providers.

import { provideHttpClient, withInterceptors } from '@angular/common/http'
import type { ApplicationConfig } from '@angular/core'
import { provideRouter } from '@angular/router'
import {
    apiHeadersInterceptor,
    apiTokenInterceptor,
    httpCachingInterceptor,
    provideNgxServices,
    type Environment
} from '@experteam-mx/ngx-services'
import { environment } from '../environments/environment'
import { routes } from './app.routes'

const envs = {
    ...environment,
    authCookie: 'token'
    // cacheRoutes is opt-in; omit or leave empty until routes are registered:
    // cacheRoutes: [
    //   { pattern: '/api/catalogs', ttl: 60_000 },
    //   { pattern: '/api/companies/.+/branches', ttl: 30_000 }
    // ]
} as Environment

export const appConfig: ApplicationConfig = {
    providers: [
        provideRouter(routes),
        provideNgxServices(envs),
        provideHttpClient(withInterceptors([
            apiHeadersInterceptor,
            apiTokenInterceptor,
            httpCachingInterceptor
        ]))
    ]
}

provideNgxServices registers ENVIRONMENT_TOKEN, which is required by the API services and some interceptors in this package.

httpCachingInterceptor caches only GET requests whose URL matches an entry in cacheRoutes (first matching RegExp pattern wins). With no routes configured, nothing is cached.

NgModule compatibility

NgxServicesModule.forRoot(environment) is still available for compatibility, but it is deprecated for new standalone applications and will be removed in 20.2.0.

import { importProvidersFrom } from '@angular/core'
import { NgxServicesModule } from '@experteam-mx/ngx-services'

providers: [
    importProvidersFrom([NgxServicesModule.forRoot(envs)])
]

Prefer provideNgxServices(envs) for all new apps.

Build

ng build @experteam-mx/ngx-services

Build output:

dist/experteam-mx/ngx-services

Publish

cd dist/experteam-mx/ngx-services
npm publish

Test

ng test @experteam-mx/ngx-services

版本与发布记录

@experteam-mx/ngx-services 共发布 332 个版本,首次发布于 2024/05/07;过去 12 个月发布了 223 个版本。

版本发布日期距今
22.0.0latest2026/11/077 天前
22.0.0-dev2.12026/10/3114 天前
20.11.62026/10/2915 天前
20.11.52026/10/2916 天前
22.0.0-dev2.02026/10/2817 天前
20.11.42026/10/2817 天前

其他发布通道:legacy-18.8 → 18.8.6,v18.8-legacy → 18.8.14,v18.9-legacy → 18.9.15,legacy → 18.8.15,current → 18.8.20,v18-beta → 18.9.16。

关于 @experteam-mx/ngx-services 的常见问题

@experteam-mx/ngx-services 是什么?

Angular common services for Experteam apps

如何安装 @experteam-mx/ngx-services?

在项目目录运行 npm install @experteam-mx/ngx-services,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:pusher-js(^7.5.0)、@angular/core(>=22.0.0)、@angular/common(>=22.0.0)、ngx-cookie-service(>=22.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@experteam-mx/ngx-services 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@experteam-mx/ngx-services 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@experteam-mx/ngx-services 可以商用吗?

@experteam-mx/ngx-services 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@experteam-mx/ngx-services 的下载量有多少?

根据 npm 官方下载统计,@experteam-mx/ngx-services 在 2026/10/14 – 2026/11/12 这 30 天内被下载 2,675 次,日均约 89 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@experteam-mx/ngx-services 还在维护吗?

最新版本 22.0.0 发布于 2026/11/07(7 天前);至今共发布 332 个版本,其中过去 12 个月发布了 223 个;首次发布于 2024/05/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。