Repository: feathersjs/feathers Branch: dove Commit: 9905f9fe9fa0 Files: 549 Total size: 2.8 MB Directory structure: gitextract_xwzctsxf/ ├── .eslintrc.js ├── .github/ │ ├── FUNDING.yml │ ├── contributing.md │ ├── issue_template.md │ ├── pull_request_template.md │ └── workflows/ │ ├── nodejs.yml │ └── update-dependencies.yml ├── .gitignore ├── .mocharc.json ├── .nycrc ├── .prettierrc ├── CHANGELOG.md ├── LICENSE ├── README.md ├── docs/ │ ├── .vitepress/ │ │ ├── components/ │ │ │ ├── Badges.vue │ │ │ ├── BlockQuote.vue │ │ │ ├── Contributors.vue │ │ │ ├── DatabaseBlock.vue │ │ │ ├── DatabaseSelect.vue │ │ │ ├── FeaturesList.vue │ │ │ ├── LanguageBlock.vue │ │ │ ├── LanguageSelect.vue │ │ │ ├── ListItem.vue │ │ │ ├── Logo.vue │ │ │ ├── Select.vue │ │ │ ├── Tab.vue │ │ │ ├── Tabs.vue │ │ │ └── TeamMember.vue │ │ ├── components.d.ts │ │ ├── config.nav.ts │ │ ├── config.sidebar.ts │ │ ├── config.ts │ │ ├── meta.ts │ │ ├── scripts/ │ │ │ └── assets.ts │ │ ├── style/ │ │ │ ├── element-plus.scss │ │ │ ├── main.postcss │ │ │ └── vars.postcss │ │ ├── theme/ │ │ │ ├── FeathersLayout.vue │ │ │ ├── index.ts │ │ │ ├── pwa.ts │ │ │ └── store.ts │ │ └── vite-env.d.ts │ ├── api/ │ │ ├── application.md │ │ ├── authentication/ │ │ │ ├── client.md │ │ │ ├── hook.md │ │ │ ├── index.md │ │ │ ├── jwt.md │ │ │ ├── local.md │ │ │ ├── oauth.md │ │ │ ├── service.md │ │ │ └── strategy.md │ │ ├── channels.md │ │ ├── client/ │ │ │ ├── rest.md │ │ │ └── socketio.md │ │ ├── client.md │ │ ├── configuration.md │ │ ├── databases/ │ │ │ ├── adapters.md │ │ │ ├── common.md │ │ │ ├── knex.md │ │ │ ├── memory.md │ │ │ ├── mongodb.md │ │ │ └── querying.md │ │ ├── errors.md │ │ ├── events.md │ │ ├── express.md │ │ ├── hooks.md │ │ ├── index.md │ │ ├── koa.md │ │ ├── schema/ │ │ │ ├── index.md │ │ │ ├── resolvers.md │ │ │ ├── schema.md │ │ │ ├── typebox.md │ │ │ └── validators.md │ │ ├── services.md │ │ └── socketio.md │ ├── auto-imports.d.ts │ ├── comparison.md │ ├── components/ │ │ ├── CTAButton.vue │ │ ├── Footer.vue │ │ ├── FooterList.vue │ │ ├── HomeCTATextSection.vue │ │ ├── HomeCreateFirstApp.vue │ │ ├── HomeFeature1.vue │ │ ├── HomeFeature1Content.vue │ │ ├── HomeFeature2.vue │ │ ├── HomeFeature2Content.vue │ │ ├── HomeFeatureGrid.vue │ │ ├── HomeFeatureGridCard.vue │ │ ├── HomeHero.vue │ │ ├── HomeIndustryPartners.vue │ │ └── HomeQuickStart.vue │ ├── cookbook/ │ │ ├── authentication/ │ │ │ ├── _discord.md │ │ │ ├── anonymous.md │ │ │ ├── apiKey.md │ │ │ ├── auth0.md │ │ │ ├── facebook.md │ │ │ ├── firebase.md │ │ │ ├── google.md │ │ │ ├── revoke-jwt.md │ │ │ └── stateless.md │ │ ├── deploy/ │ │ │ └── docker.md │ │ ├── express/ │ │ │ ├── file-uploading.md │ │ │ └── view-engine.md │ │ ├── general/ │ │ │ ├── client-test.md │ │ │ └── scaling.md │ │ └── index.md │ ├── ecosystem/ │ │ ├── PackageCard.vue │ │ ├── Packages.vue │ │ ├── helpers.ts │ │ ├── index.md │ │ ├── types.ts │ │ └── useQuery.ts │ ├── feathers-vs-firebase.md │ ├── feathers-vs-loopback.md │ ├── feathers-vs-meteor.md │ ├── feathers-vs-nest.md │ ├── feathers-vs-sails.md │ ├── guides/ │ │ ├── basics/ │ │ │ ├── authentication.md │ │ │ ├── generator.md │ │ │ ├── hooks.md │ │ │ ├── login.md │ │ │ ├── schemas.md │ │ │ ├── services.md │ │ │ ├── starting.md │ │ │ └── testing.md │ │ ├── cli/ │ │ │ ├── app.md │ │ │ ├── app.test.md │ │ │ ├── authentication.md │ │ │ ├── channels.md │ │ │ ├── client.md │ │ │ ├── client.test.md │ │ │ ├── configuration.md │ │ │ ├── custom-environment-variables.md │ │ │ ├── databases.md │ │ │ ├── declarations.md │ │ │ ├── default.json.md │ │ │ ├── hook.md │ │ │ ├── index.md │ │ │ ├── knexfile.md │ │ │ ├── log-error.md │ │ │ ├── logger.md │ │ │ ├── package.md │ │ │ ├── prettierrc.md │ │ │ ├── service.class.md │ │ │ ├── service.md │ │ │ ├── service.schemas.md │ │ │ ├── service.shared.md │ │ │ ├── service.test.md │ │ │ ├── tsconfig.md │ │ │ └── validators.md │ │ ├── frameworks.md │ │ ├── frontend/ │ │ │ └── javascript.md │ │ ├── index.md │ │ ├── migrating.md │ │ ├── security.md │ │ └── whats-new.md │ ├── help/ │ │ ├── faq.md │ │ └── index.md │ ├── index.md │ ├── package.json │ ├── public/ │ │ ├── _headers │ │ ├── _redirects │ │ ├── feathers-chat.css │ │ └── robots.txt │ ├── tsconfig.json │ └── vite.config.ts ├── generators/ │ ├── package/ │ │ ├── index.tpl.ts │ │ ├── license.tpl.ts │ │ ├── package.json.tpl.ts │ │ ├── readme.md.tpl.ts │ │ ├── test.tpl.ts │ │ └── tsconfig.json.tpl.ts │ └── package.ts ├── lerna.json ├── package.json ├── packages/ │ ├── adapter-commons/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── declarations.ts │ │ │ ├── index.ts │ │ │ ├── query.ts │ │ │ ├── service.ts │ │ │ └── sort.ts │ │ ├── test/ │ │ │ ├── commons.test.ts │ │ │ ├── fixture.ts │ │ │ ├── query.test.ts │ │ │ ├── service.test.ts │ │ │ └── sort.test.ts │ │ └── tsconfig.json │ ├── adapter-tests/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── basic.ts │ │ │ ├── declarations.ts │ │ │ ├── index.ts │ │ │ ├── methods.ts │ │ │ └── syntax.ts │ │ ├── test/ │ │ │ └── index.test.ts │ │ └── tsconfig.json │ ├── authentication/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── core.ts │ │ │ ├── hooks/ │ │ │ │ ├── authenticate.ts │ │ │ │ ├── connection.ts │ │ │ │ ├── event.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ ├── jwt.ts │ │ │ ├── options.ts │ │ │ ├── service.ts │ │ │ └── strategy.ts │ │ ├── test/ │ │ │ ├── core.test.ts │ │ │ ├── fixtures.ts │ │ │ ├── hooks/ │ │ │ │ ├── authenticate.test.ts │ │ │ │ └── event.test.ts │ │ │ ├── jwt.test.ts │ │ │ └── service.test.ts │ │ └── tsconfig.json │ ├── authentication-client/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── core.ts │ │ │ ├── hooks/ │ │ │ │ ├── authentication.ts │ │ │ │ ├── index.ts │ │ │ │ └── populate-header.ts │ │ │ ├── index.ts │ │ │ └── storage.ts │ │ ├── test/ │ │ │ ├── index.test.ts │ │ │ └── integration/ │ │ │ ├── commons.ts │ │ │ ├── express.test.ts │ │ │ ├── fixture.ts │ │ │ └── socketio.test.ts │ │ └── tsconfig.json │ ├── authentication-local/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── hooks/ │ │ │ │ ├── hash-password.ts │ │ │ │ └── protect.ts │ │ │ ├── index.ts │ │ │ └── strategy.ts │ │ ├── test/ │ │ │ ├── fixture.ts │ │ │ ├── hooks/ │ │ │ │ ├── hash-password.test.ts │ │ │ │ └── protect.test.ts │ │ │ └── strategy.test.ts │ │ └── tsconfig.json │ ├── authentication-oauth/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── index.ts │ │ │ ├── service.ts │ │ │ ├── strategy.ts │ │ │ └── utils.ts │ │ ├── test/ │ │ │ ├── index.test.ts │ │ │ ├── service.test.ts │ │ │ ├── strategy.test.ts │ │ │ ├── utils/ │ │ │ │ ├── fixture.ts │ │ │ │ └── provider.ts │ │ │ └── utils.test.ts │ │ └── tsconfig.json │ ├── cli/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── bin/ │ │ │ └── feathers.js │ │ ├── package.json │ │ ├── src/ │ │ │ └── index.ts │ │ ├── test/ │ │ │ └── cli.test.ts │ │ └── tsconfig.json │ ├── client/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── core.js │ │ ├── package.json │ │ ├── src/ │ │ │ ├── core.ts │ │ │ └── feathers.ts │ │ ├── test/ │ │ │ ├── fetch.test.ts │ │ │ ├── fixture.ts │ │ │ ├── socketio.test.ts │ │ │ └── superagent.test.ts │ │ ├── tsconfig.json │ │ └── webpack/ │ │ ├── core.js │ │ ├── create-config.js │ │ └── feathers.js │ ├── commons/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── debug.ts │ │ │ └── index.ts │ │ ├── test/ │ │ │ ├── debug.test.ts │ │ │ ├── module.test.ts │ │ │ └── utils.test.ts │ │ └── tsconfig.json │ ├── configuration/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ └── index.ts │ │ ├── test/ │ │ │ ├── config/ │ │ │ │ └── default.json │ │ │ └── index.test.ts │ │ └── tsconfig.json │ ├── create-feathers/ │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── bin/ │ │ │ └── create-feathers.js │ │ └── package.json │ ├── errors/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ └── index.ts │ │ ├── test/ │ │ │ └── index.test.ts │ │ └── tsconfig.json │ ├── express/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── public/ │ │ │ ├── 401.html │ │ │ ├── 404.html │ │ │ └── default.html │ │ ├── src/ │ │ │ ├── authentication.ts │ │ │ ├── declarations.ts │ │ │ ├── handlers.ts │ │ │ ├── index.ts │ │ │ └── rest.ts │ │ ├── test/ │ │ │ ├── authentication.test.ts │ │ │ ├── error-handler.test.ts │ │ │ ├── index.test.ts │ │ │ ├── not-found-handler.test.ts │ │ │ └── rest.test.ts │ │ └── tsconfig.json │ ├── feathers/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── application.ts │ │ │ ├── declarations.ts │ │ │ ├── events.ts │ │ │ ├── hooks.ts │ │ │ ├── index.ts │ │ │ ├── service.ts │ │ │ └── version.ts │ │ ├── test/ │ │ │ ├── application.test.ts │ │ │ ├── declarations.test.ts │ │ │ ├── events.test.ts │ │ │ └── hooks/ │ │ │ ├── after.test.ts │ │ │ ├── app.test.ts │ │ │ ├── around.test.ts │ │ │ ├── before.test.ts │ │ │ ├── error.test.ts │ │ │ └── hooks.test.ts │ │ └── tsconfig.json │ ├── generators/ │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── app/ │ │ │ │ ├── index.ts │ │ │ │ └── templates/ │ │ │ │ ├── app.test.tpl.ts │ │ │ │ ├── app.tpl.ts │ │ │ │ ├── channels.tpl.ts │ │ │ │ ├── client.test.tpl.ts │ │ │ │ ├── client.tpl.ts │ │ │ │ ├── configuration.tpl.ts │ │ │ │ ├── declarations.tpl.ts │ │ │ │ ├── gitignore.tpl.ts │ │ │ │ ├── index.html.tpl.ts │ │ │ │ ├── index.tpl.ts │ │ │ │ ├── logger.tpl.ts │ │ │ │ ├── package.json.tpl.ts │ │ │ │ ├── prettierrc.tpl.ts │ │ │ │ ├── readme.md.tpl.ts │ │ │ │ ├── services.tpl.ts │ │ │ │ ├── tsconfig.json.tpl.ts │ │ │ │ └── validators.tpl.ts │ │ │ ├── authentication/ │ │ │ │ ├── index.ts │ │ │ │ └── templates/ │ │ │ │ ├── authentication.tpl.ts │ │ │ │ ├── client.test.tpl.ts │ │ │ │ ├── config.tpl.ts │ │ │ │ └── declarations.tpl.ts │ │ │ ├── commons.ts │ │ │ ├── connection/ │ │ │ │ ├── index.ts │ │ │ │ └── templates/ │ │ │ │ ├── knex.tpl.ts │ │ │ │ └── mongodb.tpl.ts │ │ │ ├── hook/ │ │ │ │ ├── index.ts │ │ │ │ └── templates/ │ │ │ │ └── hook.tpl.ts │ │ │ ├── index.ts │ │ │ └── service/ │ │ │ ├── index.ts │ │ │ ├── templates/ │ │ │ │ ├── client.tpl.ts │ │ │ │ ├── schema.json.tpl.ts │ │ │ │ ├── schema.typebox.tpl.ts │ │ │ │ ├── service.tpl.ts │ │ │ │ ├── shared.tpl.ts │ │ │ │ └── test.tpl.ts │ │ │ └── type/ │ │ │ ├── custom.tpl.ts │ │ │ ├── knex.tpl.ts │ │ │ └── mongodb.tpl.ts │ │ ├── test/ │ │ │ ├── build/ │ │ │ │ └── .gitkeep │ │ │ ├── commons.test.ts │ │ │ ├── generators.test.ts │ │ │ └── utils.ts │ │ └── tsconfig.json │ ├── knex/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── adapter.ts │ │ │ ├── declarations.ts │ │ │ ├── error-handler.ts │ │ │ ├── hooks.ts │ │ │ └── index.ts │ │ ├── test/ │ │ │ ├── connection.ts │ │ │ ├── error-handler.test.ts │ │ │ ├── index.test.ts │ │ │ └── overrides.test.ts │ │ └── tsconfig.json │ ├── koa/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── authentication.ts │ │ │ ├── declarations.ts │ │ │ ├── handlers.ts │ │ │ ├── index.ts │ │ │ └── rest.ts │ │ ├── test/ │ │ │ ├── app.fixture.ts │ │ │ ├── authentication.test.ts │ │ │ └── index.test.ts │ │ └── tsconfig.json │ ├── memory/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ └── index.ts │ │ ├── test/ │ │ │ └── index.test.ts │ │ └── tsconfig.json │ ├── mongodb/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── adapter.ts │ │ │ ├── converters.ts │ │ │ ├── error-handler.ts │ │ │ └── index.ts │ │ ├── test/ │ │ │ ├── converters.test.ts │ │ │ └── index.test.ts │ │ └── tsconfig.json │ ├── rest-client/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── axios.ts │ │ │ ├── base.ts │ │ │ ├── fetch.ts │ │ │ ├── index.ts │ │ │ └── superagent.ts │ │ ├── test/ │ │ │ ├── axios.test.ts │ │ │ ├── declarations.ts │ │ │ ├── fetch.test.ts │ │ │ ├── index.test.ts │ │ │ ├── server.ts │ │ │ └── superagent.test.ts │ │ └── tsconfig.json │ ├── schema/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── default-schemas.ts │ │ │ ├── hooks/ │ │ │ │ ├── index.ts │ │ │ │ ├── resolve.ts │ │ │ │ └── validate.ts │ │ │ ├── index.ts │ │ │ ├── json-schema.ts │ │ │ ├── resolver.ts │ │ │ └── schema.ts │ │ ├── test/ │ │ │ ├── fixture.ts │ │ │ ├── hooks.test.ts │ │ │ ├── json-schema.test.ts │ │ │ ├── resolver.test.ts │ │ │ └── schema.test.ts │ │ └── tsconfig.json │ ├── socketio/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ ├── index.ts │ │ │ └── middleware.ts │ │ ├── test/ │ │ │ ├── events.ts │ │ │ ├── index.test.ts │ │ │ └── methods.ts │ │ └── tsconfig.json │ ├── socketio-client/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src/ │ │ │ └── index.ts │ │ ├── test/ │ │ │ ├── index.test.ts │ │ │ └── server.ts │ │ └── tsconfig.json │ ├── tests/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── resources/ │ │ │ ├── certificate.pem │ │ │ └── privatekey.pem │ │ ├── src/ │ │ │ ├── client.ts │ │ │ ├── fixture.ts │ │ │ ├── index.ts │ │ │ └── rest.ts │ │ └── tsconfig.json │ ├── transport-commons/ │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── client.d.ts │ │ ├── client.js │ │ ├── package.json │ │ ├── src/ │ │ │ ├── channels/ │ │ │ │ ├── channel/ │ │ │ │ │ ├── base.ts │ │ │ │ │ └── combined.ts │ │ │ │ ├── index.ts │ │ │ │ └── mixins.ts │ │ │ ├── client.ts │ │ │ ├── http.ts │ │ │ ├── index.ts │ │ │ ├── routing/ │ │ │ │ ├── index.ts │ │ │ │ └── router.ts │ │ │ └── socket/ │ │ │ ├── index.ts │ │ │ └── utils.ts │ │ ├── test/ │ │ │ ├── channels/ │ │ │ │ ├── channel.test.ts │ │ │ │ ├── dispatch.test.ts │ │ │ │ └── index.test.ts │ │ │ ├── client.test.ts │ │ │ ├── http.test.ts │ │ │ ├── routing/ │ │ │ │ ├── index.test.ts │ │ │ │ └── router.test.ts │ │ │ └── socket/ │ │ │ ├── index.test.ts │ │ │ └── utils.test.ts │ │ └── tsconfig.json │ └── typebox/ │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── package.json │ ├── src/ │ │ ├── default-schemas.ts │ │ └── index.ts │ ├── test/ │ │ └── index.test.ts │ └── tsconfig.json └── tsconfig.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .eslintrc.js ================================================ module.exports = { "env": { "browser": true, "es6": true, "mocha": true, "node": true }, "extends": [ "plugin:@typescript-eslint/recommended" ], "parser": "@typescript-eslint/parser", "parserOptions": { "project": "tsconfig.json", "sourceType": "module" }, "plugins": [ "@typescript-eslint", "prettier" ], "ignorePatterns": ["**/lib/", "**/dist/"], "rules": { "prettier/prettier": "error", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-unused-vars": [ "warn", // or "error" { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_", "caughtErrorsIgnorePattern": "^_", "ignoreRestSiblings": true } ] } }; ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: [daffl, marshallswain] patreon: # Replace with a single Patreon username open_collective: # ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry custom: # Replace with a single custom sponsorship URL ================================================ FILE: .github/contributing.md ================================================ # Contributing to Feathers Thank you for contributing to Feathers! :heart: :tada: Feathers embraces modularity and is broken up across multiple modules. You can find them all in the `packages/` folder. Most reflect their name on npm. For example, the code for `@feathersjs/feathers` will be in `packages/feathers`, for `@feathersjs/authentication` in `packages/authenticaiton`. ## Report a bug Before creating an issue please make sure you have checked out the docs, specifically the [FAQ](https://docs.feathersjs.com/help/faq.html) section. You might want to also try searching Github. It's pretty likely someone has already asked a similar question. If you haven't found your answer please feel free to join our [Discord server](https://discord.gg/qa8kez8QBx), create an issue on Github, or post on [Stackoverflow](http://stackoverflow.com) using the `feathersjs` tag. We try our best to monitor Stackoverflow but you're likely to get more immediate responses in Discord and Github. Issues can be reported in the [issue tracker](https://github.com/feathersjs/feathers/issues). Since feathers combines many modules it can be hard for us to assess the root cause without knowing which modules are being used and what your configuration looks like, so **it helps us immensely if you can link to a simple example that reproduces your issue**. ## Report a Security Concern We take security very seriously at Feathers. We welcome any peer review of our 100% open source code to ensure nobody's Feathers app is ever compromised or hacked. As a web application developer you are responsible for any security breaches. We do our very best to make sure Feathers is as secure as possible by default. In order to give the community time to respond and upgrade we strongly urge you report all security issues to us. Send one of the core team members a PM in [Discord](https://discord.gg/qa8kez8QBx) or email us at hello@feathersjs.com with details and we will respond ASAP. For full details refer to our [Security docs](https://docs.feathersjs.com/SECURITY.html). ## Pull Requests We :heart: pull requests and we're continually working to make it as easy as possible for people to contribute. We prefer small pull requests with minimal code changes. The smaller they are the easier they are to review and merge. A FeathersJS maintainer will pick up your PR and review it as soon as they can. They may ask for changes or reject your pull request. This is not a reflection of you as an engineer or a person. Please accept feedback graciously as we will also try to be sensitive when providing it. Although we generally accept many PRs they can be rejected for many reasons. We will be as transparent as possible but it may simply be that you do not have the same context, historical knowledge or information regarding the roadmap that the maintainers have. We value the time you take to put together any contributions so we pledge to always be respectful of that time and will try to be as open as possible so that you don't waste it. :smile: **All PRs (except documentation) should be accompanied with tests and pass the linting rules.** ### Code style Before running the tests from the `test/` folder `npm test` will run ESlint. You can check your code changes individually by running `npm run lint`. ### Tests [Mocha](http://mochajs.org/) tests are located in the `test/` folder and can be run using the `npm run mocha` or `npm test` (with ESLint and code coverage) command. ### Documentation Feathers documentation is contained in Markdown files in the [docs folder](https://github.com/feathersjs/feathers) of the main repository. To change the documentation submit a pull request to that repo, referencing any other PR if applicable, and the docs will be updated as soon as it is merged. ## Community Contributions If you've written something awesome about Feathers, for the Feathers ecosystem, or created an app using Feathers please add it to the [awesome-feathersjs](https://github.com/feathersjs-ecosystem/awesome-feathersjs). If you think your module would be a good core `feathersjs` module or [featherjs-ecosystem](https://github.com/feathersjs-ecosystem) module then please contact one of the Feathers maintainers on [Discord](https://discord.gg/qa8kez8QBx) and we can discuss whether it belongs and how to get it there. :beers: ## Contributor Code of Conduct As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/) ================================================ FILE: .github/issue_template.md ================================================ ### Steps to reproduce (First please check that this issue is not already solved as [described here](https://github.com/feathersjs/feathers/blob/dove/.github/contributing.md#report-a-bug) - if it is a general question or suggestion please start a [Discussion](https://github.com/feathersjs/feathers/discussions)) - [ ] Tell us what broke. The more detailed the better. - [ ] If you can, please create a simple example that reproduces the issue and link to a gist, jrepo, etc. This makes it much easier for us to debug and issues that have a reproducible example will get higher priority. ### Expected behavior Tell us what should happen ### Actual behavior Tell us what happens instead ### System configuration Tell us about the applicable parts of your setup. **Module versions** (especially the part that's not working): **NodeJS version**: **Operating System**: **Browser Version**: **React Native Version**: **Module Loader**: ================================================ FILE: .github/pull_request_template.md ================================================ ### Summary (If you have not already please refer to the contributing guideline as [described here](https://github.com/feathersjs/feathers/blob/dove/.github/contributing.md#pull-requests)) - [ ] Tell us about the problem your pull request is solving. - [ ] Are there any open issues that are related to this? - [ ] Is this PR dependent on PRs in other repos? If so, please mention them to keep the conversations linked together. ### Other Information If there's anything else that's important and relevant to your pull request, mention that information here. This could include benchmarks, or other information. Your PR will be reviewed by a core team member and they will work with you to get your changes merged in a timely manner. If merged your PR will automatically be added to the changelog in the next release. If this is a new feature, please remember to add the appropriate documentation in their respective pages in the `docs` folder. Thanks for contributing to Feathers! :heart: ================================================ FILE: .github/workflows/nodejs.yml ================================================ name: CI on: [push, pull_request] jobs: build: runs-on: ubuntu-latest strategy: matrix: node-version: [20.x, 22.x] services: postgres: image: postgres:latest env: POSTGRES_DB: feathers POSTGRES_PASSWORD: postgres POSTGRES_PORT: 5432 POSTGRES_USER: postgres ports: - 5432:5432 options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test env: CI: true TEST_DB: postgres ================================================ FILE: .github/workflows/update-dependencies.yml ================================================ name: Update dependencies on: schedule: - cron: '0 0 1 * *' workflow_dispatch: jobs: update-dependencies: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Use Node.js uses: actions/setup-node@v1 with: node-version: '18.x' - run: npm ci - run: | git config user.name "GitHub Actions Bot" git config user.email "hello@feathersjs.com" git checkout -b update-dependencies-$GITHUB_RUN_ID - run: | npm run update-dependencies npm install - run: | git commit -am "chore(dependencies): Update dependencies" git push origin update-dependencies-$GITHUB_RUN_ID - run: | gh pr create --title "chore(dependencies): Update all dependencies" --body "" env: GITHUB_TOKEN: ${{secrets.CI_ACCESS_TOKEN}} ================================================ FILE: .gitignore ================================================ .DS_Store # Logs logs *.log # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directory # Commenting this out is preferred by some people, see # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- node_modules .nyc_output # Users Environment Variables .lock-wscript # IDEs .idea # Distributables dist/ .nyc_output/ .cache # TypeScript compiled files packages/**/lib **/build/*.tgz *.sqlite docs/.vitepress/cache ================================================ FILE: .mocharc.json ================================================ { "timeout": 30000, "require": ["ts-node/register", "source-map-support/register"], "reporter": "Dot", "extension": ".test.ts", "exit": true } ================================================ FILE: .nycrc ================================================ { "verbose": false, "tempDirectory": "./coverage/.tmp", "semistandard": { "env": [ "mocha" ] }, "extension": [ ".ts", ".tsx", ".js" ], "exclude": [ "**/test/*", "**/dist/*", "**/*.dist.js", "**/_templates/*", "**/tests/*", "**/adapter-tests/*" ], "print": "detail", "reporter": [ "html", "text", "text-summary", "lcov" ], "watermarks": { "statements": [ 70, 90 ], "lines": [ 70, 90 ], "functions": [ 70, 90 ], "branches": [ 70, 90 ] } } ================================================ FILE: .prettierrc ================================================ { "tabWidth": 2, "useTabs": false, "printWidth": 110, "semi": false, "trailingComma": "none", "singleQuote": true } ================================================ FILE: CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - **authentication-oauth:** Fix OAuth Callback Account Takeover ([#3663](https://github.com/feathersjs/feathers/issues/3663)) ([d6b0b5c](https://github.com/feathersjs/feathers/commit/d6b0b5cfbaf6f86a63662027c25616c28e54ede1)) - **mongodb:** Ensure arbitrary objects can't be passed as MongoDB ids ([#3664](https://github.com/feathersjs/feathers/issues/3664)) ([163e664](https://github.com/feathersjs/feathers/commit/163e664f231a57041034c852b80525fc5c8cf68d)) - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) ### Bug Fixes - **client:** Ensure all client methods require valid ids ([#3661](https://github.com/feathersjs/feathers/issues/3661)) ([bc754d3](https://github.com/feathersjs/feathers/commit/bc754d3666b059b9d93799602dac427cb419ddc6)) ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) ### Bug Fixes - **oauth:** Patch open redirect and origin validation ([#3653](https://github.com/feathersjs/feathers/issues/3653)) ([ee19a0a](https://github.com/feathersjs/feathers/commit/ee19a0ae9bc2ebf23b1fe598a1f7361981b65401)) ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) ### Bug Fixes - Revert to compatible UUID package ([#3630](https://github.com/feathersjs/feathers/issues/3630)) ([5c8c9e3](https://github.com/feathersjs/feathers/commit/5c8c9e36efbbf695eccd6d8822e36e1ea75c1516)) ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - @feathersjs/memory update with query ([#3617](https://github.com/feathersjs/feathers/issues/3617)) ([4c6caa2](https://github.com/feathersjs/feathers/commit/4c6caa27e9af1312718d0c233a0c35f7739ac553)) - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) - **generators:** typebox generated schema resolver generic ([#3622](https://github.com/feathersjs/feathers/issues/3622)) ([55a4a9b](https://github.com/feathersjs/feathers/commit/55a4a9b6bb021c369fb65b50fa13869311587c3f)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - **knex:** Add support for extended operators in query builder ([#3578](https://github.com/feathersjs/feathers/issues/3578)) ([c355ae3](https://github.com/feathersjs/feathers/commit/c355ae3184f07b15b4a313aa64fb9e7fdd0524d5)) - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) - **knex:** Add tableOptions parameter for inheritance on knex adapter options to pass on knex builder ([#3539](https://github.com/feathersjs/feathers/issues/3539)) ([ba5621b](https://github.com/feathersjs/feathers/commit/ba5621bfe5e7ab01189b6b7bccb00891bc2b14c7)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) ### Bug Fixes - **generators:** Add FeathersGeneratorError ([#3556](https://github.com/feathersjs/feathers/issues/3556)) ([2a81a20](https://github.com/feathersjs/feathers/commit/2a81a204eb55c95d20fc45bf091c0131eff5a25d)) ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) - **express:** Update express to version 4.21.1 ([#3543](https://github.com/feathersjs/feathers/issues/3543)) ([56d6151](https://github.com/feathersjs/feathers/commit/56d6151624f083d6604e76746cf555ed846b6d40)) - **mongodb:** Fix mongo count ([#3541](https://github.com/feathersjs/feathers/issues/3541)) ([3e95c7d](https://github.com/feathersjs/feathers/commit/3e95c7df6ae7de6a3a406dfb61dd044ea905456f)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) ### Bug Fixes - **knex:** use driver name to identify client ([#3527](https://github.com/feathersjs/feathers/issues/3527)) ([bb075ec](https://github.com/feathersjs/feathers/commit/bb075ec8beb3ac9b0a1a8aebc3c3756d970cc6a4)) ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) ### Bug Fixes - **generators:** Fix generating of gitignore ([#3514](https://github.com/feathersjs/feathers/issues/3514)) ([cabc397](https://github.com/feathersjs/feathers/commit/cabc397d2e4378c4bce79a60f2d196713cce4d8c)) ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) ### Bug Fixes - Fix update-dependencies task ([49b9f70](https://github.com/feathersjs/feathers/commit/49b9f70aba1084aa184d9b83c5a8249b793e6a1a)) - **transport-commons:** Fix HTTP status precedence ([#3511](https://github.com/feathersjs/feathers/issues/3511)) ([5d999a0](https://github.com/feathersjs/feathers/commit/5d999a0acddc0cb7692058209dfbc62673ab5a69)) ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) ### Bug Fixes - **authentication-oauth:** Allow POST oauth callbacks ([#3497](https://github.com/feathersjs/feathers/issues/3497)) ([ffcc90b](https://github.com/feathersjs/feathers/commit/ffcc90bb95329cbb4b8f310e37024d417c216d8c)) ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) ### Bug Fixes - **adapter-commons:** Faster sorter ([#3495](https://github.com/feathersjs/feathers/issues/3495)) ([22243e4](https://github.com/feathersjs/feathers/commit/22243e4d92edc1a7343b4cf42be6dfb22e8b86d5)) - **generators:** Fix migrate:make script in generated app ([#3490](https://github.com/feathersjs/feathers/issues/3490)) ([c7b0111](https://github.com/feathersjs/feathers/commit/c7b011150152e62a35f3f8ab04d6dde6d6727583)) - **mongodb:** Added Update Method Prototype to MongoDBService Class ([#3494](https://github.com/feathersjs/feathers/issues/3494)) ([428f23a](https://github.com/feathersjs/feathers/commit/428f23a8c622cd8bc4d06253206aadd514267846)) - **mongodb:** MongoDB Aggregation improvements ([#3366](https://github.com/feathersjs/feathers/issues/3366)) ([f2829b1](https://github.com/feathersjs/feathers/commit/f2829b1f8e33d13caae3557d37225d990467fb39)) - **schema:** Allow regular functions in resolvers ([#3487](https://github.com/feathersjs/feathers/issues/3487)) ([187868e](https://github.com/feathersjs/feathers/commit/187868edd9c0c9d885c482b85be7a90655c86ca2)) - **typebox:** Add TRecord to getValidator arg1 type ([#3488](https://github.com/feathersjs/feathers/issues/3488)) ([ffbcc0a](https://github.com/feathersjs/feathers/commit/ffbcc0ad0c361f77171f9ad6224006727644433a)) ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) ### Bug Fixes - **generators:** better types for enabled methods ([#3474](https://github.com/feathersjs/feathers/issues/3474)) ([bdb3d3a](https://github.com/feathersjs/feathers/commit/bdb3d3a308322bfed3caa4214e4b6a72f1a84944)) - **knex:** Update committed to boolean type ([#3458](https://github.com/feathersjs/feathers/issues/3458)) ([5fa4dbc](https://github.com/feathersjs/feathers/commit/5fa4dbc06d0126ac18f5643562d0b74f03502caa)) - **oauth:** Export OAuthService type ([#3479](https://github.com/feathersjs/feathers/issues/3479)) ([e7185cd](https://github.com/feathersjs/feathers/commit/e7185cde63990a0d24a7180c63b61dbc8ef6cd5b)) - Reduce usage of lodash ([#3455](https://github.com/feathersjs/feathers/issues/3455)) ([8ce807a](https://github.com/feathersjs/feathers/commit/8ce807a5ca53ff5b8d5107a0656c6329404e6e6c)) ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) ### Bug Fixes - **generators:** Use module format for JS Knex migrations ([#3444](https://github.com/feathersjs/feathers/issues/3444)) ([3feaa71](https://github.com/feathersjs/feathers/commit/3feaa719443aa30b1121d928ba5b7b8f43837ffb)) - **socketio:** Handle ackTimeout of socket.io ([#3437](https://github.com/feathersjs/feathers/issues/3437)) ([2642072](https://github.com/feathersjs/feathers/commit/26420721f3eb16f716a9e68ab3ed9f415bab7a9c)) ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) - **transport-commons:** Properly delete route data ([#3433](https://github.com/feathersjs/feathers/issues/3433)) ([af01bdb](https://github.com/feathersjs/feathers/commit/af01bdbe050dd428d6fffefa1874e9a6e4182bad)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) ### Bug Fixes - **knex:** Fix Knex adapter date comparison queries ([#3429](https://github.com/feathersjs/feathers/issues/3429)) ([23bafe1](https://github.com/feathersjs/feathers/commit/23bafe1204f79ce2ab0eaaa5544fab1a3ffb5f41)) ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package feathers ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) ### Bug Fixes - **generators:** Use cross-platform ES module \_\_dirname ([#3402](https://github.com/feathersjs/feathers/issues/3402)) ([0ac4882](https://github.com/feathersjs/feathers/commit/0ac4882663bb6a78622be0d903ae6508ecb516ad)) ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) ### Bug Fixes - **cli:** Add JS extension to binaries ([#3398](https://github.com/feathersjs/feathers/issues/3398)) ([aaf181d](https://github.com/feathersjs/feathers/commit/aaf181d924d0cb67c7792a54197082c59109264d)) ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) ### Bug Fixes - **cli:** Another fix for CLI ES module loading ([#3397](https://github.com/feathersjs/feathers/issues/3397)) ([3cb3bc9](https://github.com/feathersjs/feathers/commit/3cb3bc9a32602d82193b781b583ed0f37044e778)) ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) ### Bug Fixes - **cli:** Fix another ES module issue ([#3395](https://github.com/feathersjs/feathers/issues/3395)) ([8e39884](https://github.com/feathersjs/feathers/commit/8e39884a23d0e7868546dce4f7a3ee6e954c2b31)) ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) ### Bug Fixes - Update npm create feathers to ES module ([#3393](https://github.com/feathersjs/feathers/issues/3393)) ([314ce70](https://github.com/feathersjs/feathers/commit/314ce707332eadbea4505e5e7560397632da6205)) ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) ### Bug Fixes - **generators:** Move generators and CLI to featherscloud/pinion ([#3386](https://github.com/feathersjs/feathers/issues/3386)) ([eb87c99](https://github.com/feathersjs/feathers/commit/eb87c9922db56c5610e5b808f3ffe033c830e2b2)) - **knex:** Add sqlite to returning clients ([#3389](https://github.com/feathersjs/feathers/issues/3389)) ([59fb40b](https://github.com/feathersjs/feathers/commit/59fb40b9eb34950ef2dd35b7de4762f224a171f1)) ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) ### Bug Fixes - **generators:** Harden mongodb.js to reliably extract database from any connection string ([#3264](https://github.com/feathersjs/feathers/issues/3264)) ([7b0f82c](https://github.com/feathersjs/feathers/commit/7b0f82c631ff5549cdc9a8e0ffcc705d067c2157)) - **knex:** Add Error Handler to knex \_update function ([#3371](https://github.com/feathersjs/feathers/issues/3371)) ([210f103](https://github.com/feathersjs/feathers/commit/210f1037bf69c641d4fd335cd4f084cbbac0a922)) - **schema:** Fix setting dispatch on existing nested objects ([#3380](https://github.com/feathersjs/feathers/issues/3380)) ([04efd5a](https://github.com/feathersjs/feathers/commit/04efd5ab3339beafa0e1a9ef851483a387c6ec96)) ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package feathers ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) ### Bug Fixes - allow \_patch to modify the entire base schema ([#3300](https://github.com/feathersjs/feathers/issues/3300)) ([0f41622](https://github.com/feathersjs/feathers/commit/0f41622307589b3a0b62ac411a73e6a601bda171)) - **authentication-client:** Allow to abort fetch ([#3310](https://github.com/feathersjs/feathers/issues/3310)) ([ff3e104](https://github.com/feathersjs/feathers/commit/ff3e104b62d02d45261a293aff4e9491241f486f)) - **express:** Re-export Router ([#3349](https://github.com/feathersjs/feathers/issues/3349)) ([0cbdb03](https://github.com/feathersjs/feathers/commit/0cbdb03a2d810f4855da9b21602c96e4fed7fce5)) - **generators:** use `export type` vs `export` ([#3246](https://github.com/feathersjs/feathers/issues/3246)) ([82d30fd](https://github.com/feathersjs/feathers/commit/82d30fd37914e61935e068e89fc389f6bf47aaad)) - **knex:** Add includeTriggerModifications for MSSQL support ([#3355](https://github.com/feathersjs/feathers/issues/3355)) ([cbe44b0](https://github.com/feathersjs/feathers/commit/cbe44b0e91506ab06c86355af67f83d5197bd896)) - **schema:** Allow $in and $nin queries to work for arrays ([#3352](https://github.com/feathersjs/feathers/issues/3352)) ([677c214](https://github.com/feathersjs/feathers/commit/677c214a353a7f9a1f90649b9bbec4d0d6517a6f)) - **schema:** Remove undefined $select when using resolveResult hook ([#3354](https://github.com/feathersjs/feathers/issues/3354)) ([c43e009](https://github.com/feathersjs/feathers/commit/c43e009188eb84f98e3f5f29ac4444e6967afc1f)) - **transport-commons:** Allow case insensitive route lookups ([#3353](https://github.com/feathersjs/feathers/issues/3353)) ([a4a5ab6](https://github.com/feathersjs/feathers/commit/a4a5ab6cb59048176292cd71c04a32aa71ac4642)) ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **client:** Replace placeholders in URL with route params ([#3270](https://github.com/feathersjs/feathers/issues/3270)) ([a0624eb](https://github.com/feathersjs/feathers/commit/a0624eb5a7919aa1b179a71beb1c1b9cab574525)) - **core:** context.path is now typed correctly ([#3303](https://github.com/feathersjs/feathers/issues/3303)) ([ff18b3f](https://github.com/feathersjs/feathers/commit/ff18b3f8b7c8dbc97be588f699d539226785343a)) - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) - **memory:** Ensure correct pagination totals ([#3307](https://github.com/feathersjs/feathers/issues/3307)) ([c59e1b8](https://github.com/feathersjs/feathers/commit/c59e1b80cb43571077b035ab2bf0b44f9daa5ab8)) - **schema:** HookContext is now typed in schema ([#3306](https://github.com/feathersjs/feathers/issues/3306)) ([65fab86](https://github.com/feathersjs/feathers/commit/65fab86407b813122f24db928a59986c7286f270)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) ### Bug Fixes - **authentication-oauth:** Move Grant error handling to the correct spot ([#3297](https://github.com/feathersjs/feathers/issues/3297)) ([e9c0828](https://github.com/feathersjs/feathers/commit/e9c0828937453c3f0a1bd16010089b825185eab6)) - **schema:** Add typescript as peerDependency ([#3287](https://github.com/feathersjs/feathers/issues/3287)) ([cb562ee](https://github.com/feathersjs/feathers/commit/cb562eeddfa88e34fe5727d4000fa037746b0249)) - **typebox:** Allow default value in StringEnum ([#3281](https://github.com/feathersjs/feathers/issues/3281)) ([25af09a](https://github.com/feathersjs/feathers/commit/25af09ad065e72768bf88bc8b529b68f2ca4da17)) ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) ### Bug Fixes - **authentication-oauth:** Properly handle all oAuth errors ([#3284](https://github.com/feathersjs/feathers/issues/3284)) ([148a9a3](https://github.com/feathersjs/feathers/commit/148a9a319b8e29138fda82d6c03bb489a7b4a6e1)) - **client:** Add underscored methods to clients ([#3176](https://github.com/feathersjs/feathers/issues/3176)) ([f3c01f7](https://github.com/feathersjs/feathers/commit/f3c01f7b8266bfc642c55b77ba8e5bb333542630)) - **generators:** Fix configure channels when not real-time app ([#3271](https://github.com/feathersjs/feathers/issues/3271)) ([c619ab2](https://github.com/feathersjs/feathers/commit/c619ab2c57f692c419fee610c269c1502b124852)) - **typebox:** allow TUnion inside getValidator ([#3262](https://github.com/feathersjs/feathers/issues/3262)) ([cf9df96](https://github.com/feathersjs/feathers/commit/cf9df96c1011fcf13e9c6d652b06036bb0aac1c3)) ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) ### Bug Fixes - add missing word ([#3237](https://github.com/feathersjs/feathers/issues/3237)) ([9a32184](https://github.com/feathersjs/feathers/commit/9a321848767e31176660d6937f8fa6d83ba215bd)) - **transport-commons:** Handle invalid service paths on socket lookups ([#3241](https://github.com/feathersjs/feathers/issues/3241)) ([c397ab3](https://github.com/feathersjs/feathers/commit/c397ab3a0cd184044ae4f73540549b30a396821c)) ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) ### Bug Fixes - **core:** Ensure .service does not access Object properties ([#3235](https://github.com/feathersjs/feathers/issues/3235)) ([c0b670a](https://github.com/feathersjs/feathers/commit/c0b670ac4c7bf145e36b59ea89d1387b5514c237)) - **generators:** Fix channel/service configuration order for Koa based apps ([580344e](https://github.com/feathersjs/feathers/commit/580344e96fe8a2f17fd53476af5a0c7ddefac0b6)) - **koa:** Ensure .teardown works without a server ([#3234](https://github.com/feathersjs/feathers/issues/3234)) ([818572d](https://github.com/feathersjs/feathers/commit/818572df98456bc3e1a300e879329aa8f849be64)) ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) ### Bug Fixes - **authentication-client:** Do not trigger storage methods if storage not defined ([#3210](https://github.com/feathersjs/feathers/issues/3210)) ([261acbc](https://github.com/feathersjs/feathers/commit/261acbcde387db731e434cb106a27b49dcb64a9a)) - **authentication-client:** removeAccessToken throws error if storage not defined ([#3195](https://github.com/feathersjs/feathers/issues/3195)) ([b8e2769](https://github.com/feathersjs/feathers/commit/b8e27698f7958a91fe9a4ee64ec5591d23194c44)) - **authentication-local:** Local Auth - Nested username & Password fields ([#3091](https://github.com/feathersjs/feathers/issues/3091)) ([d135526](https://github.com/feathersjs/feathers/commit/d135526da18ecf2dc620b82820e1d09d8af5c0b5)) - **authentication-oauth:** Update OAuth redirect to handle user requested redirect paths ([#3186](https://github.com/feathersjs/feathers/issues/3186)) ([3742028](https://github.com/feathersjs/feathers/commit/37420283c17bb8129c6ffdde841ce2034109cc6b)) - **authentication:** Export JwtVerifyOptions ([#3214](https://github.com/feathersjs/feathers/issues/3214)) ([d59896e](https://github.com/feathersjs/feathers/commit/d59896eb0229f1490c712f19cf84eb2bcf123698)) ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) ### Bug Fixes - **generators:** Add sourceMap to tsconfig.json template ([#3166](https://github.com/feathersjs/feathers/issues/3166)) ([3049b7a](https://github.com/feathersjs/feathers/commit/3049b7a425d01cdd3058442c7183307a06cfc87a)) - **mongodb:** Speed up multi create ([#3171](https://github.com/feathersjs/feathers/issues/3171)) ([e34f728](https://github.com/feathersjs/feathers/commit/e34f728139a1008503aa440f1b7cf6395719417b)) - **schema:** Exclude json-schema-to-ts@2.8.0 ([#3180](https://github.com/feathersjs/feathers/issues/3180)) ([aee8531](https://github.com/feathersjs/feathers/commit/aee8531b5f0578f11e43b19a469b96e6f4b170ce)) - **typebox:** Revert to TypeBox 0.25 ([#3183](https://github.com/feathersjs/feathers/issues/3183)) ([cacedf5](https://github.com/feathersjs/feathers/commit/cacedf59e3d2df836777f0cd06ab1b2484ed87c5)) ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - **adapter-commons:** Support non-default import to ease use with ESM projects ([d06f2cf](https://github.com/feathersjs/feathers/commit/d06f2cfcadda7dc23f0e2bec44f64e6be8500d02)) - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) - **memory:** Fix memory adapter readme ([#3153](https://github.com/feathersjs/feathers/issues/3153)) ([a9d826a](https://github.com/feathersjs/feathers/commit/a9d826a7dbe7df4501fbf82a47d2c3a77ca9e0c0)) - **typebox:** Implement custom TypeBuilder for backwards compatibility ([#3150](https://github.com/feathersjs/feathers/issues/3150)) ([962bd87](https://github.com/feathersjs/feathers/commit/962bd87217212320b1a68f6556a16b8a6b8f757c)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **authentication:** Ensure authentication.entity configuration can be null ([#3136](https://github.com/feathersjs/feathers/issues/3136)) ([c47349b](https://github.com/feathersjs/feathers/commit/c47349b9dcf2067b7b572c5463b15b2a8fbda972)) - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) - **generators:** Properly log unhandled rejection ([#3149](https://github.com/feathersjs/feathers/issues/3149)) ([eda8f78](https://github.com/feathersjs/feathers/commit/eda8f78fa5084c3247ad10b051610b3c51a13d24)) - **knex:** Ensure that columns are selected unambigiously and avoid duplicate id selection ([#3144](https://github.com/feathersjs/feathers/issues/3144)) ([3eb7428](https://github.com/feathersjs/feathers/commit/3eb7428f888f0e8a0fbc09f5261bff3e68a0ed63)) - **knex:** Get by id and transactions should work with params.knex ([#3146](https://github.com/feathersjs/feathers/issues/3146)) ([b172b5e](https://github.com/feathersjs/feathers/commit/b172b5ea9b461642874eb7d2ba01dc4cfc275155)) - **knex:** Only apply default order for MSSQL ([#3145](https://github.com/feathersjs/feathers/issues/3145)) ([28c2627](https://github.com/feathersjs/feathers/commit/28c26279befea6cf43cedd3af628234b170b8c91)) - **mongodb:** Add MongoDB as peerDependency ([#3148](https://github.com/feathersjs/feathers/issues/3148)) ([0137b40](https://github.com/feathersjs/feathers/commit/0137b40fb694fa95e3b7b7ad41504831b894d977)) - **typebox:** Upgrade to TypeBox 0.26.0 ([#3113](https://github.com/feathersjs/feathers/issues/3113)) ([d1d9598](https://github.com/feathersjs/feathers/commit/d1d95984dd94d2b9305e7338421f84f9c4f733fd)) ## [5.0.2](https://github.com/feathersjs/feathers/compare/v5.0.1...v5.0.2) (2023-03-23) ### Bug Fixes - **generators:** Make sure TypeScript version in generated app matches ([#3122](https://github.com/feathersjs/feathers/issues/3122)) ([f0acfdf](https://github.com/feathersjs/feathers/commit/f0acfdf9d33337bf40ca12126c2550f56e31fa3b)) - **socketio-client:** Move core dependency to the right spot ([#3117](https://github.com/feathersjs/feathers/issues/3117)) ([6cd66f1](https://github.com/feathersjs/feathers/commit/6cd66f13e4e668defb57074413846550b147a51d)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) ### Bug Fixes - **core:** Add PaginationParams to general find method ([#3095](https://github.com/feathersjs/feathers/issues/3095)) ([8ebdcf5](https://github.com/feathersjs/feathers/commit/8ebdcf5107fae5fa23920390052b871033de3a0a)) - **core:** Use Symbol.for to instantiate shared symbols ([#3087](https://github.com/feathersjs/feathers/issues/3087)) ([7f3fc21](https://github.com/feathersjs/feathers/commit/7f3fc2167576f228f8183568eb52b077160e8d65)) - **generators:** Conditionally import channels in Express app ([#3106](https://github.com/feathersjs/feathers/issues/3106)) ([c2dbaaa](https://github.com/feathersjs/feathers/commit/c2dbaaa4d1d5a5675b5812a7ed2317076ac414fe)) - **koa:** Replace koa-bodyparser with koa-body ([#3093](https://github.com/feathersjs/feathers/issues/3093)) ([2456bf8](https://github.com/feathersjs/feathers/commit/2456bf882c99ae2cddd1a39bffba7e61217fc055)) - **memory/mongodb:** $select as only property & force 'id' in '$select' ([#3081](https://github.com/feathersjs/feathers/issues/3081)) ([fbe3cf5](https://github.com/feathersjs/feathers/commit/fbe3cf5199e102b5aeda2ae33828d5034df3d105)) - **transport-commons:** Fix dispatching of arrays ([#3075](https://github.com/feathersjs/feathers/issues/3075)) ([98fdda5](https://github.com/feathersjs/feathers/commit/98fdda53187acee88137b39662c766cc62cd7b55)) # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) ### Bug Fixes - **generators:** Fix typo in service client generator ([#3068](https://github.com/feathersjs/feathers/issues/3068)) ([612032e](https://github.com/feathersjs/feathers/commit/612032eced24ecbcf255d51ff0d537d74227cfd7)) - **koa:** Make Koa app inspectable ([#3069](https://github.com/feathersjs/feathers/issues/3069)) ([4fbbfff](https://github.com/feathersjs/feathers/commit/4fbbfff2a3c625f8e6929e5a09e2cf7b739ffe11)) # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) ### Bug Fixes - **koa:** Fix missing dependency on feathers ([#3061](https://github.com/feathersjs/feathers/issues/3061)) ([80dc95f](https://github.com/feathersjs/feathers/commit/80dc95ff85c9074b8f70e3ff71562f18863ef2be)) - **schema:** validateQuery - move next function outside of try-catch ([#3053](https://github.com/feathersjs/feathers/issues/3053)) ([37fe5c4](https://github.com/feathersjs/feathers/commit/37fe5c4a4d813867f6d02098b7c77d08786248c7)) ### Features - **generators:** Final tweaks to the generators ([#3060](https://github.com/feathersjs/feathers/issues/3060)) ([1bf1544](https://github.com/feathersjs/feathers/commit/1bf1544fa8deeaa44ba354fb539dc3f1fd187767)) - **schema:** Add schema helper for handling Object ids ([#3058](https://github.com/feathersjs/feathers/issues/3058)) ([1393bed](https://github.com/feathersjs/feathers/commit/1393bed81a9ee814de6aab0e537af83e667591a2)) # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) ### Bug Fixes - **generators:** Add schema selection to CI test matrix ([#3035](https://github.com/feathersjs/feathers/issues/3035)) ([7484b16](https://github.com/feathersjs/feathers/commit/7484b164fba4ac2ee379dc5c6363f964f45e94d3)) - **generators:** Fix Knex migration generated filename ([#3033](https://github.com/feathersjs/feathers/issues/3033)) ([1ac18a7](https://github.com/feathersjs/feathers/commit/1ac18a7143173d973af982772678834f7a7334f7)) - **generators:** Generated app does not start when choosing JSON schema ([#3034](https://github.com/feathersjs/feathers/issues/3034)) ([7b8250b](https://github.com/feathersjs/feathers/commit/7b8250bd535c3c5ec7429a65139335ad43616ae0)) - **knex:** The method getModel in the knex adapter ([#3043](https://github.com/feathersjs/feathers/issues/3043)) ([77e14dd](https://github.com/feathersjs/feathers/commit/77e14dd3f4a29adff8beb805d0e6186ead59e4fe)) - **schema:** Do not change the hook context in resolvers ([#3048](https://github.com/feathersjs/feathers/issues/3048)) ([bfd8c04](https://github.com/feathersjs/feathers/commit/bfd8c04c15279063a0d4b70771715c656dda5f7c)) - **schema:** Ensure that resolveResult and resolveExternal are run as around hooks ([#3032](https://github.com/feathersjs/feathers/issues/3032)) ([71942f4](https://github.com/feathersjs/feathers/commit/71942f418e3afe167aef4f98b1a97356dae7625c)) - **typebox:** Allow nested or in and queries ([#3029](https://github.com/feathersjs/feathers/issues/3029)) ([39e0b78](https://github.com/feathersjs/feathers/commit/39e0b785238b809aa9b4dea9b95efc3c188c9baa)) ### Features - **mongodb:** Add Object ID keyword converter and update MongoDB CLI & docs ([#3041](https://github.com/feathersjs/feathers/issues/3041)) ([ca0994e](https://github.com/feathersjs/feathers/commit/ca0994eaecb5a31f310bc980d106834e11f24f41)) # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - **authentication-oauth:** Use original headers in oauth flow ([#3025](https://github.com/feathersjs/feathers/issues/3025)) ([fb3d8cc](https://github.com/feathersjs/feathers/commit/fb3d8cca123d68a77b096bc92e49baa55424afe0)) - **configuration:** Add pool and connection object to SQL database default configuration ([#3023](https://github.com/feathersjs/feathers/issues/3023)) ([092c749](https://github.com/feathersjs/feathers/commit/092c749d43f7da4d019576d1210fe7d3719a44a2)) - **databases:** Ensure that query sanitization is not necessary when using query schemas ([#3022](https://github.com/feathersjs/feathers/issues/3022)) ([dbf514e](https://github.com/feathersjs/feathers/commit/dbf514e85d1508b95c007462a39b3cadd4ff391d)) - **databases:** Improve documentation for adapters and allow dynamic Knex adapter options ([#3019](https://github.com/feathersjs/feathers/issues/3019)) ([66c4b5e](https://github.com/feathersjs/feathers/commit/66c4b5e72000dd03acb57fca1cad4737c85c9c9e)) - **feathers:** Run after all hooks first, and then after method hooks ([#3004](https://github.com/feathersjs/feathers/issues/3004)) ([3692fd5](https://github.com/feathersjs/feathers/commit/3692fd57f70564492cef8bbaf78d264627a9bf0a)) - **generators:** Add main schema to all validators ([#2997](https://github.com/feathersjs/feathers/issues/2997)) ([5854dea](https://github.com/feathersjs/feathers/commit/5854dea7f610262121a49623ec5bbd474dcd3ef3)) - **generators:** Add TypeScript as normal instead of dev dependency ([#3011](https://github.com/feathersjs/feathers/issues/3011)) ([2f67398](https://github.com/feathersjs/feathers/commit/2f673987f38b199e75aff629b7cdfcaebfd69c4c)) - **generators:** Do not removeAdditional in queries ([#3000](https://github.com/feathersjs/feathers/issues/3000)) ([ef501bc](https://github.com/feathersjs/feathers/commit/ef501bcfa528119168787e9d857f1bb90e0c3114)) - **schema:** Allow any type in resolver hooks ([#3006](https://github.com/feathersjs/feathers/issues/3006)) ([f01281f](https://github.com/feathersjs/feathers/commit/f01281f7d83262738459585fc3f53f56c0a0deb8)) - **schema:** Ensure all types of nested data are securely dispatched ([#3005](https://github.com/feathersjs/feathers/issues/3005)) ([e4a9da5](https://github.com/feathersjs/feathers/commit/e4a9da5f3288e8e9f02087754473c7a9dfda6cb1)) - **schema:** Fix TypeBox extension value query syntax inference ([#3010](https://github.com/feathersjs/feathers/issues/3010)) ([f1c7a76](https://github.com/feathersjs/feathers/commit/f1c7a76586bbb8aed66ef866c3dcd666d79f3a24)) - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) ### Features - **database:** Add and to the query syntax ([#3021](https://github.com/feathersjs/feathers/issues/3021)) ([00cb0d9](https://github.com/feathersjs/feathers/commit/00cb0d9c302ae951ae007d3d6ceba33e254edd9c)) - **generators:** Add service file for shared information ([#3008](https://github.com/feathersjs/feathers/issues/3008)) ([0a1665d](https://github.com/feathersjs/feathers/commit/0a1665d23e002afadb40ed99bf0168f0fceb0054)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Bug Fixes - **cli:** Add unhandledRejection handler to generated index file ([#2932](https://github.com/feathersjs/feathers/issues/2932)) ([e3cedc8](https://github.com/feathersjs/feathers/commit/e3cedc8e00f52d892f21fd6a3eb4ca4fe40a903c)) - **cli:** Minor generated app improvements ([#2936](https://github.com/feathersjs/feathers/issues/2936)) ([ba1a550](https://github.com/feathersjs/feathers/commit/ba1a5500a8a5ea4ab44da44ac509e48c723d7efd)) - **cli:** Properly log validation errors in log-error hook ([54c883c](https://github.com/feathersjs/feathers/commit/54c883c2bb5c35c02b1a2081b2f17554550aa1d4)) - **cli:** Use correct package manager when installing an app ([#2973](https://github.com/feathersjs/feathers/issues/2973)) ([99c2a70](https://github.com/feathersjs/feathers/commit/99c2a70b77f0b68698a66180b69a56cb20c2ca0d)) - **databases:** Make sure adapter method signatures are exported properly ([#2943](https://github.com/feathersjs/feathers/issues/2943)) ([458d668](https://github.com/feathersjs/feathers/commit/458d66859e256c5854e7590f0b4a11b233fe0374)) - **knex:** Ensure custom ids are returned on create ([#2934](https://github.com/feathersjs/feathers/issues/2934)) ([c4fa3cf](https://github.com/feathersjs/feathers/commit/c4fa3cf812d59e6e8e3831ab098bb8768c92e8f4)) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) - **schema:** Allow to add additional operators to the query syntax ([#2941](https://github.com/feathersjs/feathers/issues/2941)) ([f324940](https://github.com/feathersjs/feathers/commit/f324940d5795b41e8c6fc113defb0beb7ab03a0a)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Bug Fixes - **adapter-commons:** multiple type definition issues ([#2876](https://github.com/feathersjs/feathers/issues/2876)) ([4ff1ed0](https://github.com/feathersjs/feathers/commit/4ff1ed084eb2b2cb687de27a28c96a0dad4530b7)) - **authentication-client:** Do not cache authentication errors ([#2892](https://github.com/feathersjs/feathers/issues/2892)) ([cc4e767](https://github.com/feathersjs/feathers/commit/cc4e76726fce1ac73252cfd92e22570d4bdeca20)) - **authentication-client:** Improve socket reauthentication handling ([#2895](https://github.com/feathersjs/feathers/issues/2895)) ([9db5e7a](https://github.com/feathersjs/feathers/commit/9db5e7adb0f6aea43d607f530d8258ade98b7362)) - **authentication-client:** Remove access token for fatal 400 errors ([#2894](https://github.com/feathersjs/feathers/issues/2894)) ([cfc6c7a](https://github.com/feathersjs/feathers/commit/cfc6c7a6b9dbc7fb60816e2b7f15897c38deb98d)) - **authentication:** Fix order of connection and login event handling ([#2909](https://github.com/feathersjs/feathers/issues/2909)) ([801a503](https://github.com/feathersjs/feathers/commit/801a503425062e27f2a32b91493b6ffae3822626)) - **cli:** mongodb connection string for node 17+ ([#2875](https://github.com/feathersjs/feathers/issues/2875)) ([7fa2012](https://github.com/feathersjs/feathers/commit/7fa2012897d8429b522fbca72211fc9be1c25f7e)) - **core:** `context.type` for around hooks ([#2890](https://github.com/feathersjs/feathers/issues/2890)) ([d606ac6](https://github.com/feathersjs/feathers/commit/d606ac660fd5335c95206784fea36530dd2e851a)) - **core:** Allow services with no external methods ([#2921](https://github.com/feathersjs/feathers/issues/2921)) ([df56918](https://github.com/feathersjs/feathers/commit/df569183d1a9ed0a9e0ea5bf8d7dab52d326a33d)) - **core:** Improve service option usage and method option typings ([#2902](https://github.com/feathersjs/feathers/issues/2902)) ([164d75c](https://github.com/feathersjs/feathers/commit/164d75c0f11139a316baa91f1762de8f8eb7da2d)) - **schema:** Allow query schemas with no properties, error on unsupported types ([#2904](https://github.com/feathersjs/feathers/issues/2904)) ([b66c734](https://github.com/feathersjs/feathers/commit/b66c734357478f51b2d38fa7f3eee08640cea26e)) - **schema:** Check for undefined value in resolveQueryObjectId resolver ([#2914](https://github.com/feathersjs/feathers/issues/2914)) ([d9449fa](https://github.com/feathersjs/feathers/commit/d9449fa835f58fc9cec5f7254c50219494129140)) - **socketio:** Disconnect socket on app disconnect event ([#2896](https://github.com/feathersjs/feathers/issues/2896)) ([4ba0039](https://github.com/feathersjs/feathers/commit/4ba003907843cfc2655798a568b16f07ff8adb1b)) - **typebox:** Improve query syntax defaults ([#2888](https://github.com/feathersjs/feathers/issues/2888)) ([59f3cdc](https://github.com/feathersjs/feathers/commit/59f3cdca6376e34fe39a7b91db837d0325aeb5db)) ### Features - **adapter:** Add patch data type to adapters and refactor AdapterBase usage ([#2906](https://github.com/feathersjs/feathers/issues/2906)) ([9ddc2e6](https://github.com/feathersjs/feathers/commit/9ddc2e6b028f026f939d6af68125847e5c6734b4)) - **cli:** Use separate patch schema and types ([#2916](https://github.com/feathersjs/feathers/issues/2916)) ([7088af6](https://github.com/feathersjs/feathers/commit/7088af64a539dc7f1a016d832b77b98aaaf92603)) - **docs:** CLI and application structure guide ([#2818](https://github.com/feathersjs/feathers/issues/2818)) ([142914f](https://github.com/feathersjs/feathers/commit/142914fc001a8420056dd56db992c1c4f1bd312c)) - **schema:** Split resolver options and property resolvers ([#2889](https://github.com/feathersjs/feathers/issues/2889)) ([4822c94](https://github.com/feathersjs/feathers/commit/4822c949812e5a1dceff3c62b2f9de4781b4d601)) - **schema:** Virtual property resolvers ([#2900](https://github.com/feathersjs/feathers/issues/2900)) ([7d03b57](https://github.com/feathersjs/feathers/commit/7d03b57ae2f633bdd4a368e0d5955011fbd6c329)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) ### Bug Fixes - **cli:** Fix MongoDB connection database name parsing ([#2845](https://github.com/feathersjs/feathers/issues/2845)) ([50e7463](https://github.com/feathersjs/feathers/commit/50e7463971ef95cb98358b70a721e67554d92eb5)) - **cli:** Use proper MSSQL client ([#2853](https://github.com/feathersjs/feathers/issues/2853)) ([bae5176](https://github.com/feathersjs/feathers/commit/bae5176488b46fc377e53719d20e0036e087aa16)) - **docs:** Add JavaScript web app frontend guide ([#2834](https://github.com/feathersjs/feathers/issues/2834)) ([68cf03f](https://github.com/feathersjs/feathers/commit/68cf03f092da38ccbec5e9fd42b95d00f5a0a9f2)) - **memory:** Use for loop in \_find() for better performance ([#2844](https://github.com/feathersjs/feathers/issues/2844)) ([d6ee5f1](https://github.com/feathersjs/feathers/commit/d6ee5f1c869f0c65cb470130f35956a52356e5c3)) ### Features - **docs:** Add Awesome Ecosystem page ([f66177d](https://github.com/feathersjs/feathers/commit/f66177ded1f48ac45a7105f73c5c3cda7084c7b1)) - **mongodb:** Add ObjectId resolvers and MongoDB option in the guide ([#2847](https://github.com/feathersjs/feathers/issues/2847)) ([c5c1fba](https://github.com/feathersjs/feathers/commit/c5c1fba5718a63412075cd3838b86b889eb0bd48)) - **schema:** Add StringEnum to TypeBox module ([#2827](https://github.com/feathersjs/feathers/issues/2827)) ([65d3665](https://github.com/feathersjs/feathers/commit/65d36656f50a48f633fa3fcabaea10521d04bf1c)) # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) ### Bug Fixes - **authentication:** Improve logout and disconnect connection handling ([#2813](https://github.com/feathersjs/feathers/issues/2813)) ([dd77379](https://github.com/feathersjs/feathers/commit/dd77379d8bdcd32d529bef912e672639e4899823)) - **cli:** Ensure code injection points are not code style dependent ([#2832](https://github.com/feathersjs/feathers/issues/2832)) ([0776e26](https://github.com/feathersjs/feathers/commit/0776e26bfe4c1df9d2786499941bd3faba1715c0)) - **cli:** Only generate authentication setup when selected ([#2823](https://github.com/feathersjs/feathers/issues/2823)) ([7d219d9](https://github.com/feathersjs/feathers/commit/7d219d9c5269267b50f3ce99a5653d645f9927c1)) - **docs:** Review transport API docs and update Express middleware setup ([#2811](https://github.com/feathersjs/feathers/issues/2811)) ([1b97f14](https://github.com/feathersjs/feathers/commit/1b97f14d474f5613482f259eeaa585c24fcfab43)) - **schema:** Improve resolver performance ([#2822](https://github.com/feathersjs/feathers/issues/2822)) ([5fa900f](https://github.com/feathersjs/feathers/commit/5fa900f90d55859332c90283dddddab26ae3759c)) - **schema:** Use the same options for resolveData hook ([#2833](https://github.com/feathersjs/feathers/issues/2833)) ([ed3b050](https://github.com/feathersjs/feathers/commit/ed3b05051db6886729d4824825ca8f00c2459af7)) - **transports:** Add remaining middleware for generated apps to Koa and Express ([#2796](https://github.com/feathersjs/feathers/issues/2796)) ([0d5781a](https://github.com/feathersjs/feathers/commit/0d5781a5c72a0cbb2ec8211bfa099f0aefe115a2)) ### Features - **cli:** Add authentication client to generated client ([#2801](https://github.com/feathersjs/feathers/issues/2801)) ([bd59f91](https://github.com/feathersjs/feathers/commit/bd59f91b45a01c2eea0c4386e567f4de5aa6ad99)) - **docs:** New website and documentation pages ([#2802](https://github.com/feathersjs/feathers/issues/2802)) ([ae85fa2](https://github.com/feathersjs/feathers/commit/ae85fa216f12f7ff5d15e7039640e27a09989ea4)) # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) ### Bug Fixes - **errors:** Allows to pass no error message ([#2794](https://github.com/feathersjs/feathers/issues/2794)) ([f3ddab6](https://github.com/feathersjs/feathers/commit/f3ddab637e269e67e852ffce07b060bab2b085c0)) - **koa:** Only set error code for Feathers errors ([#2793](https://github.com/feathersjs/feathers/issues/2793)) ([d3ee41e](https://github.com/feathersjs/feathers/commit/d3ee41e27b0ea5d29b344d6584ab03e48d16e2b4)) ### Features - **cli:** Generate full client test suite and improve typed client ([#2788](https://github.com/feathersjs/feathers/issues/2788)) ([57119b6](https://github.com/feathersjs/feathers/commit/57119b6bb2797f7297cf054268a248c093ecd538)) - **cli:** Improve generated schema definitions ([#2783](https://github.com/feathersjs/feathers/issues/2783)) ([474a9fd](https://github.com/feathersjs/feathers/commit/474a9fda2107e9bcf357746320a8e00cda8182b6)) # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Bug Fixes - **authentication-oauth:** Fix regression with prefix handling in OAuth ([#2773](https://github.com/feathersjs/feathers/issues/2773)) ([b1844b1](https://github.com/feathersjs/feathers/commit/b1844b1f27feeb7e66920ec9e318872857711834)) - **core:** Ensure setup and teardown can be overriden and maintain hook functionality ([#2779](https://github.com/feathersjs/feathers/issues/2779)) ([ab580cb](https://github.com/feathersjs/feathers/commit/ab580cbcaa68d19144d86798c13bf564f9d424a6)) ### Features - **cli:** Add ability to `npm init feathers` ([#2755](https://github.com/feathersjs/feathers/issues/2755)) ([d734931](https://github.com/feathersjs/feathers/commit/d734931ffd4f983a05d9e771ce0e43b696c2bc0e)) - **cli:** Improve CLI interface ([#2753](https://github.com/feathersjs/feathers/issues/2753)) ([c7e1b7e](https://github.com/feathersjs/feathers/commit/c7e1b7e80aacb84441908c3d73512d9cf7557f7e)) - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) - **schema:** Make schemas validation library independent and add TypeBox support ([#2772](https://github.com/feathersjs/feathers/issues/2772)) ([44172d9](https://github.com/feathersjs/feathers/commit/44172d99b566d11d9ceda04f1d0bf72b6d05ce76)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) ### Bug Fixes - **authentication-oauth:** Fix oAuth origin and error handling ([#2752](https://github.com/feathersjs/feathers/issues/2752)) ([f7e1c33](https://github.com/feathersjs/feathers/commit/f7e1c33de1b7af0672a302d2ba6e15d997f0aa83)) - **schema:** Fix for Ajv global collision bug [#2681](https://github.com/feathersjs/feathers/issues/2681) ([#2702](https://github.com/feathersjs/feathers/issues/2702)) ([0b2def6](https://github.com/feathersjs/feathers/commit/0b2def6ca483fad6ca22fcc4ea9873bc027925d8)) - **socketio:** Reinitialize hooks on overriden setup method ([#2722](https://github.com/feathersjs/feathers/issues/2722)) ([5e8e7c4](https://github.com/feathersjs/feathers/commit/5e8e7c442238fdc929a0a36b8b8ca2b230ce761f)) ### Features - Add CORS support to oAuth, Express, Koa and generated application ([#2744](https://github.com/feathersjs/feathers/issues/2744)) ([fd218f2](https://github.com/feathersjs/feathers/commit/fd218f289f8ca4c101e9938e8683e2efef6e8131)) - **authentication-oauth:** Koa and transport independent oAuth authentication ([#2737](https://github.com/feathersjs/feathers/issues/2737)) ([9231525](https://github.com/feathersjs/feathers/commit/9231525a24bb790ba9c5d940f2867a9c727691c9)) - **cli:** Add custom environment variable support to generated application ([#2751](https://github.com/feathersjs/feathers/issues/2751)) ([c7bf80d](https://github.com/feathersjs/feathers/commit/c7bf80d82c28c190e3f0136d51af5b7de1bc4868)) - **cli:** Adding ClientService to CLI ([#2750](https://github.com/feathersjs/feathers/issues/2750)) ([1d45427](https://github.com/feathersjs/feathers/commit/1d45427988521ac028755cbe128685fcdf34f636)) # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **authentication-client:** Properly handle missing token error ([#2700](https://github.com/feathersjs/feathers/issues/2700)) ([160746e](https://github.com/feathersjs/feathers/commit/160746e2bceb465fd1b6a003415f8ab38daba521)) - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) - **core:** Get hooks to work reliably with custom methods ([#2714](https://github.com/feathersjs/feathers/issues/2714)) ([8d7e04a](https://github.com/feathersjs/feathers/commit/8d7e04acd0f0e2af9f4c13efee652d296dd3bc51)) - **knex:** Fix PostgreSQL integration issues and run CI tests against pg ([#2698](https://github.com/feathersjs/feathers/issues/2698)) ([1f71d78](https://github.com/feathersjs/feathers/commit/1f71d7884656c1494004931f4979ad59d23e4ee6)) - **mongodb:** Ensure transactions are used properly in create ([#2699](https://github.com/feathersjs/feathers/issues/2699)) ([fe22615](https://github.com/feathersjs/feathers/commit/fe22615b7fa17d3c20ac26d6f82097917c9b63f6)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) ### Bug Fixes - **authentication-client:** Ensure reAuthenticate works in parallel with other requests ([#2690](https://github.com/feathersjs/feathers/issues/2690)) ([41b3761](https://github.com/feathersjs/feathers/commit/41b376106b47e2f40a8914db7a5ed2935e070c08)) - **cli:** Fix flaky authentication migration and SQL id schema types ([#2676](https://github.com/feathersjs/feathers/issues/2676)) ([04ce9a5](https://github.com/feathersjs/feathers/commit/04ce9a53f4226cd6283f9dc241876e90ddf48618)) - Freeze the resolver context ([#2685](https://github.com/feathersjs/feathers/issues/2685)) ([247dccb](https://github.com/feathersjs/feathers/commit/247dccb2eb72551962030321cb1c0ecb11b0181e)) - **socketio-client:** Make Socket.io client event target compatible ([#2686](https://github.com/feathersjs/feathers/issues/2686)) ([716c49a](https://github.com/feathersjs/feathers/commit/716c49a270e4be5e5276192092c292f72ffcfa19)) ### Features - **cli:** Add support for Prettier ([#2684](https://github.com/feathersjs/feathers/issues/2684)) ([83aa8f9](https://github.com/feathersjs/feathers/commit/83aa8f9f212cb122d831dca8858852b0ac9b4da8)) - **cli:** Improve generated application folder structure ([#2678](https://github.com/feathersjs/feathers/issues/2678)) ([d114557](https://github.com/feathersjs/feathers/commit/d114557721e73d6302aa88c11e3726dbcbd5c92b)) # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) ### Bug Fixes - **cli:** Fix compilation folders that got mixed up ([fc4cb74](https://github.com/feathersjs/feathers/commit/fc4cb742f7f9164096d9319b13dfaaa5f54686a6)) # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) ### Bug Fixes - **cli:** Generator fixes to work with the new guide ([#2674](https://github.com/feathersjs/feathers/issues/2674)) ([b773fa5](https://github.com/feathersjs/feathers/commit/b773fa5dbd7ff450cfb2f7b93e64882592262712)) # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Bug Fixes - **authentication-oauth:** Fix bug and properly set Grant defaults ([#2659](https://github.com/feathersjs/feathers/issues/2659)) ([cb93bb9](https://github.com/feathersjs/feathers/commit/cb93bb911fd92282424da2db805cd685b7e4a45b)) - **authentication:** Add safe dispatch data for authentication requests ([#2662](https://github.com/feathersjs/feathers/issues/2662)) ([d8104a1](https://github.com/feathersjs/feathers/commit/d8104a19ee9181e6a5ea81014af29ff9a3c28a8a)) - **schema:** Fix dispatch resolver hook to convert actually resolved data ([#2663](https://github.com/feathersjs/feathers/issues/2663)) ([f7e87db](https://github.com/feathersjs/feathers/commit/f7e87dbb9a0bc8d89aee47318dddbaa4d6ba5b91)) ### Features - **authentication-local:** Add passwordHash property resolver ([#2660](https://github.com/feathersjs/feathers/issues/2660)) ([b41279b](https://github.com/feathersjs/feathers/commit/b41279b55eea3771a6fa4983a37be2413287bbc6)) - **cli:** Add generators for new Knex SQL database adapter ([#2673](https://github.com/feathersjs/feathers/issues/2673)) ([0fb2c0f](https://github.com/feathersjs/feathers/commit/0fb2c0f629116f71184b8698c383af8cfd149688)) - **cli:** Add hook generator ([#2667](https://github.com/feathersjs/feathers/issues/2667)) ([24e4bc0](https://github.com/feathersjs/feathers/commit/24e4bc04a67fadee0e6a96a8389d788faba5c305)) - **cli:** Add support for JavaScript to the new CLI ([#2668](https://github.com/feathersjs/feathers/issues/2668)) ([ebac587](https://github.com/feathersjs/feathers/commit/ebac587f7d00dc7607c3f546352d79f79b89a5d4)) - **cli:** Add typed client to a generated app ([#2669](https://github.com/feathersjs/feathers/issues/2669)) ([5b801b5](https://github.com/feathersjs/feathers/commit/5b801b5017ddc3eaa95622b539f51d605916bc86)) - **cli:** Initial Feathers v5 CLI and Pinion generator ([#2578](https://github.com/feathersjs/feathers/issues/2578)) ([7f59ae7](https://github.com/feathersjs/feathers/commit/7f59ae7f1471895ba8a82aa4702f1a23f71b7682)) - **knex:** Add KnexJS SQL database adapter to core ([#2671](https://github.com/feathersjs/feathers/issues/2671)) ([9380fff](https://github.com/feathersjs/feathers/commit/9380fff58596e8bb90b8bb098d2795b7eadfec20)) # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) ### Bug Fixes - **express:** Ensure Express options can be set before configuring REST transport ([#2655](https://github.com/feathersjs/feathers/issues/2655)) ([c9b8f74](https://github.com/feathersjs/feathers/commit/c9b8f74a0196acb99be44ac5e0fff3f1128288cd)) - **schema:** Always resolve dispatch in resolveAll and add getDispatch method ([#2645](https://github.com/feathersjs/feathers/issues/2645)) ([145b366](https://github.com/feathersjs/feathers/commit/145b366435695438fbc8db9fdb161162ca9049ad)) - **schema:** remove `default` from queryProperty schemas ([#2646](https://github.com/feathersjs/feathers/issues/2646)) ([940a2b6](https://github.com/feathersjs/feathers/commit/940a2b6868d2f77f81edb1661f6417ec2ea6e372)) ### Features - **client:** Improve client side custom method support ([#2654](https://github.com/feathersjs/feathers/issues/2654)) ([c138acf](https://github.com/feathersjs/feathers/commit/c138acf50affbe6b66177d084d3c7a3e9220f09f)) - **core:** Rename async hooks to around hooks, allow usual registration format ([#2652](https://github.com/feathersjs/feathers/issues/2652)) ([2a485a0](https://github.com/feathersjs/feathers/commit/2a485a07929184261f27437fc0fdfe5a44694834)) # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) ### Bug Fixes - **schema:** Allows resolveData with different resolvers based on method ([#2644](https://github.com/feathersjs/feathers/issues/2644)) ([be71fa2](https://github.com/feathersjs/feathers/commit/be71fa2fe260e05b7dcc0d5f439e33f2e9ec2434)) # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) ### Bug Fixes - **authentication-oauth:** Fix regression using incorrect callback and redirect_uri ([#2631](https://github.com/feathersjs/feathers/issues/2631)) ([43d8a08](https://github.com/feathersjs/feathers/commit/43d8a082d7e1807f8a431c44a1dbd9b04c3af0d2)) - **core:** Do not throw missing method error for regular hook methods ([#2636](https://github.com/feathersjs/feathers/issues/2636)) ([afe9a3b](https://github.com/feathersjs/feathers/commit/afe9a3b3d49897eff045ee237ca2937a6b975291)) - **schema:** Add Combine helper to allow merging schema types that use ([#2637](https://github.com/feathersjs/feathers/issues/2637)) ([06d03e9](https://github.com/feathersjs/feathers/commit/06d03e91abb1347576c2351c12322d01c58473e5)) - **typescript:** Make additional types generic to work with extended types ([#2625](https://github.com/feathersjs/feathers/issues/2625)) ([269fdec](https://github.com/feathersjs/feathers/commit/269fdecc5961092dc8608b3cbe16f433c80bfa96)) ### Features - **schema:** Add resolveAll hook ([#2643](https://github.com/feathersjs/feathers/issues/2643)) ([85527d7](https://github.com/feathersjs/feathers/commit/85527d71cb78852880696e5d96abdcdf24593934)) - **schema:** Add resolver for safe external data dispatching ([#2641](https://github.com/feathersjs/feathers/issues/2641)) ([72b980e](https://github.com/feathersjs/feathers/commit/72b980e05631136d30c8f1468dee45ec6a8d2503)) - **schema:** Add schema resolver converter functionality ([#2640](https://github.com/feathersjs/feathers/issues/2640)) ([26d9e05](https://github.com/feathersjs/feathers/commit/26d9e05327d6e0144466cd57d6fcc11ac7ecb06a)) # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **authentication-oauth:** Don't send origins in Grant's config, as it will be considered another provider ([#2617](https://github.com/feathersjs/feathers/issues/2617)) ([ae3dddd](https://github.com/feathersjs/feathers/commit/ae3dddd8a654924465512d56b4651413912c6932)) - **configuration:** Only validate the initial configuration against the schema ([#2622](https://github.com/feathersjs/feathers/issues/2622)) ([386c5e2](https://github.com/feathersjs/feathers/commit/386c5e2e67bfad4fb4333f2e3e17f7d7e09ac27e)) - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) ### Features - **schema:** Add querySyntax helper to create full query schemas ([#2621](https://github.com/feathersjs/feathers/issues/2621)) ([2bbb103](https://github.com/feathersjs/feathers/commit/2bbb103b2f3e30fb0fff935f92ad3276a1a67e41)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Bug Fixes - **adapter-commons:** Clarify adapter query filtering ([#2607](https://github.com/feathersjs/feathers/issues/2607)) ([2dac771](https://github.com/feathersjs/feathers/commit/2dac771b0a3298d6dd25994d05186701b0617718)) - **adapter-tests:** Ensure multi tests can run standalone ([#2608](https://github.com/feathersjs/feathers/issues/2608)) ([d7243f2](https://github.com/feathersjs/feathers/commit/d7243f20e84d9dde428ad8dfc7f48388ca569e6e)) - **authentication-oauth:** Fix issue with overriding the default Grant configuration ([#2615](https://github.com/feathersjs/feathers/issues/2615)) ([b345857](https://github.com/feathersjs/feathers/commit/b3458578532f9750de2940aeb8afdc75cb0b46f2)) - **authentication-oauth:** Make oAuth authentication work with cookie-session ([#2614](https://github.com/feathersjs/feathers/issues/2614)) ([9f10bfc](https://github.com/feathersjs/feathers/commit/9f10bfc75083d5bcabea77cfb385aa3965cdf6d6)) - **client:** Fix @feathersjs/client types field ([#2596](https://github.com/feathersjs/feathers/issues/2596)) ([d719f54](https://github.com/feathersjs/feathers/commit/d719f54daee63daf9ed5cc762626ca15131086de)) - **express:** Fix typo in types reference in package.json ([#2613](https://github.com/feathersjs/feathers/issues/2613)) ([eacf1b3](https://github.com/feathersjs/feathers/commit/eacf1b3474e6d9da69b8671244c23a75cff87d95)) - **transport-commons:** Ensure socket queries are always plain objects ([#2597](https://github.com/feathersjs/feathers/issues/2597)) ([97313e1](https://github.com/feathersjs/feathers/commit/97313e121cfee4199f10012e95b8507557aa507e)) ### Features - **mongodb:** Add feathers-mongodb adapter as @feathersjs/mongodb ([#2610](https://github.com/feathersjs/feathers/issues/2610)) ([6d43734](https://github.com/feathersjs/feathers/commit/6d43734a53db02c435cafc52a22dca414e5d0940)) - **schema:** Allow hooks to run resolvers in sequence ([#2609](https://github.com/feathersjs/feathers/issues/2609)) ([d85c507](https://github.com/feathersjs/feathers/commit/d85c507c76d07e48fc8e7e28ff7de0ef435e0ef8)) - **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5)) - **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28)) ### BREAKING CHANGES - **adapter-commons:** Changes the common adapter base class to use `sanitizeQuery` and `sanitizeData` # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) ### Bug Fixes - **adapter-tests:** Add tests for pagination in multi updates ([#2472](https://github.com/feathersjs/feathers/issues/2472)) ([98a811a](https://github.com/feathersjs/feathers/commit/98a811ac605575ff812a08d0504729a5efe7a69c)) - **core:** Ensure that dynamically registered services are always set up ([#2593](https://github.com/feathersjs/feathers/issues/2593)) ([27cc7d0](https://github.com/feathersjs/feathers/commit/27cc7d08321861cd69e6b66e1fdfa43c50664820)) - **schema:** result resolver correctly resolves paginated find result ([#2594](https://github.com/feathersjs/feathers/issues/2594)) ([6511e45](https://github.com/feathersjs/feathers/commit/6511e45bd0624f1a629530719709f4b27fecbe0b)) ### Features - **authentication:** Add setup method for auth strategies ([#1611](https://github.com/feathersjs/feathers/issues/1611)) ([a3c3581](https://github.com/feathersjs/feathers/commit/a3c35814dccdbbf6de96f04f60b226ce206c6dbe)) - **configuration:** Allow app configuration to be validated against a schema ([#2590](https://github.com/feathersjs/feathers/issues/2590)) ([a268f86](https://github.com/feathersjs/feathers/commit/a268f86da92a8ada14ed11ab456aac0a4bba5bb0)) - **core:** Add app.setup and app.teardown hook support ([#2585](https://github.com/feathersjs/feathers/issues/2585)) ([ae4ebee](https://github.com/feathersjs/feathers/commit/ae4ebee5d39957651473007c4d3adb210160e040)) - **core:** Add app.teardown functionality ([#2570](https://github.com/feathersjs/feathers/issues/2570)) ([fcdf524](https://github.com/feathersjs/feathers/commit/fcdf524ae1995bb59265d39f12e98b7794bed023)) - **core:** Finalize app.teardown() functionality ([#2584](https://github.com/feathersjs/feathers/issues/2584)) ([1a166f3](https://github.com/feathersjs/feathers/commit/1a166f3ded811ecacf0ae8cb67880bc9fa2eeafa)) - **transport-commons:** add `context.http.response` ([#2524](https://github.com/feathersjs/feathers/issues/2524)) ([5bc9d44](https://github.com/feathersjs/feathers/commit/5bc9d447043c2e2b742c73ed28ecf3b3264dd9e5)) # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) ### Bug Fixes - **express:** Fix application typings to work with typed configuration ([#2539](https://github.com/feathersjs/feathers/issues/2539)) ([b9dfaee](https://github.com/feathersjs/feathers/commit/b9dfaee834b13864c1ed4f2f6a244eb5bb70395b)) - **hooks:** Allow all built-in hooks to be used the async and regular way ([#2559](https://github.com/feathersjs/feathers/issues/2559)) ([8f9f631](https://github.com/feathersjs/feathers/commit/8f9f631e0ce89de349207db72def84e7ab496a4a)) - **queryProperty:** allow compound oneOf ([#2545](https://github.com/feathersjs/feathers/issues/2545)) ([3077d2d](https://github.com/feathersjs/feathers/commit/3077d2d896a38d579ce4d5b530e21ad332bcf221)) - **schema:** Properly handle resolver errors ([#2540](https://github.com/feathersjs/feathers/issues/2540)) ([31fbdff](https://github.com/feathersjs/feathers/commit/31fbdff8bd848ac7e0eda56e307ac34b1bfcf17f)) # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) ### Bug Fixes - **authentication-oauth:** OAuth redirect lost sometimes due to session store race ([#2514](https://github.com/feathersjs/feathers/issues/2514)) ([#2515](https://github.com/feathersjs/feathers/issues/2515)) ([6109c44](https://github.com/feathersjs/feathers/commit/6109c44428c6b8f6bb4e089be760ea1a4ef3d01e)) - **schema:** Do not error for schemas without properties ([#2519](https://github.com/feathersjs/feathers/issues/2519)) ([96fdb47](https://github.com/feathersjs/feathers/commit/96fdb47d45fd88a8039aa9cc9ec8aebd98672b95)) - **schema:** Fix resolver data type and use new validation feature in test fixture ([#2523](https://github.com/feathersjs/feathers/issues/2523)) ([1093f12](https://github.com/feathersjs/feathers/commit/1093f124b60524cbd9050fcf07ddaf1d558973da)) ### Features - **express, koa:** make transports similar ([#2486](https://github.com/feathersjs/feathers/issues/2486)) ([26aa937](https://github.com/feathersjs/feathers/commit/26aa937c114fb8596dfefc599b1f53cead69c159)) - **schema:** Allow to use custom AJV and test with ajv-formats ([#2513](https://github.com/feathersjs/feathers/issues/2513)) ([ecfa4df](https://github.com/feathersjs/feathers/commit/ecfa4df29f029f6ca8517cacf518c14b46ffeb4e)) - **schema:** Improve schema typing, validation and extensibility ([#2521](https://github.com/feathersjs/feathers/issues/2521)) ([8c1b350](https://github.com/feathersjs/feathers/commit/8c1b35052792e82d13be03c06583534284fbae82)) # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Bug Fixes - **adapter-commons:** clean up in sort.ts and select function ([#2492](https://github.com/feathersjs/feathers/issues/2492)) ([c3ec8a4](https://github.com/feathersjs/feathers/commit/c3ec8a418bdc85506e3c5100015720a45454d8d3)) - **adapter-commons:** Fix sorting for embedded objects ([#2488](https://github.com/feathersjs/feathers/issues/2488)) ([9c22f70](https://github.com/feathersjs/feathers/commit/9c22f70a838cb6341775d91705a7527c8fc5590e)) - missing express types for Request, Response ([#2498](https://github.com/feathersjs/feathers/issues/2498)) ([ee67131](https://github.com/feathersjs/feathers/commit/ee67131bbaa24c54d3d781bdf8820015759ac488)) - **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110)) ### Features - **authentication-oauth:** Allow dynamic oAuth redirect ([#2469](https://github.com/feathersjs/feathers/issues/2469)) ([b7143d4](https://github.com/feathersjs/feathers/commit/b7143d4c0fbe961e714f79512be04449b9bbd7d9)) - **core:** add `context.http` and move `statusCode` there ([#2496](https://github.com/feathersjs/feathers/issues/2496)) ([b701bf7](https://github.com/feathersjs/feathers/commit/b701bf77fb83048aa1dffa492b3d77dd53f7b72b)) - **core:** Improve legacy hooks integration ([08c8b40](https://github.com/feathersjs/feathers/commit/08c8b40999bf3889c61a4d4fad97a2c4f78bafc9)) - **transport-commons:** Ability to register routes with custom params ([#2482](https://github.com/feathersjs/feathers/issues/2482)) ([497990a](https://github.com/feathersjs/feathers/commit/497990ae4a980e5a52a1f0f932db12cd0e6e254a)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package feathers # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package feathers # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package feathers # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) ### Bug Fixes - **core:** Allow to return a new hook context in basic hooks ([#2462](https://github.com/feathersjs/feathers/issues/2462)) ([422b6fc](https://github.com/feathersjs/feathers/commit/422b6fc11cf9e42f4234f0823a0b06a4df50982d)) ### Features - **schema:** Allow resolvers to validate a schema ([#2465](https://github.com/feathersjs/feathers/issues/2465)) ([7d9590b](https://github.com/feathersjs/feathers/commit/7d9590bbe12b94b8b5a7987684f5d4968e426481)) # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) ### Bug Fixes - **authentication-local:** adds error handling for undefined/null password field ([#2444](https://github.com/feathersjs/feathers/issues/2444)) ([4323f98](https://github.com/feathersjs/feathers/commit/4323f9859a66a7fe3f7f15d81476bd81b735c226)) ### Features - **schema:** Initial version of schema definitions and resolvers ([#2441](https://github.com/feathersjs/feathers/issues/2441)) ([c57a5cd](https://github.com/feathersjs/feathers/commit/c57a5cd56699a121647be4506d8f967e6d72ecae)) # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package feathers # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package feathers # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) ### Bug Fixes - **core:** Clean up readme ([eb3b4f2](https://github.com/feathersjs/feathers/commit/eb3b4f248c0816c92a2300cceed18a6f2518508a)) - **core:** Set version back to development ([b328767](https://github.com/feathersjs/feathers/commit/b3287676cd773e164fd646ba4cffbf81983a9157)) # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) ### Bug Fixes - **koa:** Throw a NotFound Feathers error on missing paths ([#2415](https://github.com/feathersjs/feathers/issues/2415)) ([e013f98](https://github.com/feathersjs/feathers/commit/e013f98315d550ced6eacffd615c61bb0912b4ba)) # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Bug Fixes - **authentication-oauth:** Omit query from internal calls ([#2398](https://github.com/feathersjs/feathers/issues/2398)) ([04c7c83](https://github.com/feathersjs/feathers/commit/04c7c83eeaa6a7466c84b958071b468ed42f0b0f)) - **core:** Add list of protected methods that can not be used for custom methods ([#2390](https://github.com/feathersjs/feathers/issues/2390)) ([6584a21](https://github.com/feathersjs/feathers/commit/6584a216e5a7d5f2a45822be6bfcb91c35cc2252)) - **hooks:** Migrate built-in hooks and allow backwards compatibility ([#2358](https://github.com/feathersjs/feathers/issues/2358)) ([759c5a1](https://github.com/feathersjs/feathers/commit/759c5a19327a731af965c3604119393b3d09a406)) - **koa:** Use extended query parser for compatibility ([#2397](https://github.com/feathersjs/feathers/issues/2397)) ([b2944ba](https://github.com/feathersjs/feathers/commit/b2944bac3ec6d5ecc80dc518cd4e58093692db74)) - Update database adapter common repository urls ([#2380](https://github.com/feathersjs/feathers/issues/2380)) ([3f4db68](https://github.com/feathersjs/feathers/commit/3f4db68d6700c7d9023ecd17d0d39893f75a19fd)) ### Features - **typescript:** Allow to pass generic service options to adapter services ([#2392](https://github.com/feathersjs/feathers/issues/2392)) ([f9431f2](https://github.com/feathersjs/feathers/commit/f9431f242354f804cafb835519f98dd405ac4f0b)) - Support being a built-in CodeSandbox sandbox ([#2381](https://github.com/feathersjs/feathers/issues/2381)) ([a2ac25a](https://github.com/feathersjs/feathers/commit/a2ac25a26e80530f7c50b88ef15eef46ee2b0634)) - **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) ### Bug Fixes - **transport-commons:** Fix route placeholder registration and improve radix router performance ([#2336](https://github.com/feathersjs/feathers/issues/2336)) ([4d84dfd](https://github.com/feathersjs/feathers/commit/4d84dfd092ce0510312e975d5cd57e04973fb311)) - **typescript:** Move Paginated type back for better compatibility ([#2350](https://github.com/feathersjs/feathers/issues/2350)) ([2917d05](https://github.com/feathersjs/feathers/commit/2917d05fffb4716d3c4cdaa5ac6a1aee0972e8a6)) ### Features - **koa:** KoaJS transport adapter ([#2315](https://github.com/feathersjs/feathers/issues/2315)) ([2554b57](https://github.com/feathersjs/feathers/commit/2554b57cf05731df58feeba9c12faab18e442107)) # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) ### Features - **deno:** Feathers core build for Deno ([#2299](https://github.com/feathersjs/feathers/issues/2299)) ([dece8fb](https://github.com/feathersjs/feathers/commit/dece8fbc0e7601f1505ce8bbb1e4e69cc26e8f98)) - **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package feathers # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) ### Bug Fixes - **adapter-tests:** Add test that verified paginated total ([#2273](https://github.com/feathersjs/feathers/issues/2273)) ([879bd6b](https://github.com/feathersjs/feathers/commit/879bd6b24f42e04eeeeba110ddddda3e1e1dea34)) - **dependencies:** Fix transport-commons dependency and update other dependencies ([#2284](https://github.com/feathersjs/feathers/issues/2284)) ([05b03b2](https://github.com/feathersjs/feathers/commit/05b03b27b40604d956047e3021d8053c3a137616)) - **feathers:** Always enable hooks on default service methods ([#2275](https://github.com/feathersjs/feathers/issues/2275)) ([827cc9b](https://github.com/feathersjs/feathers/commit/827cc9b752eecdaf63605d7dffd86f531b7e4af3)) ### Features - **adapter-commons:** Added mongoDB like search in embedded objects ([687e3c7](https://github.com/feathersjs/feathers/commit/687e3c7c36904221b2707d0220c0893e3cb1faa9)) # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - **adapter-commons:** Always respect paginate.max ([#2267](https://github.com/feathersjs/feathers/issues/2267)) ([f588257](https://github.com/feathersjs/feathers/commit/f5882575536624ed3a32bb6e3ff1919fa17e366d)) - **transport-commons:** Do not error when adding an undefined connection to a channel ([#2268](https://github.com/feathersjs/feathers/issues/2268)) ([28114c4](https://github.com/feathersjs/feathers/commit/28114c495d6564868bb3ffbf619bf80b774dce4b)) - Resolve some type problems ([#2260](https://github.com/feathersjs/feathers/issues/2260)) ([a3d75fa](https://github.com/feathersjs/feathers/commit/a3d75fa29490e8a19412a12bc993ee7bb573068f)) - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) - **adapter-commons:** Return missing overloads ([#2203](https://github.com/feathersjs/feathers/issues/2203)) ([bbe7e2a](https://github.com/feathersjs/feathers/commit/bbe7e2a131633e9a6e7aac7f7fa02a312bca63c7)) - **socketio-client:** Fix client transport-commons reference ([#2164](https://github.com/feathersjs/feathers/issues/2164)) ([3a42c54](https://github.com/feathersjs/feathers/commit/3a42c544058456b19c7e21827226541bfa6ad621)) ### Features - **core:** Public custom service methods ([#2270](https://github.com/feathersjs/feathers/issues/2270)) ([e65abfb](https://github.com/feathersjs/feathers/commit/e65abfb5388df6c19a11c565cf1076a29f32668d)) - Application service types default to any ([#1566](https://github.com/feathersjs/feathers/issues/1566)) ([d93ba9a](https://github.com/feathersjs/feathers/commit/d93ba9a17edd20d3397bb00f4f6e82e804e42ed6)) - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) - **authentication-client:** Throw separate OauthError in authentication client ([#2189](https://github.com/feathersjs/feathers/issues/2189)) ([fa45ec5](https://github.com/feathersjs/feathers/commit/fa45ec520b21834e103e6fe4200b06dced56c0e6)) - **core:** Remove Uberproto ([#2178](https://github.com/feathersjs/feathers/issues/2178)) ([ddf8821](https://github.com/feathersjs/feathers/commit/ddf8821f53317e6a378657f7d66acb03a037ee47)) - **transport-commons:** New built-in high performance radix router ([#2177](https://github.com/feathersjs/feathers/issues/2177)) ([6d18065](https://github.com/feathersjs/feathers/commit/6d180651b4eb40289ecea3df3575f207aa6c5d1f)) ### BREAKING CHANGES - **core:** Services no longer extend Uberproto objects and `service.mixin()` is no longer available. # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) ### Features - **memory:** Move feathers-memory into @feathersjs/memory ([#2153](https://github.com/feathersjs/feathers/issues/2153)) ([dd61fe3](https://github.com/feathersjs/feathers/commit/dd61fe371fb0502f78b8ccbe1f45a030e31ecff6)) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### Bug Fixes - **errors:** Format package.json with spaces ([cbd31c1](https://github.com/feathersjs/feathers/commit/cbd31c10c2c574de63d6ca5e55dbfb73a5fdd758)) ### chore - **configuration:** Remove environment variable substitution ([#1942](https://github.com/feathersjs/feathers/issues/1942)) ([caaa21f](https://github.com/feathersjs/feathers/commit/caaa21ffdc6a8dcac82fb403c91d9d4b781a6c0a)) - **package:** Remove @feathersjs/primus packages from core ([#1919](https://github.com/feathersjs/feathers/issues/1919)) ([d20b7d5](https://github.com/feathersjs/feathers/commit/d20b7d5a70f4d3306e294696156e8aa0337c35e9)), closes [#1899](https://github.com/feathersjs/feathers/issues/1899) ### Features - **core:** Migrate @feathersjs/feathers to TypeScript ([#1963](https://github.com/feathersjs/feathers/issues/1963)) ([7812529](https://github.com/feathersjs/feathers/commit/7812529ff0f1008e21211f1d01efbc49795dbe55)) - **core:** use @feathers/hooks and add async type ([#1929](https://github.com/feathersjs/feathers/issues/1929)) ([a5c4756](https://github.com/feathersjs/feathers/commit/a5c47562eae8410c82fe2f6308f26f8e78b6a3e8)) - **transport-commons:** Remove legacy message format and unnecessary client timeouts ([#1939](https://github.com/feathersjs/feathers/issues/1939)) ([5538881](https://github.com/feathersjs/feathers/commit/5538881a08bc130de42c5984055729d8336f8615)) ### BREAKING CHANGES - **configuration:** Falls back to node-config instead of adding additional functionality like path replacements and automatic environment variable insertion. - **transport-commons:** Removes the old message format and client service timeout - **package:** Remove primus packages to be moved into the ecosystem. # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### Bug Fixes - **authentication-oauth:** Updated typings for projects with strictNullChecks ([#1941](https://github.com/feathersjs/feathers/issues/1941)) ([be91206](https://github.com/feathersjs/feathers/commit/be91206e3dba1e65a81412b7aa636bece3ab4aa2)) - **errors:** Format package.json with spaces ([cbd31c1](https://github.com/feathersjs/feathers/commit/cbd31c10c2c574de63d6ca5e55dbfb73a5fdd758)) ### chore - **configuration:** Remove environment variable substitution ([#1942](https://github.com/feathersjs/feathers/issues/1942)) ([caaa21f](https://github.com/feathersjs/feathers/commit/caaa21ffdc6a8dcac82fb403c91d9d4b781a6c0a)) - **package:** Remove @feathersjs/primus packages from core ([#1919](https://github.com/feathersjs/feathers/issues/1919)) ([d20b7d5](https://github.com/feathersjs/feathers/commit/d20b7d5a70f4d3306e294696156e8aa0337c35e9)), closes [#1899](https://github.com/feathersjs/feathers/issues/1899) ### Features - **core:** Migrate @feathersjs/feathers to TypeScript ([#1963](https://github.com/feathersjs/feathers/issues/1963)) ([7812529](https://github.com/feathersjs/feathers/commit/7812529ff0f1008e21211f1d01efbc49795dbe55)) - **core:** use @feathers/hooks and add async type ([#1929](https://github.com/feathersjs/feathers/issues/1929)) ([a5c4756](https://github.com/feathersjs/feathers/commit/a5c47562eae8410c82fe2f6308f26f8e78b6a3e8)) - **transport-commons:** Remove legacy message format and unnecessary client timeouts ([#1939](https://github.com/feathersjs/feathers/issues/1939)) ([5538881](https://github.com/feathersjs/feathers/commit/5538881a08bc130de42c5984055729d8336f8615)) ### BREAKING CHANGES - **configuration:** Falls back to node-config instead of adding additional functionality like path replacements and automatic environment variable insertion. - **transport-commons:** Removes the old message format and client service timeout - **package:** Remove primus packages to be moved into the ecosystem. ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) ### Bug Fixes - **authentication-client:** Allow reAuthentication using specific strategy ([#2140](https://github.com/feathersjs/feathers/issues/2140)) ([2a2bbf7](https://github.com/feathersjs/feathers/commit/2a2bbf7f8ee6d32b9fac8afab3421286b06e6443)) - **socketio-client:** Throw an error and show a warning if someone tries to use socket.io-client v3 ([#2135](https://github.com/feathersjs/feathers/issues/2135)) ([cc3521c](https://github.com/feathersjs/feathers/commit/cc3521c935a1cbd690e29b7057998e3898f282db)) - **typescript:** Fix `data` property definition in @feathersjs/errors ([#2018](https://github.com/feathersjs/feathers/issues/2018)) ([ef1398c](https://github.com/feathersjs/feathers/commit/ef1398cd5b19efa50929e8c9511ca5684a18997f)) ## [4.5.10](https://github.com/feathersjs/feathers/compare/v4.5.9...v4.5.10) (2020-11-08) ### Bug Fixes - **authentication:** consistent response return between local and jwt strategy ([#2042](https://github.com/feathersjs/feathers/issues/2042)) ([8d25be1](https://github.com/feathersjs/feathers/commit/8d25be101a2593a9e789375c928a07780b9e28cf)) - **authentication-oauth:** session.destroy is undefined when use cookie-session package ([#2100](https://github.com/feathersjs/feathers/issues/2100)) ([46e84b8](https://github.com/feathersjs/feathers/commit/46e84b83f2acce985380243fc6d08c64e96f0068)) - **package:** Fix clean script in non Unix environments ([#2110](https://github.com/feathersjs/feathers/issues/2110)) ([09b62c0](https://github.com/feathersjs/feathers/commit/09b62c0c7e636caf620904ba87d61f168a020f05)) - **typescript:** Add user property to the Params. ([#2090](https://github.com/feathersjs/feathers/issues/2090)) ([1e94265](https://github.com/feathersjs/feathers/commit/1e942651fbaaf07fc66c159225fbc992a0174bf4)) ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) ### Bug Fixes - **authentication-local:** Keep non-objects in protect hook ([#2085](https://github.com/feathersjs/feathers/issues/2085)) ([5a65e2e](https://github.com/feathersjs/feathers/commit/5a65e2e6cee0a15614f23ee2e0d3c25d3365027d)) - **authentication-oauth:** Always end session after oAuth flows are finished ([#2087](https://github.com/feathersjs/feathers/issues/2087)) ([d219d0d](https://github.com/feathersjs/feathers/commit/d219d0d89c5e45aa289dd67cb0c8bdc05044c846)) - **configuration:** Fix handling of config values that start with . or .. but are not actually relative paths; e.g. ".foo" or "..bar" ([#2065](https://github.com/feathersjs/feathers/issues/2065)) ([d07bf59](https://github.com/feathersjs/feathers/commit/d07bf5902e9c8c606f16b9523472972d3d2e9b49)) - **rest-client:** Handle non-JSON errors with fetch adapter ([#2086](https://github.com/feathersjs/feathers/issues/2086)) ([e24217a](https://github.com/feathersjs/feathers/commit/e24217ad1e784ad71cd9d64fe1727dd02f039991)) ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) - **authentication-client:** Fix storage type so it works with all supported interfaces ([#2041](https://github.com/feathersjs/feathers/issues/2041)) ([6ee0e78](https://github.com/feathersjs/feathers/commit/6ee0e78d55cf1214f61458f386b94c350eec32af)) ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) ### Bug Fixes - **authentication:** Add JWT getEntityQuery ([#2013](https://github.com/feathersjs/feathers/issues/2013)) ([e0e7fb5](https://github.com/feathersjs/feathers/commit/e0e7fb5162940fe776731283b40026c61d9c8a33)) - **typescript:** Revert add overload types for `find` service methods ([#1972](https://github.com/feathersjs/feathers/issues/1972))" ([#2025](https://github.com/feathersjs/feathers/issues/2025)) ([a9501ac](https://github.com/feathersjs/feathers/commit/a9501acb4d3ef58dfb87d62c57a9bf76569da281)) ## [4.5.6](https://github.com/feathersjs/feathers/compare/v4.5.5...v4.5.6) (2020-07-12) ### Bug Fixes - **authentication:** Omit query in JWT strategy ([#2011](https://github.com/feathersjs/feathers/issues/2011)) ([04ce7e9](https://github.com/feathersjs/feathers/commit/04ce7e98515fe9d495cd0e83e0da097e9bcd7382)) ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) ### Bug Fixes - **authentication:** Include query params when authenticating via authenticate hook [#2009](https://github.com/feathersjs/feathers/issues/2009) ([4cdb7bf](https://github.com/feathersjs/feathers/commit/4cdb7bf2898385ddac7a1692bc9ac2f6cf5ad446)) - **authentication-oauth:** Updated typings for projects with strictNullChecks ([#1941](https://github.com/feathersjs/feathers/issues/1941)) ([be91206](https://github.com/feathersjs/feathers/commit/be91206e3dba1e65a81412b7aa636bece3ab4aa2)) - **typescript:** add overload types for `find` service methods ([#1972](https://github.com/feathersjs/feathers/issues/1972)) ([ef55af0](https://github.com/feathersjs/feathers/commit/ef55af088d05d9d36aba9d9f8d6c2c908a4f20dd)) ## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-04-29) ### Bug Fixes - **authentication-local:** Allow to hash passwords in array data ([#1936](https://github.com/feathersjs/feathers/issues/1936)) ([64705f5](https://github.com/feathersjs/feathers/commit/64705f5d9d4dc27f799da3a074efaf74379a3398)) - **authentication-oauth:** Add getEntity method to oAuth authentication and remove provider field for other calls ([#1935](https://github.com/feathersjs/feathers/issues/1935)) ([d925c1b](https://github.com/feathersjs/feathers/commit/d925c1bd193b5c19cb23a246f04fc46d0429fc75)) ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) ### Bug Fixes - **authentication:** Remove entity from connection information on logout ([#1889](https://github.com/feathersjs/feathers/issues/1889)) ([b062753](https://github.com/feathersjs/feathers/commit/b0627530d61babe15dd84369d3093ccae4b780ca)) - **authentication-oauth:** Allow req.feathers to be used in oAuth authentication requests ([#1886](https://github.com/feathersjs/feathers/issues/1886)) ([854c9ca](https://github.com/feathersjs/feathers/commit/854c9cac9a9a5f8f89054a90feb24ab5c4766f5f)) - **errors:** Add 410 Gone to errors ([#1849](https://github.com/feathersjs/feathers/issues/1849)) ([6801428](https://github.com/feathersjs/feathers/commit/6801428f8fd17dbfebcdb6f1b0cd01433a4033dc)) - **typescript:** Add type keys to service pagination options. ([#1888](https://github.com/feathersjs/feathers/issues/1888)) ([859c601](https://github.com/feathersjs/feathers/commit/859c601519c7cb399e8b1667bb50073466812d5c)) - **typescript:** Use stricter type for HookContext 'method' prop ([#1896](https://github.com/feathersjs/feathers/issues/1896)) ([24a41b7](https://github.com/feathersjs/feathers/commit/24a41b74486ddadccad18f3ae63afdac5bd373c7)) ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) ### Bug Fixes - Updated typings for express middleware ([#1839](https://github.com/feathersjs/feathers/issues/1839)) ([6b8e897](https://github.com/feathersjs/feathers/commit/6b8e8971a9dbb08913edd1be48826624645d9dc1)) - **authentication:** Improve JWT strategy configuration error message ([#1844](https://github.com/feathersjs/feathers/issues/1844)) ([2c771db](https://github.com/feathersjs/feathers/commit/2c771dbb22d53d4f7de3c3f514e57afa1a186322)) - **package:** update grant-profile to version 0.0.11 ([#1841](https://github.com/feathersjs/feathers/issues/1841)) ([5dcd2aa](https://github.com/feathersjs/feathers/commit/5dcd2aa3483059cc7a2546b145dd72b4705fe2fe)) - **test:** typo in password ([#1797](https://github.com/feathersjs/feathers/issues/1797)) ([dfba6ec](https://github.com/feathersjs/feathers/commit/dfba6ec2f21adf3aa739218cf870eaaaa5df6e9c)) - **typescript:** Make HookMap and HookObject generics. ([#1815](https://github.com/feathersjs/feathers/issues/1815)) ([d10145d](https://github.com/feathersjs/feathers/commit/d10145d91a09aef7bce5af80805a3c0fa9d94f26)) ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package feathers # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) ### Bug Fixes - Add `params.authentication` type, remove `hook.connection` type ([#1732](https://github.com/feathersjs/feathers/issues/1732)) ([d46b7b2](https://github.com/feathersjs/feathers/commit/d46b7b2abac8862c0e4dbfce20d71b8b8a96692f)) ### Features - **authentication-oauth:** Set oAuth redirect URL dynamically and pass query the service ([#1737](https://github.com/feathersjs/feathers/issues/1737)) ([0b05f0b](https://github.com/feathersjs/feathers/commit/0b05f0b58a257820fa61d695a36f36455209f6a1)) - **rest-client:** Allow for customising rest clients ([#1780](https://github.com/feathersjs/feathers/issues/1780)) ([c5cfec7](https://github.com/feathersjs/feathers/commit/c5cfec7a4aafcaffaab0cdacb9b5d297ff20320f)) ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) ### Bug Fixes - **adapter-commons:** Filter arrays in queries ([#1724](https://github.com/feathersjs/feathers/issues/1724)) ([872b669](https://github.com/feathersjs/feathers/commit/872b66906a806ab92ca41b5f6f504ff0af1ce79e)) ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) ### Bug Fixes - Gracefully handle errors in publishers ([#1710](https://github.com/feathersjs/feathers/issues/1710)) ([0616306](https://github.com/feathersjs/feathers/commit/061630696762e9dbf1dc4e738094992ba16989fc)) # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) ### Bug Fixes - **authentication-client:** Reset authentication promise on socket disconnect ([#1696](https://github.com/feathersjs/feathers/issues/1696)) ([3951626](https://github.com/feathersjs/feathers/commit/395162633ff22e95833a3c2900cb9464bb5b056f)) - **core:** Improve hook missing parameter message by adding the service name ([#1703](https://github.com/feathersjs/feathers/issues/1703)) ([2331c2a](https://github.com/feathersjs/feathers/commit/2331c2a3dd70d432db7d62a76ed805d359cbbba5)) - **rest-client:** Allow to customize getting the query ([#1594](https://github.com/feathersjs/feathers/issues/1594)) ([5f21272](https://github.com/feathersjs/feathers/commit/5f212729849414c4da6f0d51edd1986feca992ee)) - **transport-commons:** Allow to properly chain SocketIo client.off ([#1706](https://github.com/feathersjs/feathers/issues/1706)) ([a4aecbc](https://github.com/feathersjs/feathers/commit/a4aecbcd3578c1cf4ecffb3a58fb6d26e15ee513)) - **typescript:** Allow specific service typings for `Hook` and `HookContext` ([#1688](https://github.com/feathersjs/feathers/issues/1688)) ([f5d0ddd](https://github.com/feathersjs/feathers/commit/f5d0ddd9724bf5778355535d2103d59daaad6294)) ### Features - **authentication:** Add parseStrategies to allow separate strategies for creating JWTs and parsing headers ([#1708](https://github.com/feathersjs/feathers/issues/1708)) ([5e65629](https://github.com/feathersjs/feathers/commit/5e65629b924724c3e81d7c81df047e123d1c8bd7)) - **authentication-oauth:** Set oAuth redirect URL dynamically ([#1608](https://github.com/feathersjs/feathers/issues/1608)) ([1293e08](https://github.com/feathersjs/feathers/commit/1293e088abbb3d23f4a44680836645a8049ceaae)) ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) ### Bug Fixes - **authentication:** Retain object references in authenticate hook ([#1675](https://github.com/feathersjs/feathers/issues/1675)) ([e1939be](https://github.com/feathersjs/feathers/commit/e1939be19d4e79d3f5e2fe69ba894a11c627ae99)) - **authentication-oauth:** Allow hash based redirects ([#1676](https://github.com/feathersjs/feathers/issues/1676)) ([ffe7cf3](https://github.com/feathersjs/feathers/commit/ffe7cf3fbb4e62d7689065cf7b61f25f602ce8cf)) ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package feathers ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) ### Bug Fixes - Add jsonwebtoken TypeScript type dependency ([317c80a](https://github.com/feathersjs/feathers/commit/317c80a9205e8853bb830a12c3aa1a19e95f9abc)) - Only initialize default Express session if oAuth is actually used ([#1648](https://github.com/feathersjs/feathers/issues/1648)) ([9b9b43f](https://github.com/feathersjs/feathers/commit/9b9b43ff09af1080e4aaa537064bac37b881c9a2)) - Small type improvements ([#1624](https://github.com/feathersjs/feathers/issues/1624)) ([50162c6](https://github.com/feathersjs/feathers/commit/50162c6e562f0a47c6a280c4f01fff7c3afee293)) ## [4.3.8](https://github.com/feathersjs/feathers/compare/v4.3.7...v4.3.8) (2019-10-14) ### Bug Fixes - Remove adapter commons type alternatives ([#1620](https://github.com/feathersjs/feathers/issues/1620)) ([c9f3086](https://github.com/feathersjs/feathers/commit/c9f3086344420b57dbce7c4169cf550c97509f0d)) ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) ### Bug Fixes - Improve authentication client default storage initialization ([#1613](https://github.com/feathersjs/feathers/issues/1613)) ([d7f5107](https://github.com/feathersjs/feathers/commit/d7f5107ef76297b4ca6db580afc5e2b372f5ee4d)) - improve Service and AdapterService types ([#1567](https://github.com/feathersjs/feathers/issues/1567)) ([baad6a2](https://github.com/feathersjs/feathers/commit/baad6a26f0f543b712ccb40359b3933ad3a21392)) - make \_\_hooks writable and configurable ([#1520](https://github.com/feathersjs/feathers/issues/1520)) ([1c6c374](https://github.com/feathersjs/feathers/commit/1c6c3742ecf1cb813be56074da89e6736d03ffe8)) - Typings for express request and response properties ([#1609](https://github.com/feathersjs/feathers/issues/1609)) ([38cf8c9](https://github.com/feathersjs/feathers/commit/38cf8c950c1a4fb4a6d78d68d70e7fdd63b71c3c)) ## [4.3.6](https://github.com/feathersjs/feathers/compare/v4.3.5...v4.3.6) (2019-10-07) ### Bug Fixes - Check query for NaN ([#1607](https://github.com/feathersjs/feathers/issues/1607)) ([f1a781f](https://github.com/feathersjs/feathers/commit/f1a781f)) ## [4.3.5](https://github.com/feathersjs/feathers/compare/v4.3.4...v4.3.5) (2019-10-07) ### Bug Fixes - Authentication type improvements and timeout fix ([#1605](https://github.com/feathersjs/feathers/issues/1605)) ([19854d3](https://github.com/feathersjs/feathers/commit/19854d3)) - Change this reference in client libraries to explicitly passed app ([#1597](https://github.com/feathersjs/feathers/issues/1597)) ([4e4d10a](https://github.com/feathersjs/feathers/commit/4e4d10a)) - Improve error message when authentication strategy is not allowed ([#1600](https://github.com/feathersjs/feathers/issues/1600)) ([317a312](https://github.com/feathersjs/feathers/commit/317a312)) ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) ### Bug Fixes - Reset version number after every publish ([#1596](https://github.com/feathersjs/feathers/issues/1596)) ([f24f82f](https://github.com/feathersjs/feathers/commit/f24f82f)) - Typing improvements ([#1580](https://github.com/feathersjs/feathers/issues/1580)) ([7818aec](https://github.com/feathersjs/feathers/commit/7818aec)) ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) ### Bug Fixes - check for undefined access token ([#1571](https://github.com/feathersjs/feathers/issues/1571)) ([976369d](https://github.com/feathersjs/feathers/commit/976369d)) - Small improvements in dependencies and code structure ([#1562](https://github.com/feathersjs/feathers/issues/1562)) ([42c13e2](https://github.com/feathersjs/feathers/commit/42c13e2)) ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) ### Bug Fixes - Add info to express error handler logger type ([#1557](https://github.com/feathersjs/feathers/issues/1557)) ([3e1d26c](https://github.com/feathersjs/feathers/commit/3e1d26c)) - LocalStrategy authenticates without username ([#1560](https://github.com/feathersjs/feathers/issues/1560)) ([2b258fd](https://github.com/feathersjs/feathers/commit/2b258fd)), closes [#1559](https://github.com/feathersjs/feathers/issues/1559) ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) ### Bug Fixes - Fix regression in transport commons ([#1551](https://github.com/feathersjs/feathers/issues/1551)) ([ed9e934](https://github.com/feathersjs/feathers/commit/ed9e934)) - Omit standard protocol ports from the default hostname ([#1543](https://github.com/feathersjs/feathers/issues/1543)) ([ef16d29](https://github.com/feathersjs/feathers/commit/ef16d29)) - Use long-timeout for JWT expiration timers ([#1552](https://github.com/feathersjs/feathers/issues/1552)) ([65637ec](https://github.com/feathersjs/feathers/commit/65637ec)) # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) ### Bug Fixes - Only remove token on NotAuthenticated error in authentication client and handle error better ([#1525](https://github.com/feathersjs/feathers/issues/1525)) ([13a8758](https://github.com/feathersjs/feathers/commit/13a8758)) # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) ### Bug Fixes - Fix auth publisher mistake ([08bad61](https://github.com/feathersjs/feathers/commit/08bad61)) # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) ### Bug Fixes - Expire and remove authenticated real-time connections ([#1512](https://github.com/feathersjs/feathers/issues/1512)) ([2707c33](https://github.com/feathersjs/feathers/commit/2707c33)) - Update all dependencies ([7d53a00](https://github.com/feathersjs/feathers/commit/7d53a00)) - Use WeakMap to connect socket to connection ([#1509](https://github.com/feathersjs/feathers/issues/1509)) ([64807e3](https://github.com/feathersjs/feathers/commit/64807e3)) ### Features - Let strategies handle the connection ([#1510](https://github.com/feathersjs/feathers/issues/1510)) ([4329feb](https://github.com/feathersjs/feathers/commit/4329feb)) # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) ### Bug Fixes - @feathersjs/adapter-commons: `update` id is non-nullable ([#1468](https://github.com/feathersjs/feathers/issues/1468)) ([43ec802](https://github.com/feathersjs/feathers/commit/43ec802)) - Add getEntityId to JWT strategy and fix legacy Socket authentication ([#1488](https://github.com/feathersjs/feathers/issues/1488)) ([9a3b324](https://github.com/feathersjs/feathers/commit/9a3b324)) - Add method to reliably get default authentication service ([#1470](https://github.com/feathersjs/feathers/issues/1470)) ([e542cb3](https://github.com/feathersjs/feathers/commit/e542cb3)) - Do not error in authentication client on logout ([#1473](https://github.com/feathersjs/feathers/issues/1473)) ([8211b98](https://github.com/feathersjs/feathers/commit/8211b98)) - Improve Params typing ([#1474](https://github.com/feathersjs/feathers/issues/1474)) ([54a3aa7](https://github.com/feathersjs/feathers/commit/54a3aa7)) # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package feathers # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) ### Bug Fixes - Fix feathers-memory dependency that did not get updated ([9422b13](https://github.com/feathersjs/feathers/commit/9422b13)) - Remove unnecessary top level export files in @feathersjs/express ([#1442](https://github.com/feathersjs/feathers/issues/1442)) ([73c3fb2](https://github.com/feathersjs/feathers/commit/73c3fb2)) ### Features - @feathersjs/express allow to pass an existing Express application instance ([#1446](https://github.com/feathersjs/feathers/issues/1446)) ([853a6b0](https://github.com/feathersjs/feathers/commit/853a6b0)) # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) ### Bug Fixes - @feathersjs/adapter-commons: remove data from `remove` arguments ([#1426](https://github.com/feathersjs/feathers/issues/1426)) ([fd54ae9](https://github.com/feathersjs/feathers/commit/fd54ae9)) - @feathersjs/express: allow middleware arrays ([#1421](https://github.com/feathersjs/feathers/issues/1421)) ([b605ab8](https://github.com/feathersjs/feathers/commit/b605ab8)) - @feathersjs/express: replace `reduce` with `map` ([#1429](https://github.com/feathersjs/feathers/issues/1429)) ([44542e9](https://github.com/feathersjs/feathers/commit/44542e9)) - Clean up hooks code ([#1407](https://github.com/feathersjs/feathers/issues/1407)) ([f25c88b](https://github.com/feathersjs/feathers/commit/f25c88b)) - Fix @feathersjs/feathers typings http import ([abbc07b](https://github.com/feathersjs/feathers/commit/abbc07b)) - Fix OpenCollective link ([28888a1](https://github.com/feathersjs/feathers/commit/28888a1)) - Improve transport-commons types ([#1396](https://github.com/feathersjs/feathers/issues/1396)) ([f9d8536](https://github.com/feathersjs/feathers/commit/f9d8536)) - Updated typings for ServiceMethods ([#1409](https://github.com/feathersjs/feathers/issues/1409)) ([b5ee7e2](https://github.com/feathersjs/feathers/commit/b5ee7e2)) ### Features - adapter-commons: add `allowsMulti(method)` to AdapterService ([#1431](https://github.com/feathersjs/feathers/issues/1431)) ([e688851](https://github.com/feathersjs/feathers/commit/e688851)) - Add hook-less methods and service option types to adapter-commons ([#1433](https://github.com/feathersjs/feathers/issues/1433)) ([857f54a](https://github.com/feathersjs/feathers/commit/857f54a)) # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Make oAuth paths more consistent and improve authentication client ([#1377](https://github.com/feathersjs/feathers/issues/1377)) ([adb2543](https://github.com/feathersjs/feathers/commit/adb2543)) - Set authenticated: true after successful authentication ([#1367](https://github.com/feathersjs/feathers/issues/1367)) ([9918cff](https://github.com/feathersjs/feathers/commit/9918cff)) - Typings fix and improvements. ([#1364](https://github.com/feathersjs/feathers/issues/1364)) ([515b916](https://github.com/feathersjs/feathers/commit/515b916)) - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) ### Bug Fixes - Throw NotAuthenticated on token verification errors ([#1357](https://github.com/feathersjs/feathers/issues/1357)) ([e0120df](https://github.com/feathersjs/feathers/commit/e0120df)) - **typescript:** finally should be optional ([#1350](https://github.com/feathersjs/feathers/issues/1350)) ([f439a9e](https://github.com/feathersjs/feathers/commit/f439a9e)) - Add fallback for legacy socket authenticate event ([#1356](https://github.com/feathersjs/feathers/issues/1356)) ([61b1056](https://github.com/feathersjs/feathers/commit/61b1056)) - Correctly read the oauth strategy config ([#1349](https://github.com/feathersjs/feathers/issues/1349)) ([9abf314](https://github.com/feathersjs/feathers/commit/9abf314)) - Fix versioning tests. Closes [#1346](https://github.com/feathersjs/feathers/issues/1346) ([dd519f6](https://github.com/feathersjs/feathers/commit/dd519f6)) - Use `export =` in TypeScript definitions ([#1285](https://github.com/feathersjs/feathers/issues/1285)) ([12d0f4b](https://github.com/feathersjs/feathers/commit/12d0f4b)) ### Features - Add global disconnect event ([#1355](https://github.com/feathersjs/feathers/issues/1355)) ([85afcca](https://github.com/feathersjs/feathers/commit/85afcca)) # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) ### Bug Fixes - Add registerPublisher alias for .publish ([#1302](https://github.com/feathersjs/feathers/issues/1302)) ([98fe8f8](https://github.com/feathersjs/feathers/commit/98fe8f8)) - Always require strategy parameter in authentication ([#1327](https://github.com/feathersjs/feathers/issues/1327)) ([d4a8021](https://github.com/feathersjs/feathers/commit/d4a8021)) - Bring back params.authenticated ([#1317](https://github.com/feathersjs/feathers/issues/1317)) ([a0ffd5e](https://github.com/feathersjs/feathers/commit/a0ffd5e)) - Do not log as errors below a 500 response ([#1256](https://github.com/feathersjs/feathers/issues/1256)) ([33fd0e4](https://github.com/feathersjs/feathers/commit/33fd0e4)) - Guard against null in client side logout function ([#1319](https://github.com/feathersjs/feathers/issues/1319)) ([fa7f057](https://github.com/feathersjs/feathers/commit/fa7f057)) - Handle error oAuth redirect in authentication client ([#1307](https://github.com/feathersjs/feathers/issues/1307)) ([12d48ee](https://github.com/feathersjs/feathers/commit/12d48ee)) - Improve authentication parameter handling ([#1333](https://github.com/feathersjs/feathers/issues/1333)) ([6e77204](https://github.com/feathersjs/feathers/commit/6e77204)) - Improve oAuth option handling and usability ([#1335](https://github.com/feathersjs/feathers/issues/1335)) ([adb137d](https://github.com/feathersjs/feathers/commit/adb137d)) - Merge httpStrategies and authStrategies option ([#1308](https://github.com/feathersjs/feathers/issues/1308)) ([afa4d55](https://github.com/feathersjs/feathers/commit/afa4d55)) - Rename jwtStrategies option to authStrategies ([#1305](https://github.com/feathersjs/feathers/issues/1305)) ([4aee151](https://github.com/feathersjs/feathers/commit/4aee151)) - Update version number check ([53575c5](https://github.com/feathersjs/feathers/commit/53575c5)) - Updated HooksObject typings ([#1300](https://github.com/feathersjs/feathers/issues/1300)) ([b28058c](https://github.com/feathersjs/feathers/commit/b28058c)) ### Features - Add params.headers to all transports when available ([#1303](https://github.com/feathersjs/feathers/issues/1303)) ([ebce79b](https://github.com/feathersjs/feathers/commit/ebce79b)) - Change and *JWT methods to *accessToken ([#1304](https://github.com/feathersjs/feathers/issues/1304)) ([5ac826b](https://github.com/feathersjs/feathers/commit/5ac826b)) - express use service.methods ([#945](https://github.com/feathersjs/feathers/issues/945)) ([3f0b1c3](https://github.com/feathersjs/feathers/commit/3f0b1c3)) # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Add test to make sure different id in adapter query works ([#1165](https://github.com/feathersjs/feathers/issues/1165)) ([0ba4580](https://github.com/feathersjs/feathers/commit/0ba4580)) - Add whitelist and filter support to common adapter service ([#1132](https://github.com/feathersjs/feathers/issues/1132)) ([df1daaa](https://github.com/feathersjs/feathers/commit/df1daaa)) - Added path and method in to express request for passport ([#1112](https://github.com/feathersjs/feathers/issues/1112)) ([afa1cb4](https://github.com/feathersjs/feathers/commit/afa1cb4)) - Authentication core improvements ([#1260](https://github.com/feathersjs/feathers/issues/1260)) ([c5dc7a2](https://github.com/feathersjs/feathers/commit/c5dc7a2)) - Catch connection initialization errors ([#1043](https://github.com/feathersjs/feathers/issues/1043)) ([4f9acd6](https://github.com/feathersjs/feathers/commit/4f9acd6)) - Compare socket event data using lodash's isEqual instead of indexOf ([#1061](https://github.com/feathersjs/feathers/issues/1061)) ([f706db3](https://github.com/feathersjs/feathers/commit/f706db3)) - Do not inherit app object from Object prototype ([#1153](https://github.com/feathersjs/feathers/issues/1153)) ([ed8c2e4](https://github.com/feathersjs/feathers/commit/ed8c2e4)) - Fix AdapterService multi option when set to true ([#1134](https://github.com/feathersjs/feathers/issues/1134)) ([40402fc](https://github.com/feathersjs/feathers/commit/40402fc)) - Improve JWT authentication option handling ([#1261](https://github.com/feathersjs/feathers/issues/1261)) ([31b956b](https://github.com/feathersjs/feathers/commit/31b956b)) - make codeclimate conform to rule of three ([#1076](https://github.com/feathersjs/feathers/issues/1076)) ([0a2ce87](https://github.com/feathersjs/feathers/commit/0a2ce87)) - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - More robust parsing of mongodb connection string. Use new url parser. ([#1002](https://github.com/feathersjs/feathers/issues/1002)) ([74b31df](https://github.com/feathersjs/feathers/commit/74b31df)) - Normalize params to object even when it is falsy ([#1012](https://github.com/feathersjs/feathers/issues/1012)) ([af97818](https://github.com/feathersjs/feathers/commit/af97818)) - Only merge authenticated property on update ([8a564f7](https://github.com/feathersjs/feathers/commit/8a564f7)) - reduce authentication connection hook complexity and remove unnecessary checks ([fa94b2f](https://github.com/feathersjs/feathers/commit/fa94b2f)) - support a secretProvider ([#1063](https://github.com/feathersjs/feathers/issues/1063)) ([9da26ad](https://github.com/feathersjs/feathers/commit/9da26ad)) - Support Logger swallowing ([#995](https://github.com/feathersjs/feathers/issues/995)) ([5b3b37e](https://github.com/feathersjs/feathers/commit/5b3b37e)), closes [/github.com/feathersjs/generator-feathers/pull/392#issuecomment-420408312](https://github.com//github.com/feathersjs/generator-feathers/pull/392/issues/issuecomment-420408312) - Throw error in `filterQuery` when query parameter is unknown ([#1131](https://github.com/feathersjs/feathers/issues/1131)) ([cd1a183](https://github.com/feathersjs/feathers/commit/cd1a183)) - Update 401.html ([#983](https://github.com/feathersjs/feathers/issues/983)) ([cec6bae](https://github.com/feathersjs/feathers/commit/cec6bae)) - Update 404.html ([#984](https://github.com/feathersjs/feathers/issues/984)) ([72132d1](https://github.com/feathersjs/feathers/commit/72132d1)) - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) - Update adapter common tests to check for falsy ([#1140](https://github.com/feathersjs/feathers/issues/1140)) ([2856722](https://github.com/feathersjs/feathers/commit/2856722)) - Update adapter tests to not rely on error instance ([#1202](https://github.com/feathersjs/feathers/issues/1202)) ([6885e0e](https://github.com/feathersjs/feathers/commit/6885e0e)) - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) - **adapter-commons:** Keep Symbols when filtering a query ([#1141](https://github.com/feathersjs/feathers/issues/1141)) ([c9f55d8](https://github.com/feathersjs/feathers/commit/c9f55d8)) - **authentication:** Fall back when req.app is not the application when emitting events ([#1185](https://github.com/feathersjs/feathers/issues/1185)) ([6a534f0](https://github.com/feathersjs/feathers/commit/6a534f0)) - **chore:** Add .npmignore to adapter-commons ([8e129d8](https://github.com/feathersjs/feathers/commit/8e129d8)) - **chore:** Properly configure and run code linter ([#1092](https://github.com/feathersjs/feathers/issues/1092)) ([fd3fc34](https://github.com/feathersjs/feathers/commit/fd3fc34)) - **chore:** Remove CLI and generators that belong in their own repositories ([#1091](https://github.com/feathersjs/feathers/issues/1091)) ([e894ac8](https://github.com/feathersjs/feathers/commit/e894ac8)) - **compile-task:** on windows machine ([#60](https://github.com/feathersjs/feathers/issues/60)) ([617e0a4](https://github.com/feathersjs/feathers/commit/617e0a4)) - **docs/new-features:** syntax highlighting ([#347](https://github.com/feathersjs/feathers/issues/347)) ([4ab7c95](https://github.com/feathersjs/feathers/commit/4ab7c95)) - **knex:** Fix knex + sql server issues when using authentication generator ([#257](https://github.com/feathersjs/feathers/issues/257)) ([8f8f75f](https://github.com/feathersjs/feathers/commit/8f8f75f)) - **package:** update @feathersjs/commons to version 2.0.0 ([#31](https://github.com/feathersjs/feathers/issues/31)) ([c1ef5b1](https://github.com/feathersjs/feathers/commit/c1ef5b1)) - **package:** update @feathersjs/commons to version 2.0.0 ([#692](https://github.com/feathersjs/feathers/issues/692)) ([ca665ab](https://github.com/feathersjs/feathers/commit/ca665ab)) - **package:** update config to version 3.0.0 ([#1100](https://github.com/feathersjs/feathers/issues/1100)) ([c9f4b42](https://github.com/feathersjs/feathers/commit/c9f4b42)) - use minimal RegExp matching for better performance ([#977](https://github.com/feathersjs/feathers/issues/977)) ([3ca7e97](https://github.com/feathersjs/feathers/commit/3ca7e97)) - **package:** update @feathersjs/commons to version 2.0.0 ([#45](https://github.com/feathersjs/feathers/issues/45)) ([9e82595](https://github.com/feathersjs/feathers/commit/9e82595)) - **package:** update @feathersjs/commons to version 2.0.0 ([#84](https://github.com/feathersjs/feathers/issues/84)) ([78ed39c](https://github.com/feathersjs/feathers/commit/78ed39c)) - **package:** update debug to version 3.0.0 ([#2](https://github.com/feathersjs/feathers/issues/2)) ([7e19603](https://github.com/feathersjs/feathers/commit/7e19603)) - **package:** update debug to version 3.0.0 ([#22](https://github.com/feathersjs/feathers/issues/22)) ([0b62606](https://github.com/feathersjs/feathers/commit/0b62606)) - **package:** update debug to version 3.0.0 ([#30](https://github.com/feathersjs/feathers/issues/30)) ([baf7a00](https://github.com/feathersjs/feathers/commit/baf7a00)) - **package:** update debug to version 3.0.0 ([#31](https://github.com/feathersjs/feathers/issues/31)) ([902ddf5](https://github.com/feathersjs/feathers/commit/902ddf5)) - **package:** update debug to version 3.0.0 ([#31](https://github.com/feathersjs/feathers/issues/31)) ([f23d617](https://github.com/feathersjs/feathers/commit/f23d617)) - **package:** update debug to version 3.0.0 ([#45](https://github.com/feathersjs/feathers/issues/45)) ([2391434](https://github.com/feathersjs/feathers/commit/2391434)) - **package:** update debug to version 3.0.0 ([#45](https://github.com/feathersjs/feathers/issues/45)) ([9b9bde5](https://github.com/feathersjs/feathers/commit/9b9bde5)) - **package:** update debug to version 3.0.0 ([#555](https://github.com/feathersjs/feathers/issues/555)) ([f788804](https://github.com/feathersjs/feathers/commit/f788804)) - **package:** update debug to version 3.0.0 ([#59](https://github.com/feathersjs/feathers/issues/59)) ([fedcf06](https://github.com/feathersjs/feathers/commit/fedcf06)) - **package:** update debug to version 3.0.0 ([#61](https://github.com/feathersjs/feathers/issues/61)) ([6f5009c](https://github.com/feathersjs/feathers/commit/6f5009c)) - **package:** update debug to version 3.0.0 ([#83](https://github.com/feathersjs/feathers/issues/83)) ([49f1de9](https://github.com/feathersjs/feathers/commit/49f1de9)) - **package:** update debug to version 3.0.0 ([#86](https://github.com/feathersjs/feathers/issues/86)) ([fd1bb6b](https://github.com/feathersjs/feathers/commit/fd1bb6b)) - **package:** update debug to version 3.0.1 ([#46](https://github.com/feathersjs/feathers/issues/46)) ([f8ada69](https://github.com/feathersjs/feathers/commit/f8ada69)) - **package:** update generator-feathers to version 1.0.3 ([#81](https://github.com/feathersjs/feathers/issues/81)) ([0c66bc5](https://github.com/feathersjs/feathers/commit/0c66bc5)) - **package:** update generator-feathers to version 1.0.5 ([#83](https://github.com/feathersjs/feathers/issues/83)) ([229caba](https://github.com/feathersjs/feathers/commit/229caba)) - **package:** update generator-feathers to version 1.0.6 ([#86](https://github.com/feathersjs/feathers/issues/86)) ([7ae8e56](https://github.com/feathersjs/feathers/commit/7ae8e56)) - **package:** update generator-feathers to version 1.1.0 ([#93](https://github.com/feathersjs/feathers/issues/93)) ([f393e4c](https://github.com/feathersjs/feathers/commit/f393e4c)) - **package:** update generator-feathers to version 1.1.1 ([#95](https://github.com/feathersjs/feathers/issues/95)) ([3279ba9](https://github.com/feathersjs/feathers/commit/3279ba9)) - **package:** update generator-feathers to version 1.2.0 ([#96](https://github.com/feathersjs/feathers/issues/96)) ([8eb5674](https://github.com/feathersjs/feathers/commit/8eb5674)) - **package:** update generator-feathers to version 1.2.10 ([#115](https://github.com/feathersjs/feathers/issues/115)) ([c1db2b2](https://github.com/feathersjs/feathers/commit/c1db2b2)) - **package:** update generator-feathers to version 1.2.11 ([#116](https://github.com/feathersjs/feathers/issues/116)) ([bba6550](https://github.com/feathersjs/feathers/commit/bba6550)) - **package:** update generator-feathers to version 1.2.12 ([#119](https://github.com/feathersjs/feathers/issues/119)) ([e5c737d](https://github.com/feathersjs/feathers/commit/e5c737d)) - **package:** update generator-feathers to version 1.2.2 ([#98](https://github.com/feathersjs/feathers/issues/98)) ([ee629e3](https://github.com/feathersjs/feathers/commit/ee629e3)), closes [#97](https://github.com/feathersjs/feathers/issues/97) - **package:** update generator-feathers to version 1.2.3 ([#99](https://github.com/feathersjs/feathers/issues/99)) ([b6cf361](https://github.com/feathersjs/feathers/commit/b6cf361)) - **package:** update generator-feathers to version 1.2.4 ([#101](https://github.com/feathersjs/feathers/issues/101)) ([2182fef](https://github.com/feathersjs/feathers/commit/2182fef)) - **package:** update generator-feathers to version 1.2.5 ([#104](https://github.com/feathersjs/feathers/issues/104)) ([295f6aa](https://github.com/feathersjs/feathers/commit/295f6aa)) - **package:** update generator-feathers to version 1.2.6 ([#106](https://github.com/feathersjs/feathers/issues/106)) ([66125dc](https://github.com/feathersjs/feathers/commit/66125dc)) - **package:** update generator-feathers to version 1.2.9 ([#110](https://github.com/feathersjs/feathers/issues/110)) ([17e55dc](https://github.com/feathersjs/feathers/commit/17e55dc)) - **package:** update generator-feathers to version 2.0.0 ([#126](https://github.com/feathersjs/feathers/issues/126)) ([eff6627](https://github.com/feathersjs/feathers/commit/eff6627)) - **package:** update generator-feathers to version 2.1.0 ([#128](https://github.com/feathersjs/feathers/issues/128)) ([b712355](https://github.com/feathersjs/feathers/commit/b712355)) - **package:** update generator-feathers to version 2.1.1 ([#129](https://github.com/feathersjs/feathers/issues/129)) ([1f91c0b](https://github.com/feathersjs/feathers/commit/1f91c0b)) - **package:** update generator-feathers to version 2.2.0 ([#130](https://github.com/feathersjs/feathers/issues/130)) ([308ad0b](https://github.com/feathersjs/feathers/commit/308ad0b)) - **package:** update generator-feathers to version 2.3.0 ([#131](https://github.com/feathersjs/feathers/issues/131)) ([7894807](https://github.com/feathersjs/feathers/commit/7894807)) - **package:** update generator-feathers to version 2.3.1 ([#132](https://github.com/feathersjs/feathers/issues/132)) ([c3e3187](https://github.com/feathersjs/feathers/commit/c3e3187)) - **package:** update generator-feathers to version 2.4.0 ([#137](https://github.com/feathersjs/feathers/issues/137)) ([1645d2e](https://github.com/feathersjs/feathers/commit/1645d2e)) - **package:** update generator-feathers to version 2.4.1 ([#140](https://github.com/feathersjs/feathers/issues/140)) ([e5a5f7c](https://github.com/feathersjs/feathers/commit/e5a5f7c)) - **package:** update generator-feathers to version 2.4.4 ([#151](https://github.com/feathersjs/feathers/issues/151)) ([3dcd480](https://github.com/feathersjs/feathers/commit/3dcd480)) - **package:** update generator-feathers to version 2.5.2 ([#155](https://github.com/feathersjs/feathers/issues/155)) ([493ca4b](https://github.com/feathersjs/feathers/commit/493ca4b)) - **package:** update generator-feathers to version 2.5.3 ([#156](https://github.com/feathersjs/feathers/issues/156)) ([ef570a8](https://github.com/feathersjs/feathers/commit/ef570a8)) - **package:** update generator-feathers to version 2.5.4 ([#158](https://github.com/feathersjs/feathers/issues/158)) ([787f30c](https://github.com/feathersjs/feathers/commit/787f30c)) - **package:** update generator-feathers to version 2.5.5 ([#159](https://github.com/feathersjs/feathers/issues/159)) ([bbd1b29](https://github.com/feathersjs/feathers/commit/bbd1b29)) - **package:** update generator-feathers to version 2.5.6 ([#161](https://github.com/feathersjs/feathers/issues/161)) ([cb72a5c](https://github.com/feathersjs/feathers/commit/cb72a5c)) - **package:** update generator-feathers to version 2.6.0 ([#164](https://github.com/feathersjs/feathers/issues/164)) ([6212ec9](https://github.com/feathersjs/feathers/commit/6212ec9)) - **package:** update generator-feathers-plugin to version 0.11.0 ([#105](https://github.com/feathersjs/feathers/issues/105)) ([d40bb75](https://github.com/feathersjs/feathers/commit/d40bb75)) - **package:** update generator-feathers-plugin to version 0.12.1 ([#112](https://github.com/feathersjs/feathers/issues/112)) ([f374e01](https://github.com/feathersjs/feathers/commit/f374e01)) - **package:** update generator-feathers-plugin to version 1.0.0 ([#134](https://github.com/feathersjs/feathers/issues/134)) ([ee905b0](https://github.com/feathersjs/feathers/commit/ee905b0)) - **package:** update jsonwebtoken to version 8.0.0 ([#567](https://github.com/feathersjs/feathers/issues/567)) ([6811626](https://github.com/feathersjs/feathers/commit/6811626)) - **package:** update ms to version 2.0.0 ([#509](https://github.com/feathersjs/feathers/issues/509)) ([7e4b0b6](https://github.com/feathersjs/feathers/commit/7e4b0b6)) - **package:** update passport to version 0.4.0 ([#558](https://github.com/feathersjs/feathers/issues/558)) ([dcb14a5](https://github.com/feathersjs/feathers/commit/dcb14a5)) - **package:** update passport-jwt to version 4.0.0 ([#58](https://github.com/feathersjs/feathers/issues/58)) ([77a3800](https://github.com/feathersjs/feathers/commit/77a3800)) - **package:** update socket.io to version 2.0.0 ([#75](https://github.com/feathersjs/feathers/issues/75)) ([d4a4b71](https://github.com/feathersjs/feathers/commit/d4a4b71)) - **package:** update yeoman-environment to version 2.0.0 ([#89](https://github.com/feathersjs/feathers/issues/89)) ([2355652](https://github.com/feathersjs/feathers/commit/2355652)) - **package:** update yeoman-generator to version 2.0.0 ([#279](https://github.com/feathersjs/feathers/issues/279)) ([4f38e8b](https://github.com/feathersjs/feathers/commit/4f38e8b)) - **package:** update yeoman-generator to version 2.0.0 ([#46](https://github.com/feathersjs/feathers/issues/46)) ([7071095](https://github.com/feathersjs/feathers/commit/7071095)) - **package:** update yeoman-generator to version 3.0.0 ([#374](https://github.com/feathersjs/feathers/issues/374)) ([acdbbca](https://github.com/feathersjs/feathers/commit/acdbbca)) ### chore - **package:** Move adapter tests into their own module ([#1164](https://github.com/feathersjs/feathers/issues/1164)) ([dcc1e6b](https://github.com/feathersjs/feathers/commit/dcc1e6b)) - drop support for Node.js 0.10 ([#48](https://github.com/feathersjs/feathers/issues/48)) ([3f7555a](https://github.com/feathersjs/feathers/commit/3f7555a)) ### Features - @feathers/cli: introduce option to choose jest for tests instead of mocha ([#1057](https://github.com/feathersjs/feathers/issues/1057)) ([1356a1c](https://github.com/feathersjs/feathers/commit/1356a1c)) - @feathersjs/authentication-oauth ([#1299](https://github.com/feathersjs/feathers/issues/1299)) ([656bae7](https://github.com/feathersjs/feathers/commit/656bae7)) - Add authentication through oAuth redirect to authentication client ([#1301](https://github.com/feathersjs/feathers/issues/1301)) ([35d8043](https://github.com/feathersjs/feathers/commit/35d8043)) - Add AuthenticationBaseStrategy and make authentication option handling more explicit ([#1284](https://github.com/feathersjs/feathers/issues/1284)) ([2667d92](https://github.com/feathersjs/feathers/commit/2667d92)) - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - Added generators for feathers-objection & feathers-cassandra ([#1010](https://github.com/feathersjs/feathers/issues/1010)) ([c8b27d0](https://github.com/feathersjs/feathers/commit/c8b27d0)) - Allow registering a service at the root level ([#1115](https://github.com/feathersjs/feathers/issues/1115)) ([c73d322](https://github.com/feathersjs/feathers/commit/c73d322)) - Allow to skip sending service events ([#1270](https://github.com/feathersjs/feathers/issues/1270)) ([b487bbd](https://github.com/feathersjs/feathers/commit/b487bbd)) - Authentication v3 client ([#1240](https://github.com/feathersjs/feathers/issues/1240)) ([65b43bd](https://github.com/feathersjs/feathers/commit/65b43bd)) - Authentication v3 core server implementation ([#1205](https://github.com/feathersjs/feathers/issues/1205)) ([1bd7591](https://github.com/feathersjs/feathers/commit/1bd7591)) - Authentication v3 Express integration ([#1218](https://github.com/feathersjs/feathers/issues/1218)) ([82bcfbe](https://github.com/feathersjs/feathers/commit/82bcfbe)) - Authentication v3 local authentication ([#1211](https://github.com/feathersjs/feathers/issues/1211)) ([0fa5f7c](https://github.com/feathersjs/feathers/commit/0fa5f7c)) - Common database adapter utilities and test suite ([#1130](https://github.com/feathersjs/feathers/issues/1130)) ([17b3dc8](https://github.com/feathersjs/feathers/commit/17b3dc8)) - Make custom query for oAuth authentication ([#1124](https://github.com/feathersjs/feathers/issues/1124)) ([5d43e3c](https://github.com/feathersjs/feathers/commit/5d43e3c)) - Remove (hook, next) signature and SKIP support ([#1269](https://github.com/feathersjs/feathers/issues/1269)) ([211c0f8](https://github.com/feathersjs/feathers/commit/211c0f8)) - Support params symbol to skip authenticate hook ([#1296](https://github.com/feathersjs/feathers/issues/1296)) ([d16cf4d](https://github.com/feathersjs/feathers/commit/d16cf4d)) ### BREAKING CHANGES - Rewrite for authentication v3 - Update authentication strategies for @feathersjs/authentication v3 - **package:** Removes adapter tests from @feathersjs/adapter-commons - Move database adapter utilities from @feathersjs/commons into its own module - This module no longer supports Node.js 0.10 ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ Feathers - The API and real-time application framework --- [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/feathers.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/feathers) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) Feathers is a full-stack framework for creating web APIs and real-time applications with TypeScript or JavaScript. Feathers can interact with any backend technology, supports many databases out of the box and works with any frontend like React, VueJS, Angular, React Native, Android or iOS. # Getting started Get started with just three commands: ```bash $ npm create feathers my-new-app $ cd my-new-app $ npm run dev ``` To learn more about Feathers visit the website at [feathersjs.com](http://feathersjs.com) or jump right into [the Feathers guides](https://feathersjs.com/guides/). # Contributing To start developing, clone this repository, then run: ``` cd feathers npm install ``` To run all tests run ``` npm test ``` Individual tests can be run in the module you are working on: ``` cd packages/feathers npm test ``` # License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: docs/.vitepress/components/Badges.vue ================================================ ================================================ FILE: docs/.vitepress/components/BlockQuote.vue ================================================ ================================================ FILE: docs/.vitepress/components/Contributors.vue ================================================ ================================================ FILE: docs/.vitepress/components/DatabaseBlock.vue ================================================ ================================================ FILE: docs/.vitepress/components/DatabaseSelect.vue ================================================ ================================================ FILE: docs/.vitepress/components/FeaturesList.vue ================================================ ================================================ FILE: docs/.vitepress/components/LanguageBlock.vue ================================================ ================================================ FILE: docs/.vitepress/components/LanguageSelect.vue ================================================ ================================================ FILE: docs/.vitepress/components/ListItem.vue ================================================ ================================================ FILE: docs/.vitepress/components/Logo.vue ================================================ ================================================ FILE: docs/.vitepress/components/Select.vue ================================================ ================================================ FILE: docs/.vitepress/components/Tab.vue ================================================ ================================================ FILE: docs/.vitepress/components/Tabs.vue ================================================ ================================================ FILE: docs/.vitepress/components/TeamMember.vue ================================================ ================================================ FILE: docs/.vitepress/components.d.ts ================================================ /* eslint-disable */ // @ts-nocheck // biome-ignore lint: disable // oxlint-disable // ------ // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 export {} /* prettier-ignore */ declare module 'vue' { export interface GlobalComponents { Badges: typeof import('./components/Badges.vue')['default'] BlockQuote: typeof import('./components/BlockQuote.vue')['default'] Contributors: typeof import('./components/Contributors.vue')['default'] DatabaseBlock: typeof import('./components/DatabaseBlock.vue')['default'] DatabaseSelect: typeof import('./components/DatabaseSelect.vue')['default'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] ElInput: typeof import('element-plus/es')['ElInput'] ElOption: typeof import('element-plus/es')['ElOption'] ElRadio: typeof import('element-plus/es')['ElRadio'] ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup'] ElSelect: typeof import('element-plus/es')['ElSelect'] FeaturesList: typeof import('./components/FeaturesList.vue')['default'] LanguageBlock: typeof import('./components/LanguageBlock.vue')['default'] LanguageSelect: typeof import('./components/LanguageSelect.vue')['default'] ListItem: typeof import('./components/ListItem.vue')['default'] Logo: typeof import('./components/Logo.vue')['default'] Select: typeof import('./components/Select.vue')['default'] Tab: typeof import('./components/Tab.vue')['default'] Tabs: typeof import('./components/Tabs.vue')['default'] TeamMember: typeof import('./components/TeamMember.vue')['default'] } } ================================================ FILE: docs/.vitepress/config.nav.ts ================================================ import { releases } from './meta' // import { version } from '../package.json' const version = 5 export default [ { text: 'Guides', link: '/guides/' }, { text: 'API', link: '/api/' }, { text: 'Help', link: '/help/' }, { text: `v${version}`, items: [ { text: 'Release Notes ', link: releases }, { text: 'Crow v4 ', link: 'https://crow.docs.feathersjs.com' }, { text: 'Buzzard v3 ', link: 'https://buzzard.docs.feathersjs.com' } ] }, { text: 'Ecosystem', link: '/ecosystem/' } ] ================================================ FILE: docs/.vitepress/config.sidebar.ts ================================================ const comparisonSidebar = [ { text: 'Compare Feathers', items: [ { text: 'Overview', link: '/comparison' }, { text: 'Feathers vs Firebase', link: '/feathers-vs-firebase' }, { text: 'Feathers vs Meteor', link: '/feathers-vs-meteor' }, { text: 'Feathers vs Sails', link: '/feathers-vs-sails' }, { text: 'Feathers vs Loopback', link: '/feathers-vs-loopback' } ] } ] export default { '/guides': [ { text: 'Getting Started', collapsible: true, items: [ { text: 'Quick start', link: '/guides/basics/starting.md' }, { text: 'Creating an app', link: '/guides/basics/generator.md' }, { text: 'Authentication', link: '/guides/basics/authentication.md' }, { text: 'Services', link: '/guides/basics/services.md' }, { text: 'Hooks', link: '/guides/basics/hooks.md' }, { text: 'Schemas', link: '/guides/basics/schemas.md' }, { text: 'Logging in', link: '/guides/basics/login.md' } // { // text: 'Writing Tests', // link: '/guides/basics/testing.md' // } ] }, { text: 'Frontend', collapsible: true, collapsed: false, items: [ { text: 'JavaScript', link: '/guides/frontend/javascript.md' } // { // text: 'Frontend Frameworks', // link: '/guides/frameworks.md' // } ] }, { text: 'CLI', collapsible: true, collapsed: true, items: [ { text: '📖 Readme', link: '/guides/cli/index.md' }, { text: '📂 config', items: [ { text: '📄 default.json', link: '/guides/cli/default.json.md' }, { text: '📄 custom-environment-variables.json', link: '/guides/cli/custom-environment-variables.md' } ] }, { text: '📂 src', items: [ { text: '📂 hooks', items: [ { text: '📄 <hook>', link: '/guides/cli/hook.md' }, { text: '📄 log-error', link: '/guides/cli/log-error.md' } ] }, { text: '📂 services', items: [ { text: '📂 <service>', items: [ { text: '📄 <service>', link: '/guides/cli/service.md' }, { text: '📄 <service>.class', link: '/guides/cli/service.class.md' }, { text: '📄 <service>.schemas', link: '/guides/cli/service.schemas.md' }, { text: '📄 <service>.shared', link: '/guides/cli/service.shared.md' } ] } ] }, { text: '📄 app', link: '/guides/cli/app.md' }, { text: '📄 authentication', link: '/guides/cli/authentication.md' }, { text: '📄 channels', link: '/guides/cli/channels.md' }, { text: '📄 client', link: '/guides/cli/client.md' }, { text: '📄 configuration', link: '/guides/cli/configuration.md' }, { text: '📄 declarations', link: '/guides/cli/declarations.md' }, { text: '📄 logger', link: '/guides/cli/logger.md' }, { text: '📄 validators', link: '/guides/cli/validators.md' }, { text: '📄 <database>', link: '/guides/cli/databases.md' } ] }, { text: '📂 test', items: [ { text: '📄 client.test', link: '/guides/cli/client.test.md' }, { text: '📄 app.test', link: '/guides/cli/app.test.md' }, { text: '📄 <service>.test', link: '/guides/cli/service.test.md' } ] }, { text: '📄 .prettierrc', link: '/guides/cli/prettierrc.md' }, { text: '📄 knexfile', link: '/guides/cli/knexfile.md' }, { text: '📄 package.json', link: '/guides/cli/package.md' }, { text: '📄 tsconfig.json', link: '/guides/cli/tsconfig.md' } ] }, { text: 'Migrating', // collapsible: true, items: [ { text: "What's new?", link: '/guides/whats-new.md' }, { text: 'Migration guide', link: '/guides/migrating.md' } ] } ], '/api': [ { text: 'Core', collapsible: true, items: [ { text: 'Application', link: '/api/application' }, { text: 'Services', link: '/api/services' }, { text: 'Hooks', link: '/api/hooks' }, { text: 'Events', link: '/api/events' }, { text: 'Errors', link: '/api/errors' } ] }, { text: 'Transports', collapsible: true, collapsed: true, items: [ { text: 'Configuration', link: '/api/configuration' }, { text: 'Koa', link: '/api/koa' }, { text: 'Express', link: '/api/express' }, { text: 'Socket.io', link: '/api/socketio' }, { text: 'Channels', link: '/api/channels' } ] }, { text: 'Authentication', collapsible: true, collapsed: true, items: [ { text: 'Overview', link: '/api/authentication/' }, { text: 'Service', link: '/api/authentication/service' }, { text: 'Hook', link: '/api/authentication/hook' }, { text: 'Strategies', link: '/api/authentication/strategy' }, { text: 'JWT', link: '/api/authentication/jwt' }, { text: 'Local', link: '/api/authentication/local' }, { text: 'OAuth', link: '/api/authentication/oauth' } ] }, { text: 'Client', collapsible: true, collapsed: true, items: [ { text: 'Feathers Client', link: '/api/client' }, { text: 'REST Client', link: '/api/client/rest' }, { text: 'Socket.io Client', link: '/api/client/socketio' }, { text: 'Authentication', link: '/api/authentication/client' } ] }, { text: 'Schema', collapsible: true, collapsed: true, items: [ { text: 'Overview', link: '/api/schema/' }, { text: 'TypeBox', link: '/api/schema/typebox' }, { text: 'JSON schema', link: '/api/schema/schema' }, { text: 'Validators', link: '/api/schema/validators' }, { text: 'Resolvers', link: '/api/schema/resolvers' } ] }, { text: 'Databases', collapsible: true, collapsed: true, items: [ { text: 'Adapters', link: '/api/databases/adapters' }, { text: 'Common API', link: '/api/databases/common' }, { text: 'Querying', link: '/api/databases/querying' }, { text: 'MongoDB', link: '/api/databases/mongodb' }, { text: 'SQL', link: '/api/databases/knex' }, { text: 'Memory', link: '/api/databases/memory' } ] } ], '/help': [ { text: 'Help', items: [ { text: 'Getting Help', link: '/help/' }, { text: 'FAQ', link: '/help/faq' } ] } ], '/cookbook': [ { text: 'General', items: [ { text: 'Scaling', link: '/cookbook/general/scaling' } ] }, { text: 'Authentication', items: [ { text: 'Anonymous', link: '/cookbook/authentication/anonymous' }, { text: 'API Key', link: '/cookbook/authentication/apiKey' }, { text: 'Auth0', link: '/cookbook/authentication/auth0' }, { text: 'Facebook', link: '/cookbook/authentication/facebook' }, { text: 'Google', link: '/cookbook/authentication/google' }, { text: 'Firebase', link: '/cookbook/authentication/firebase' }, { text: 'Discord', link: '/cookbook/authentication/_discord' }, { text: 'Stateless JWT', link: '/cookbook/authentication/stateless' }, { text: 'Revoking JWTs', link: '/cookbook/authentication/revoke-jwt' } ] }, { text: 'Express', items: [ { text: 'File Uploads', link: '/cookbook/express/file-uploading' }, { text: 'View Engine SSR', link: '/cookbook/express/view-engine' } ] }, { text: 'Deployment', items: [ { text: 'Dockerize a Feathers App', link: '/cookbook/deploy/docker' } ] } ], '/comparison': comparisonSidebar, '/feathers-vs-firebase': comparisonSidebar, '/feathers-vs-meteor': comparisonSidebar, '/feathers-vs-sails': comparisonSidebar, '/feathers-vs-loopback': comparisonSidebar } ================================================ FILE: docs/.vitepress/config.ts ================================================ import { defineConfig } from 'vitepress' import { discord, font, github, ogImage, ogUrl, twitter, feathersDescription, feathersName } from './meta' import sidebar from './config.sidebar' import nav from './config.nav' // For sitemap/search import { createWriteStream } from 'node:fs' import { SitemapStream } from 'sitemap' import { resolve } from 'node:path' const links: any[] = [] export default defineConfig({ lang: 'en-US', title: feathersName, description: feathersDescription, head: [ ['meta', { name: 'theme-color', content: '#ffffff' }], ['link', { rel: 'icon', href: '/logo.svg', type: 'image/svg+xml' }], ['link', { rel: 'alternate icon', href: '/favicon.ico', type: 'image/png', sizes: '16x16' }], [ 'meta', { name: 'author', content: `daffl, marshallswain, and FeathersJS contributors` } ], [ 'meta', { name: 'keywords', content: 'feathersjs, feathers, react, vue, preact, svelte, solid, typescript, esm, node, deno, cloudflare, workers' } ], ['meta', { property: 'og:title', content: feathersName }], ['meta', { property: 'og:description', content: feathersDescription }], ['meta', { property: 'og:url', content: ogUrl }], ['meta', { property: 'og:image', content: ogImage }], ['meta', { name: 'twitter:title', content: feathersName }], ['meta', { name: 'twitter:description', content: feathersDescription }], ['meta', { name: 'twitter:image', content: ogImage }], ['meta', { name: 'twitter:card', content: 'summary_large_image' }], ['link', { href: font, rel: 'stylesheet' }], ['link', { rel: 'mask-icon', href: '/logo.svg', color: '#ffffff' }], ['link', { rel: 'apple-touch-icon', href: '/apple-touch-icon.png', sizes: '180x180' }] ], lastUpdated: true, markdown: { theme: { light: 'vitesse-light', dark: 'vitesse-dark' } }, themeConfig: { logo: '/logo.svg', editLink: { pattern: 'https://github.com/feathersjs/feathers/edit/dove/docs/:path', text: 'Suggest changes to this page' }, socialLinks: [ { icon: 'discord', link: discord }, { icon: 'github', link: github } ], footer: { message: 'Released under the MIT License.', copyright: `Copyright © 2012-${new Date().getFullYear()} FeathersJS contributors` }, nav, sidebar }, // for sitemap/search transformHtml: (_: any, id: any, { pageData }: any) => { if (!/[\\/]404\.html$/.test(id)) links.push({ // you might need to change this if not using clean urls mode url: pageData.relativePath.replace(/((^|\/)index)?\.md$/, '$2'), lastmod: pageData.lastUpdated }) }, // for sitemap/search buildEnd: async ({ outDir }) => { const sitemap = new SitemapStream({ hostname: 'https://dove.feathersjs.com/' }) const writeStream = createWriteStream(resolve(outDir, 'sitemap.xml')) sitemap.pipe(writeStream) links.forEach((link) => sitemap.write(link)) sitemap.end() await new Promise((r) => writeStream.on('finish', r)) } }) ================================================ FILE: docs/.vitepress/meta.ts ================================================ // noinspection ES6PreferShortImport: IntelliJ IDE hint to avoid warning to use `~/contributors`, will fail on build if changed /* Texts */ export const feathersName = 'feathers' export const feathersShortName = 'feathers' export const feathersDescription = 'The API & Real-time Application Framework' /* CDN fonts and styles */ export const googleapis = 'https://fonts.googleapis.com' export const gstatic = 'https://fonts.gstatic.com' export const font = `${googleapis}/css2?family=Readex+Pro:wght@200;400;600&display=swap` /* vitepress head */ export const ogUrl = 'https://feathersjs.com/' export const ogImage = `${ogUrl}og.png` /* GitHub and social links */ export const github = 'https://github.com/feathersjs/feathers' export const releases = 'https://github.com/feathersjs/feathers/releases' export const contributing = 'https://github.com/feathersjs/feathers/blob/master/.github/contributing.md' export const discord = 'https://discord.gg/qa8kez8QBx' export const twitter = null; /* Avatar/Image/Sponsors servers */ export const preconnectLinks = [googleapis, gstatic] export const preconnectHomeLinks = [googleapis, gstatic] /* PWA runtime caching urlPattern regular expressions */ export const pwaFontsRegex = new RegExp(`^${googleapis}/.*`, 'i') export const pwaFontStylesRegex = new RegExp(`^${gstatic}/.*`, 'i') ================================================ FILE: docs/.vitepress/scripts/assets.ts ================================================ import { promises as fs } from 'fs' import fg from 'fast-glob' import { font, preconnectHomeLinks, preconnectLinks } from '../meta' const preconnect = ` ${preconnectLinks.map(l => ``).join('\n')} ${preconnectLinks.map(l => ``).join('\n')} ` const preconnectHome = ` ${preconnectHomeLinks.map(l => ``).join('\n')} ${preconnectHomeLinks.map(l => ``).join('\n')} ` export const optimizePages = async (pwa: boolean) => { const names = await fg('./.vitepress/dist/**/*.html', { onlyFiles: true }) await Promise.all(names.map(async (i) => { let html = await fs.readFile(i, 'utf-8') let prefetchImg = '\n\t' let usePreconnect = preconnect if (i.endsWith('/dist/index.html')) { usePreconnect = preconnectHome prefetchImg = ` ${prefetchImg} \t \t ` } // we need the font on development, so the font entry is added in vitepress head html = html.replace(``, '') html = html.replace( //g, ` ${usePreconnect} `).trim() if (pwa) { html = html.replace( '', ` \t${prefetchImg} \t\n`, ) } else { html = html.replace( '', ` ${prefetchImg} `, ) } // TODO: dark/light theme, don't remove yet // html = html.replace( // '', // '\t\n', // ) html = html.replace( /aria-hidden="true"/gi, 'tabindex="-1" aria-hidden="true"', ).replace( / replaced with h2 with the same size */ .home-content h2 { margin-top: 2rem; font-size: 1.35rem; border-bottom: none; margin-bottom: 0; } img.resizable-img { width: unset; height: unset; } body[data-language='js'] pre.language-selectable[data-language='ts'] { display: none; } body[data-language='ts'] pre.language-selectable[data-language='js'] { display: none; } ================================================ FILE: docs/.vitepress/style/vars.postcss ================================================ /** * Colors * -------------------------------------------------------------------------- */ :root { --primary: #ed8a80; /* congo pink */ --primary-content: #3C3C3B; /* charcoal */ --neutral: #27464F; /* midnight green */ --neutral-content: #EDEDED; /* cloud */ --secondary: #EDEDED; /* charcoal */ --secondary-content: #3C3C3B; /* cloud */ --accent: #3C3C3B; /* charcoal */ --accent-content: #EDEDED; /* cloud */ --btn-focus-scale: 1.05; --vp-c-accent: rgb(218, 180, 11); --vp-c-brand: var(--primary); --vp-c-brand-light: #FFA69D; --vp-c-brand-lighter: #FA978D; --vp-c-brand-dark: #e47f75; --vp-c-brand-darker: #db6d62; --vp-code-block-bg: rgba(125,125,125,0.04); --vp-c-green-light: rgb(18, 181, 157); --vp-custom-block-tip-border: rgba(18, 181, 157, 0.5); --vp-custom-block-tip-bg: rgba(18, 181, 157, 0.1); --vp-code-line-highlight-color: rgba(18, 181, 157, 0.2); /* --vp-code-line-highlight-color: #eea74b22; */ /* --vp-code-line-highlight-color: #db6d6232; */ /* --vp-code-line-highlight-color: #db6d6232; */ /* --vp-code-line-highlight-color: rgba(0, 0, 0, 0.1); */ } .dark { --vp-code-block-bg: rgba(0,0,0,0.2); --vp-code-line-highlight-color: rgba(18, 181, 157, 0.15); } /** * Component: Button * -------------------------------------------------------------------------- */ :root { --vp-button-brand-border: var(--vp-c-brand-light); --vp-button-brand-text: var(--vp-c-text-dark-1); --vp-button-brand-bg: var(--vp-c-brand); --vp-button-brand-hover-border: var(--vp-c-brand-light); --vp-button-brand-hover-text: var(--vp-c-text-dark-1); --vp-button-brand-hover-bg: var(--vp-c-brand-light); --vp-button-brand-active-border: var(--vp-c-brand-light); --vp-button-brand-active-text: var(--vp-c-text-dark-1); --vp-button-brand-active-bg: var(--vp-button-brand-bg); } /** * Component: Home * -------------------------------------------------------------------------- */ :root { --vp-home-hero-name-color: transparent; --vp-home-hero-name-background: -webkit-linear-gradient( 120deg, #f850ce 30%, #c10893 ); --vp-home-hero-image-background-image: linear-gradient( -45deg, #ffffff8f 30%, #ff85f75e ); --vp-home-hero-image-filter: blur(30px); } @media (min-width: 640px) { :root { --vp-home-hero-image-filter: blur(56px); } } @media (min-width: 960px) { :root { --vp-home-hero-image-filter: blur(72px); } } /** * Component: Algolia * -------------------------------------------------------------------------- */ .DocSearch { --docsearch-primary-color: var(--vp-c-brand) !important; } ================================================ FILE: docs/.vitepress/theme/FeathersLayout.vue ================================================ ================================================ FILE: docs/.vitepress/theme/index.ts ================================================ import googleAnalytics from 'vitepress-plugin-google-analytics' import 'element-plus/theme-chalk/dark/css-vars.css' import '../vite-env.d' import Theme from 'vitepress/theme' import { inBrowser } from 'vitepress' import '../style/main.postcss' import '../style/vars.postcss' import 'uno.css' import FeathersLayout from './FeathersLayout.vue' import Tab from '../components/Tab.vue' import Tabs from '../components/Tabs.vue' import Select from '../components/Select.vue' import Badges from '../components/Badges.vue' import Logo from '../components/Logo.vue' import BlockQuote from '../components/BlockQuote.vue' import LanguageBlock from '../components/LanguageBlock.vue' import DatabaseBlock from '../components/DatabaseBlock.vue' import '../style/element-plus.scss' // import 'element-plus/dist/index.css' if (inBrowser) import('./pwa') export default { ...Theme, Layout: FeathersLayout, enhanceApp({ app }) { googleAnalytics({ id: 'G-XQ8CKCD9L6' }), // Globally register components so they don't have to be imported in the template. app.component('Tabs', Tabs) app.component('Tab', Tab) app.component('Select', Select) app.component('Badges', Badges) app.component('Logo', Logo) app.component('BlockQuote', BlockQuote) app.component('LanguageBlock', LanguageBlock) app.component('DatabaseBlock', DatabaseBlock) } } ================================================ FILE: docs/.vitepress/theme/pwa.ts ================================================ import { registerSW } from 'virtual:pwa-register' registerSW({ immediate: true }) ================================================ FILE: docs/.vitepress/theme/store.ts ================================================ import { createGlobalState, useStorage } from '@vueuse/core' export const useGlobalLanguage = createGlobalState(() => useStorage('global-language', 'ts')) export const useGlobalDb = createGlobalState(() => useStorage('global-db', 'sql')) ================================================ FILE: docs/.vitepress/vite-env.d.ts ================================================ /// declare module '*.vue' { import type { DefineComponent } from 'vue' const component: DefineComponent<{}, {}, any> export default component } ================================================ FILE: docs/api/application.md ================================================ --- outline: deep --- # Application [![npm version](https://img.shields.io/npm/v/@feathersjs/authentication-client.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/feathers) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/feathers/CHANGELOG.md) ``` npm install @feathersjs/feathers --save ``` The core `@feathersjs/feathers` module provides the ability to initialize a new Feathers application instance. It works in Node, React Native and the browser (see the [client](./client.md) chapter for more information). Each instance allows for registration and retrieval of [services](./services.md), [hooks](./hooks.md), plugin configuration, and getting and setting configuration options. An initialized Feathers application is referred to as the **app object**. ```ts import { feathers } from '@feathersjs/feathers' type ServiceTypes = { // Add registered services here } // Types for `app.set(name, value)` and `app.get(name)` type Configuration = { port: number } const app = feathers() ``` ## .use(path, service [, options]) `app.use(path, service [, options]) -> app` allows registering a [service object](./services.md) on a given `path`. ```ts import { feathers, type Id } from '@feathersjs/feathers' class MessageService { async get(id: Id) { return { id, text: `This is the ${id} message!` } } } type ServiceTypes = { // Add services path to type mapping here messages: MessageService } const app = feathers() // Register a service instance on the app app.use('messages', new MessageService()) // Get the service and call the service method with the correct types const message = await app.service('messages').get('test') ``` ### path The `path` is a string that should be URL friendly and may contain `/` as a separator. `path` can also be `/` to register a service at the root level. A path may contain placeholders in the form of `:userId/messages` which will be included in `params.route` by a transport. ### options The following options are available: - `methods` (default: `['find', 'get', 'create', 'patch', 'update','remove']`) - A list of official and [custom service methods](services.md#custom-methods) that should be available to clients. When using this option **all** method names that should be available externally must be passed. Those methods will automatically be available for use with [hooks](./hooks). - `events` - A list of [public custom events sent by this service](./events.md#custom-events) ```ts import { EventEmitter } from 'events' import { feathers, type Id } from '@feathersjs/feathers' // Feathers services will always be event emitters // but we can also extend it for better type consistency class MessageService extends EventEmitter { async doSomething(data: { message: string }, params: Params) { this.emit('something', 'I did something') return data } async get(id: Id) { return { id, text: `This is the ${id} message!` } } } type ServiceTypes = { // Add services path to type mapping here messages: MessageService } const app = feathers() // Register a service with options app.use('messages', new MessageService(), { methods: ['get', 'doSomething'], events: ['something'] }) ```
If the `methods` property is `undefined`, all standard methods will be enabled and accessible externally.
## .unuse(path) `app.unuse(path)` unregisters an existing service on `path` and calls the services [.teardown method](./services.md#teardownapp-path) if it is implemented. ## .service(path) `app.service(path) -> service` returns the [service object](./services.md) for the given path. Feathers internally creates a new object from each registered service. This means that the object returned by `app.service(path)` will provide the same methods and functionality as your original service object but also functionality added by Feathers and its plugins like [service events](./events.md) and [additional methods](./services.md#feathers-functionality). ```ts const messageService = app.service('messages') const message = await messageService.get('test') console.log(message) messageService.on('created', (message: Message) => { console.log('Created a todo') }) ```
Note that a server side `app.service(path)` only allows the original service name (e.g. `app.service(':userId/messages')`) and does not parse placeholders. To get a service with route paramters use [.lookup](#lookuppath)
## .lookup(path) `app.lookup(path)` allows to look up a full path and will return the `data` (route parameters) and `service` **on the server**. ```ts const lookup = app.lookup('messages/4321') // lookup.service -> app.service('messages') // lookup.data -> { __id: '4321' } // `lookup.dta` needs to be passed as `params.route` lookup.service.find({ route: lookup.data }) ``` Case insensitive lookups can be enabled in the `app` file like this: ```ts app.routes.caseSensitive = false ``` ## .hooks(hooks) `app.hooks(hooks) -> app` allows registration of application-level hooks. For more information see the [application hooks section in the hooks chapter](./hooks.md#application-hooks). ## .publish([event, ] publisher) `app.publish([event, ] publisher) -> app` registers a global event publisher. For more information see the [channels publishing](./channels.md#publishing) chapter. ## .configure(callback) `app.configure(callback) -> app` runs a `callback` function that gets passed the application object. It is used to initialize plugins and can be used to separate your application into different files. ```ts const setupService = (app: Application) => { app.use('/todos', todoService) } app.configure(setupService) ``` ## .setup([server]) `app.setup([server]) -> Promise` is used to initialize all services by calling each [services .setup(app, path)](services.md#setupapp-path) method (if available). It will also use the `server` instance passed (e.g. through `http.createServer`) to set up SocketIO (if enabled) and any other provider that might require the server instance. You can register [application setup hooks](./hooks.md#setup-and-teardown) to e.g. set up database connections and other things required to be initialized on startup in a certain order. Normally `app.setup` will be called automatically when starting the application via [app.listen([port])](#listen-port) but there are cases (like in tests) when it can be called explicitly. ## .teardown([server]) `app.teardown([server]) -> Promise` can be called to gracefully shut down the application. When the app has been set up with a server (e.g. by calling `app.listen()`) the server will be closed automatically when calling `app.teardown()`. You can also register [application hooks](./hooks.md#setup-and-teardown) on teardown to e.g. close database connection etc. ## .listen(port) `app.listen([port]) -> Promise` starts the application on the given port. It will set up all configured transports (if any) and then run [app.setup(server)](#setup-server) with the server object and then return the server object. `listen` will only be available if a server side transport (REST or websocket) has been configured. ## .set(name, value) `app.set(name, value) -> app` assigns setting `name` to `value`.
`app.set` is global to the application. It is used for storing application wide information like database connection strings etc. **Do not use it for storing request or service specific data.** This can be done by adding data to the [hook context](./hooks.md#hook-context).
```ts import { feathers } from '@feathersjs/feathers' type ServiceTypes = { // Add services path to type mapping here } // app.get and app.set can be typed when initializing the app type Configuration = { port: number } const app = feathers() app.set('port', 3030) app.listen(app.get('port')) ```
On the server, settings are usually initialized using [Feathers configuration](configuration.md).
## .get(name) `app.get(name) -> value` retrieves the setting `name`. ## .on(eventname, listener) Provided by the core [NodeJS EventEmitter .on](https://nodejs.org/api/events.html#events_emitter_on_eventname_listener). Registers a `listener` method (`function(data) {}`) for the given `eventname`. ```js app.on('login', (user) => console.log('Logged in', user)) ``` ## .emit(eventname, data) Provided by the core [NodeJS EventEmitter .emit](https://nodejs.org/api/events.html#events_emitter_emit_eventname_args). ```ts type MyEventData = { message: string } app.emit('myevent', { message: 'Something happened' }) app.on('myevent', (data: MyEventData) => console.log('myevent happened', data)) ```
`app` can not receive or send events to or from clients. A [custom service](./services.md) should be used for that.
## .removeListener(eventname) Provided by the core [NodeJS EventEmitter .removeListener](https://nodejs.org/api/events.html#events_emitter_removelistener_eventname_listener). Removes all or the given listener for `eventname`. ## .mixins `app.mixins` contains a list of service mixins. A mixin is a callback (`(service, path, options) => {}`) that gets run for every service that is being registered. Adding your own mixins allows to add functionality to every registered service. ```ts import type { Id } from '@feathersjs/feathers' // Mixins have to be added before registering any services app.mixins.push((service: any, path: string) => { service.sayHello = function () { return `Hello from service at '${path}'` } }) app.use('/todos', { async get(id: Id) { return { id } } }) app.service('todos').sayHello() // -> Hello from service at 'todos' ``` ## .services `app.services` contains an object of all [services](./services.md) keyed by the path they have been registered via `app.use(path, service)`. This allows to return a list of all available service names: ```ts const servicePaths = Object.keys(app.services) servicePaths.forEach((path) => { const service = app.service(path) }) ```
To retrieve services use [app.service(path)](#service-path), not `app.services[path]` directly.
A Feathers [client](client.md) does not know anything about the server it is connected to. This means that `app.services` will _not_ automatically contain all services available on the server. Instead, the server has to provide the list of its services, e.g. through a [custom service](./services.md): ```ts class InfoService { constructor(public app: Application) {} async find() { return { service: Object.keys(this.app.services) } } } app.use('info', new InfoService(app)) ``` ## .defaultService `app.defaultService` can be a function that returns an instance of a new standard service for `app.service(path)` if there isn't one registered yet. By default it throws a `NotFound` error when you are trying to access a service that doesn't exist. ```ts import { MemoryService } from '@feathersjs/memory' // For every `path` that doesn't have a service // Automatically return a new in-memory service app.defaultService = function (path: string) { return new MemoryService() } ``` This is used by the [client transport adapters](./client.md) to automatically register client side services that talk to a Feathers server. ================================================ FILE: docs/api/authentication/client.md ================================================ --- outline: deep --- # Authentication Client [![npm version](https://img.shields.io/npm/v/@feathersjs/authentication-client.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/authentication-client) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/authentication-client/CHANGELOG.md) ``` npm install @feathersjs/authentication-client --save ``` The `@feathersjs/authentication-client` module allows you to easily authenticate a Feathers client against a Feathers server. It is not required, but makes it easier to implement authentication in your client by automatically storing and sending the access token and handling re-authenticating when a websocket disconnects. ## Usage ```ts import { feathers } from '@feathersjs/feathers' import socketio from '@feathersjs/socketio-client' import io from 'socket.io-client' import authentication from '@feathersjs/authentication-client' const socket = io('http://api.feathersjs.com') const app = feathers() // Setup the transport (Rest, Socket, etc.) here app.configure(socketio(socket)) // Available options are listed in the "Options" section app.configure(authentication()) ``` ## Options The following options are available for `app.configure(authentication(options))`: - `storage` (default: `localStorage` if available, `MemoryStorage` otherwise) - The storage to store the access token. For React Native use `import { AsyncStorage } from 'react-native'` - `path` (default: '/authentication') - The path of the authentication service - `locationKey` (default: `'access_token'`) - The name of the window hash parameter to parse for an access token from the `window.location`. Usually used by the OAuth flow. - `locationErrorKey` (default: `'error') - The name of the window hash parameter to parse for authentication errors. Usually used by the OAuth flow. - `jwtStrategy` (default: `'jwt'`) - The access token authentication strategy - `storageKey` (default: `'feathers-jwt'`) - Key for storing the token in `storage` - `header` (default: `'Authorization'`) - Name of the accessToken header - `scheme` (default: `'Bearer'`) - The HTTP header scheme - Authentication (default: `AuthenticationClient`) - Allows to provide a [customized authentication client class](#customization)
Verifying or parsing the token on the client usually isn't necessary since the server does that on JWT authentication and returns with the token information but it can still be done manually with the [jwt-decode](https://www.npmjs.com/package/jwt-decode) package.
## app.reAuthenticate([force]) `app.reAuthenticate() -> Promise` will try to authenticate using the access token from the storage or the window location (e.g. after a successful [OAuth](./oauth.md) login). This is normally called to either show your application (when successful) or showing a login page or redirecting to the appropriate OAuth link. ```js try { await app.reAuthenticate() showDashboard() } catch (error) { showLoginPage() } ```
`app.reAuthenticate()` has to be called when you want to use the token from storage. **There is no need to call it more than once**, so you’d typically only do it once when the application initializes. When successful, all subsequent requests will send their authentication information automatically.
In some rare cases, for example making sure the user object returned by `app.get('authentication')` is up-to-date after it was changed on the server, you may force reauthentication via `app.reAuthenticate(true)`. ## app.authenticate(data) `app.authenticate(data) -> Promise` will try to authenticate with a Feathers server by passing a `strategy` and other properties as credentials. ```ts try { // Authenticate with the local email/password strategy await app.authenticate({ strategy: 'local', email: 'my@email.com', password: 'my-password' }) // Show e.g. logged in dashboard page } catch (error: any) { // Show login page (potentially with `e.message`) console.error('Authentication error', e) } ``` - `data {Object}` - of the format `{strategy [, ...otherProps]}` - `strategy {String}` - the name of the strategy to be used to authenticate. Required. - `...otherProps {Properties} ` vary depending on the chosen strategy. Above is an example of using the `local` strategy. ## app.logout() Removes the access token from storage on the client. It also calls the `remove` method of the [authentication service](./service.md). ## app.get('authentication') `app.get('authentication') -> Promise` is a Promise that resolves with the current authentication information. For most strategies this is the best place to **get the currently authenticated user**: ```js // Returns the authenticated user const { user } = await app.get('authentication') // Gets the authenticated accessToken (JWT) const { accessToken } = await app.get('authentication') ``` ## app.authentication Returns the instance of the [AuthenticationClient](#authenticationclient). ## AuthenticationClient ### service `app.authentication.service` returns an instance of the authentication client service, normally `app.service('authentication')`. ### storage `app.authentication.storage` returns the storage instance (e.g. window.LocalStorage, React Native AsyncStorage or an in-memory store). ### handleSocket(socket) `app.authentication.handleSocket(socket) -> void` makes sure that a websocket real-time connection is always re-authenticated before making any other request. ### getFromLocation(location) `app.authentication.getFromLocation(location) -> Promise` tries to retrieve an access token from `window.location`. This usually means the `access_token` in the hash set by the [OAuth authentication strategy](./oauth.md). ### setAccessToken(token) `app.authentication.setAccessToken(token) -> Promise` sets the access token in the storage (normally `feathers-jwt` in `window.localStorage`). ### getAccessToken() `app.authentication.getAccessToken() -> Promise` returns the access token from `storage`. If not found it will try to get the access token via [getFromLocation()]() or return `null` if neither was successful. ### removeAccessToken() `app.authentication.removeAccessToken() -> Promise` removes the access token from the storage. ### reset() `app.authentication.reset()` resets the authentication state without explicitly logging out. Should not be called directly. ### handleError() `app.authentication.handleError(error, type: 'authenticate'|'logout') -> Promise` handles any error happening in the `authenticate` or `logout` method. By default it removes the access token if the error is a `NotAuthenticate` error. Otherwise it does nothing. ### reAuthenticate(force, strategy?) `app.authentication.reAuthenticate(force = false, strategy) -> Promise` will re-authenticate with the current access token from [app.authentication.getAccessToken()](). If `force` is set to `true` it will always re-authenticate, with the default `false` only when not already authenticated. `strategy` is an optional parameter which defaults to the configured `jwtStrategy`. ### authenticate() The internal method called when using [app.authenticate()](#app-authenticate-data). ### logout() The internal method called when using [app.logout()](#app-logout). ## Customization The [AuthenticationClient]() can be extended to provide custom functionality and then passed during initialization: ```ts import { feathers } from '@feathersjs/feathers' import socketio from '@feathersjs/socketio-client' import io from 'socket.io-client' import authentication, { AuthenticationClient } from '@feathersjs/authentication-client' const socket = io('http://api.feathersjs.com') const app = feathers() class MyAuthenticationClient extends AuthenticationClient { getFromLocation(location) { // Do custom location things here return super.getFromLocation(location) } } // Setup the transport (Rest, Socket, etc.) here app.configure(socketio(socket)) // Pass the custom authentication client class as the `Authentication` option app.configure( authentication({ Authentication: MyAuthenticationClient }) ) ``` ## Hooks The following hooks are added to the client side application automatically (when calling `app.configure(authentication())`). ### authentication Hook that ensures for every request that authentication is completed and successful. It also makes the authentication information available in the client side `params` (e.g. `params.user`). ### populateHeader Adds the appropriate `Authorization` header for any REST request. ================================================ FILE: docs/api/authentication/hook.md ================================================ --- outline: deep --- # Authenticate Hook The `authenticate` hook will use `params.authentication` of the service method call and run [authenticationService.authenticate()](./service.md#authenticate-data-params-strategies). The hook will - Throw an error if the strategy fails - Throw an error if no authentication information is set and it is an external call (`params.provider` is set) or do nothing if it is an internal call (`params.provider` is `undefined`) - If successful, merge `params` with the return value of the authentication strategy For example, a successful [JWT strategy](./jwt.md) authentication will set: ```js params.authentication.payload // The decoded payload params.authentication.strategy === 'jwt' // The strategy name params.user // or params[entity] if entity is not `null` ``` In the following hooks and for the service method call. It can be used as a `before` or `around` [hook](../hooks.md). ## authenticate(...strategies) Check `params.authentication` against a list of authentication strategy names. ```ts import { authenticate } from '@feathersjs/authentication' // Authenticate with `jwt` and `api-key` strategy // using app.service('authentication') as the authentication service app.service('messages').hooks({ around: { all: [authenticate('jwt', 'api-key')] } }) ``` ## authenticate(options) Check `params.authentication` against a list of strategies and specific authentication service. Available `options` are: - `service` - The path to the authentication service - `strategies` - A list of strategy names ```js import { authenticate } from '@feathersjs/authentication' // Authenticate with `jwt` and `api-key` strategy // using app.service('v1/authentication') as the authentication service app.service('messages').hooks({ before: { all: [ authenticate({ service: 'v1/authentication', strategies: ['jwt', 'api-key'] }) ] } }) ``` ================================================ FILE: docs/api/authentication/index.md ================================================ --- outline: deep --- # Authentication Overview The `@feathersjs/authentication` plugins provide a collection of tools for username/password, JWT and OAuth (GitHub, Facebook etc.) authentication as well as custom authentication mechanisms. It consists of the following core modules: - `@feathersjs/authentication` which includes - The [AuthenticationService](./service.md) that allows to register [authentication strategies](./strategy.md) and create and manage access tokens - The [JWTStrategy](./jwt.md) to use JWTs to make authenticated requests - The [authenticate hook](./hook.md) to limit service calls to an authentication strategy. - [Local authentication](./local.md) for local username/password authentication - [OAuth authentication](./oauth.md) for Google, GitHub, Facebook etc. authentication - [The authentication client](./client.md) to use Feathers authentication on the client.
`@feathersjs/authentication` is an abstraction for different authentication mechanisms. It does not handle things like user verification or password reset functionality etc. This can be implemented manually, with the help of libraries like [feathers-authentication-management](https://github.com/feathers-plus/feathers-authentication-management) or a platform like [Auth0](https://auth0.com/).
================================================ FILE: docs/api/authentication/jwt.md ================================================ --- outline: deep --- # JWT Authentication [![npm version](https://img.shields.io/npm/v/@feathersjs/authentication.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/authentication) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/authentication/CHANGELOG.md) ``` npm install @feathersjs/authentication --save ``` The `JWTStrategy` is an [authentication strategy](./strategy.md) included in `@feathersjs/authentication` for authenticating [JSON web tokens (JWT)](https://jwt.io/): ```json { "strategy": "jwt", "accessToken": "" } ``` ## Usage ```ts import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication' import type { Application } from './declarations' declare module './declarations' { interface ServiceTypes { authentication: AuthenticationService } } export const authentication = (app: Application) => { const authentication = new AuthenticationService(app) authentication.register('jwt', new JWTStrategy()) app.use('authentication', authentication) } ``` ## Options Options are set in the [authentication configuration](./service.md#configuration) under the strategy name. Available options are: - `header` (default: `'Authorization'`): The HTTP header containing the JWT - `schemes` (default: `[ 'Bearer', 'JWT' ]`): An array of schemes to support The default settings support passing the JWT through the following HTTP headers: ``` Authorization: Authorization: Bearer Authorization: JWT ``` Options are usually set under the registered name via [Feathers configuration](../configuration.md) in `config/default.json` or `config/.json`: ```json { "authentication": { "jwt": { "header": "X-Auth" } } } ```
Since the default options are what most clients expect for JWT authentication they usually don't need to be customized.
To change the settings for generating and validating a JWT see the [authentication service configuration](./service.md#configuration) ## JwtStrategy ### getEntity(id, params) `jwtStrategy.getEntity(id, params)` returns the entity instance for `id`, usually `entityService.get(id, params)`. It will _not_ be called if `entity` in the [authentication configuration](./service.md#configuration) is set to `null`. ### authenticate(data, params) `jwtStrategy.authenticate(data, params)` will try to verify `data.accessToken` by calling the strategies [authenticationService.verifyAccessToken](./service.md). Returns a promise that resolves with the following format: ```js { [entity], accessToken, authentication: { strategy: 'jwt', payload } } ```
Since the JWT strategy returns an `accessToken` property (the same as the token sent to this strategy), that access token will also be returned by [authenticationService.create](./service.md#create-data-params) instead of creating a new one.
### getEntityQuery(params) Returns the `query` to use when calling `entityService.get` (default: `{}`). ### parse(req, res) Parse the HTTP request headers for JWT authentication information. By default in the `Authorization` header. Returns a promise that resolves with either `null` or data in the form of: ```js { strategy: '', accessToken: '' } ``` ## Customization ```ts import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication' import { LocalStrategy } from '@feathersjs/authentication-local' import type { Application } from './declarations' declare module './declarations' { interface ServiceTypes { authentication: AuthenticationService } } class MyJwtStrategy extends JWTStrategy { // Only allow authenticating activated users async getEntityQuery(params: Params) { return { active: true } } } export default (app: Application) => { const authentication = new AuthenticationService(app) authentication.register('jwt', new MyJwtStrategy()) // ... app.use('authentication', authentication) } ``` ================================================ FILE: docs/api/authentication/local.md ================================================ --- outline: deep --- # Local Authentication [![npm version](https://img.shields.io/npm/v/@feathersjs/authentication-local.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/authentication-local) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/authentication-local/CHANGELOG.md) ``` npm install @feathersjs/authentication-local --save ``` `@feathersjs/authentication-local` provides a `LocalStrategy` for authenticating with a username/email and password combination, e.g. ```json { "strategy": "local", "email": "hello@feathersjs.com", "password": "supersecret" } ``` ## Usage ```ts import { AuthenticationService } from '@feathersjs/authentication' import { LocalStrategy } from '@feathersjs/authentication-local' import type { Application } from './declarations' declare module './declarations' { interface ServiceTypes { authentication: AuthenticationService } } export const authentication = (app: Application) => { const authentication = new AuthenticationService(app) authentication.register('local', new LocalStrategy()) app.use('authentication', authentication) } ``` ## Options Options are set in the [authentication configuration](./service.md#configuration) under the strategy name. Available options are: - `usernameField`: Name of the username field (e.g. `'email'`), may be a nested property (e.g. `'auth.email'`) - `passwordField`: Name of the password field (e.g. `'password'`), may be a nested property (e.g. `'auth.password'`) - `hashSize` (default: `10`): The BCrypt salt length - `errorMessage` (default: `'Invalid login'`): The error message to return on errors - `entityUsernameField` (default: `usernameField`): Name of the username field on the entity if authentication request data and entity field names are different - `entityPasswordField` (default: `passwordField`): Name of the password field on the entity if authentication request data and entity field names are different Options are usually set under the registered name via [Feathers configuration](../configuration.md) in `config/default.json` or `config/.json`: ```json { "authentication": { "local": { "usernameField": "email", "passwordField": "password" } } } ``` ## LocalStrategy
The methods described in this section are intended for [customization](#customization) purposes and internal calls. They usually do not need to be called directly.
### getEntityQuery(query, params) `localStrategy.getEntityQuery(query, params) -> Promise` returns the query for finding the entity. `query` includes the `usernameField` or `entityUsernameField` as `{ [field]: username }` and by default returns a promise that resolves with `{ $limit: 1 }` combined with `query`. ### findEntity(username, params) `localStrategy.findEntity(username, params) -> Promise` return the entity for a given username and service call parameters. It will use the query returned by `getEntityQuery` and call `.find` on the entity (usually `/users`) service. It will return a promise that resolves with the first result of the `.find` call or throw an error if nothing was found. ### getEntity(entity, params) `localStrategy.getEntity(authResult, params) -> Promise` returns the external representation for `entity` that will be sent back to the client. ### hashPassword(password) `localStrategy.hashPassword(password) -> Promise` creates a safe one-way hash of the given plain `password` string. By default [bCryptJS](https://www.npmjs.com/package/bcryptjs) is used. ### comparePassword(entity, password) `localStrategy.comparePassword(entity, password) -> Promise` compares a plain text `password` with the hashed password of the `entity` returned by `findEntity`. Returns the `entity` or throws an error if the passwords don't match. ### authenticate(authentication, params) `localStrategy.authenticate(authentication, params)` is the main endpoint implemented by any [authentication strategy](./strategy.md). It is usually called for authentication requests for this strategy by the [AuthenticationService](./service.md). ## Customization The `LocalStrategy` can be customized like any ES6 class and then registered on the [AuthenticationService](./service.md): ```ts import type { Application, Params, Query } from '@feathersjs/feathers' import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication' import { LocalStrategy } from '@feathersjs/authentication-local' class MyLocalStrategy extends LocalStrategy { async getEntityQuery(query: Query, params: Params) { // Query for use but only include `active` users return { ...query, active: true, $limit: 1 } } } export default (app: Application) => { const authService = new AuthenticationService(app) authService.register('local', new MyLocalStrategy()) // ... app.use('/authentication', authService) } ``` ## Helpers ### Protecting fields As of Feathers v5, external [resolvers](../schema/resolvers.md) using the `schemaHooks.resolveExternal` hook are the preferred method to hide or change fields for external requests. The following will always hide the user password for external responses and events: ```ts import { resolve, schemaHooks } from '@feathersjs/schema' export const userExternalResolver = resolve({ properties: { // The password should never be visible externally password: async () => undefined } }) app.service('users').hooks({ after: { all: [schemaHooks.resolveExternal(userExternalResolver)] } }) ``` ### passwordHash The `passwordHash` utility provides a [property resolver function](../schema/resolvers.md#property-resolvers) that uses a local strategy to securely [hash the password](#hashpassword-password) before storing it in the database. The following options are available: - `strategy` - The name of the local strategy (usually `'local'`) - `service` - The path of the authentication service (will use `app.get('defaultAuthentication')` by default) ```ts export const userDataResolver = resolve({ properties: { password: passwordHash({ strategy: 'local' }) } }) ``` ### hashPassword(field) The `hashPassword` hook is provided for Feathers v4 backwards compatibility but **has been deprecated** in favour of the [passwordHash resolver](#passwordhash). ### protect(...fields) The `protect` hook is provided for Feathers v4 backwards compatibility but **has been deprecated** in favour of [external data resolvers](../schema/resolvers.md). ================================================ FILE: docs/api/authentication/oauth.md ================================================ --- outline: deep --- # OAuth [![npm version](https://img.shields.io/npm/v/@feathersjs/authentication-oauth.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/authentication-oauth) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/authentication-oauth/CHANGELOG.md) ``` npm install @feathersjs/authentication-oauth --save ``` `@feathersjs/authentication-oauth` allows to authenticate with over 180 OAuth providers (Google, Facebook, GitHub etc.) using [grant](https://github.com/simov/grant), an OAuth middleware module for NodeJS. ## Usage The following section covers oAuth authentication strategy [setup](#setup) and a more detailed description of the possible oAuth [flows](#flow) and [oAuth URLs](#oauth-urls). ### Setup The following is a standard oAuth setup. The `OAuthStrategy` often needs to be [customized](#customization) to include additional fields (like the avatar, email address or username) from the oAuth provider. ```ts import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication' import { LocalStrategy } from '@feathersjs/authentication-local' import { OAuthStrategy, oauth } from '@feathersjs/authentication-oauth' import type { Application } from './declarations' declare module './declarations' { interface ServiceTypes { authentication: AuthenticationService } } export const authentication = (app: Application) => { const authentication = new AuthenticationService(app) authentication.register('jwt', new JWTStrategy()) authentication.register('github', new OAuthStrategy()) authentication.register('google', new OAuthStrategy()) app.use('authentication', authentication) app.configure(oauth({})) } ``` The following settings for `app.configure(oauth())` are available: - `linkStrategy` (default: `'jwt'`) - The name of the stratagy to use for [account linking](#account-linking) - `authService` (default: `app.get('defaultAuthentication')`) - The path of the authentication service to use - `expressSession` - An Express middleware for handling sessions. By default will use an HTTP cookie that is only available for the oAuth flow. **This normally does not need to be changed.** - `koaSession` - A Koa middleware for handling sessions. By default will use an HTTP cookie that is only available for the oAuth flow. **This normally does not need to be changed.** ### Providers For specific OAuth provider setup see the following [cookbook](../../cookbook/) guides: - [Auth0](../../cookbook/authentication/auth0.md) - [Facebook](../../cookbook/authentication/facebook.md) - [Google](../../cookbook/authentication/google.md) ### Flow There are two ways to initiate OAuth authentication: 1. Through the browser (most common) - User clicks on link to OAuth URL (`oauth/`) - Gets redirected to provider and authorizes the application - Callback to the [OauthStrategy](#oauthstrategy) which - Gets the users profile - Finds or creates the user (entity) for that profile - The [AuthenticationService](./service.md) creates an access token for that entity - Redirects back to the origin URL including the generated access token - The frontend (e.g. the Feathers [authentication client](./client.md)) uses the returned access token to authenticate 2. With an existing access token, e.g. obtained through the Facebook mobile SDK - Authenticate normally through the [authentication service](./service.md) with `{ strategy: '', accessToken: 'oauth access token' }`. - Calls the [OauthStrategy](#oauthstrategy) which - Gets the users profile - Finds or creates the entity for that profile - Returns the authentication result
If you are attempting to authenticate using an existing oAuth access token, ensure that you have added the strategy (e.g. 'facebook') to the allowed [authStrategies](./service.md#configuration) configuration.
### OAuth URLs There are two URLs and redirects that are important for OAuth authentication: - `http(s):///oauth/`: The main URL to initiate the OAuth flow. **Link to this from the browser.** - `http(s):///oauth//callback`: The callback path that should be **set in the OAuth provider application settings.** In the browser any OAuth flow can be initiated with a link like this: ```html Login with GitHub ``` ### Account linking To **link an existing user** the current access token can be added to the OAuth flow query using the `feathers_token` query parameter: ```html Login with GitHub ``` This will use the user (entity) of that access token to link the OAuth account to. Using the [authentication client](./client.md) you can get the current access token via `app.get('authentication')`: ```ts const { accessToken } = await app.get('authentication') ``` ### Redirects The recommended way to enable redirects is to set a list of allowed `origins` in your [application configuration](../configuration.md) (e.g. `config/default.json`). This will ensure cross origin restrictions across your application and allow oAuth authentication from different frontend applications. ```js { "origins": [ // Allow redirect to a local development frontend // (e.g. a create-react-app server) and our production URL "http://localhost:500", "https://myapp.feathersjs.com" ] } ``` **Alternatively**, the `redirect` configuration can be used to redirect back to the frontend application after OAuth authentication was successful and an access token for the user has been created by the [authentication service](./service.md) or if authentication failed. It works cross domain and by default includes the access token or error message in the window location hash. The following configuration ```js { "authentication": { "oauth": { "redirect": "https://app.mydomain.com/" } } } ``` A successful oAuth flow will redirect to the origin or redirect URL in the form of `https://app.mydomain.com/#access_token=` or `https://app.mydomain.com/#error=`. Redirects can be customized with the [getRedirect()](#getredirect-data) method of the OAuth strategy. The [authentication client](./client.md) handles the default redirects automatically already.
The redirect is using a hash instead of a query string by default because it is not logged server side and can be easily read on the client. You can force query based redirect by adding a `?` to the end of the `redirect` option.
If the `redirect` option is not set and no origin is available the authentication result data will be sent as JSON instead. Dynamic redirects to the same URL are possible by setting the `redirect` query parameter in the OAuth flow. For example, the following OAuth link: ```html Login with GitHub ``` With the above configuration will redirect to `https://app.mydomain.com/dashboard` after the OAuth flow. ## Options Options are usually set under the registered name via [Feathers configuration](../configuration.md) in `config/default.json` or `config/.json` under the `authentication.oauth` section. Available options are: - `origins` (default: `app.get('origins')`): A list of URLs from which oAuth authentication should be allowed. For example setting this option to`[ "https://feathersjs.com", "https://feathers.cloud" ]` would allow requests from those domains and redirect back to where the request came from. This can be used **instead of** the `redirect` option for a more consisten cross origin configuration via the `app.get('origins')` configuration value and to allow oAuth logins from multiple domains. - `redirect`: The URL of the frontend to redirect to with the access token (or error message). The [authentication client](./client.md) handles those redirects automatically. If not set, the authentication result will be sent as JSON instead. - `defaults`: Default [Grant configuration](https://github.com/simov/grant#configuration) used for all strategies. The following default options are set automatically: - `prefix` (default: `'/oauth'`) - The OAuth base path - `origin` (default: `http(s)://host[:port]`) - The server path for the oAuth flow to redirect back to. Set this if you are e.g. running your local server on HTTPS - `` (e.g. `twitter`): The [Grant configuration](https://github.com/simov/grant#configuration) used for a specific strategy.
Removing the `redirect` option allows to troubleshoot troubleshoot OAuth authentication errors as a JSON response by opening the oAuth URL directly in the browser.
```json { "authentication": { "origins": ["localhost:3030"], "oauth": { "redirect": "/frontend", "google": { "key": "...", "secret": "...", "custom_params": { "access_type": "offline" } }, "twitter": { "key": "...", "secret": "..." } } } } ```
All OAuth strategies will by default always look for configuration under `authentication.oauth.`. If `authentication.oauth` is not set in the configuration, OAuth authentication will be disabled.
Here is a [list of all Grant configuration options](https://github.com/simov/grant#all-available-options) that are available: | Key | Location | Description | | :------------------------- | :------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------- | | request_url | [oauth.json](https://github.com/simov/grant/blob/master/config/oauth.json) | OAuth1/step1 | | authorize_url | [oauth.json](https://github.com/simov/grant/blob/master/config/oauth.json) | OAuth1/step2 or OAuth2/step1 | | access_url | [oauth.json](https://github.com/simov/grant/blob/master/config/oauth.json) | OAuth1/step3 or OAuth2/step2 | | oauth | [oauth.json](https://github.com/simov/grant/blob/master/config/oauth.json) | OAuth version number | | scope_delimiter | [oauth.json](https://github.com/simov/grant/blob/master/config/oauth.json) | string delimiter used for concatenating multiple scopes | | protocol, host, path | `defaults` | used to generate `redirect_uri` | | transport | `defaults` | [transport](#response-data-transport) to use to deliver the response data in your final `callback` route | | state | `defaults` | toggle random `state` string generation for OAuth2 | | key | `[provider]` | OAuth app key, reserved aliases: `consumer_key` and `client_id` | | secret | `[provider]` | OAuth app secret, reserved aliases: `consumer_secret` and `client_secret` | | scope | `[provider]` | list of scopes to request | | custom_params | `[provider]` | custom authorization [parameters](#custom-parameters) and their values | | subdomain | `[provider]` | string to be [embedded](#subdomain-urls) in `request_url`, `authorize_url` and `access_url` | | nonce | `[provider]` | toggle random `nonce` string generation for [OpenID Connect](#openid-connect) providers | | callback | `[provider]` | final callback route on your server to receive the [response data](#response-data) | | dynamic | `[provider]` | allow [dynamic override](#dynamic-override) of configuration | | overrides | `[provider]` | [static overrides](#static-overrides) for a provider | | response | `[provider]` | [limit](#limit-response-data) the response data | | token_endpoint_auth_method | `[provider]` | authentication method for the [token endpoint](#token-endpoint-auth-method) | | name | generated | provider's [name](#grant), used to generate `redirect_uri` | | profile_url | [grant-profile](https://github.com/simov/grant-profile) | The URL to retrieve the user profile from | | [provider] | generated | provider's [name](#grant) as key | | redirect_uri | generated | OAuth app [redirect URI](#redirect-uri), generated using `protocol`, `host`, `path` and `name` | ## OAuthStrategy ### entityId `oauthStrategy.entityId -> string` returns the name of the id property of the entity. ### getEntityQuery(profile, params) `oauthStrategy.getEntityQuery(profile, params) -> Promise` returns the entity lookup query to find the entity for a profile. By default returns ```js { [`${this.name}Id`]: profile.sub || profile.id } ``` ### getEntityData(profile, entity, params) `oauthStrategy.getEntityData(profile, existing, params) -> Promise` returns the data to either create a new or update an existing entity. `entity` is either the existing entity or `null` when creating a new entity. ### getProfile(data, params) `oauthStrategy.getProfile(data, params) -> Promise` returns the user profile information from the OAuth provider that was used for the login. `data` is the OAuth callback information which normally contains e.g. the OAuth access token. ### getRedirect (data) `oauthStrategy.getRedirect(data) -> Promise` returns the URL to redirect to after a successful OAuth login and entity lookup or creation. By default it redirects to `authentication.oauth.redirect` from the configuration with `#access_token=` added to the end of the URL. The `access_token` hash is e.g. used by the [authentication client](./client.md) to log the user in after a successful OAuth login. The default redirects do work cross domain. ### getAllowedOrigin (params) `oauthStrategy.getAllowedOrigin(params) -> Promise` returns the redirect base URL or throws an error if it is not allowed. ### getCurrentEntity(params) `oauthStrategy.getCurrentEntity(params) -> Promise` returns the currently linked entity for the given `params`. It will either use the entity authenticated by `params.authentication` or return `null`. ### findEntity(profile, params) `oauthStrategy.findEntity(profile, params) -> Promise` finds an entity for a given OAuth profile. Uses `{ [${this.name}Id]: profile.id }` by default. ### createEntity(profile, params) `oauthStrategy.createEntity(profile, params) -> Promise` creates a new entity for the given OAuth profile. Uses `{ [${this.name}Id]: profile.id }` by default. ### updateEntity(entity, profile, params) `oauthStrategy.updateEntity(entity, profile, params) -> Promise` updates an existing entity with the given profile. Uses `{ [${this.name}Id]: profile.id }` by default. ### authenticate(authentication, params) `oauthStrategy.authenticate(authentication, params)` is the main endpoint implemented by any [authentication strategy](./strategy.md). It is usually called for authentication requests for this strategy by the [AuthenticationService](./service.md). ## Customization Normally, any OAuth provider set up in the [configuration](#configuration) will be initialized with the default [OAuthStrategy](#oauthstrategy). The flow for a specific provider can be customized by extending `OAuthStrategy` class and registering it under that name on the [AuthenticationService](./service.md): ```ts import { Application } from '@feathersjs/feathers' import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication' import type { OAuthProfile } from '@feathersjs/authentication' import { OAuthStrategy } from '@feathersjs/authentication-oauth' declare module './declarations' { interface ServiceTypes { authentication: AuthenticationService } } class MyGithubStrategy extends OAuthStrategy { async getEntityData(profile: OAuthProfile) { // Include the `email` from the GitHub profile when creating // or updating a user that logged in with GitHub const baseData = await super.getEntityData(profile) return { ...baseData, email: profile.email } } } export default (app: Application) => { const authentication = new AuthenticationService(app) authentication.register('github', new MyGithubStrategy()) // ... app.use('authentication', authentication) } ``` ================================================ FILE: docs/api/authentication/service.md ================================================ --- outline: deep --- # Authentication Service [![npm version](https://img.shields.io/npm/v/@feathersjs/authentication.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/authentication) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/authentication/CHANGELOG.md) ``` npm install @feathersjs/authentication --save ``` The `AuthenticationService` is a [Feathers service](../services.md) that allows to register different [authentication strategies](./strategy.md) and manage access tokens (using [JSON web tokens (JWT)](https://jwt.io/) by default). This section describes - The [standard setup](#setup) used by the generator - How to [configure](#configuration) authentication and where the configuration should go - The different [authentication flows](#authentication-flows) - The methods available on the authentication service - How to [customize](#customization) the authentication service - The [Events](#events) sent by the authentication service ## Setup The standard setup initializes an [AuthenticationService](#authenticationservice) at the `/authentication` path with a [JWT strategy](./jwt.md), [Local strategy](./local.md) and [OAuth authentication](./oauth.md) (if selected). ```ts import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication' import { LocalStrategy } from '@feathersjs/authentication-local' import type { Application } from './declarations' declare module './declarations' { interface ServiceTypes { authentication: AuthenticationService } } export const authentication = (app: Application) => { const authentication = new AuthenticationService(app) authentication.register('jwt', new JWTStrategy()) authentication.register('local', new LocalStrategy()) app.use('authentication', authentication) } ``` ## Configuration The standard authentication service configuration is normally located in the `authentication` section of a [configuration file](../configuration.md) (default: `config/default.json`).
The authentication service can also be configured dynamically or without Feathers configuration by using [app.set](../application.md#set-name-value), e.g. `app.set('authentication', config)`.
The following options are available: - `secret`: The JWT signing secret. - `service`: The path of the entity service - `authStrategies`: A list of authentication strategy names to allow on this authentication service to create access tokens. - `parseStrategies`: A list of authentication strategies that should be used to parse HTTP requests. Defaults to the same as `authStrategies`. - `entity`: The name of the field that will contain the entity after successful authentication. Will also be used to set `params[entity]` (usually `params.user`) when using the [authenticate hook](./hook). Can be `null` if no entity is used (see [stateless tokens](../../cookbook/authentication/stateless.md)). - `entityId`: The id property of an entity object. Only necessary if the entity service does not have an `id` property (e.g. when using a custom entity service). - `jwtOptions`: All options available for the [node-jsonwebtoken package](https://github.com/auth0/node-jsonwebtoken). An authentication service configuration in `config/default.json` can look like this: ```json { "authentication": { "secret": "CHANGE_ME", "entity": "user", "service": "users", "authStrategies": ["jwt", "local"], "jwtOptions": { "header": { "typ": "access" }, "audience": "https://yourdomain.com", "issuer": "feathers", "algorithm": "HS256", "expiresIn": "1d" } } } ```
`typ` in the `header` options is not a typo, it is part of the [JWT JOSE header specification](https://tools.ietf.org/html/rfc7519#section-5).
Additionally to the above configuration, most [strategies](./strategy.md) will look for their own configuration under the name it was registered. An example can be found in the [local strategy configuration](./local.md#configuration). ## Authentication flows Below are the flows how the authentication service can be used. ### To _create a new JWT_ For any strategy allowed in `authStrategies`, a user can call `app.service('/authentication').create(data)` or `POST /authentication` with `data` as `{ strategy: name, ...loginData }`. Internally authentication will then - Call the strategy `.authenticate` method with `data` - Create a JWT for the entity returned by the strategy - Return the JWT (`accessToken`) and the additional information from the strategy For `local` strategy, the user has to be created before doing auth, otherwise, a 401 `NotAuthenticated` error will be sent. ### To _authenticate an external request_ For any HTTP request and strategy allowed in `parseStrategies` or - if not set - `authStrategies` authentication will: - Call [strategy.parse](./strategy.md#parse-req-res) and set the return value of the first strategy that does not return `null` as `params.authentication` - Verify `params.authentication` using the [authenticate hook](./hook.md) which calls the strategy `.authenticate` method with `params.authentication` as the data - Merge the return value of the strategy with `params` (e.g. setting `params.user`) ### To authenticate _your own service request_ For any service that uses the [authenticate hook](./hook.md) called internally you can set `params.authentication` in the service call which will then: - Verify `params.authentication` using the [authenticate hook](./hook.md) which calls the strategy `.authenticate` method with `params.authentication` as the data - Merge the return value of the strategy with `params` (e.g. setting `params.user`)
You can set `params.authentication` for internal requests on the server but usually setting the entity (`params.user` in most cases) if you already have it available should be preferred. This will avoid the overhead of running authentication again if it has already been done.
## AuthenticationService ### constructor(app [, configKey]) `const authService = new AuthenticationService(app, configKey = 'authentication')` initializes a new authentication service with the [Feathers application](../application.md) instance and a `configKey` which is the name of the configuration property to use via [app.get()](../application.md#get-name) (default: `app.get('authentication')`). Upon initialization it will also update the configuration with the [default settings](#configuration). ### authenticate(data, params, ...strategies) `authService.authenticate(data, params, ...strategies) -> Promise` is the main authentication method and authenticates `data` and `params` against a list of strategies in `strategies`. `data` _must_ always contain a `strategy` property indicating the name of the strategy. If `data.strategy` is not available or not allowed (included in the `strategies` list) a `NotAuthenticated` error will be thrown. Otherwise the result of [strategy.authenticate()](./strategy.md#authenticate-authentication-params) will be returned. ### create(data, params) `authService.create(data, params) -> Promise` runs `authService.authenticate` with `data`, `params` and the list of `strategies` from `authStrategies` in the [configuration](#configuration). As with any other [Feathers service](../services.md), this method will be available to clients, e.g. running a `POST /authentication`. If successful it will create a JWT with the payload taken from [authService.getPayload](#getpayload-authresult-params) and the options from [authService.getTokenOptions](#gettokenoptions-authresult-params). `data` _must_ always contain a valid and allowed `strategy` name. Will emit the [`login` event](#app-on-login). ### remove(id, params) `authService.remove(id, params) -> Promise` should be called with `id` set to `null` or to the authenticated access token. Will verify `params.authentication` and emit the [`logout` event](#app-on-logout) if successful. ### configuration `authService.configuration` returns a copy of current value of `app.get(configKey)` (default: `app.get('authentication')`). This is a deep copy of the configuration and is not intended to be modified. In order to change the configuration, [app.set(configKey)](../application.md#set-name-value) should be used: ```ts const config = app.get('authentication') // Update configuration with a new entity app.set('authentication', { ...config, entity: 'some other entity name' }) ``` ### register(name, strategy) `authService.register(name, strategy)` registers an [authentication strategy](./strategy.md) under `name` and calls the strategy methods `setName`, `setApplication`, `setAuthentication` and `verifyConfiguration` if they are implemented. ### getStrategy(name) `service.getStrategy(name)` returns the authentication strategy registered under `name`. Usually authentication strategies do not need to be used directly. ### getStrategies(...names) `service.getStrategies(...names) -> AuthenticationStrategy[]` returns the [authentication strategies](./strategy.md) that exist for a list of names. The returned array may include `undefined` values if the strategy does not exist. Usually authentication strategies do not need to be used directly. ```js const [localStrategy] = authService.getStrategies('local') ``` ### createAccessToken(payload) `authService.createAccessToken(payload, [options, secret]) -> Promise` creates a new access token. By default it is a [JWT](https://jwt.io/) with `payload`, using [configuration.jwtOptions](#configuration) merged with `options` (optional). It will either use `authService.configuration.secret` or the optional `secret` to sign the JWT. Throws an error if the access token can not be created. ```ts const token = await app.service('authentication').createAccessToken({ permission: 'admin' }) ```
Normally, it is not necessary to call this method directly. Calling [authService.create(data, params)](#create-data-params) using an authentication strategy will take care of creating the correct access token.
### verifyAccessToken(accessToken) `authService.verifyAccessToken(accessToken, [options, secret]) -> Promise` verifies the access token. By default it will try to verify a JWT using `configuration.jwtOptions` merged with `options` (optional). Will either use `configuration.secret` or the optional `secret` to verify the JWT. Returns the encoded payload or throws an error. ### getTokenOptions(authResult, params) `authService.getTokenOptions(authResult, params) -> Promise` returns the options for creating a new access token based on the return value from calling [authService.authenticate()](#authenticate-data-params-strategies). Called internally on [authService.create()](#create-data-params). It will try to set the JWT `subject` to the entity (user) id if it is available which will then be used by the [JWT strategy](./jwt.md) to populate `params[entity]` (usually `params.user`). ### getPayload(authResult, params) `authService.getPayload(authResult, params) -> Promise` returns the access token payload for an authentication result (the return value of [authService.create()](#create-data-params)) and [service call parameters](../services.md#params). Called internally on [.create](#create-data-params). Returns either `params.payload` or an empty object (`{}`). ### parse(req, res, ...strategies) `authService.parse(req, res, ...strategies) -> Promise` parses a [NodeJS HTTP request](https://nodejs.org/api/http.html#http_class_http_incomingmessage) and [HTTP response](https://nodejs.org/api/http.html#http_class_http_serverresponse) for authentication information using `strategies` calling [each strategies `.parse()` method](./strategy.md#parse-req-res) if it is implemented. Will return the value of the first strategy that didn't return `null`. This does _not_ authenticate the request, it will only return authentication information that can be used by `authService.authenticate` or `authService.create`. ### setup(path, app) `authService.setup(path, app)` verifies the [configuration](#configuration) and makes sure that - A `secret` has been set - If `entity` is not `null`, check if the entity service is available and make sure that either the `entityId` configuration or the `entityService.id` property is set. - Register internal hooks to send events and keep real-time connections up to date. All custom hooks should be registered at this time. ## app.get('defaultAuthentication') After registering an authentication service, it will set the `defaultAuthentication` property on the application to its configuration name (`configKey` set in the constructor) if it does not exist. `app.get('defaultAuthentication')` will be used by other parts of Feathers authentication to access the authentication service if it is not otherwise specified. Usually this will be `'authentication'`. ## Customization The `AuthenticationService` can be customized like any other class: ```ts import type { Params } from '@feathersjs/feathers' import type { AuthenticationResult } from '@feathersjs/authentication' import { AuthenticationService } from '@feathersjs/authentication' class MyAuthService extends AuthenticationService { async getPayload(authResult: AuthenticationResult, params: Params) { // Call original `getPayload` first const payload = await super.getPayload(authResult, params) const { user } = authResult if (user && user.permissions) { payload.permissions = user.permissions } return payload } } app.use('/authentication', new MyAuthService(app)) ``` Things to be aware of when extending the authentication service: - When implementing your own `constructor`, always call `super(app, configKey)` - When overriding a method, calling `super.method` and working with its return value is recommended unless you are certain your custom method behaves exactly the same way, otherwise things may no longer work as expected. - When extending `setup`, `super.setup(path, app)` should always be called, otherwise events and real-time connection authentication will no longer work. ## Events For both, `login` and `logout` the event data is `(authenticationResult, params, context) => {}` as follows: - `authResult` is the return value of the `authService.create` or `authService.remove` call. It usually contains the user and access token. - `params` is the service call parameters - `context` is the service methods [hook context](../hooks.md#hook-context) ### app.on('login') `app.on('login', (authenticationResult, params, context) => {})` will be sent after a user logs in. This means, after any successful external call to [authService.create](#create-data-params).
The `login` event is also sent for e.g. reconnections of websockets and may not always have a corresponding `logout` event. Use the [`disconnect` event](../channels.md#app-on-disconnect) for handling disconnection.
### app.on('logout') `app.on('logout', (authenticationResult, params, context) => {})` will be sent after a user explicitly logs out. This means after any successful external call to [authService.remove](#remove-id-params). ================================================ FILE: docs/api/authentication/strategy.md ================================================ --- outline: deep --- # Authentication Strategies An authentication strategy is any object or class that implements at least an [authenticate(data, params)]() method. They can be registered with the AuthenticationService to authenticate service calls and other requests. The following strategies already come with Feathers: - [JWTStrategy](./jwt.md) in `@feathersjs/authentication` - [LocalStrategy](./local.md) in `@feathersjs/authentication-local` - [OAuthStrategy](./oauth.md) in `@feathersjs/authentication-oauth` More details on how to customize existing strategies can be found in their API documentation. This section describes the common methods for all authentication strategies and how a custom authentication strategy can be implemented. ## setName(name) Will be called with the `name` under which the strategy has been [registered on the authentication service](./service.md#register-name-strategy). Does not have to be implemented. ## setApplication(app) Will be called with the [Feathers application](../application.md) instance. Does not have to be implemented. ## setAuthentication(service) Will be called with the [Authentication service](./service.md) this strategy has been registered on. Does not have to be implemented. ## verifyConfiguration() Synchronously verify the configuration for this strategy and throw an error if e.g. required fields are not set. Does not have to be implemented. ## authenticate(authentication, params) Authenticate `authentication` data with additional `params`. `authenticate` should throw a `NotAuthenticated` if it failed or return an authentication result object. ## parse(req, res) Parse a given plain Node HTTP request and response and return `null` or the authentication information it provides. Does not have to be implemented. This is called by the authentication service. See [AuthService.parse](https://dove.feathersjs.com/api/authentication/service.html#parse-req-res-strategies) ## AuthenticationBaseStrategy The `AuthenticationBaseStrategy` class provides a base class that already implements some of the strategy methods below with some common functionality: - [setName](#setname-name) sets `this.name` - [setApplication](#setapplication-app) sets `this.app` - [setAuthentication](#setauthentication-service) sets `this.authentication` - `configuration` getter returns `this.authentication.configuration[this.name]` - `entityService` getter returns the entity (usually `/users`) service from `this.app` ## Examples Examples for authentication strategies can be found in the [Cookbook](../../cookbook/): - [Anonymous strategy](../../cookbook/authentication/anonymous.md) ================================================ FILE: docs/api/channels.md ================================================ --- outline: deep --- # Channels On a Feathers server with a real-time transport (like [Socket.io](./socketio.md)) configured, event channels determine which connected clients to send [real-time events](./events.md) to and how the sent data should look. This chapter describes: - [Concepts](#concepts) of real-time communication - [An example](#example) channels.js file - [Real-time Connections](#connections) and how to access them - [Channel usage](#channels) and how to retrieve, join and leave channels - [Publishing events](#publishing) to channels
Channels functionality will not be available in the following two scenarios: - When you're making a rest-only API, not using a real-time adapter. - When you're using Feathers on the client. Only server-side Feathers has channel management.
Here are some example logic conditions where channels are useful: - Real-time events should only be sent to authenticated users - Users should only get updates about messages from chat rooms they joined - Only users in the same organization should receive real-time updates about their data changes - Only admins should be notified when new users are created - When a user is created, modified or removed, non-admins should only receive a "safe" version of the user object (e.g. only `email`, `id` and `avatar`) ## Concepts A **_channel_** is basically an array of **_connection_** objects. Each array is explicitly given a name. When using a real-time server transport and a new client connects, you can tell the server to explicitly add that client's connection object to any relevant channels. Any connection in a channel will receive all events that are sent to that channel. This allows clients to receive only their intended messages. When using a real-time transport, the server pushes events (such as "created", "removed" etc. for a particular service) down to its clients. Using channels allows customizing which clients should receive each event. The client doesn’t subscribe to individual channels, directly, but rather subscribes to specific events like `created`, `patched`, custom events, etc, in which they are interested. Those events will only fire for a client if the server pushes data to one a channel to which the client has been added. You can have any number of channels. This helps to organise how data is sent and to control the volume of data, by not sending things that aren't relevant. The server can also change connection channel membership from time to time, eg. before vs after login. The server needs to explicitly **publish** channels it is interested in sharing with clients before they become available. ## Example The example below shows a `channels.js` file illustrating how the different parts fit together: ```ts import type { RealTimeConnection, Params } from '@feathersjs/feathers' import type { Application, HookContext } from './declarations' export default function (app: any) { if (typeof app.channel !== 'function') { // If no real-time functionality has been configured just return return } app.on('connection', (connection: RealTimeConnection) => { // On a new real-time connection, add it to the anonymous channel app.channel('anonymous').join(connection) }) app.on('login', (AuthenticationResult: any, { connection }: Params) => { // connection can be undefined if there is no // real-time connection, e.g. when logging in via REST if (connection) { // The connection is no longer anonymous, remove it app.channel('anonymous').leave(connection) // Add it to the authenticated user channel app.channel('authenticated').join(connection) } }) // eslint-disable-next-line no-unused-vars app.publish((data: any, context: HookContext) => { // Here you can add event publishers to channels set up in `channels.js` // To publish only for a specific event use `app.publish(eventname, () => {})` console.log( 'Publishing all events to all authenticated users. See `channels.js` and https://docs.feathersjs.com/api/channels.html for more information.' ) // e.g. to publish all service events to all authenticated users use return app.channel('authenticated') }) } ``` ## Connections A connection is an object that represents a real-time connection. It is the same object as `socket.feathers` in a [Socket.io](./socketio.md#params) middleware. You can add any kind of information to it but most notably, when using [authentication](./authentication/service.md), it will contain the authenticated user. By default it is located in `connection.user` once the client has authenticated on the socket (usually by calling `app.authenticate()` on the [client](./client.md)). We can get access to the `connection` object by listening to `app.on('connection', connection => {})` or `app.on('login', (payload, { connection }) => {})`.
When a connection is terminated it will be automatically removed from all channels.
### app.on('connection') `app.on('connection', connection => {})` is fired every time a new real-time connection is established. This is a good place to add the connection to a channel for anonymous users (in case we want to send any real-time updates to them): ```ts import type { RealTimeConnection } from '@feathersjs/feathers' app.on('connection', (connection: RealTimeConnection) => { // On a new real-time connection, add it to the // anonymous channel app.channel('anonymous').join(connection) }) ``` ### app.on('disconnect') `app.on('disconnect', connection => {})` is fired every time real-time connection is disconnected. This is a good place to to handle disconnections outside of a logout. A connection that is disconnected will always leave all its channels automatically. ### app.on('login') `app.on('login', (authenticationResult, params, context) => {})` is sent by the [AuthenticationService](./authentication/service.md#app-on-login) on successful login. This is a good place to add the connection to channels related to the user (e.g. chat rooms, admin status etc.) ```ts import type { Params } from '@feathersjs/feathers' import type { AuthenticationResult } from '@feathersjs/authentication' app.on('login', (payload: AuthenticationResult, { connection }: Params) => { // connection can be undefined if there is no // real-time connection, e.g. when logging in via REST if (connection) { // The user attached to this connection const { user } = connection // The connection is no longer anonymous, remove it app.channel('anonymous').leave(connection) // Add it to the authenticated user channel app.channel('authenticated').join(connection) // Channels can be named anything and joined on any condition ` // E.g. to send real-time events only to admins use if (user.isAdmin) { app.channel('admins').join(connection) } // If the user has joined e.g. chat rooms user.rooms.forEach((room) => { app.channel(`rooms/${room.id}`).join(connection) }) } }) ``` ### app.on('logout') `app.on('logout', (AuthenticationResult, params, context) => {})` is sent by the [AuthenticationService](./authentication/service.md) on successful logout: ```ts import type { Params } from '@feathersjs/feathers' import type { AuthenticationResult } from '@feathersjs/authentication' app.on('logout', (payload: AuthenticationResult, { connection }: Params) => { if (connection) { // Join the channels a logged out connection should be in app.channel('anonymous').join(connection) } }) ```
On `logout` the connection will be removed from all existing channels automatically.
## Channels A channel is an object that contains a number of connections. It can be created via `app.channel` and allows a connection to join or leave it. ### app.channel(...names) `app.channel(name) -> Channel`, when given a single name, returns an existing or new named channel: ```ts app.channel('admins') // the admin channel app.channel('authenticated') // the authenticated channel ``` `app.channel(name1, name2, ... nameN) -> Channel`, when given multiples names, will return a combined channel. A combined channel contains a list of all connections (without duplicates) and re-directs `channel.join` and `channel.leave` calls to all its child channels. ```ts // Combine the anonymous and authenticated channel const combinedChannel = app.channel('anonymous', 'authenticated') // Join the `anonymous` and `authenticated` channel combinedChannel.join(connection) // Join the `admins` and `chat` channel app.channel('admins', 'chat').join(connection) // Leave the `admins` and `chat` channel app.channel('admins', 'chat').leave(connection) // Make user with `_id` 5 leave the admins and chat channel app.channel('admins', 'chat').leave((connection) => { return connection.user._id === 5 }) ``` ### app.channels `app.channels -> [string]` returns a list of all existing channel names. ```ts app.channel('authenticated') app.channel('admins', 'users') app.channels // [ 'authenticated', 'admins', 'users' ] app.channel(app.channels) // will return a channel with all connections ``` This is useful to e.g. remove a connection from all channels: ```ts import type { RealTimeConnection } from '@feathersjs/feathers' // When a user is removed, make all their connections leave every channel app.service('users').on('removed', (user: User) => { app.channel(app.channels).leave((connection: RealTimeConnection) => { return user._id === connection.user._id }) }) ``` ### channel.join(connection) `channel.join(connection) -> Channel` adds a connection to this channel. If the channel is a combined channel, add the connection to all its child channels. If the connection is already in the channel it does nothing. Returns the channel object. ```ts import type { Params } from '@feathersjs/feathers' import type { AuthenticationResult } from '@feathersjs/authentication' app.on('login', (payload: AuthenticationResult, { connection }: Params) => { if (connection && connection.user.isAdmin) { // Join the admins channel app.channel('admins').join(connection) // Calling a second time will do nothing app.channel('admins').join(connection) } }) ``` ### channel.leave(connection|fn) `channel.leave(connection|fn) -> Channel` removes a connection from this channel. If the channel is a combined channel, remove the connection from all its child channels. Also allows to pass a callback that is run for every connection and returns if the connection should be removed or not. Returns the channel object. ```ts import type { RealTimeConnection } from '@feathersjs/feathers' // Make the user with `_id` 5 leave the `admins` channel app.channel('admins').leave((connection: RealTimeConnection) => { return connection.user._id === 5 }) ``` ### channel.filter(fn) `channel.filter(fn) -> Channel` returns a new channel filtered by a given function which gets passed the connection. ```ts import type { RealTimeConnection } from '@feathersjs/feathers' // Returns a new channel with all connections of the user with `_id` 5 const userFive = app .channel(app.channels) .filter((connection: RealTimeConnection) => connection.user._id === 5) ``` ### channel.send(data) `channel.send(data) -> Channel` returns a copy of this channel with customized data that should be sent for this event. Usually this should be handled by modifying either the service method result or setting client "safe" data in `context.dispatch` but in some cases it might make sense to still change the event data for certain channels. What data will be sent as the event data will be determined by the first available in the following order: 1. `data` from `channel.send(data)` 2. `context.dispatch` 3. `context.result` ```ts import type { RealTimeConnection } from '@feathersjs/feathers' app.on('connection', (connection: RealTimeConnection) => { // On a new real-time connection, add it to the // anonymous channel app.channel('anonymous').join(connection) }) // Send the `users` `created` event to all anonymous // users but use only the name as the payload app.service('users').publish('created', (data: User) => { return app.channel('anonymous').send({ name: data.name }) }) ```
If a connection is in multiple channels (e.g. `users` and `admins`) it will get the data from the _first_ channel that it is in.
### channel.connections `channel.connections -> [ object ]` contains a list of all connections in this channel. ### channel.length `channel.length -> integer` returns the total number of connections in this channel. ## Publishing Publishers are callback functions that return which channel(s) to send an event to. They can be registered at the application and the service level and for all or specific events. A publishing function gets the event data and context object (`(data, context) => {}`) and returns a named or combined channel, an array of channels or `null`. Only one publisher can be registered for one type. Besides the standard [service event names](./events.md#service-events) an event name can also be a [custom event](./events.md#custom-events). `context` is the [hook context object](./hooks.md) from the service call or an object containing `{ path, service, app, result }` for custom events. ### service.publish([event,] fn) `service.publish([event,] fn) -> service` registers a publishing function for a specific service for a specific event or all events if no event name was given. ```ts import { HookContext } from './declarations' import type { Params } from '@feathersjs/feathers' import type { AuthenticationResult } from '@feathersjs/authentication' app.on('login', (payload: AuthenticationResult, { connection }: Params) => { // connection can be undefined if there is no // real-time connection, e.g. when logging in via REST if (connection && connection.user.isAdmin) { app.channel('admins').join(connection) } }) // Publish all messages service events only to its room channel app.service('messages').publish((data: Message, context: HookContext) => { return app.channel(`rooms/${data.roomId}`) }) // Publish the `created` event to admins and the user that sent it app.service('users').publish('created', (data: User, context: HookContext) => { return [ app.channel('admins'), app.channel(app.channels).filter((connection) => connection.user._id === context.params.user._id) ] }) // Prevent all events in the `password-reset` service from being published app.service('password-reset').publish(() => null) ``` ### app.publish([event,] fn) `app.publish([event,] fn) -> app` registers a publishing function for all services for a specific event or all events if no event name was given. ```ts import type { Params } from '@feathersjs/feathers' import type { AuthenticationResult } from '@feathersjs/authentication' app.on('login', (payload: AuthenticationResult, { connection }: Params) => { // connection can be undefined if there is no // real-time connection, e.g. when logging in via REST if (connection) { app.channel('authenticated').join(connection) } }) // Publish all events to all authenticated users app.publish((data: any, context: HookContext) => { return app.channel('authenticated') }) // Publish the `log` custom event to all connections app.publish('log', (data: any, context: HookContext) => { return app.channel(app.channels) }) ``` ### Publisher precedence The first publisher callback found in the following order will be used: 1. Service publisher for a specific event 2. Service publisher for all events 3. App publishers for a specific event 4. App publishers for all events ## Keeping channels updated Since every application will be different, keeping the connections assigned to channels up to date (e.g. if a user joins/leaves a room) is up to you. In general, channels should reflect your persistent application data. This means that it normally isn't necessary for e.g. a user to request to directly join a channel. This is especially important when running multiple instances of an application since channels are only _local_ to the current instance. Instead, the relevant information (e.g. what rooms a user is currently in) should be stored in the database and then the active connections can be re-distributed into the appropriate channels listening to the proper [service events](./events.md). The following example updates all active connections for a given user when the user object (which is assumed to have a `rooms` array being a list of room ids the user has joined) is updated or removed: ```ts import type { RealTimeConnection } from '@feathersjs/feathers' import type { Params } from '@feathersjs/feathers' import type { AuthenticationResult } from '@feathersjs/authentication' // Join a channel given a user and connection const joinChannels = (user: User, connection: RealTimeConnection) => { app.channel('authenticated').join(connection) // Assuming that the chat room/user assignment is stored // on an array of the user user.rooms.forEach((room) => app.channel(`rooms/${roomId}`).join(connection)) } // Get a user to leave all channels const leaveChannels = (user: User) => { app.channel(app.channels).leave((connection) => connection.user._id === user._id) } // Leave and re-join all channels with new user information const updateChannels = (user: User) => { // Find all connections for this user const { connections } = app.channel(app.channels).filter((connection) => connection.user._id === user._id) // Leave all channels leaveChannels(user) // Re-join all channels with the updated user information connections.forEach((connection) => joinChannels(user, connection)) } app.on('login', (payload: AuthenticationResult, { connection }: Params) => { if (connection) { // Join all channels on login joinChannels(connection.user, connection) } }) // On `updated` and `patched`, leave and re-join with new room assignments app.service('users').on('updated', updateChannels) app.service('users').on('patched', updateChannels) // On `removed`, remove the connection from all channels app.service('users').on('removed', leaveChannels) ```
The number active connections is usually one (or none) but unless you prevent it explicitly Feathers is not preventing multiple logins of the same user (e.g. with two open browser windows or on a mobile device).
================================================ FILE: docs/api/client/rest.md ================================================ --- outline: deep --- # REST Client The following chapter describes the use of - [@feathersjs/rest-client](#feathersjsrest-client) as a client side Feathers HTTP API integration - [Direct connection](#http-api) with any other HTTP client ## rest-client [![npm version](https://img.shields.io/npm/v/@feathersjs/client.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/rest-client) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/rest-client/CHANGELOG.md) ``` npm install @feathersjs/rest-client --save ``` `@feathersjs/rest-client` allows to connect to a service exposed through a REST HTTP transport (e.g. with [Koa](../koa.md#rest) or [Express](../express.md#rest)) using [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), [Superagent](https://github.com/ladjs/superagent) or [Axios](https://github.com/mzabriskie/axios).
For directly using a Feathers REST API (via HTTP) without using Feathers on the client see the [HTTP API](#http-api) section.
REST client services do emit `created`, `updated`, `patched` and `removed` events but only _locally for their own instance_. Real-time events from other clients can only be received by using a real-time transport like [Socket.io](./socketio.md).
A client application can only use **a single transport** (e.g. either REST or Socket.io). Using two transports in the same client application is not necessary.
### rest([baseUrl]) REST client services can be initialized by loading `@feathersjs/rest-client` and initializing a client object with a base URL. ```ts import { feathers } from '@feathersjs/feathers' import rest from '@feathersjs/rest-client' const app = feathers() // Connect to the same as the browser URL (only in the browser) const restClient = rest() // Connect to a different URL const restClient = rest('http://feathers-api.com') // Configure an AJAX library (see below) with that client app.configure(restClient.fetch(window.fetch.bind(window))) // Connect to the `http://feathers-api.com/messages` service const messages = app.service('messages') ``` The base URL is relative from where services are registered. That means that - A service at `http://api.feathersjs.com/api/v1/messages` with a base URL of `http://api.feathersjs.com` would be available as `app.service('api/v1/messages')` - A base URL of `http://api.feathersjs.com/api/v1` would be `app.service('messages')`.
In the browser `window.fetch` (which the same as the global `fetch`) has to be passed as `window.fetch.bind(window)` otherwise it will be called with an incorrect context, causing a JavaScript error: `Failed to execute 'fetch' on 'Window': Illegal invocation`.
### params.headers Request specific headers can be through `params.headers` in a service call: ```js app.service('messages').create( { text: 'A message from a REST client' }, { headers: { 'X-Requested-With': 'FeathersJS' } } ) ``` ### params.connection Allows to pass additional options specific to the AJAX library. `params.connection.headers` will be merged with `params.headers`: ```js app.configure(restClient.axios(axios)) app.service('messages').get(1, { connection: { // Axios specific options here } }) ``` ### app.rest `app.rest` contains a reference to the `connection` object passed to `rest().(connection)`. ### Request libraries The Feathers REST client can be used with several HTTP request libraries. #### Fetch The [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) is the recommended way to make client connections since it does not require a third party library on most platforms: ```js // In Node app.configure(restClient.fetch(fetch)) // In modern browsers app.configure(restClient.fetch(window.fetch.bind(window))) ``` Where supported, an [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) can be used to abort fetch requests: ```js const controller = new AbortController() app.configure(restClient.fetch(fetch)) app.service('messages').get(1, { connection: { signal: controller.signal } }) controller.abort() ``` #### Superagent [Superagent](http://visionmedia.github.io/superagent/) currently works with a default configuration: ```ts import superagent from 'superagent' app.configure(restClient.superagent(superagent)) ``` #### Axios [Axios](http://github.com/mzabriskie/axios) currently works with a default configuration: ```js import axios from 'axios' app.configure(restClient.axios(axios)) ``` To use default values for all requests, `axios.create` with [the axios configuration](https://axios-http.com/docs/req_config) can be used: ```js import axios from 'axios' app.configure( restClient.axios( axios.create({ headers: { 'X-Requested-With': 'My-Feathers-Frontend' } }) ) ) ``` ### Custom Methods On the client, [custom service methods](../services.md#custom-methods) registered using the `methods` option when registering the service via `restClient.service()`: ```ts import { feathers } from '@feathersjs/feathers' import type { Params } from '@feathersjs/feathers' import rest from '@feathersjs/rest-client' import type { RestService } from '@feathersjs/rest-client' // `data` and return type of custom method type CustomMethodData = { name: string } type CustomMethodResponse = { acknowledged: boolean } type ServiceTypes = { // The type is a RestService extended with custom methods myservice: RestService & { myCustomMethod(data: CustomMethodData, params: Params): Promise } } const client = feathers() // Connect to the same as the browser URL (only in the browser) const restClient = rest().fetch(window.fetch.bind(window)) // Connect to a different URL const restClient = rest('http://feathers-api.com').fetch(window.fetch.bind(window)) // Configure an AJAX library (see below) with that client client.configure(restClient) // Register a REST client service with all methods listed client.use('myservice', restClient.service('myservice'), { methods: ['find', 'get', 'create', 'update', 'patch', 'remove', 'myCustomMethod'] }) // Then it can be used like other service methods client.service('myservice').myCustomMethod(data, params) ```
Just like on the server _all_ methods you want to use have to be listed in the `methods` option.
### Connecting to multiple servers It is possible to instantiate and use individual services pointing to different servers by calling `rest('server').().service(name)`: ```ts import { feathers } from '@feathersjs/feathers' import rest from '@feathersjs/rest-client' const app = feathers() const client1 = rest('http://feathers-api.com').fetch(window.fetch.bind(window)) const client2 = rest('http://other-feathers-api.com').fetch(window.fetch.bind(window)) // With additional options to e.g. set authentication information const client2 = rest('http://other-feathers-api.com').fetch(window.fetch.bind(window), { headers: { Authorization: 'Bearer ' } }) // Configuring this will initialize default services for http://feathers-api.com app.configure(client1) // Connect to the `http://feathers-api.com/messages` service const messages = app.service('messages') // Register /users service that points to http://other-feathers-api.com/users app.use('users', client2.service('users')) const users = app.service('users') ```
If the authentication information is different, it needs to be set as an option as shown above or via `params.headers` when making the request.
### Extending rest clients This can be useful if you e.g. wish to override how the query is transformed before it is sent to the API. ```ts import type { Query } from '@feathersjs/feathers' import { FetchClient } from '@feathersjs/rest-client' import qs from 'qs' class CustomFetch extends FetchClient { getQuery(query: Query) { if (Object.keys(query).length !== 0) { const queryString = qs.stringify(query, { strictNullHandling: true }) return `?${queryString}` } return '' } } app.configure(restClient.fetch(fetch, CustomFetch)) ``` ## HTTP API You can communicate with a Feathers REST API using any other HTTP REST client. The following section describes what HTTP method, body and query parameters belong to which service method call. All query parameters in a URL will be set as `params.query` on the server. Other service parameters can be set through [hooks](../hooks.md) and [Express middleware](../express.md). URL query parameter values will always be strings. Conversion (e.g. the string `'true'` to boolean `true`) on the server is done via [schemas](../schema/index.md) or [hooks](../hooks.md). The body type for `POST`, `PUT` and `PATCH` requests is determined by the request type. You should also make sure you are setting your `Accept` header to `application/json`. Here is the mapping of service methods to REST API calls: | Service method | HTTP method | Path | | -------------- | ----------- | ----------- | | .find() | GET | /messages | | .get() | GET | /messages/1 | | .create() | POST | /messages | | .update() | PUT | /messages/1 | | .patch() | PATCH | /messages/1 | | .remove() | DELETE | /messages/1 | ### Authentication Authenticating HTTP (REST) requests is a two step process. First you have to obtain a JWT from the [authentication service](../authentication/service.md) by POSTing the strategy you want to use: ```json // POST /authentication the Content-Type header set to application/json { "strategy": "local", "email": "your email", "password": "your password" } ``` Here is what that looks like with curl: ```bash curl -H "Content-Type: application/json" -X POST -d '{"strategy":"local","email":"your email","password":"your password"}' http://localhost:3030/authentication ``` Then to authenticate subsequent requests, add the returned `accessToken` to the `Authorization` header as `Bearer `: ```bash curl -H "Content-Type: application/json" -H "Authorization: Bearer " http://localhost:3030/messages ``` For more information see the [authentication API documentation](../). ### find Retrieves a list of all matching resources from the service ``` GET /messages?status=read&user=10 ``` Will call `messages.find({ query: { status: 'read', userId: '10' } })` on the server. If you want to use any of the built-in find operands ($le, $lt, $ne, $eq, $in, etc.) the general format is as follows: ``` GET /messages?field[$operand]=value&field[$operand]=value2 ``` For example, to find the records where field _status_ is not equal to **active** you could do ``` GET /messages?status[$ne]=active ``` The find API allows the use of $limit, $skip, $sort, and $select in the query. These special parameters can be passed directly inside the query object: ``` // Find all messages that are read, limit to 10, only include text field. {"status": "read", "$limit":10, "$select": ["name"] } } // JSON GET /messages?status=read&$limit=10&$select[]=text // HTTP ``` More information about the possible parameters for official database adapters can be found [in the database querying section](../databases/querying.md). ### get Retrieve a single resource from the service. ``` GET /messages/1 ``` Will call `messages.get(1, {})` on the server. ``` GET /messages/1?status=read ``` Will call `messages.get(1, { query: { status: 'read' } })` on the server. ### create Create a new resource with `data` which may also be an array. ``` POST /messages { "text": "I really have to iron" } ``` Will call `messages.create({ "text": "I really have to iron" }, {})` on the server. ``` POST /messages [ { "text": "I really have to iron" }, { "text": "Do laundry" } ] ```
With a [database adapters](../databases/adapters.md) the [`multi` option](../databases/common.md) has to be set explicitly to support creating multiple entries.
### update Completely replace a single or multiple resources. ``` PUT /messages/2 { "text": "I really have to do laundry" } ``` Will call `messages.update(2, { text: 'I really have to do laundry' }, {})` on the server. When no `id` is given by sending the request directly to the endpoint something like: ``` PUT /messages?status=unread { "status": "read" } ``` Will call `messages.update(null, { status: 'read' }, { query: { status: 'unread' } })` on the server. ### patch Merge the existing data of a single or multiple resources with the new `data`. ``` PATCH /messages/2 { "status": "read" } ``` Will call `messages.patch(2, { status: 'read' }, {})` on the server. When no `id` is given by sending the request directly to the endpoint something like: ``` PATCH /messages?status=unread { "status": "read" } ``` Will call `messages.patch(null, { status: 'read' }, { query: { status: 'unread' } })` on the server to change the status for all read messages.
With a [database adapters](../databases/adapters.md) the [`multi` option](../databases/common.md) has to be set to support patching multiple entries.
This is supported out of the box by the Feathers [database adapters](../databases/adapters.md) ### remove Remove a single or multiple resources: ``` DELETE /messages/2 ``` Will call `messages.remove(2, {} })`. When no `id` is given by sending the request directly to the endpoint something like: ``` DELETE /messages?status=archived ``` Will call `messages.remove(null, { query: { status: 'archived' } })` to delete all read messages.
With a [database adapters](../databases/adapters.md) the [`multi` option](../databases/common.md) has to be set to support patching multiple entries.
### Custom methods [Custom service methods](../services.md#custom-methods) can be called directly via HTTP by sending a POST request and setting the `X-Service-Method` header to the method you want to call: ``` POST /messages X-Service-Method: myCustomMethod { "message": "Hello world" } ``` Via CURL: ```bash curl -H "Content-Type: application/json" -H "X-Service-Method: myCustomMethod" -X POST -d '{"message": "Hello world"}' http://localhost:3030/myservice ``` This will call `messages.myCustomMethod({ message: 'Hello world' }, {})`. ### Route placeholders Service URLs can have placeholders, e.g. `users/:userId/messages`. (see in [express](../express.md#params.route) or [koa](../koa.md#params.route)) You can call the client with route placeholders in the `params.route` property: ```ts import { feathers } from '@feathersjs/feathers' import rest from '@feathersjs/rest-client' const app = feathers() // Connect to the same as the browser URL (only in the browser) const restClient = rest() // Connect to a different URL const restClient = rest('http://feathers-api.com') // Configure an AJAX library (see below) with that client app.configure(restClient.fetch(window.fetch.bind(window))) // Connect to the `http://feathers-api.com/messages` service const messages = app.service('users/:userId/messages') // Call the `http://feathers-api.com/users/2/messages` URL messages.find({ route: { userId: 2 } }) ``` This can also be achieved by using the client bundled, sharing several `servicePath` variable exported in the [service shared file](../../guides/cli/service.shared.md#Variables) file. ```ts import rest from '@feathersjs/rest-client' // usersMessagesPath contains 'users/:userId/messages' import { createClient, usersMessagesPath } from 'my-app' const connection = rest('https://myapp.com').fetch(window.fetch.bind(window)) const client = createClient(connection) // Call the `https://myapp.com/users/2/messages` URL client.service(usersMessagesPath).find({ route: { userId: 2 } }) ``` ================================================ FILE: docs/api/client/socketio.md ================================================ --- outline: deep --- # Socket.io Client ## socketio-client [![npm version](https://img.shields.io/npm/v/@feathersjs/client.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/socketio-client) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/socketio-client/CHANGELOG.md) ``` npm install @feathersjs/socketio-client socket.io-client --save ``` The `@feathersjs/socketio-client` module allows to connect to services exposed through the [Socket.io transport](../socketio.md) via a Socket.io socket. We recommend using Feathers and the `@feathersjs/socketio-client` module on the client if possible since it can also handle reconnection and reauthentication. If however, you want to use a direct Socket.io connection without using Feathers on the client, see the [Direct connection](#direct-connection) section.
Socket.io is also used to _call_ service methods. Using sockets for both calling methods and receiving real-time events is generally faster than using [REST](./rest.md). There is therefore no need to use both REST and Socket.io in the same client application.
### socketio(socket) Initialize the Socket.io client using a given socket and the default options. ```ts import { feathers } from '@feathersjs/feathers' import socketio from '@feathersjs/socketio-client' import io from 'socket.io-client' const socket = io('http://api.feathersjs.com') const app = feathers() // Set up Socket.io client with the socket app.configure(socketio(socket)) // Receive real-time events through Socket.io app.service('messages').on('created', (message) => console.log('New message created', message)) // Call the `messages` service app.service('messages').create({ text: 'A message from a REST client' }) ``` ### `app.io` `app.io` contains a reference to the `socket` object passed to `socketio(socket [, options])` ```ts app.io.on('disconnect', (reason: any) => { // Show offline message }) ``` ### Custom Methods On the client, [custom service methods](../services.md#custom-methods) are also registered using the `methods` option when registering the service via `socketClient.service()`: ```ts import { feathers } from '@feathersjs/feathers' import type { Params } from '@feathersjs/feathers' import socketio from '@feathersjs/socketio-client' import type { SocketService } from '@feathersjs/socketio-client' import io from 'socket.io-client' // `data` and return type of custom method type CustomMethodData = { name: string } type CustomMethodResponse = { acknowledged: boolean } type ServiceTypes = { // The type is a Socket service extended with custom methods myservice: SocketService & { myCustomMethod(data: CustomMethodData, params: Params): Promise } } const socket = io('http://api.feathersjs.com') const client = feathers() const socketClient = socketio(socket) // Set up Socket.io client with the socket client.configure(socketClient) // Register a socket client service with all methods listed client.use('myservice', socketClient.service('myservice'), { methods: ['find', 'get', 'create', 'update', 'patch', 'remove', 'myCustomMethod'] }) // Then it can be used like other service methods client.service('myservice').myCustomMethod(data, params) ```
Just like on the server _all_ methods you want to use have to be listed in the `methods` option.
### Route placeholders Service URLs can have placeholders, e.g. `users/:userId/messages`. (see in [express](../express.md#params.route) or [koa](../koa.md#params.route)) You can call the client with route placeholders in the `params.route` property: ```ts import { feathers } from '@feathersjs/feathers' import socketio from '@feathersjs/socketio-client' import io from 'socket.io-client' const socket = io('http://api.feathersjs.com') const app = feathers() // Set up Socket.io client with the socket app.configure(socketio(socket)) // Call `users/2/messages` app.service('users/:userId/messages').find({ route: { userId: 2 } }) ``` This can also be achieved by using the client bundled, sharing several `servicePath` variable exported in the [service shared file](../../guides/cli/service.shared.md#Variables) file. ```ts import rest from '@feathersjs/rest-client' const connection = rest('https://myapp.com').fetch(window.fetch.bind(window)) const client = createClient(connection) // Call the `https://myapp.com/users/2/messages` URL client.service(usersMyMessagesPath).find({ route: { userId: 2 } }) import io from 'socket.io-client' import socketio from '@feathersjs/socketio-client' import { createClient, usersMessagesPath } from 'my-app' const socket = io('http://api.my-feathers-server.com') const connection = socketio(socket) const client = createClient(connection) const messageService = client.service('users/:userId/messages') // Call `users/2/messages` app.service('users/:userId/messages').find({ route: { userId: 2 } }) ``` ## Direct connection Feathers sets up a normal Socket.io server that you can connect to with any Socket.io compatible client, usually the [Socket.io client](http://socket.io/docs/client-api/) either by loading the `socket.io-client` module or `/socket.io/socket.io.js` from the server. Query parameter types do not have to be converted from strings as they do for REST requests.
The socket connection URL has to point to the server root which is where Feathers will set up Socket.io.
```html ``` Service methods can be called by emitting a `` event followed by the service path and method parameters. The service path is the name the service has been registered with (in `app.use`), without leading or trailing slashes. An optional callback following the `function(error, data)` Node convention will be called with the result of the method call or any errors that might have occurred. `params` will be set as `params.query` in the service method call. Other service parameters can be set through a [Socket.io middleware](../socketio.md). If the service path or method does not exist, an appropriate Feathers error will be returned. ### Authentication There are two ways to establish an authenticated Socket.io connection. Either by calling the authentication service or by sending authentication headers. #### Via authentication service Sockets will be authenticated automatically by calling [.create](#create) on the [authentication service](../authentication/service.md): ```ts import io from 'socket.io-client' const socket = io('http://localhost:3030') socket.emit( 'create', 'authentication', { strategy: 'local', email: 'hello@feathersjs.com', password: 'supersecret' }, function (error, authResult) { console.log(authResult) // authResult will be {"accessToken": "your token", "user": user } // You can now send authenticated messages to the server } ) ```
When a socket disconnects and then reconnects, it has to be authenticated again before making any other request that requires authentication. This is usually done with the [jwt strategy](../authentication/jwt.md) using the `accessToken` from the `authResult`. The [authentication client](../authentication/client.md) handles this already automatically.
```js socket.on('connect', () => { socket.emit( 'create', 'authentication', { strategy: 'jwt', accessToken: authResult.accessToken }, function (error, newAuthResult) { console.log(newAuthResult) } ) }) ``` #### Via handshake headers If the authentication strategy (e.g. JWT or API key) supports parsing headers, an authenticated websocket connection can be established by adding the information in the [extraHeaders option](https://socket.io/docs/client-api/#With-extraHeaders): ```ts import io from 'socket.io-client' const socket = io('http://localhost:3030', { extraHeaders: { Authorization: `Bearer ` } }) ```
The authentication strategy needs to be included in the [`authStrategies` configuration](../authentication/service.md#configuration).
### find Retrieves a list of all matching resources from the service ```js socket.emit('find', 'messages', { status: 'read', user: 10 }, (error, data) => { console.log('Found all messages', data) }) ``` Will call `app.service('messages').find({ query: { status: 'read', user: 10 } })` on the server. ### get Retrieve a single resource from the service. ```js socket.emit('get', 'messages', 1, (error, message) => { console.log('Found message', message) }) ``` Will call `app.service('messages').get(1, {})` on the server. ```js socket.emit('get', 'messages', 1, { status: 'read' }, (error, message) => { console.log('Found message', message) }) ``` Will call `app.service('messages').get(1, { query: { status: 'read' } })` on the server. ### create Create a new resource with `data` which may also be an array. ```js socket.emit( 'create', 'messages', { text: 'I really have to iron' }, (error, message) => { console.log('Todo created', message) } ) ``` Will call `app.service('messages').create({ text: 'I really have to iron' }, {})` on the server. ```js socket.emit('create', 'messages', [{ text: 'I really have to iron' }, { text: 'Do laundry' }]) ``` Will call `app.service('messages').create` with the array. ### update Completely replace a single or multiple resources. ```js socket.emit( 'update', 'messages', 2, { text: 'I really have to do laundry' }, (error, message) => { console.log('Todo updated', message) } ) ``` Will call `app.service('messages').update(2, { text: 'I really have to do laundry' }, {})` on the server. The `id` can also be `null` to update multiple resources: ```js socket.emit( 'update', 'messages', null, { status: 'unread' }, { status: 'read' } ) ``` Will call `app.service('messages').update(null, { status: 'read' }, { query: { satus: 'unread' } })` on the server. ### patch Merge the existing data of a single or multiple resources with the new `data`. ```js socket.emit( 'patch', 'messages', 2, { read: true }, (error, message) => { console.log('Patched message', message) } ) ``` Will call `app.service('messages').patch(2, { read: true }, {})` on the server. The `id` can also be `null` to update multiple resources: ```js socket.emit( 'patch', 'messages', null, { status: 'read' }, { status: 'unread' }, (error, message) => { console.log('Patched message', message) } ) ``` Will call `app.service('messages').patch(null, { status: 'read' }, { query: { status: 'unread' } })` on the server, to change the status for all read app.service('messages'). ### remove Remove a single or multiple resources: ```js socket.emit('remove', 'messages', 2, {}, (error, message) => { console.log('Removed a message', message) }) ``` Will call `app.service('messages').remove(2, {})` on the server. The `id` can also be `null` to remove multiple resources: ```js socket.emit('remove', 'messages', null, { status: 'archived' }) ``` Will call `app.service('messages').remove(null, { query: { status: 'archived' } })` on the server to delete all messages with status `archived`. ### Custom methods [Custom service methods](../services.md#custom-methods) can be called directly via Socket.io by sending a `socket.emit(methodName, serviceName, data, query)` message: ```js socket.emit('myCustomMethod', 'myservice', { message: 'Hello world' }, {}, (error, data) => { console.log('Called myCustomMethod', data) }) ``` ### Listening to events Listening to service events allows real-time behaviour in an application. [Service events](../events.md) are sent to the socket in the form of `servicepath eventname`. #### created The `created` event will be published with the callback data, when a service `create` returns successfully. ```ts const socket = io('http://localhost:3030/') socket.on('messages created', (message: Message) => { console.log('Got a new Todo!', message) }) ``` #### updated, patched The `updated` and `patched` events will be published with the callback data, when a service `update` or `patch` method calls back successfully. ```ts const socket = io('http://localhost:3030/') socket.on('my/messages updated', (message: Message) => { console.log('Got an updated Todo!', message) }) socket.emit( 'update', 'my/messages', 1, { text: 'Updated text' }, {}, (error, callback) => { // Do something here } ) ``` #### removed The `removed` event will be published with the callback data, when a service `remove` calls back successfully. ```js const socket = io('http://localhost:3030/') socket.on('messages removed', (message: Message) => { // Remove element showing the Todo from the page $('#message-' + message.id).remove() }) ``` #### Custom events [Custom events](../events.md#custom-events) can be listened to accordingly: ```ts const socket = io('http://localhost:3030/') socket.on('messages myevent', function (data: any) { console.log('Got myevent event', data) }) ``` ================================================ FILE: docs/api/client.md ================================================ --- outline: deep --- # Feathers Client One of the most notable features of Feathers is that it can also be used as the client. In contrast with most other frameworks, it isn't a separate library; instead you get the exact same functionality with a client and on a server. This means you can use [services](./services.md) and [hooks](./hooks.md) and configure plugins. By default, a Feathers client automatically creates services that talk to a Feathers server. In order to connect to a Feathers server, a client creates [Services](./services.md) that use a REST or websocket connection to relay method calls and - for a real-time transport like Socket.io - allow listening to [events](./events.md) on the server. This means the [Feathers application instance](./application.md) is usable the exact same way as on the server. Modules most relevant on the client are: - `@feathersjs/feathers` to initialize a new Feathers [application](./application.md) - [@feathersjs/rest-client](./client/rest.md) to connect to services through REST HTTP provided by [Koa](./koa.md) or [Express](./express.md). - [@feathersjs/socketio-client](./client/socketio.md) to connect to services through [Socket.io](./socketio.md). - [@feathersjs/authentication-client](./authentication/client.md) to authenticate a client
You do not have to use Feathers on the client to connect to a Feathers server. The client [REST client](./client/rest.md) and [Socket.io client](./client/socketio.md) chapters also describe how to use the connection directly without Feathers on the client side.
This chapter describes how to set up Feathers as the client in Node, React Native and in the browser with a module loader like Webpack or Parcel or through a ` ``` ================================================ FILE: docs/api/configuration.md ================================================ --- outline: deep --- # Configuration [![npm version](https://img.shields.io/npm/v/@feathersjs/configuration.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/configuration) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/configuration/CHANGELOG.md) ``` npm install @feathersjs/configuration --save ``` `@feathersjs/configuration` is a wrapper for [node-config](https://github.com/lorenwest/node-config) to make configuration values available via [app.get](./application.md#get-name) which can then be used to configure an application. By default it will look in `config/*` for `default.json`. It will be merged with other configuration files in the `config/` folder using the `NODE_ENV` environment variable. So setting `NODE_ENV=production` will merge `config/default.json` with `config/production.json`. For more information also see the [node-config docs](https://github.com/lorenwest/node-config/wiki/Configuration-Files). ## Usage `app.configure(configuration())` loads the configuration from `node-config` and makes it available via `app.get()`. ```ts import { feathers } from '@feathersjs/feathers' import configuration from '@feathersjs/configuration' // Use the application root and `config/` as the configuration folder const app = feathers().configure(configuration()) // Will return 3030 with `{ "port": 3030 }` in config/default.json app.get('port') ```
Direct access to nested config properties is not supported via `app.get()`. To access a nested config property (e.g. `Customer.dbConfig.host`, use `app.get('Customer').dbConfig.host`.
## Configuration validation `app.configure(configuration(validator))` loads the configuration from `node-config`, makes it available via `app.get()` and validates the original configuration against a [Feathers schema](./schema/) validator when [app.setup](./application.md#setup-server) (or [app.listen](./application.md#listen-port)) is called. ```ts import { feathers } from '@feathersjs/feathers' import { Ajv } from '@feathersjs/schema' import { Type, getValidator } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' import configuration from '@feathersjs/configuration' const configurationSchema = Type.Object( { port: Type.Number(), host: Type.String() }, { $id: 'Configuration', additionalProperties: false } ) const configurationValidator = getValidator(configurationSchema, new Ajv()) type ServiceTypes = {} // Use the schema type for typed `app.get` and `app.set` calls type Configuration = Static // Use the application root and `config/` as the configuration folder const app = feathers().configure(configuration(configurationValidator)) // Configuration will only be validated now app .listen() .then(() => console.log('Server started')) .catch((error) => { // Configuration validation errors will show up here console.log(error.data) }) ``` ## Environment variables As recommended by node-config, it is possible to override the configuration with custom variables by passing a JSON object in the [`NODE_CONFIG` environment variable](https://github.com/lorenwest/node-config/wiki/Environment-Variables#node_config): ``` $ export NODE_CONFIG='{ "port": 8080, "host": "production.app" }' $ node myapp.js ``` Individual environment variables can be used through [Custom Environment Variables](https://github.com/lorenwest/node-config/wiki/Environment-Variables#custom-environment-variables) by creating a `config/custom-environment-variables.json` like this: ```js { "port": "PORT", "mongodb": "MONGOHQ_URL" } ``` ## Configuration directory By default, Feathers will use the `config/` directory in the root of your project’s source directory. To change this, e.g., if you have Feathers installed under the `server/` directory and you want your configuration at `server/config/`, you have to set the `NODE_CONFIG_DIR` environment variable in `app.js` _before_ importing `@feathersjs/configuration`: ``` $ export NODE_CONFIG_DIR=server/config $ node myapp.js ```
The NODE_CONFIG_DIR environment variable isn’t used directly by @feathersjs/configuration but by the [node-config](https://github.com/lorenwest/node-config) module that it uses. For more information on configuring node-config settings, see the [Configuration Files Wiki page](https://github.com/lorenwest/node-config/wiki/Configuration-Files).
================================================ FILE: docs/api/databases/adapters.md ================================================ --- outline: deep --- # Overview Feathers database adapters are modules that provide [services](../services.md) that implement standard [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) functionality for a specific database. They use a [common API](./common.md) for initialization and settings, and they provide a [common query syntax](./querying.md).
[Services](../services.md) allow to implement access to _any_ database or API. The database adapters listed here are just convenience wrappers with a common API. See the community adapters section for support for other datastores.
## Core Adapters The following data storage adapters are available in Feathers core | Core Package | Supported Data Stores | | -------------------- | -------------------------------------------------------------------------------------------------------------- | | [Memory](./memory) | Memory | | [MongoDB](./mongodb) | MongoDB | | [SQL (Knex)](./knex) | MySQL
MariaDB
PostgreSQL
CockroachDB
SQLite
Amazon Redshift
OracleDB
MSSQL | ## Community Adapters There are also many community maintained adapters for other databases and ORMs which can be found on the [Ecosystem page](/ecosystem/?cat=Database&sort=lastPublish). ================================================ FILE: docs/api/databases/common.md ================================================ --- outline: deep --- # Common API The Feathers database adapters implement a common interface for initialization, pagination, extending and querying. This chapter describes the common adapter initialization and options, how to enable and use pagination, the details on how specific service methods behave and how to extend an adapter with custom functionality.
Every database adapter is an implementation of the [Feathers service interface](../services.md). If there is no adapter available for your database of choice, you can still use it directly in a [custom service](../services.md). We recommend being familiar with Feathers services, service events and hooks and the database before using a database adapter.
## Initialization ### `new Service(options)` Each adapter exports a `Service` class that can be exported and extended. ```ts import { NameService } from 'feathers-' app.use('/messages', new NameService()) app.use('/messages', new NameService({ id, events, paginate })) ``` ### Options The following options are available for all database adapters: - `id {string}` (_optional_) - The name of the id field property (usually set by default to `id` or `_id`). - `paginate {Object}` (_optional_) - A [pagination object](#pagination) containing a `default` and `max` page size - `multi {string[]|boolean}` (_optional_, default: `false`) - Allow `create` with arrays and `patch` and `remove` with id `null` to change multiple items. Can be `true` for all methods or an array of allowed methods (e.g. `[ 'remove', 'create' ]`) The following legacy options are still available but should be avoided: - `events {string[]}` (_optional_, **deprecated**) - A list of [custom service events](../events.md#custom-events) sent by this service. Use the `events` option when [registering the service with app.use](../application.md#usepath-service--options) instead. - `operators {string[]}` (_optional_, **deprecated**) - A list of additional non-standard query parameters to allow (e.g `[ '$regex' ]`). Not necessary when using a [query schema](../schema/validators.md#validatequery) - `filters {Object}` (_optional_, **deprecated**) - An object of additional top level query filters, e.g. `{ $populate: true }`. Can also be a converter function like `{ $ignoreCase: (value) => value === 'true' ? true : false }`. Not necessary when using a [query schema](../schema/validators.md#validatequery) For database specific options see the adapter documentation. ## Pagination When initializing an adapter you can set the following pagination options in the `paginate` object: - `default` - Sets the default number of items when `$limit` is not set - `max` - Sets the maximum allowed number of items per page (even if the `$limit` query parameter is set higher) When `paginate.default` is set, `find` will return a _page object_ (instead of the normal array) in the following form: ``` { "total": "", "limit": "", "skip": "", "data": [/* data */] } ``` The pagination options can be set as follows: ```js const service = require('feathers-') // Set the `paginate` option during initialization app.use( '/todos', service({ paginate: { default: 5, max: 25 } }) ) // override pagination in `params.paginate` for this call app.service('todos').find({ paginate: { default: 100, max: 200 } }) // disable pagination for this call app.service('todos').find({ paginate: false }) ```
Disabling or changing the default pagination is not available in the client. Only `params.query` is passed to the server (also see a [workaround here](https://github.com/feathersjs/feathers/issues/382#issuecomment-288125825))
## params.adapter Setting the `adapter` in the [service method `params`](../services.md#params) allows do dynamically modify the database adapter options based on the request. This e.g. allows to temporarily allow multiple entry creation/changes or the pagination settings. ```ts const messages = [ { text: 'message 1' }, { text: 'message 2' } ] // Enable multiple entry insertion for this request app.service('messages').create(messages, { adapter: { multi: true } }) ```
If the adapter has a `Model` option, `params.adapter.Model` can be used to point to different databases based on the request to e.g. allow multi-tenant systems. This is usually done by setting `context.params.adapter` in a [hook](../hooks.md).
## params.paginate Setting `paginate` in the [service method `params`](../services.md#params) allows to change or disable the default pagination for a single request: ```ts // Get all messages as an array const allMessages = await app.service('messages').find({ paginate: false }) ``` ## Extending Adapters There are two ways to extend existing database adapters. Either by extending the base class or by adding functionality through hooks. ### Classes All modules also export an [ES6 class](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes) as `Service` that can be directly extended. See the [Service CLI guide](../../guides/cli/service.class.md) on how to override existing and implement new methods. ## Service methods This section describes specifics on how the [service methods](../services.md) are implemented for all adapters. ### constructor(options) Initializes a new service. Should call `super(options)` when overwritten. ### Methods without hooks The database adapters support calling their service methods without any hooks by adding a `_` in front of the method name as `_find`, `_get`, `_create`, `_patch`, `_update` and `_remove`. This can be useful if you need the raw data from the service and don't want to trigger any of its hooks. ```js // Call `get` without running any hooks const message = await app.service('/messages')._get('') ```
These methods are only available internally on the server, not on the client side and only for the Feathers database adapters. They do _not_ send any events.
### adapter.find(params) `adapter.find(params) -> Promise` returns a list of all records matching the query in `params.query` using the [common querying mechanism](./querying.md). Will either return an array with the results or a page object if [pagination is enabled](#pagination). ```ts // Find all messages for user with id 1 const messages = await app.service('messages').find({ query: { userId: 1 } }) console.log(messages) // Find all messages belonging to room 1 or 3 const roomMessages = await app.service('messages').find({ query: { roomId: { $in: [1, 3] } } }) console.log(roomMessages) ``` Find all messages for user with id 1 ``` GET /messages?userId=1 ``` Find all messages belonging to room 1 or 3 ``` GET /messages?roomId[$in]=1&roomId[$in]=3 ``` ### adapter.get(id, params) `adapter.get(id, params) -> Promise` retrieves a single record by its unique identifier (the field set in the `id` option during initialization). ```ts const message = await app.service('messages').get(1) console.log(message) ``` ``` GET /messages/1 ``` ### adapter.create(data, params) `adapter.create(data, params) -> Promise` creates a new record with `data`. `data` can also be an array to create multiple records. ```ts const message = await app.service('messages').create({ text: 'A test message' }) console.log(message) const messages = await app.service('messages').create([ { text: 'Hi' }, { text: 'How are you' } ]) console.log(messages) ``` ``` POST /messages { "text": "A test message" } ``` ### adapter.update(id, data, params) `adapter.update(id, data, params) -> Promise` completely replaces a single record identified by `id` with `data`. Does not allow replacing multiple records (`id` can't be `null`). `id` can not be changed. ```ts const updatedMessage = await app.service('messages').update(1, { text: 'Updates message' }) console.log(updatedMessage) ``` ``` PUT /messages/1 { "text": "Updated message" } ``` ### adapter.patch(id, data, params) `adapter.patch(id, data, params) -> Promise` merges a record identified by `id` with `data`. `id` can be `null` to allow replacing multiple records (all records that match `params.query` the same as in `.find`). `id` can not be changed. ```ts const patchedMessage = await app.service('messages').patch(1, { text: 'A patched message' }) console.log(patchedMessage) const params = { query: { read: false } } // Mark all unread messages as read const multiPatchedMessages = await app.service('messages').patch( null, { read: true }, params ) ``` ``` PATCH /messages/1 { "text": "A patched message" } ``` Mark all unread messages as read ``` PATCH /messages?read=false { "read": true } ``` ### adapter.remove(id, params) `adapter.remove(id, params) -> Promise` removes a record identified by `id`. `id` can be `null` to allow removing multiple records (all records that match `params.query` the same as in `.find`). ```ts const removedMessage = await app.service('messages').remove(1) console.log(removedMessage) const params = { query: { read: true } } // Remove all read messages const removedMessages = await app.service('messages').remove(null, params) ``` ``` DELETE /messages/1 ``` Remove all read messages ``` DELETE /messages?read=true ``` ================================================ FILE: docs/api/databases/knex.md ================================================ --- outline: deep --- # SQL Databases [![npm version](https://img.shields.io/npm/v/@feathersjs/knex.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/knex) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/knex/CHANGELOG.md) Support for SQL databases like PostgreSQL, MySQL, MariaDB, SQLite or MSSQL is provided in Feathers via the `@feathersjs/knex` database adapter which uses [KnexJS](https://knexjs.org/). Knex is a fast and flexible query builder for SQL and supports many databases without the overhead of a full blown ORM like Sequelize. It still provides an intuitive syntax and more advanced tooling like migration support. ```bash $ npm install --save @feathersjs/knex ```
The Knex adapter implements the [common database adapter API](./common) and [querying syntax](./querying).
## API ### KnexService(options) `new KnexService(options)` returns a new service instance initialized with the given options. The following example extends the `KnexService` and then uses the `sqliteClient` (or relevant client for your SQL database type) from the app configuration and provides it to the `Model` option, which is passed to the new `MessagesService`. ```ts import type { Params } from '@feathersjs/feathers' import { KnexService } from '@feathersjs/knex' import type { KnexAdapterParams, KnexAdapterOptions } from '@feathersjs/knex' import type { Application } from '../../declarations' import type { Messages, MessagesData, MessagesQuery } from './messages.schema' export interface MessagesParams extends KnexAdapterParams {} export class MessagesService extends KnexService< Messages, MessagesData, ServiceParams > {} export const messages = (app: Application) => { const options: KnexAdapterOptions = { paginate: app.get('paginate'), Model: app.get('sqliteClient'), name: 'messages' } app.use('messages', new MessagesService(options)) } ``` ### Options The Knex specific adapter options are: - `Model {Knex}` (**required**) - The KnexJS database instance - `name {string}` (**required**) - The name of the table - `schema {string}` (_optional_) - The name of the schema table prefix (example: `schema.table`) - `tableOptions {only: boolean` (_optional_) - For PostgreSQL only. Argument for passing options to knex db builder. ONLY keyword is used before the tableName to discard inheriting tables' data. (https://knexjs.org/guide/query-builder.html#common) - `extendedOperators {[string]: string}` (_optional_) - A map defining additional operators for the query builder. Example: `{ $fulltext: '@@' }` for PostgreSQL full text search. See [Knex source](https://github.com/knex/knex/blob/master/lib/formatter/wrappingFormatter.js#L10) for operators supported by Knex. The [common API options](./common.md#options) are: - `id {string}` (_optional_, default: `'id'`) - The name of the id field property. By design, Knex will always add an `id` property. - `paginate {Object}` (_optional_) - A [pagination object](#pagination) containing a `default` and `max` page size - `multi {string[]|boolean}` (_optional_, default: `false`) - Allow `create` with arrays and `patch` and `remove` with id `null` to change multiple items. Can be `true` for all methods or an array of allowed methods (e.g. `[ 'remove', 'create' ]`) There are additionally several legacy options in the [common API options](./common.md#options) ### getModel([params]) `service.getModel([params])` returns the [Knex](https://knexjs.org/guide/query-builder.html) client for this table. ### db(params) `service.db([params])` returns the Knex database instance for a request. This will include the `schema` table prefix and use a transaction if passed in `params`. ### createQuery(params) `service.createQuery(params)` returns a query builder for a service request, including all conditions matching the query syntax. This method can be overriden to e.g. [include associations](#associations) or used in a hook customize the query and then passing it to the service call as [params.knex](#paramsknex). ```ts app.service('messages').hooks({ before: { find: [ async (context: HookContext) => { const query = context.service.createQuery(context.params) // do something with query here query.orderBy('name', 'desc') context.params.knex = query } ] } }) ``` ### params.knex When making a [service method](https://docs.feathersjs.com/api/services.html) call, `params` can contain an `knex` property which allows to modify the options used to run the KnexJS query. See [createQuery](#createqueryparams) for an example. ## Querying In addition to the [common querying mechanism](./querying.md), this adapter also supports the following operators. Note that these operators need to be added for each query-able property to the [TypeBox query schema](../schema/typebox.md#query-schemas) or [JSON query schema](../schema/schema.md#querysyntax) like this: ```ts const messageQuerySchema = Type.Intersect( [ // This will additionally allow querying for `{ name: { $ilike: 'Dav%' } }` querySyntax(messageQueryProperties, { name: { $ilike: Type.String() } }), // Add additional query properties here Type.Object({}) ], { additionalProperties: false } ) ``` ### $like Find all records where the value matches the given string pattern. The following query retrieves all messages that start with `Hello`: ```ts app.service('messages').find({ query: { text: { $like: 'Hello%' } } }) ``` Through the REST API: ``` /messages?text[$like]=Hello% ``` ### $notlike The opposite of `$like`; resulting in an SQL condition similar to this: `WHERE some_field NOT LIKE 'X'` ```ts app.service('messages').find({ query: { text: { $notlike: '%bar' } } }) ``` Through the REST API: ``` /messages?text[$notlike]=%bar ``` ### $ilike For PostgreSQL only, the keywork $ilike can be used instead of $like to make the match case insensitive. The following query retrieves all messages that start with `hello` (case insensitive): ```ts app.service('messages').find({ query: { text: { $ilike: 'hello%' } } }) ``` Through the REST API: ``` /messages?text[$ilike]=hello% ``` ## Search Basic search can be implemented with the [query operators](#querying). ## Associations While [resolvers](../schema/resolvers.md) offer a reasonably performant way to fetch associated entities, it is also possible to join tables to populate and query related data. This can be done by overriding the [createQuery](#createqueryparams) method and using the [Knex join methods](https://knexjs.org/guide/query-builder.html#join) to join the tables of related services. ### Querying Considering a table like this: ```ts await db.schema.createTable('todos', (table) => { table.increments('id') table.string('text') table.bigInteger('personId').references('id').inTable('people').notNullable() return table }) ``` To query based on properties from the `people` table, join the tables you need in `createQuery` like this: ```ts class TodoService> extends KnexService { createQuery(params: KnexAdapterParams) { const query = super.createQuery(params) query.join('people as person', 'todos.personId', 'person.id') return query } } ``` This will alias the table name from `people` to `person` (since our Todo only has a single person) and then allow to query all related properties as dot separated properties like `person.name`, including the [Feathers query syntax](./querying.md): ```ts // Find the Todos for all Daves older than 100 app.service('todos').find({ query: { 'person.name': 'Dave', 'person.age': { $gt: 100 } } }) ``` Note that in most applications, the query-able properties have to explicitly be added to the [TypeBox query schema](../schema/typebox.md#query-schemas) or [JSON query schema](../schema/schema.md#querysyntax). Support for the query syntax for a single property can be added with the `queryProperty` helper: ```ts import { queryProperty } from '@feathersjs/typebox' export const todoQueryProperties = Type.Pick(userSchema, ['text']) export const todoQuerySchema = Type.Intersect( [ querySyntax(userQueryProperties), // Add additional query properties here Type.Object( { // Only query the name for strings 'person.name': Type.String(), // Support the query syntax for the age 'person.age': queryProperty(Type.Number()) }, { additionalProperties: false } ) ], { additionalProperties: false } ) ``` ### Populating Related properties from the joined table can be added as aliased properties with [query.select](https://knexjs.org/guide/query-builder.html#select): ```ts class TodoService> extends KnexService { createQuery(params: KnexAdapterParams) { const query = super.createQuery(params) query .join('people as person', 'todos.personId', 'person.id') // This will add a `personName` property .select('person.name as personName') // This will add a `person.age' property .select('person.age') return query } } ```
Since SQL does not have a concept of nested objects, joined properties will be dot separated strings, **not nested objects**. Conversion can be done by e.g. using Lodash `_.set` in a [resolver converter](../schema/resolvers.md#options).
This works well for individual properties, however if you require the complete (and safe) representation of the entire related data, use a [resolver](../schema/resolvers.md) instead. ## Transactions The Knex adapter comes with three hooks that allows to run service method calls in a transaction. They can be used as application wide hooks or per service. To use the transactions feature, you must ensure that the three hooks (start, end and rollback) are being used. At the start of any request, a new transaction will be started. All the changes made during the request to the services that are using knex will use the transaction. At the end of the request, if successful, the changes will be commited. If an error occurs, the changes will be forfeit, all the `creates`, `patches`, `updates` and `deletes` are not going to be commited. The object that contains `transaction` is stored in the `params.transaction` of each request.
If you call another Knex service within a hook and want to share the transaction you will have to pass `context.params.transaction` in the parameters of the service call.
Sometimes it can be important to know when the transaction has been completed (committed or rolled back). For example, we might want to wait for transaction to complete before we send out any realtime events. This can be done by awaiting on the `transaction.committed` promise which will always resolve to either `true` in case the transaction has been committed, or `false` in case the transaction has been rejected. ```ts app.service('messages').publish(async (data, context) => { const { transaction } = context.params if (transaction) { const success = await transaction.committed if (!success) { return [] } } return app.channel(`rooms/${data.roomId}`) }) ``` This also works with nested service calls and nested transactions. For example, if a service calls `transaction.start()` and passes the transaction param to a nested service call, which also calls `transaction.start()` in it's own hooks, they will share the top most `committed` promise that will resolve once all of the transactions have successfully committed. ### Example Transaction Setup We will be using TypeBox schemas throughout, but that is not a requirement. We will have two services `Order` and `ShippingOrder` When we create an `Order` we want to automatically create a `ShippingOrder`, but if `Order` or `ShippingOrder` fail to be created we want to roll everything back and not save either. #### Order Schema ```ts export const orderSchema = Type.Object( { id: Type.String({ format: 'uuid' }), item: Type.String(), address: Type.String(), quantity: Type.Number() }, { $id: 'Order', additionalProperties: false } ) ``` #### Shipping Order Schema ```ts export const shippingOrderSchema = Type.Object( { id: Type.String({ format: 'uuid' }), order_id: Type.String({ format: 'uuid', $schema: 'Order' }), expedited: Type.Boolean(), shipped: Type.Boolean() }, { $id: 'ShippingOrder', additionalProperties: false } ) ``` #### After hook Let's start by adding our logic to automatically create our `ShippingOrder`. In our `order.ts` file we can add this hook ```ts after: { create: [ async (context: HookContext) => { const ourOrder = context.result as Order //Let's not deal with arrays or pagination for now await context.app .service(shippingOrderPath) .create({ expedited: true, shipped: false, order_id: ourOrder.id }) } ] } ``` #### The problem Now that we have our logic in, `Order` will automatically create `ShippingOrder`. But what if something goes wrong and the `Order` is created but `ShippingOrder` isn't. This could cause an order to never be shipped. We can solve this problem in two ways outlined below.
You can emulate an error by throwing an error in the before create hook of your `shipping-order.ts` file ```ts create: [ async () => { throw new Error('Fail') }, schemaHooks.validateData(shippingOrderDataValidator), schemaHooks.resolveData(shippingOrderDataResolver) ] ```
#### Application wide wrapping transaction Using the global hooks in `src/app.ts` we are able to wrap all of our `create`, `update`, and `patch` hooks. ```ts import { transaction } from '@feathersjs/knex' const transactionHandler = async (context: HookContext, next: NextFunction) => { try { console.log('Start our work') await transaction.start()(context) await next() await transaction.end()(context) console.log('Work done') } catch (err) { console.log('Rollback') await transaction.rollback()(context) throw err } } // Register hooks that run on all service methods app.hooks({ around: { create: [transactionHandler], patch: [transactionHandler], update: [transactionHandler], delete: [transactionHandler] } }) ``` What this does is for any `create`/`update`/`patch`/`delete` request, we are starting a transaction that will be available in `context.params.transaction`. Note this does not mean we are done, when a `create` request is made to `Order`, it will have `context.params.transaction` available to it but we have to pass that along to `ShippingOrder` create request. Let's revisit our hook that automatically creates `ShippingOrder` and modify it to pass our transaction with the request. ```ts after: { create: [ async (context: HookContext) => { const ourOrder = context.result as Order await context.app.service(shippingOrderPath).create( { expedited: true, shipped: false, order_id: ourOrder.id }, { transaction: context.params.transaction } // <-- ) } ] } ```
We have to use await here otherwise the transaction will close before the creation is finished. For something like sending an email, you can opt to not await. ```ts context.params.transaction?.committed.then((success: any) => { if (!success) return //Send Email }) ```
### Service wide wrapping transaction The simplest way of doing this is - Add `transaction.start()` in the before create hook. - Add `transaction.end()` in the after create hook. - Add `transaction.rollback()` in the error all hook. ```ts app.service(orderPath).hooks({ around: { // ... }, before: { // ... create: [ schemaHooks.validateData(orderDataValidator), schemaHooks.resolveData(orderDataResolver), transaction.start() ] }, after: { create: [ async (context: HookContext) => { const ourOrder = context.result as Order //Let's not deal with arrays or pagination for now await context.app .service(shippingOrderPath) .create( { expedited: true, shipped: false, order_id: ourOrder.id }, { transaction: context.params.transaction } ) }, transaction.end() ] }, error: { all: [transaction.rollback()] } }) ``` #### Example with around hook When utilizing the around hook, you must pass the context manually. Remember to handle your errors as well, since `around` hooks will not throw into the `error` hook ```ts { around: { create: [ async (context: HookContext, next: NextFunction) => { console.log('Start Work') await transaction.start()(context) try { //We can do any work here, similar to a before hook await next() const ourOrder = context.result as Order await context.app .service(shippingOrderPath) .create( { expedited: true, shipped: false, order_id: ourOrder.id }, { transaction: context.params.transaction } ) console.log('End Work') transaction.end()(context) } catch (err) { console.log('Rollback') transaction.rollback()(context) throw err } } ] } } ``` ## Error handling The adapter only throws [Feathers Errors](https://docs.feathersjs.com/api/errors.html) with the message to not leak sensitive information to a client. On the server, the original error can be retrieved through a secure symbol via `import { ERROR } from '@feathersjs/knex'` ```ts import { ERROR } from 'feathers-knex' try { await knexService.doSomething() } catch (error: any) { // error is a FeathersError with just the message // Safely retrieve the Knex error const knexError = error[ERROR] } ``` ## Migrations In a generated application, migrations are already set up. See the [CLI guide](../../guides/cli/knexfile.md) and the [KnexJS migrations documentation](https://knexjs.org/guide/migrations.html) for more information. ================================================ FILE: docs/api/databases/memory.md ================================================ --- outline: deep --- # Memory Adapter [![npm version](https://img.shields.io/npm/v/@feathersjs/memory.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/memory) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/memory/CHANGELOG.md) `@feathersjs/memory` is a service adatper for in-memory data storage that works on all platforms. It is normally not used to store data on a production server but can be useful for data that isn't persistent and to e.g. cache data in browser or React Native applications. ```bash $ npm install --save @feathersjs/memory ```
The memory adapter implements the [common database adapter API](./common) and [querying syntax](./querying).
## API ### Usage ```ts import { MemoryService } from '@feathersjs/memory' type Message = { id: number text: string } type MessageData = Pick class MyMessageService extends MemoryService {} app.use('messages', new MyMessageService({})) ``` ### Options The following options are available: - `id` (_optional_, default: `'id'`) - The name of the id field property. - `startId` (_optional_, default: `0`) - An id number to start with that will be incremented for every new record (unless it is already set). - `store` (_optional_) - An object with id to item assignments to pre-initialize the data store - `events` (_optional_) - A list of [custom service events](https://docs.feathersjs.com/api/events.html#custom-events) sent by this service - `paginate` (_optional_) - A [pagination object](https://docs.feathersjs.com/api/databases/common.html#pagination) containing a `default` and `max` page size - `allow` (_optional_) - A list of additional query parameters to allow - `multi` (_optional_) - Allow `create` with arrays and `update` and `remove` with `id` `null` to change multiple items. Can be `true` for all methods or an array of allowed methods (e.g. `[ 'remove', 'create' ]`) ================================================ FILE: docs/api/databases/mongodb.md ================================================ --- outline: deep --- # MongoDB [![npm version](https://img.shields.io/npm/v/@feathersjs/mongodb.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/mongodb) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/mongodb/CHANGELOG.md) Support for MongoDB is provided in Feathers via the `@feathersjs/mongodb` database adapter which uses the [MongoDB Client for Node.js](https://www.npmjs.com/package/mongodb). The adapter uses the [MongoDB Aggregation Framework](https://www.mongodb.com/docs/manual/aggregation/), internally, and enables using Feathers' friendly syntax with the full power of [aggregation operators](https://www.mongodb.com/docs/manual/meta/aggregation-quick-reference/). The adapter automatically uses the [MongoDB Query API](https://www.mongodb.com/docs/drivers/node/current/quick-reference/) when you need features like [Collation](https://www.mongodb.com/docs/drivers/node/current/fundamentals/collations/). ```bash $ npm install --save @feathersjs/mongodb ```
The MongoDB adapter implements the [common database adapter API](./common) and [querying syntax](./querying).
## API ### `MongoDBService(options)` `new MongoDBService(options)` returns a new service instance initialized with the given options. The following example extends the `MongoDBService` and then uses the `mongodbClient` from the app configuration and provides it to the `Model` option, which is passed to the new `MessagesService`. ```ts import type { Params } from '@feathersjs/feathers' import { MongoDBService } from '@feathersjs/mongodb' import type { MongoDBAdapterParams, MongoDBAdapterOptions } from '@feathersjs/mongodb' import type { Application } from '../../declarations' import type { Messages, MessagesData, MessagesQuery } from './messages.schema' export interface MessagesParams extends MongoDBAdapterParams {} export class MessagesService extends MongoDBService< Messages, MessagesData, ServiceParams > {} export const messages = (app: Application) => { const options: MongoDBAdapterOptions = { paginate: app.get('paginate'), Model: app.get('mongodbClient').then((db) => db.collection('messages')) } app.use('messages', new MessagesService(options)) } ``` Here's an overview of the `options` object: ### Options MongoDB adapter specific options are: - `Model {Promise}` (**required**) - A Promise that resolves with the MongoDB collection instance. This can also be the return value of an `async` function without `await` - `disableObjectify {boolean}` (_optional_, default `false`) - This will disable conversion of the id field to a MongoDB ObjectID if you want to e.g. use normal strings - `useEstimatedDocumentCount {boolean}` (_optional_, default `false`) - If `true` document counting will rely on `estimatedDocumentCount` instead of `countDocuments` - `disabledOperators {string[]}` (_optional_, default `['$rename']`) - A list of [MongoDB update operators](https://www.mongodb.com/docs/manual/reference/operator/update/) to block in `patch` data. See [Securing update operators](#securing-update-operators) for details. The [common API options](./common.md#options) are: - `id {string}` (_optional_, default: `'_id'`) - The name of the id field property. By design, MongoDB will always add an `_id` property. But you can choose to use a different property as your primary key. - `paginate {Object}` (_optional_) - A [pagination object](#pagination) containing a `default` and `max` page size - `multi {string[]|boolean}` (_optional_, default: `false`) - Allow `create` with arrays and `patch` and `remove` with id `null` to change multiple items. Can be `true` for all methods or an array of allowed methods (e.g. `[ 'remove', 'create' ]`) There are additionally several legacy options in the [common API options](./common.md#options) ### getModel() `getModel([params])` returns a Promise that resolves with the MongoDB collection object. The optional `params` is the service parameters which may allow to override the collection via [params.adapter](./common.md#paramsadapter). ### aggregateRaw(params) The `find` method has been split into separate utilities for converting params into different types of MongoDB requests. When using `params.pipeline`, the `aggregateRaw` method is used to convert the Feathers params into a MongoDB aggregation pipeline with the `model.aggregate` method. This method returns a raw MongoDB Cursor object, which can be used to perform custom pagination or in custom server scripts, if desired. ### findRaw(params) `findRaw(params)` This method is used when there is no `params.pipeline` and uses the common `model.find` method. It returns a raw MongoDB Cursor object, which can be used to perform custom pagination or in custom server scripts, if desired. ### makeFeathersPipeline(params) `makeFeathersPipeline(params)` takes a set of Feathers params and converts them to a pipeline array, ready to pass to `model.aggregate`. This utility comprises the bulk of the `aggregateRaw` functionality, but does not use `params.pipeline`. ### Custom Params The `@feathersjs/mongodb` adapter utilizes three custom params which control adapter-specific features: `params.pipeline`, `params.mongodb`, and `params.adapter`. As mentioned [here](/api/services#params), these custom params are not intended to be used directly from the client. Directly exposing `params.pipeline` or `params.mongodb` to the client directly would expose the entire database to the client through powerful pipeline queries. #### params.adapter Allows to dynamically set the [adapter options](#options) (like the `Model` collection) for a service method call. #### params.pipeline Used for [aggregation pipelines](#aggregation-pipeline). Whenever this property is set, the adapter will use the `model.aggregate` method instead of the `model.find` method. The `pipeline` property should be an array of [aggregation stages](https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/). #### params.mongodb When making a [service method](/api/services.md) call, `params` can contain an`mongodb` property (for example, `{ upsert: true }`) which allows modifying the options used to run the MongoDB query. This param can be used for both find and aggregation queries. ## Transactions [MongoDB Transactions](https://docs.mongodb.com/manual/core/transactions/) can be used by passing a `session` in [params.mongodb](#paramsmongodb). For example in a [hook](../hooks.md): ```ts import { ObjectId } from 'mongodb' import { HookContext } from '../declarations' export const myHook = async (context: HookContext) => { const { app } = context const session = app.get('mongoClient').startSession() try { await session.withTransaction(async () => { const fooData = { message: 'Data for foo' } const barData = { text: 'Data for bar' } await app.service('fooService').create(fooData, { mongodb: { session } }) await app.service('barService').create(barData, { mongodb: { session } }) }) } finally { await session.endSession() } } ``` ## Indexes Indexes and unique constraints can be added to the `Model` Promise, usually in the `getOptions` in `.class`: ```ts export const getOptions = (app: Application): MongoDBAdapterOptions => { return { paginate: app.get('paginate'), Model: app .get('mongodbClient') .then((db) => db.collection('myservice')) .then((collection) => { collection.createIndex({ email: 1 }, { unique: true }) return collection }) } } ```
Note that creating indexes for an existing collection with many entries should be done as a separate operation instead. See the [MongoDB createIndex documentation](https://www.mongodb.com/docs/manual/reference/method/db.collection.createIndex/) for more information.
## Querying Additionally to the [common querying mechanism](./querying.md) this adapter also supports [MongoDB's query syntax](https://www.mongodb.com/docs/manual/tutorial/query-documents/) and the `update` method also supports MongoDB [update operators](https://www.mongodb.com/docs/manual/reference/operator/update/). ## Securing update operators The `patch` method supports MongoDB [update operators](https://www.mongodb.com/docs/manual/reference/operator/update/) like `$push`, `$inc`, and `$unset` in the data payload. While this is powerful, it can be a security risk if patch data from the client is not properly validated. For example, an authenticated user who can patch their own profile could send: ```ts // Escalate privileges by pushing to a roles array await app.service('users').patch(userId, { $push: { roles: 'admin' } }) // Expose internal fields by renaming them await app.service('users').patch(userId, { $rename: { secretField: 'public' } }) ``` ### Schema validation The primary defense is to use [schema validation](../schema/validators.md) on your patch data. When your schema only allows known fields with known types, unexpected operators will be rejected before they reach the database. ### The `disabledOperators` option As an additional layer of defense, the `disabledOperators` option blocks specific update operators from being passed through to MongoDB. By default, `$rename` is blocked. To block additional operators on a service: ```ts new MongoDBService({ Model: app.get('mongodbClient').then((db) => db.collection('users')), disabledOperators: ['$rename', '$unset', '$inc'] }) ``` To override per-call via `params.adapter`: ```ts service.patch(id, data, { adapter: { disabledOperators: ['$rename', '$unset'] } }) ``` To allow all operators (not recommended without schema validation): ```ts new MongoDBService({ Model: app.get('mongodbClient').then((db) => db.collection('messages')), disabledOperators: [] }) ``` ## Search
Note that in a normal application all MongoDB specific operators have to explicitly be added to the [TypeBox query schema](../schema/typebox.md#query-schemas) or [JSON query schema](../schema/schema.md#querysyntax).
There are two ways to perform search queries with MongoDB: - Perform basic Regular Expression matches using the `$regex` filter. - Perform full-text search using the `$search` filter. ### Basic Regex Search You can perform basic search using regular expressions with the `$regex` operator. Here's an example query. ```js { text: { $regex: 'feathersjs', $options: 'igm' }, } ``` ### Full-Text Search See the MongoDB documentation for instructions on performing full-text search using the `$search` operator: - Perform [full-text queries on self-hosted MongoDB](https://www.mongodb.com/docs/manual/core/link-text-indexes/). - Perform [full-text queries on MongoDB Atlas](https://www.mongodb.com/docs/atlas/atlas-search/) (MongoDB's first-party hosted database). - Perform [full-text queries with the MongoDB Pipeline](https://www.mongodb.com/docs/manual/tutorial/text-search-in-aggregation/) ## Aggregation Pipeline In Feathers v5 Dove, we added support for the full power of MongoDB's Aggregation Framework and blends it seamlessly with the familiar Feathers Query syntax. The `find` method automatically uses the aggregation pipeline when `params.pipeline` is set. The Aggregation Framework is accessed through the mongoClient's `model.aggregate` method, which accepts an array of "stages". Each stage contains an operator which describes an operation to apply to the previous step's data. Each stage applies the operation to the results of the previous step. It’s now possible to perform any of the [Aggregation Stages](https://www.mongodb.com/docs/upcoming/reference/operator/aggregation-pipeline/) like `$lookup` and `$unwind`, integration with the normal Feathers queries. Here's how it works with the operators that match the Feathers Query syntax. Let's convert the following Feathers query: ```ts const query = { text: { $regex: 'feathersjs', $options: 'igm' }, $sort: { createdAt: -1 }, $skip: 20, $limit: 10 } ``` The above query looks like this when converted to aggregation pipeline stages: ```ts ;[ // returns the set of records containing the word "feathersjs" { $match: { text: { $regex: 'feathersjs', $options: 'igm' } } }, // Sorts the results of the previous step by newest messages, first. { $sort: { createdAt: -1 } }, // Skips the first 20 records of the previous step { $skip: 20 }, // returns the next 10 records { $limit: 10 } ] ``` ### Pipeline Queries You can use the `params.pipeline` array to append additional stages to the query. This next example uses the `$lookup` operator together with the `$unwind` operator to populate a `user` attribute onto each message based on the message's `userId` property. ```ts const result = await app.service('messages').find({ query: { $sort: { name: 1 } }, pipeline: [ { $lookup: { from: 'users', localField: 'userId', foreignField: '_id', as: 'user' } }, { $unwind: { path: '$user' } } ], paginate: false }) ``` ### Aggregation Stages In the example, above, the `query` is added to the pipeline, first. Then additional stages are added in the `pipeline` option: - The `$lookup` stage creates an array called `user` which contains any matches in `message.userId`, so if `userId` were an array of ids, any matches would be in the `users` array. However, in this example, the `userId` is a single id, so... - The `$unwind` stage turns the array into a single `user` object. The above is like doing a join, but without the data transforming overhead like you'd get with an SQL JOIN. If you have properly applied index to your MongoDB collections, the operation will typically execute extremely fast for a reasonable amount of data. A couple of other notable query stages: - `$graphLookup` lets you recursively pull in a tree of data from a single collection. - `$search` lets you do full-text search on fields All stages of the pipeline happen directly on the MongoDB server. Read through the full list of supported stages [in the MongoDB documentation](https://www.mongodb.com/docs/upcoming/reference/operator/aggregation-pipeline/). ### The `$feathers` Stage The previous section showed how to append stages to a query using `params.pipeline`. Well, `params.pipeline` also supports a custom `$feathers` operator/stage which allows you to specify exactly where in the pipeline the Feathers Query gets injected. ### Example: Proxy Permissions Imagine a scenario where you want to query the `pages` a user can edit by referencing a `permissions` collection to find out which pages the user can actually edit. Each record in the `permissions` record has a `userId` and a `pageId`. So we need to find and return only the pages to which the user has access by calling `GET /pages` from the client. We could put the following query in a hook to pull the correct `pages` from the database in a single query THROUGH the permissions collection. Remember, the request is coming in on the `pages` service, but we're going to query for pages `through` the permissions collection. Assume we've already authenticated the user, so the user will be found at `context.params.user`. ```ts // Assume this query on the client const pages = await app.service('pages').find({ query: {} }) // And put this query in a hook to populate pages "through" the permissions collection const result = await app.service('permissions').find({ query: {}, pipeline: [ // query all permissions records which apply to the current user { $match: { userId: context.params.user._id } }, // populate the pageId onto each `permission` record, as an array containing one page { $lookup: { from: 'pages', localField: 'pageId', foreignField: '_id', as: 'page' } }, // convert the `page` array into an object, so now we have an array of permissions with permission.page on each. { $unwind: { path: '$page' } }, // Add a permissionId to each page { $addFields: { 'page.permissionId': '$_id' } }, // discard the permission and only keep the populated `page`, and bring it top level in the array { $replaceRoot: { newRoot: '$page' } }, // apply the feathers query stages to the aggregation pipeline. // now the query will apply to the pages, since we made the pages top level in the previous step. { $feathers: {} } ], paginate: false }) ``` Notice the `$feathers` stage in the above example. It will apply the query to that stage in the pipeline, which allows the query to apply to pages even though we had to make the query through the `permissions` service. If we were to express the above query with JavaScript, the final result would the same as with the following example: ```ts // perform a db query to get the permissions const permissions = await context.app.service('permissions').find({ query: { userId: context.params.user._id }, paginate: false }) // make a list of pageIds const pageIds = permissions.map((permission) => permission.pageId) // perform a db query to get the pages with matching `_id` const pages = await context.app.service('pages').find({ query: { _id: { $in: pageIds } }, paginate: false }) // key the permissions by pageId for easy lookup const permissionsByPageId = permissions.reduce((byId, current) => { byId[current.pageId] = current return byId }, {}) // Add the permissionId to each `page` record. const pagesWithPermissionId = pages.map((page) => { page.permissionId = permissionByPageId[page._id]._id return page }) // And now apply the original query, whatever the client may have sent, to the pages. // It might require another database query ``` Both examples look a bit complex, but te one using aggregation stages will be much quicker because all stages run in the database server. It will also be quicker because it all happens in a single database query! One more obstacle for using JavaScript this way is that if the user's query changed (from the front end), we would likely be required to edit multiple different parts of the JS logic in order to correctly display results. With the pipeline example, above, the query is very cleanly applied. ## Collation This adapter includes support for [collation and case insensitive indexes available in MongoDB v3.4](https://docs.mongodb.com/manual/release-notes/3.4/#collation-and-case-insensitive-indexes). Collation parameters may be passed using the special `collation` parameter to the `find()`, `remove()` and `patch()` methods. **Example: Patch records with case-insensitive alphabetical ordering** The example below would patch all student records with grades of `'c'` or `'C'` and above (a natural language ordering). Without collations this would not be as simple, since the comparison `{ $gt: 'c' }` would not include uppercase grades of `'C'` because the code point of `'C'` is less than that of `'c'`. ```ts const patch = { shouldStudyMore: true } const query = { grade: { $gte: 'c' } } const collation = { locale: 'en', strength: 1 } const patchedStudent = await students.patch(null, patch, { query, collation }) ``` **Example: Find records with a case-insensitive search** Similar to the above example, this would find students with a grade of `'c'` or greater, in a case-insensitive manner. ```ts const query = { grade: { $gte: 'c' } } const collation = { locale: 'en', strength: 1 } const collatedStudents = await students.find({ query, collation }) ``` For more information on MongoDB's collation feature, visit the [collation reference page](https://docs.mongodb.com/manual/reference/collation/). ## ObjectIds MongoDB uses [ObjectId](https://www.mongodb.com/docs/manual/reference/method/ObjectId/) object as primary keys. To store them in the right format they have to be converted from and to strings. ### AJV keyword To validate and convert strings to an object id using AJV, the `keywordObjectId` [AJV keyword](https://ajv.js.org/api.html#ajv-addkeyword-definition-string-object-ajv) helper can be used. It is set up automatically in a generated application using MongoDB. ```ts import { keywordObjectId } from '@feathersjs/mongodb' const validator = new Ajv() validator.addKeyword(keywordObjectId) ``` ### ObjectIdSchema Both, `@feathersjs/typebox` and `@feathersjs/schema` export an `ObjectIdSchema` helper that creates a schema which can be both, a MongoDB ObjectId or a string that will be converted with the `objectid` keyword: ```ts import { ObjectIdSchema } from '@feathersjs/typebox' // or '@feathersjs/schema' const typeboxSchema = Type.Object({ userId: ObjectIdSchema() }) const jsonSchema = { type: 'object', properties: { userId: ObjectIdSchema() } } ```
The `ObjectIdSchema` helper will only work when the [`objectid` AJV keyword](#ajv-keyword) is registered.
### ObjectId resolvers While the AJV format checks if an object id is valid, it still needs to be converted to the right type. An alternative the the [AJV converter](#ajv-converter) is to use [Feathers resolvers](../schema/resolvers.md). The following [property resolver](../schema/resolvers.md) helpers can be used.
ObjectId resolvers do not need to be used when using the [AJV keyword](#ajv-keyword). They are useful however when using another JSON schema validation library.
#### resolveObjectId `resolveObjectId` resolves a property as an object id. It can be used as a direct property resolver or called with the original value. ```ts import { resolveObjectId } from '@feathersjs/mongodb' export const messageDataResolver = resolve({ properties: { userId: resolveObjectId } }) export const messageDataResolver = resolve({ properties: { userId: async (value, _message, context) => { // If the user is an admin, allow them to create messages for other users if (context.params.user.isAdmin && value !== undefined) { return resolveObjectId(value) } // Otherwise associate the record with the id of the authenticated user return context.params.user._id } } }) ``` #### resolveQueryObjectId `resolveQueryObjectId` allows to query for object ids. It supports conversion from a string to an object id as well as conversion for values from the [$in, $nin and $ne query syntax](./querying.md). ```ts import { resolveQueryObjectId } from '@feathersjs/mongodb' export const messageQueryResolver = resolve({ properties: { userId: resolveQueryObjectId } }) ``` ## Dates While MongoDB has a native `Date` type, the most reliable way to deal with dates is to send and store them as UTC millisecond timestamps e.g. returned by [Date.now()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now) or [new Date().getTime()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime) which is also used in the [Feathers getting started guide](../../guides/basics/generator.md). This has a few advantages: - No conversion between different string types - No timezone and winter/summer time issues - Easier calculations and query-ability ================================================ FILE: docs/api/databases/querying.md ================================================ --- outline: deep --- # Querying All official database adapters support a common way for querying, sorting, limiting and selecting `find` and `get` method calls as part of `params.query`. Querying also applies `update`, `patch` and `remove` method calls.
When used via REST URLs all query values are strings and may need to be converted to the correct type. In a v5 application this is done automatically using [schemas](../schema/index.md).
## Filters Filters are special properties (starting with a `$`) added at the top level of a query. They can determine page settings, the properties to select and more. ### $limit `$limit` will return only the number of results you specify: ```js // Retrieves the first two unread messages app.service('messages').find({ query: { $limit: 2, read: false } }) ``` ``` GET /messages?$limit=2&read=false ```
With [pagination enabled](common.md#pagination), to just get the number of available records set `$limit` to `0`. This will only run a (fast) counting query against the database and return a page object with the `total` and an empty `data` array.
### $skip `$skip` will skip the specified number of results: ```js // Retrieves the next two unread messages app.service('messages').find({ query: { $limit: 2, $skip: 2, read: false } }) ``` ``` GET /messages?$limit=2&$skip=2&read=false ``` ### $sort `$sort` will sort based on the object you provide. It can contain a list of properties by which to sort mapped to the order (`1` ascending, `-1` descending). ```js // Find the 10 newest messages app.service('messages').find({ query: { $limit: 10, $sort: { createdAt: -1 } } }) ``` ``` /messages?$limit=10&$sort[createdAt]=-1 ``` ### $select `$select` allows to pick which fields to include in the result. This will work for any service method. ```js // Only return the `text` and `userId` field in a message app.service('messages').find({ query: { $select: ['text', 'userId'] } }) app.service('messages').get(1, { query: { $select: ['text'] } }) ``` ``` GET /messages?$select[]=text&$select[]=userId GET /messages/1?$select[]=text ``` ### $or Find all records that match any of the given criteria. ```js // Find all messages that are not marked as archived // or any message from room 2 app.service('messages').find({ query: { $or: [{ archived: { $ne: true } }, { roomId: 2 }] } }) ``` ``` GET /messages?$or[0][archived][$ne]=true&$or[1][roomId]=2 ``` ### $and Find all records that match all of the given criteria. ```js // Find all messages that are not marked as archived and in room 2 app.service('messages').find({ query: { $and: [{ archived: { $ne: true } }, { roomId: 2 }] } }) ``` ``` GET /messages?$and[0][archived][$ne]=true&$and[1][roomId]=2 ``` ## Operators Operators either query a property for a specific value or determine nested special properties (starting with a `$`) that allow querying the property for certain conditions. When multiple operators are set, all conditions have to apply for a property to match. ### Equality All fields that do not contain special query parameters are compared directly for equality. ```js // Find all unread messages in room #2 app.service('messages').find({ query: { read: false, roomId: 2 } }) ``` ``` GET /messages?read=false&roomId=2 ``` ### $in, $nin Find all records where the property does (`$in`) or does not (`$nin`) match any of the given values. ```js // Find all messages in room 2 or 5 app.service('messages').find({ query: { roomId: { $in: [2, 5] } } }) ``` ``` GET /messages?roomId[$in][]=2&roomId[$in][]=5 ``` ### $lt, $lte Find all records where the value is less (`$lt`) or less and equal (`$lte`) to a given value. ```js // Find all messages older than a day const DAY_MS = 24 * 60 * 60 * 1000 app.service('messages').find({ query: { createdAt: { $lt: new Date().getTime() - DAY_MS } } }) ``` ``` GET /messages?createdAt[$lt]=1479664146607 ``` ### $gt, $gte Find all records where the value is more (`$gt`) or more and equal (`$gte`) to a given value. ```js // Find all messages within the last day const DAY_MS = 24 * 60 * 60 * 1000 app.service('messages').find({ query: { createdAt: { $gt: new Date().getTime() - DAY_MS } } }) ``` ``` GET /messages?createdAt[$gt]=1479664146607 ``` ### $ne Find all records that do not equal the given property value. ```js // Find all messages that are not marked as archived app.service('messages').find({ query: { archived: { $ne: true } } }) ``` ``` GET /messages?archived[$ne]=true ``` ## Search Searching is not part of the common querying syntax since it is very specific to the database you are using. For built in databases, see the [SQL search](./knex.md#search) and [MongoDb search](./mongodb.md#search) documentation. If you are using [a community supported adapter](/ecosystem/?cat=Database&sort=lastPublish) their documentation may contain additional information on how to implement search functionality. ================================================ FILE: docs/api/errors.md ================================================ --- outline: deep --- # Errors [![npm version](https://img.shields.io/npm/v/@feathersjs/errors.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/errors) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/errors/CHANGELOG.md) ``` npm install @feathersjs/errors --save ``` The `@feathersjs/errors` module contains a set of standard error classes used by all other Feathers modules. ## Examples Here are a few ways that you can use them: ```ts import { NotFound, GeneralError, BadRequest } from '@feathersjs/errors' // If you were to create an error yourself. const notFound = new NotFound('User does not exist') // You can wrap existing errors const existing = new GeneralError(new Error('I exist')) // You can also pass additional data const data = new BadRequest('Invalid email', { email: 'sergey@google.com' }) // You can also pass additional data without a message const dataWithoutMessage = new BadRequest({ email: 'sergey@google.com' }) // If you need to pass multiple errors const validationErrors = new BadRequest('Invalid Parameters', { errors: { email: 'Email already taken' } }) // You can also omit the error message and we'll put in a default one for you const validationErrors = new BadRequest({ errors: { email: 'Invalid Email' } }) ``` ## Feathers errors The following error types, all of which are instances of `FeathersError`, are available: - 400: `BadRequest` - 401: `NotAuthenticated` - 402: `PaymentError` - 403: `Forbidden` - 404: `NotFound` - 405: `MethodNotAllowed` - 406: `NotAcceptable` - 408: `Timeout` - 409: `Conflict` - 411: `LengthRequired` - 422: `Unprocessable` - 429: `TooManyRequests` - 500: `GeneralError` - 501: `NotImplemented` - 502: `BadGateway` - 503: `Unavailable`
All of the Feathers core modules and most plugins and database adapters automatically emit the appropriate Feathers errors for you. For example, most of the database adapters will already send `Conflict` or `Unprocessable` errors on validation errors.
Feathers errors contain the following fields: - `name` - The error name (e.g. "BadRequest", "ValidationError", etc.) - `message` - The error message string - `code` - The HTTP status code - `className` - A CSS class name that can be handy for styling errors based on the error type. (e.g. "bad-request" , etc.) - `data` - An object containing anything you passed to a Feathers error except for the `errors` object and `message`. - `errors` - An object containing whatever was passed to a Feathers error inside `errors`. This is typically validation errors or if you want to group multiple errors together.
To convert a Feathers error back to an object call `error.toJSON()`. A normal `console.log` of a JavaScript Error object will not automatically show those additional properties described above (even though they can be accessed directly).
## Custom errors You can create custom errors by extending from the `FeathersError` class and calling its constructor with `(message, name, code, className, data)`: - `message` - The error message - `name` - The error name (e.g. `MyError`) - `code` - An [HTTP error code](https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) - `className` - The full name of the error class (e.g. `my-error`) - `data` - Additional data to include in the error ```ts import { FeathersError } from '@feathersjs/errors' class UnsupportedMediaType extends FeathersError { constructor(message: string, data: any) { super(message, 'UnsupportedMediaType', 415, 'unsupported-media-type', data) } } const error = new UnsupportedMediaType('Not supported') console.log(error.toJSON()) ``` ## Error Handling It is important to make sure that errors get cleaned up before they go back to the client. [Express error handling middleware](https://docs.feathersjs.com/api/express.html#expresserrorhandler) works only for REST calls. If you want to make sure that ws errors are handled as well, you need to use [application error hooks](hooks.md#application-hooks) which are called on any service call error. Here is an example error handler you can add to app.hooks errors. ```js const errors = require('@feathersjs/errors') const errorHandler = (ctx) => { if (ctx.error) { const error = ctx.error if (!error.code) { const newError = new errors.GeneralError('server error') ctx.error = newError return ctx } if (error.code === 404 || process.env.NODE_ENV === 'production') { error.stack = null } return ctx } } ``` then add it as an [application level](./application.md#hooks-hooks) error hook ```ts app.hooks({ //... error: { all: [errorHandler] } }) ``` ================================================ FILE: docs/api/events.md ================================================ --- outline: deep --- # Events Events are the key part of Feathers real-time functionality. All events in Feathers are provided through the [NodeJS EventEmitter](https://nodejs.org/api/events.html) interface. This section describes - A quick overview of the [NodeJS EventEmitter interface](#eventemitters) - The standard [service events](#service-events) - How to allow sending [custom events](#custom-events) from the server to the client
For more information on how to safely send real-time events to clients, see the [Channels chapter](./channels.md).
## EventEmitters Once registered, any [service](./services.md) gets turned into a standard [NodeJS EventEmitter](https://nodejs.org/api/events.html) and can be used accordingly. ```ts const messages = app.service('messages') // Listen to a normal service event messages.on('patched', (message: Message) => console.log('message patched', message)) // Only listen to an event once messsages.once('removed', (message: Message) => console.log('First time a message has been removed', message)) // A reference to a handler const onCreatedListener = (message: Message) => console.log('New message created', message) // Listen `created` with a handler reference messages.on('created', onCreatedListener) // Unbind the `created` event listener messages.removeListener('created', onCreatedListener) // Send a custom event messages.emit('customEvent', { anything: 'Data can be anything' }) ``` ## Service Events Any service automatically emits `created`, `updated`, `patched` and `removed` events when the respective service method returns successfully. This works on the client as well as on the server. Events are not fired until all [hooks](./hooks.md) have executed. When the client is using [Socket.io](socketio.md), events will be pushed automatically from the server to all connected clients. This is how Feathers does real-time.
To disable sending of events e.g. when updating a large amount of data, set [context.event](./hooks.md#context-event) to `null` in a hook.
Additionally to the event `data`, all events also get the [hook context](./hooks.md) from their method call passed as the second parameter. ### created The `created` event will fire with the result data when a service `create` returns successfully. ```ts import { feathers, type Params, type HookContext } from '@feathersjs/feathers' type Message = { text: string } class MessageService { async create(data: Message) { return data } } const app = feathers<{ messages: MessageService }>() app.use('messages', new MessageService()) // Retrieve the wrapped service object which is also an EventEmitter const messages = app.service('messages') messages.on('created', (message: Message, contexHookContext) => console.log('created', message)) messages.create({ text: 'We have to do something!' }) ``` ### updated, patched The `updated` and `patched` events will fire with the callback data when a service `update` or `patch` method calls back successfully. ```ts import { feathers } from '@feathersjs/feathers' import type { Id, Params, HookContext } from '@feathersjs/feathers' type Message = { text: string } class MessageService { async update(id: Id, data: Message) { return data } async patch(id: Id, data: Message) { return data } } const app = feathers<{ messages: MessageService }>() app.use('messages', new MessageService()) const messages = app.service('my/messages') messages.on('updated', (message: Message, context: HookContext) => console.log('updated', message)) messages.on('patched', (message: Message) => console.log('patched', message)) messages.update(0, { text: 'updated message' }) messages.patch(0, { text: 'patched message' }) ``` ### removed The `removed` event will fire with the callback data when a service `remove` calls back successfully. ```ts import { feathers } from '@feathersjs/feathers' import type { Id, Params, HookContext } from '@feathersjs/feathers' type Message = { text: string } class MessageService { async remove(id: Id, params: Params) { return { id } } } const app = feathers<{ messages: MessageService }>() app.use('messages', new MessageService()) const messages = app.service('messages') messages.on('removed', (message: Message, context: HookContext) => console.log('removed', message)) messages.remove(1) ``` ## Custom events By default, real-time clients will only receive the [standard events](#service-events). However, it is possible to define a list of custom events that should also be sent to the client when registering the service with [app.use](./application.md##use-path-service-options), when `service.emit('customevent', data)` is called on the server. The `context` for custom events won't be a full hook context but just an object containing `{ app, service, path, result }`.
Custom events can only be sent from the server to the client, not the other way (client to server). A [custom service](./services.md) should be used for those cases.
For example, a payment service that sends status events to the client while processing a payment could look like this: ```ts class PaymentService { async create(data: any, params: Params) { const customer = await createStripeCustomer(params.user) this.emit('status', { status: 'created' }) const payment = await createPayment(data) this.emit('status', { status: 'completed' }) return payment } } // Then register it like this: app.use('payments', new PaymentService(), { events: ['status'] }) ``` Using `service.emit` custom events can also be sent in a hook: ```js app.service('payments').hooks({ after: { create(context: HookContext) { context.service.emit('status', { status: 'completed' }) } } }) ``` Custom events can be [published through channels](./channels.md#publishing) just like standard events and listened to it in a [Feathers client](./client.md) or [directly on the socket connection](./client/socketio.md#listening-to-events): ```js client.service('payments').on('status', (data) => {}) // or socket.on('payments status', (data) => {}) ``` ================================================ FILE: docs/api/express.md ================================================ --- outline: deep --- # Express [![npm version](https://img.shields.io/npm/v/@feathersjs/express.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/express) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/express/CHANGELOG.md) ``` npm install @feathersjs/express --save ``` The `@feathersjs/express` module contains [Express](http://expressjs.com/) framework integrations for Feathers: - The [Express framework bindings](#expressapp) to make a Feathers application Express compatible - An Express based transport to expose services through a [REST API](#expressrest) - An [Express error handler](#expresserrorhandler) for [Feathers errors](./errors.md) ```ts import { feathers } from '@feathersjs/feathers' import express from '@feathersjs/express' const app = express(feathers()) ```
As of Feathers v5, [Koa](./koa.md) is the recommended framework integration since it is more modern, faster and easier to use. When chosen explicitly, you should already be familiar with [Express](http://expressjs.com/en/guide/routing.html).
## express(app) `express(app) -> app` is a function that turns a [Feathers application](./application.md) into a fully Express (4+) compatible application that additionally to Feathers functionality also lets you use the [Express API](http://expressjs.com/en/4x/api.html). ```ts import { feathers } from '@feathersjs/feathers' import express from '@feathersjs/express' const app = express(feathers()) ``` Note that `@feathersjs/express` also exposes the Express [built-in middleware](#built-ins) ## express(app, expressApp) `express(app, expressApp) -> app` allows to extend an existing Express application with the Feathers application `app`. ## express() If no Feathers application is passed, `express() -> app` returns a plain Express application just like a normal call to Express would. ## app.use(path, service|mw|\[mw\]) `app.use(path, service|mw|[mw]) -> app` registers either a [service object](./services.md), an [Express middleware](http://expressjs.com/en/guide/writing-middleware.html) or an array of [Express middleware](http://expressjs.com/en/guide/writing-middleware.html) on the given path. If [a service object](./services.md) is passed it will use Feathers registration mechanism, for a middleware function Express. ```ts // Register a service app.use('todos', { async get(id) { return { id } } }) // Register an Express middleware app.use('/test', (req, res) => { res.json({ message: 'Hello world from Express middleware' }) }) // Register multiple Express middleware functions app.use( '/test', (req, res, next) => { res.data = 'Step 1 worked' next() }, (req, res) => { res.json({ message: `Hello world from Express middleware ${res.data}` }) } ) ``` ## app.listen(port) `app.listen(port) -> Promise` will first call Express [app.listen](http://expressjs.com/en/4x/api.html#app.listen) and then internally also call the [app.setup(server)](./application.md#setup-server). ```ts // Listen on port 3030 const server = await app.listen(3030) ``` ## app.setup(server) `app.setup(server) -> app` is usually called internally by `app.listen` but in the cases described below needs to be called explicitly. ### Sub-Apps When registering an application as a sub-app, `app.setup(server)` has to be called to initialize the sub-apps services. ```ts import { feathers } from '@feathersjs/feathers' import express from '@feathersjs/express' const api = feathers() api.use('service', myService) const mainApp = express(feathers()).use('/api/v1', api) const server = await mainApp.listen(3030) // Now call setup on the Feathers app with the server await api.setup(server) ``` ### HTTPS HTTPS requires creating a separate server in which case `app.setup(server)` also has to be called explicitly. In a generated application `src/index.js` should look like this: ```ts import https from 'https' import { app } from './app' const port = app.get('port') const server = https .createServer( { key: fs.readFileSync('privatekey.pem'), cert: fs.readFileSync('certificate.pem') }, app ) .listen(443) // Call app.setup to initialize all services and SocketIO app.setup(server) server.on('listening', () => logger.info('Feathers application started')) ``` ### Virtual Hosts The [vhost](https://github.com/expressjs/vhost) Express middleware can be used to run a Feathers application on a virtual host but again requires `app.setup(server)` to be called explicitly. ```ts import vhost from 'vhost' import { feathers } from '@feathersjs/feathers' import express from '@feathersjs/express' const app = express(feathers()) app.use('/todos', todoService) const host = express().use(vhost('foo.com', app)) const server = await host.listen(8080) // Here we need to call app.setup because .listen on our virtual hosted // app is never called app.setup(server) ``` ## rest() Registers a Feathers transport mechanism that allows you to expose and consume [services](./services.md) through a [RESTful API](https://en.wikipedia.org/wiki/Representational_state_transfer). This means that you can call a service method through the `GET`, `POST`, `PUT`, `PATCH` and `DELETE` [HTTP methods](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol): | Service method | HTTP method | Path | | -------------- | ----------- | ----------- | | .find() | GET | /messages | | .get() | GET | /messages/1 | | .create() | POST | /messages | | .update() | PUT | /messages/1 | | .patch() | PATCH | /messages/1 | | .remove() | DELETE | /messages/1 | ### app.configure(rest()) Configures the transport provider with a standard formatter sending JSON response via [res.json](http://expressjs.com/en/4x/api.html#res.json). ```ts import { feathers } from '@feathersjs/feathers' import express, { json, urlencoded, rest } from '@feathersjs/express' // Create an Express compatible Feathers application const app = express(feathers()) // Turn on JSON parser for REST services app.use(json()) // Turn on URL-encoded parser for REST services app.use(urlencoded({ extended: true })) // Set up REST transport app.configure(rest()) ```
The `json` and `urlencoded` body parser and [params middleware](#params) has to be registered **before** any service.
### app.configure(rest(formatter)) The default REST response formatter is a middleware that formats the data retrieved by the service as JSON. If you would like to configure your own `formatter` middleware pass a `formatter(req, res)` function. This middleware will have access to `res.data` which is the data returned by the service. [res.format](http://expressjs.com/en/4x/api.html#res.format) can be used for content negotiation. ```ts import { feathers } from '@feathersjs/feathers' import express, { json, urlencoded, rest } from '@feathersjs/express' const app = express(feathers()) // Turn on JSON parser for REST services app.use(json()) // Turn on URL-encoded parser for REST services app.use(urlencoded({ extended: true })) // Set up REST transport app.configure( rest(function (req, res) { // Format the message as text/plain res.format({ 'text/plain': function () { res.end(`The Message is: "${res.data.text}"`) } }) }) ) ``` ## Custom service middleware Custom Express middleware that only should run before or after a specific service can be passed to `app.use` in the order it should run: ```ts const todoService = { async get(id: Id) { return { id, description: `You have to do ${id}!` } } } app.use('todos', logRequest, todoService, updateData) ```
Custom middleware will only run for REST requests and not when used with other transports (like Socket.io). If possible try to avoid custom middleware and use [hooks](hooks.md) or customized services instead which will work for all transports.
Middleware that runs after the service has the service call information available as - `res.data` - The data that will be sent - `res.hook` - The [hook](./hooks.md) context of the service method call For example `updateData` could look like this: ```js function updateData(req, res, next) { res.data.updateData = true next() } ``` If you run `res.send` in a custom middleware after the service and don't call `next`, other middleware (like the REST formatter) will be skipped. This can be used to e.g. render different views for certain service method calls, for example to export a file as CSV: ```ts import json2csv from 'json2csv' const fields = ['done', 'description'] app.use('todos', todoService, function (req, res) { const result = res.data const data = result.data // will be either `result` as an array or `data` if it is paginated const csv = json2csv({ data, fields }) res.type('csv') res.end(csv) }) ``` ## params All Express middleware will have access to the `req.feathers` object to set properties on the service method `params`: ```ts import { feathers } from '@feathersjs/feathers' import type { Id, Params } from '@feathersjs/feathers' import express, { json, urlencoded, rest } from '@feathersjs/express' const app = express(feathers()) app.use(json()) app.use(urlencoded({ extended: true })) app.use(function (req, res, next) { req.feathers.fromMiddleware = 'Hello world' next() }) app.configure(rest()) app.use('todos', { async get(id: Id, params: Params) { console.log(params.provider) // -> 'rest' console.log(params.fromMiddleware) // -> 'Hello world' return { id, params, description: `You have to do ${id}!` } } }) app.listen(3030) ``` Avoid setting `req.feathers = something` directly since it may already contain information that other Feathers plugins rely on. Adding individual properties or using `{ ...req.feathers, something }` is the more reliable option.
Since the order of Express middleware matters, any middleware that sets service parameters has to be registered **before** `app.configure(rest())` or as a [custom service middleware](#custom-service-middleware)
Although it may be convenient to set `req.feathers.req = req` to have access to the request object in the service, we recommend keeping your services as provider independent as possible. There usually is a way to pre-process your data in a middleware so that the service does not need to know about the HTTP request or response.
### params.query `params.query` will contain the URL query parameters sent from the client. For the REST transport the query string is parsed using the [qs](https://github.com/ljharb/qs) module. For some query string examples see the [database querying](./databases/querying.md) chapter.
Only `params.query` is passed between the server and the client, other parts of `params` are not. This is for security reasons so that a client can't set things like `params.user` or the database options. You can always map from `params.query` to other `params` properties in a [hook](./hooks.md).
For example: ``` GET /messages?read=true&$sort[createdAt]=-1 ``` Will set `params.query` to ```json { "read": "true", "$sort": { "createdAt": "-1" } } ```
Note that the URL is a string so type conversion may be necessary. This is usually done with [query schemas and resolvers](./schema/index.md).
If an array in your request consists of more than 20 items, the [qs](https://www.npmjs.com/package/qs) parser implicitly [converts](https://github.com/ljharb/qs#parsing-arrays) it to an object with indices as keys. To extend this limit, you can set a custom query parser: `app.set('query parser', str => qs.parse(str, {arrayLimit: 1000}))`
### params.provider For any [service method call](./services.md) made through REST `params.provider` will be set to `rest`. In a [hook](./hooks.md) this can for example be used to prevent external users from making a service method call: ```ts import { HookContext } from 'declarations' app.service('users').hooks({ before: { remove: [ async (context: HookContext) => { // check for if(context.params.provider) to prevent any external call if (context.params.provider === 'rest') { throw new Error('You can not delete a user via REST') } } ] } }) ``` ### params.headers `params.headers` will contain the original service request headers. ### params.route Express route placeholders in a service URL will be added to the services `params.route`. See the [FAQ entry on nested routes](../help/faq.md#how-do-i-do-nested-or-custom-routes) for more details on when and when not to use nested routes. ```ts import { feathers } from '@feathersjs/feathers' import express, { rest } from '@feathersjs/express' const app = express(feathers()) app.configure(rest()) app.use(function (req, res, next) { req.feathers.fromMiddleware = 'Hello world' next() }) app.use('users/:userId/messages', { async get(id, params) { console.log(params.query) // -> ?query console.log(params.provider) // -> 'rest' console.log(params.fromMiddleware) // -> 'Hello world' console.log(params.route.userId) // will be `1` for GET /users/1/messages return { id, params, read: false, text: `Feathers is great!`, createdAt: new Date().getTime() } } }) app.listen(3030) ``` ## Middleware `@feathersjs/express` comes with the following middleware ### notFound(options) `notFound()` returns middleware that returns a `NotFound` (404) [Feathers error](./errors.md). It should be used as the last middleware **before** the error handler. The following options are available: - `verbose`: Set to `true` if the URL should be included in the error message (default: `false`) ```ts import { notFound, errorHandler } from '@feathersjs/express' // Return errors that include the URL app.use(notFound({ verbose: true })) app.use(errorHandler()) ``` ### errorHandler() `errorHandler` is an [Express error handler](https://expressjs.com/en/guide/error-handling.html) middleware that formats any error response to a REST call as JSON (or HTML if e.g. someone hits our API directly in the browser) and sets the appropriate error code.
You can still use any other Express compatible [error middleware](http://expressjs.com/en/guide/error-handling.html) with Feathers.
Just like in Express, the error handler has to be registered _after_ all middleware and services.
#### app.use(errorHandler()) Set up the error handler with the default configuration. ```ts import { feathers } from '@feathersjs/feathers' import express from '@feathersjs/express' const app = express(feathers()) // before starting the app app.use(express.errorHandler()) ``` #### app.use(errorHandler(options)) ```ts import { feathers } from '@feathersjs/feathers' import express from '@feathersjs/express' const app = express(feathers()) // Just like Express your error middleware needs to be // set up last in your middleware chain. app.use( express.errorHandler({ html: function (error, req, res, next) { // render your error view with the error object res.render('error', error) } }) ) app.use( errorHandler({ html: { 404: 'path/to/notFound.html', 500: 'there/will/be/robots.html' } }) ) ```
If you want to have the response in json format be sure to set the `Accept` header in your request to `application/json` otherwise the default error handler will return HTML.
The following options can be passed when creating a new error handler: - `html` (Function|Object) [optional] - A custom formatter function or an object that contains the path to your custom html error pages. Can also be set to `false` to disable html error pages altogether so that only JSON is returned. - `logger` (Function|false) (default: `console`) - Set a logger object to log the error (it will be logger with `logger.error(error)` ### authenticate() `express.authenticate(...strategies)` allows to protect an Express middleware with an [authentication service](./authentication/service.md) that has [strategies](./authentication/strategy.md) registered that can parse HTTP headers. It will set the authentication information on the `req.feathers` object (e.g. `req.feathers.user`). The following example protects the `/hello` endpoint with the JWT strategy (so the `Authorization: Bearer ` header needs to be set) and uses the user email to render the message: ```ts import { authenticate } from '@feathersjs/express' app.use('/hello', authenticate('jwt'), (req, res) => { const { user } = req.feathers res.render(`Hello ${user.email}`) }) // When using with the non-default authentication service app.use( '/hello', authenticate({ service: 'v2/auth', strategies: ['jwt', 'api-key'] }), (req, res) => { const { user } = req.feathers res.render(`Hello ${user.email}`) } ) ``` When clicking a normal link, web browsers do _not_ send the appropriate header. In order to initate an authenticated request to a middleware from a browser link, there are two options. One is using a session which is described in the [Server Side rendering guide](../cookbook/express/view-engine.md), another is to add the JWT access token to the query string and mapping it to an authentication request: ```ts import { authenticate } from '@feathersjs/express' const setQueryAuthentication = (req, res, next) => { const { access_token } = req.query if (access_token) { req.authentication = { strategy: 'jwt', accessToken: access_token } } next() } // Request this with `hello?access_token=` app.use('/hello', setQueryAuthentication, authenticate('jwt'), (req, res) => { const { user } = req.feathers res.render(`Hello ${user.email}`) }) ``` How to get the access token from the authentication client is described in the [authentication client documentation](../api/authentication/client.md#app-get-authentication).
When using HTTPS URLs are safely encrypted but when using this method you have to make sure that access tokens are not logged through any of your logging mechanisms.
### parseAuthentication The `parseAuthentication` middleware is registered automatically and will use the strategies of the default [authentication service](./authentication/service.md) to parse headers for authentication information. If you want to additionally parse authentication with a different authentication service this middleware can be registered again with that service configured. ```ts import { parseAuthentication } from '@feathersjs/express' app.use( parseAuthentication({ service: 'api/v1/authentication', strategies: ['jwt', 'local'] }) ) ``` ### cors A reference to the [cors](https://github.com/expressjs/cors) module. ### compression A reference to the [compression](https://github.com/expressjs/compression) module. ### Built ins Note that `@feathersjs/express` also exposes the standard [Express middleware](http://expressjs.com/en/4x/api.html#express): - `json` - A JSON body parser - `urlencoded` - A URL encoded form body parser - `serveStatic` - To statically host files in a folder - `Router` - Creates an Express router object ================================================ FILE: docs/api/hooks.md ================================================ --- outline: deep --- # Hooks Hooks are pluggable middleware functions that can be registered **around**, **before**, **after** or on **error**(s) of a [service method](./services.md). Multiple hook functions can be chained to create complex work-flows. A hook is **transport independent**, which means it does not matter if it has been called internally on the server, through HTTP(S) (REST), websockets or any other transport Feathers supports. They are also service agnostic, meaning they can be used with ​**any**​ service regardless of whether they use a database or not. Hooks are commonly used to handle things like permissions, validation, logging, [authentication](./authentication/hook.md), [data schemas and resolvers](./schema/index.md), sending notifications and more. This pattern keeps your application logic flexible, composable, and easier to trace through and debug. For more information about the design patterns behind hooks see [this blog post](https://blog.feathersjs.com/api-service-composition-with-hooks-47af13aa6c01). ## Quick Example The following example logs the runtime of any service method on the `messages` service and adds `createdAt` property before saving the data to the database: ```ts import { feathers, type HookContext, type NextFunction } from '@feathersjs/feathers' const app = feathers() app.service('messages').hooks({ around: { all: [ // A hook that wraps around all other hooks and the service method // logging the total runtime of a successful call async (context: HookContext, next: NextFunction) => { const startTime = Date.now() await next() console.log(`Method ${context.method} on ${context.path} took ${Date.now() - startTime}ms`) } ] }, before: { create: [ async (context: HookContext) => { context.data = { ...context.data, createdAt: Date.now() } } ] } }) ```
While it is always possible to add properties like `createdAt` in the above example via hooks, the preferred way to make data modifications like this in Feathers 5 is via [schemas and resolvers](./schema/index.md).
## Hook functions ### before, after and error `before`, `after` and `error` hook functions are functions that are `async` or return a promise and take the [hook context](#hook-context) as the parameter and return nothing or throw an error. ```ts import { HookContext } from '../declarations' export const hookFunction = async (context: HookContext) => { // Do things here } ``` For more information see the [hook flow](#hook-flow) section. ### around `around` hooks are a special kind of hook that allow to control the entire `before`, `after` and `error` flow in a single function. They are a Feathers specific version of the generic [@feathersjs/hooks](https://github.com/feathersjs/hooks). An `around` hook is an `async` function that accepts two arguments: - The [hook context](#hook-context) - An asynchronous `next` function. Somewhere in the body of the hook function, there is a call to `await next()`, which calls the `next` hooks OR the original function if all other hooks have run. In its simplest form, an around hook looks like this: ```js import { HookContext, NextFunction } from '../declarations' export const myAfoundHook = async (context: HookContext, next: NextFunction) => { try { // Code before `await next()` runs before the main function await next() // Code after `await next()` runs after the main function. } catch (error) { // Do things on error } finally { // Do things always } } ``` Any around hook can be wrapped around another function. Calling `await next()` will either call the next hook in the chain or the service method if all other hooks have run. ## Hook flow In general, hooks are executed in the order [they are registered](#registering-hooks) with `around` hooks running first: - `around` hooks (before `await next()`) - `before` hooks - service method - `after` hooks - `around` hooks (after `await next()`) Note that since `around` hooks wrap **around** everything, the first hook to run will be the last to execute its code after `await next()`. This is reverse of the order `after` hooks execute. The hook flow can be affected as follows. ### Throwing an error When an error is thrown (or the promise is rejected), all subsequent hooks - and the service method call if it didn't run already - will be skipped and only the error hooks will run. The following example throws an error when the text for creating a new message is empty. You can also create very similar hooks to use your Node validation library of choice. ```ts app.service('messages').hooks({ before: { create: [ async (context: HookContext) => { if (context.data.text.trim() === '') { throw new Error('Message text can not be empty') } } ] } }) ``` ### Setting `context.result` When `context.result` is set in an `around` hook before calling `await next()` or in a `before` hook, the original [service method](./services.md) call will be skipped. All other hooks will still execute in their normal order. The following example always returns the currently [authenticated user](./authentication/service.md) instead of the actual user for all `get` method calls: ```js app.service('users').hooks({ before: { get: [ async (context: HookContext) => { // Never call the actual users service // just use the authenticated user context.result = context.params.user } ] } }) ``` ## Hook context The hook `context` is passed to a hook function and contains information about the service method call. It has **read only** properties that should not be modified and **_writeable_** properties that can be changed for subsequent hooks.
The `context` object is the same throughout a service method call so it is possible to add properties and use them in other hooks at a later time.
If you want to inspect the hook context, e.g. via `console.log`, the object returned by [context.toJSON()](#contexttojson) should be used, otherwise you won't see all properties that are available.
### `context.app` `context.app` is a _read only_ property that contains the [Feathers application object](./application.md). This can be used to retrieve other services (via `context.app.service('name')`) or configuration values. ### `context.service` `context.service` is a _read only_ property and contains the service this hook currently runs on. ### `context.path` `context.path` is a _read only_ property and contains the service name (or path) without leading or trailing slashes. ### `context.method` `context.method` is a _read only_ property with the name of the [service method](./services.md) (`find`, `get`, `create`, `update`, `patch`, `remove`). ### `context.type` `context.type` is a _read only_ property with the hook type (one of `around`, `before`, `after` or `error`). ### `context.params` `context.params` is a **writeable** property that contains the [service method](./services.md) parameters (including `params.query`). For more information see the [service params documentation](./services.md#params). ### `context.id` `context.id` is a **writeable** property and the `id` for a `get`, `remove`, `update` and `patch` service method call. For `remove`, `update` and `patch`, `context.id` can also be `null` when modifying multiple entries. In all other cases it will be `undefined`. ### `context.data` `context.data` is a **writeable** property containing the data of a `create`, `update` and `patch` service method call.
`context.data` will only be available for `create`, `update`, `patch` and [custom methods](./services.md#custom-methods).
### `context.error` `context.error` is a **writeable** property with the error object that was thrown in a failed method call. It can be modified to change the error that is returned at the end.
`context.error` will only be available if `context.type` is `error`.
### `context.result` `context.result` is a **writeable** property containing the result of the successful service method call. It is only available in `after` hooks. `context.result` can also be set in - An `around` or `before` hook to skip the actual service method (database) call - An `error` hook to swallow the error and return a result instead
`context.result` will only be available if `context.type` is `after` or if `context.result` has been set.
### `context.dispatch` `context.dispatch` is a **writeable, optional** property and contains a "safe" version of the data that should be sent to any client. If `context.dispatch` has not been set `context.result` will be sent to the client instead. `context.dispatch` only affects the data sent through a Feathers Transport like [REST](./express.md) or [Socket.io](./socketio.md). An internal method call will still get the data set in `context.result`.
`context.dispatch` is used by the `schemaHooks.resolveDispatch` [resolver](./schema/resolvers.md). Use dispatch resolvers whenever possible to get safe representations external data.
### `context.http` `context.http` is a **writeable, optional** property that allows customizing HTTP response specific properties. The following properties can be set: - `context.http.status` - Sets the [HTTP status code](https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) that should be returned. Usually the most appropriate status code will be picked automatically but there are cases where it needs to be customized. - `context.http.headers` - An object with additional HTTP response headers - `context.http.location` - Setting this property will trigger a redirect for HTTP requests.
Setting `context.http` properties will have no effect when using a websocket real-time connection.
### `context.event` `context.event` is a **writeable, optional** property that allows service events to be skipped by setting it to `null` ### `context.toJSON()` `context.toJSON()` returns a full object representation of the hook context and all its properties. ## Registering hooks Hook functions are registered on a service through the `app.service().hooks(hooks)` method. The most commonly used registration format is ```js { [type]: { // around, before, after or error all: [ // list of hooks that should run for every method here ], [methodName]: [ // list of method hooks here ] } } ``` This means usual hook registration looks like this: ```ts // The standard all at once way (also used by the generator) // an array of functions per service method name (and for `all` methods) app.service('servicename').hooks({ around: { all: [ async (context: HookContext, next: NextFunction) => { console.log('around all hook ran') await next() } ], find: [ /* other hook functions here */ ], get: [], create: [], update: [], patch: [], remove: [], // Custom methods use hooks as well myCustomMethod: [] }, before: { all: [async (context: HookContext) => console.log('before all hook ran')], find: [ /* other hook functions here */ ], get: [] // ...etc }, after: { find: [async (context: HookContext) => console.log('after find hook ran')] }, error: {} }) ```
Hooks will only be available for the standard service methods or methods passed in `options.methods` to [app.use](application.md#usepath-service--options). See the [documentation for @feathersjs/hooks](https://github.com/feathersjs/hooks) how to use hooks on other methods.
Since around hooks offer the same functionality as `before`, `after` and `error` hooks at the same time they can also be registered without a nested object: ```ts import { HookContext, NextFunction } from './declarations' // Passing an array of around hooks that run for every method app.service('servicename').hooks([ async (context: HookContext, next: NextFunction) => { console.log('around all hook ran') await next() } ]) // Passing an object with method names and a list of around hooks app.service('servicename').hooks({ get: [ async (context: HookContext, next: NextFunction) => { console.log('around get hook ran') await next() } ], create: [], update: [], patch: [], remove: [], myCustomMethod: [] }) ``` ## Application hooks ### Service hooks To add hooks to every service `app.hooks(hooks)` can be used. Application hooks are [registered in the same format as service hooks](#registering-hooks) and also work exactly the same. Note when application hooks will be executed: - `around` application hook will run around all other hooks - `before` application hooks will always run _before_ all service `before` hooks - `after` application hooks will always run _after_ all service `after` hooks - `error` application hooks will always run _after_ all service `error` hooks Here is an example for a very useful application hook that logs every service method error with the service and method name as well as the error stack. ```ts import { HookContext } from './declarations' app.hooks({ error: { all: [ async (context: HookContext) => { console.error(`Error in '${context.path}' service method '${context.method}'`, context.error.stack) } ] } }) ``` ### Setup and teardown A special kind of application hooks are [app.setup](./application.md#setupserver) and [app.teardown](./application.md#teardownserver) hooks. They are around hooks that can be used to initialize database connections etc. and only run once when the application starts or shuts down. Setup and teardown hooks only have `context.app` and `context.server` available in the hook context. ```ts import { MongoClient } from 'mongodb' app.hooks({ setup: [ async (context: HookContext, next: NextFunction) => { // E.g. wait for MongoDB connection to complete await context.app.get('mongoClient').connect() await next() } ], teardown: [ async (context: HookContext, next: NextFunction) => { // Close MongoDB connection await context.app.get('mongoClient').close() await next() } ] }) ``` ================================================ FILE: docs/api/index.md ================================================ --- outline: deep --- # API This section describes all the individual modules and APIs of Feathers. ## Core Feathers core functionality that works on the client and the server - [Application](./application.md) - The main Feathers application API - [Services](./services.md) - Service objects and their methods and Feathers specific functionality - [Hooks](./hooks.md) - Pluggable middleware for service methods - [Events](./events.md) - Events sent by Feathers service methods - [Errors](./errors.md) - A collection of error classes used throughout Feathers ## Transports Expose a Feathers application as an API server - [Configuration](./configuration.md) - A node-config wrapper to initialize configuration of a server side application. - [Koa](./koa.md) - Feathers KoaJS framework bindings, REST API provider and error middleware. - [Express](./express.md) - Feathers Express framework bindings, REST API provider and error middleware. - [Socket.io](./socketio.md) - The Socket.io real-time transport provider - [Channels](./channels.md) - Channels are used to send real-time events to clients ## Authentication Feathers authentication mechanism - [Service](./authentication/service.md) - The main authentication service configuration - [Hook](./authentication/hook.md) - The hook used to authenticate service method calls - [Strategies](./authentication/strategy.md) - More about authentication strategies - [Local](./authentication/local.md) - Local email/password authentication - [JWT](./authentication/jwt.md) - JWT authentication - [OAuth](./authentication/oauth.md) - Using OAuth logins (Facebook, Twitter etc.) ## Client More details on how to use Feathers on the client - [Usage](./client.md) - Feathers client usage in Node, React Native and the browser (also with Webpack and Browserify) - [REST](./client/rest.md) - Feathers client and direct REST API server usage - [Socket.io](./client/socketio.md) - Feathers client and direct Socket.io API server usage - [Authentication](authentication/client) - A client for Feathers authentication ## Schema Model definitions for validating and resolving data. - [TypeBox](./schema/typebox.md) - Integration for TypeBox, a JSON schema type builder - [JSON schema](./schema/schema.md) - JSON schema integration - [Validators](./schema/validators.md) - Schema validators and validation hooks - [Resolvers](./schema/resolvers.md) - Dynamic data resolvers ## Databases Feathers common database adapter API and querying mechanism - [Adapters](./databases/adapters.md) - A list of supported database adapters - [Common API](./databases/common.md) - Database adapter common initialization and configuration API - [Querying](./databases/querying.md) - The common querying mechanism - [MongoDB](./databases/querying.md) - The adapter for MongoDB databases - [SQL](./databases/knex.md) - The adapter for SQL databases using KnexJS - [Memory](./databases/memory.md) - The adapter for in-memory data storage ================================================ FILE: docs/api/koa.md ================================================ --- outline: deep --- # Koa [![npm version](https://img.shields.io/npm/v/@feathersjs/koa.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/koa) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/koa/CHANGELOG.md) ``` npm install @feathersjs/koa --save ``` The `@feathersjs/koa` module contains the [KoaJS](https://koajs.com/) framework integrations for Feathers. It will turn the Feathers app into a fully compatible KoaJS application. ## koa(app) `koa(app) -> app` is a function that turns a [Feathers application](./application.md) into a fully KoaJS compatible application that additionally to Feathers functionality also lets you use the [KoaJS API](https://koajs.com/). ```ts import { feathers } from '@feathersjs/feathers' import { koa, errorHandler, bodyParser, rest } from '@feathersjs/koa' const app = koa(feathers()) app.use(errorHandler()) app.use(authentication()) app.use(bodyParser()) app.configure(rest()) ``` Also see the [additional middleware](#middleware) that `@feathersjs/koa` exposes. ## koa(app, koaApp) `koa(app, koaApp) -> app` allows to extend an existing Koa application with the Feathers application `app`. ## koa() If no Feathers application is passed, `koa() -> app` returns a plain Koa application (`new Koa()`). ## app.use(location|mw[, service]) `app.use(location|mw[, service]) -> app` registers either a [service object](./services.md), or a Koa middleware. If a path and [service object](./services.md) is passed it will use Feathers registration mechanism, for a middleware function Koa. ## app.listen(port) `app.listen(port) -> HttpServer` will first call Koa [app.listen](https://github.com/koajs/koa/blob/master/docs/api/index.md#applisten) and then internally also call the [Feathers app.setup(server)](./application.md#setupserver). ```js // Listen on port 3030 const server = await app.listen(3030) ``` ## app.setup(server) `app.setup(server) -> app` is usually called internally by `app.listen` but in the cases described below needs to be called explicitly. ### HTTPS HTTPS requires creating a separate server in which case `app.setup(server)` also has to be called explicitly. In a generated application `src/index.js` should look like this: ```ts import https from 'https' import { app } from './app' const port = app.get('port') const server = https .createServer( { key: fs.readFileSync('privatekey.pem'), cert: fs.readFileSync('certificate.pem') }, app.callback() ) .listen(443) // Call app.setup to initialize all services and SocketIO app.setup(server) server.on('listening', () => logger.info('Feathers application started')) ``` ## params In a Koa middleware, `ctx.feathers` is an object which will be extended as `params` in a service method call. ```ts import { rest } from '@feathersjs/koa' import type { NextFunction } from '@feathersjs/koa' import type { Id, Params } from '@feathersjs/feathers' class TodoService { async get(id: Id, params: Params & { fromMiddleware: string }) { const { fromMiddleware } = params return { id, fromMiddleware } } } // Register Koa middleware app.use(async (ctx: any, next: NextFunction) => { ctx.feathers = { ...ctx.feathers, fromMiddleware: 'Hello from Koa middleware' } await next() }) app.configure(rest()) // Register a service app.use('todos', new TodoService()) ```
Note that `app.configure(rest())` has to happen **after** any custom middleware.
### params.query `params.query` will contain the URL query parameters sent from the client parsed using [koa-qs](https://github.com/koajs/qs).
Only `params.query` is passed between the server and the client, other parts of `params` are not. This is for security reasons so that a client can't set things like `params.user` or the database options. You can always map from `params.query` to other `params` properties in a [hook](./hooks.md).
To increase the array limit in query strings, `koa-qs` can be reinitalized with the options for the [qs](https://www.npmjs.com/package/qs) module: ```ts // app.ts import koaQs from 'koa-qs' // ... koaQs(app, 'extended', { arrayLimit: 200 }) ``` ### params.provider For any [service method call](./services.md) made through REST `params.provider` will be set to `rest`. ### params.route Route placeholders in a service URL will be added to the services `params.route`. See the [FAQ entry on nested routes](../help/faq.md#how-do-i-do-nested-or-custom-routes) for more details on when and when not to use nested routes. ```ts import { feathers } from '@feathersjs/feathers' import { koa, errorHandler, bodyParser, rest } from '@feathersjs/koa' const app = koa(feathers()) app.use('users/:userId/messages', { async get(id, params) { console.log(params.query) // -> ?query console.log(params.provider) // -> 'rest' console.log(params.fromMiddleware) // -> 'Hello world' console.log(params.route) // will be `{ userId: '1' }` for GET /users/1/messages return { id, params, read: false, text: `Feathers is great!`, createdAt: new Date().getTime() } } }) app.listen(3030) ``` ## Service middleware When registering a service, it is also possible to pass custom Koa middleware that should run `before` the specific service method in the `koa` [service option](./application.md#usepath-service--options): ```ts app.use('/todos', new TodoService(), { koa: { before: [ async (ctx, next) => { ctx.feathers // data that will be merged into sevice `params` // This will run all subsequent middleware and the service call await next() // Then we have additional properties available on the context ctx.hook // the hook context from the method call ctx.body // the return value } ] } }) ``` Note that the order of middleware will be `[...before, serviceMethod]`. ## Middleware ### rest ```ts import { rest } from '@feathersjs/koa' app.configure(rest()) ``` Configures the middleware for handling service calls via HTTP. It will also register authentication header parsing. The following (optional) options are available: - `formatter` - A middleware that formats the response body - `authentication` - The authentication `service` and `strategies` to use for parsing authentication information ### errorHandler ```ts import { errorHandler } from '@feathersjs/koa' app.use(errorHandler()) ``` A middleware that formats errors as a Feathers error and sets the proper status code. Needs to be the first middleware registered in order to catch all other errors. ### authenticate A middleware that allows to authenticate a user (or other authentication entity) using the [authentication service](./authentication/service.md) setting `ctx.feathers.user`. Not necessary for use with services but can be used in custom middleware. ```ts import { authenticate } from '@feathersjs/koa' // Authenticate other middleware with the JWT strategy app.use(authenticate('jwt')) // Authenticate a non default service app.use( authenticate({ service: 'api/v1', strategies: ['jwt'] }) ) ``` ### parseAuthentication The `parseAuthentication` middleware is registered automatically and will use the strategies of the default [authentication service](./authentication/service.md) to parse headers for authentication information. If you want to additionally parse authentication with a different authentication service this middleware can be registered again with that service configured. ```ts import { parseAuthentication } from '@feathersjs/koa' app.use( parseAuthentication({ service: 'api/v1/authentication', strategies: ['jwt', 'local'] }) ) ``` ### bodyParser A reference to the [koa-body](https://github.com/koajs/koa-body) module. ### cors A reference to the [@koa/cors](https://github.com/koajs/cors) module. ### serveStatic A reference to the [koa-static](https://github.com/koajs/static) module. ================================================ FILE: docs/api/schema/index.md ================================================ --- outline: deep --- # Schema Overview [![npm version](https://img.shields.io/npm/v/@feathersjs/schema.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/schema) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/schema/CHANGELOG.md) `@feathersjs/schema` provides a way to define data models and to dynamically resolve them. It comes in in the following main parts: - [JSON schema](https://json-schema.org/) using [TypeBox](./typebox.md) or [plain JSON schema](./schema.md) to define a data model with TypeScript types and validations. This allows us to: - Automatically get TypeScript types from schema definitions - Automatically generate API documentation - Create [database adapter](../databases/common.md) models without duplicating the data format - [Validators](./validators.md) take a [TypeBox](./typebox.md) or [JSON](./schema.md) schema to validate data to - Ensure data is valid and always in the right format - Validate query string queries and convert them to the right type - [Resolvers](./resolvers.md) - Resolve properties based on a context (usually the [hook context](../hooks.md)). This can be used for many different things like: - Adding default and computed values - Populating associations - Securing queries and e.g. limiting requests to a user - Removing protected properties for external requests - Ability to add read- and write permissions on the property level - Hashing passwords and validating dynamic password policies ================================================ FILE: docs/api/schema/resolvers.md ================================================ --- outline: deep --- # Resolvers Resolvers dynamically resolve individual properties based on a context, in a Feathers application usually the [hook context](../hooks.md#hook-context). This provide a flexible way to do things like: - Populating associations - Returning computed properties - Securing queries and e.g. limiting requests for a user - Setting context (e.g. logged in user or organization) specific default values - Removing protected properties for external requests - Add read- and write permissions on the property level - Hashing passwords and validating dynamic password policies You can create a resolver for any data type and resolvers can also be used outside of Feathers. ## Example Here is an example for a standalone resolver using a custom context: ```ts import { resolve } from '@feathersjs/schema' type User = { id: number name: string } type Message = { id: number userId: number likes: number text: string user: User } class MyContext { getUser(id) { return { id, name: 'David' } } getLikes(messageId) { return 10 } } const messageResolver = resolve({ likes: (value, message, context) => { return context.getLikes(message.id) }, user: (value, message, context) => { return context.getUser(message.userId) } }) const resolvedMessage = await messageResolver.resolve( { id: 1, userId: 23, text: 'Hello!' }, new MyContext() ) ``` ## Property resolvers Property resolvers are a map of property names to resolver functions. A resolver function is an `async` or regular function that resolves a property on a data object. If it returns `undefined` the property will not be included. It gets passed the following parameters: - `value` - The current value which can also be `undefined` - `data` - The initial data object - `context` - The context for this resolver - `status` - Additional status information like current property resolver path, the properties that should be resolved or a reference to the initial context. ```ts const userResolver = resolve({ isDrinkingAge: async (value, user, context) => { const drinkingAge = await context.getDrinkingAge(user.country) return user.age >= drinkingAge }, fullName: (value, user, context) => { return `${user.firstName} ${user.lastName}` } }) ```
Property resolver functions should only return a value and not have side effects. This means a property resolver **should not** do things like create new data or modify the `data` or `context` object. [Hooks](../hooks.md) should be used for side effects.
## Virtual property resolvers Virtual resolvers are property resolvers that do not use the `value` but instead always return a value of their own. The parameters are (`(data, context, status)`). The above example can be written like this: ```ts import { resolve, virtual } from '@feathersjs/schema' const userResolver = resolve({ isDrinkingAge: virtual(async (user, context) => { const drinkingAge = await context.getDrinkingAge(user.country) return user.age >= drinkingAge }), fullName: virtual((user, context) => { return `${user.firstName} ${user.lastName}` }) }) ```
Virtual resolvers should always be used when combined with a [database adapter](../databases/adapters.md) in order to make valid [$select queries](../databases/querying.md#select). Otherwise queries could try to select fields that do not exist in the database which will throw an error.
## Options A resolver takes the following options as the second parameter: - `converter` (optional): A `(data, context) => {}` or `async (data, context) => {}` function that can return a completely new representation of the data. A `converter` runs before `properties` resolvers. ```ts const userResolver = resolve( { isDrinkingAge: async (value, user, context) => { const drinkingAge = await context.getDrinkingAge(user.country) return user.age >= drinkingAge }, fullName: async (value, user, context) => { return `${user.firstName} ${user.lastName}` } }, { // Convert the raw data into a new structure before running property resolvers converter: async (rawData, context) => { return { firstName: rawData.data.first_name, lastName: rawData.data.last_name } } } ) ``` ## Hooks In a Feathers application, resolvers are used through [hooks](../hooks.md) to convert service `query`, `data` and `response`. The context for these resolvers is always the [hook context](../hooks.md#hook-context). ### resolveData Data resolvers use the `hooks.resolveData(...resolvers)` hook and convert the `data` from a `create`, `update` or `patch` [service method](../services.md) or a [custom method](../services.md#custom-methods). This can be used to validate against the schema and e.g. hash a password before storing it in the database or to remove properties the user is not allowed to write. It is possible to pass multiple objects containing resolvers which will run in the order they are passed. Subsequent resolver objects will receive the output from previous resolvers. `schemaHooks.resolveData` can be used as an `around` and `before` hook. ```ts import { hooks as schemaHooks, resolve } from '@feathersjs/schema' import { Type } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' import type { HookContext } from '../declarations' const messageSchema = Type.Object( { id: Type.Number(), text: Type.String(), createdAt: Type.Number(), updatedAt: Type.Number(), userId: Type.Number() }, { $id: 'Message', additionalProperties: false } ) type Message = Static // Pick the data for creating a new message const messageDataSchema = Type.Pick(messageSchema, ['text']) type MessageData = Static // Resolver that automatically set `userId` and `createdAt` const messageDataResolver = resolve({ // Associate the currently authenticated user userId: (value, message, context) => context.params?.user.id, // Return the current date createdAt: () => Date.now() }) // Resolver that automatically sets `updatedAt` const messagePatchResolver = resolve({ // Return the current date updatedAt: () => Date.now() }) app.service('users').hooks({ before: { create: [schemaHooks.resolveData(messageDataResolver)], patch: [schemaHooks.resolveData(messagePatchResolver)] } }) ``` Note that as an `all` hook `resolveData` will run for any method that has `data`, including [custom methods](../services.md#custom-methods). If you want to validate custom methods differently the hook should be registered on each service method it is used: ```ts app.service('users').hooks({ before: { create: [schemaHooks.resolveData(messageDataResolver)], update: [schemaHooks.resolveData(messageDataResolver)], patch: [schemaHooks.resolveData(messageDataResolver)], customMethod: [schemaHooks.resolveData(customMethodDataResolver)] } }) ``` ### resolveResult Result resolvers use the `hooks.resolveResult(...resolvers)` hook and resolve the data that is returned by a service call ([context.result](../hooks.md#context-result) in a hook). This can be used to populate associations or add other computed properties etc. It is possible to pass multiple resolvers which will run in the order they are passed, using the previous data.
`schemaHooks.resolveResult` must be used as an `around` hook. This is to ensure that the database adapters will be able to handle [$select queries](../databases/querying.md#select) properly when using [virtual properties](#virtual-property-resolvers).
```ts import { hooks as schemaHooks, resolve, virtual } from '@feathersjs/schema' import { Type } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' import type { HookContext } from '../declarations' const userSchema = Type.Object( { id: Type.Number(), email: Type.String(), password: Type.String(), avatar: Type.Optional(Type.String()) }, { $id: 'User', additionalProperties: false } ) type User = Static const messageSchema = Type.Object( { id: Type.Number(), text: Type.String(), createdAt: Type.Number(), userId: Type.Number(), user: Type.Ref(userSchema) }, { $id: 'Message', additionalProperties: false } ) type Message = Static export const messageResolver = resolve({ user: virtual(async (message, context) => { // Populate the user associated via `userId` const user = await context.app.service('users').get(message.userId) return user }) }) app.service('messages').hooks({ around: { all: [schemaHooks.resolveResult(messageResolver)] } }) ``` ### resolveExternal External (or dispatch) resolver use the `hooks.resolveDispatch(...resolvers)` hook to return a safe version of the data that will be sent to external clients. It is possible to pass multiple resolvers which will run in the order they are passed, using the previous data. Returning `undefined` for a property resolver will exclude the property which can be used to hide sensitive data like the user password. This includes nested associations and real-time events. `schemaHooks.resolveExternal` can be used as an `around` or `after` hook. ```ts import { hooks as schemaHooks, resolve } from '@feathersjs/schema' import { Type } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' import type { HookContext } from '../declarations' const userSchema = Type.Object( { id: Type.Number(), email: Type.String(), password: Type.String(), avatar: Type.Optional(Type.String()) }, { $id: 'User', additionalProperties: false } ) type User = Static export const userExternalResolver = resolve({ // Always hide the password for external responses password: () => undefined }) // Dispatch should be resolved on every method app.service('users').hooks({ around: { all: [schemaHooks.resolveExternal(userExternalResolver)] } }) ```
In order to get the safe data from resolved associations **all services** involved need the `schemaHooks.resolveExternal` hook registered even if it does not need a resolver (`schemaHooks.resolveExternal()`). `schemaHooks.resolveExternal` should be registered first when used as an `around` hook or last when used as an `after` hook so that it gets the final result data.
### resolveQuery Query resolvers use the `hooks.resolveQuery(...resolvers)` hook to modify `params.query`. This is often used to set default values or limit the query so a user can only request data they are allowed to see. It is possible to pass multiple resolvers which will run in the order they are passed, using the previous data. `schemaHooks.resolveQuery` can be used as an `around` or `before` hook. In this example for a `User` schema we are first checking if a user is available in our request. In the case a user is available we are returning the user's ID. Otherwise we return whatever value was provided for `id`. `context.params.user` would only be set if the request contains a user. This is usually the case when an external request is made. In the case of an internal request we may not have a specific user we are dealing with, and we will just return `value`. If we were to receive an internal request, such as `app.service('users').get(123)`, `context.params.user` would be `undefined` and we would just return the `value` which is `123`. ```ts import { hooks as schemaHooks, resolve } from '@feathersjs/schema' import { Type } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' import type { HookContext } from '../declarations' const userSchema = Type.Object( { id: Type.Number(), email: Type.String(), password: Type.String(), avatar: Type.Optional(Type.String()) }, { $id: 'User', additionalProperties: false } ) type User = Static export const userQueryProperties = Type.Pick(userSchema, ['id', 'email']) export const userQuerySchema = querySyntax(userQueryProperties) export type UserQuery = Static export const userQueryResolver = resolve({ // If there is an authenticated user, they can only see their own data id: (value, query, context) => { if (context.params.user) { return context.params.user.id } return value } }) // The query can be resolved on every method app.service('users').hooks({ before: { all: [resolveQuery(userQueryResolver)] } }) ``` For a more complicated example. We will make a separate `queryResolver`, called `companyFilterQueryResolver`, that will act as a ownership filter. We will have a `Company` service that is owned by a `User`. We will assume our app has two registered users and two companies. Each user owning one company. For simplicity, `User1` owns `Company1`, and `User2` owns `Company2` We want to make sure only the user that owns the company can make any requests related to it. Our schema contains a `ownerUser` field, this is the owner of the company. When a request is made to the company schema, we are effectivly filtering our search for companies to be only those whose `ownerUser` matches the requesting user's id. So if a `GET /company` request is made by `User1`, our resolver will convert our query to `GET /company?name=Company1&ownerUser={User1.id}`. The result will only return an array of 1 company to `User1` Similarily, if a patch request was made by `User1` to modify `Company2`. A `404` would occur, as resulting query would search the database for a `Company2` that is owned by `User1` which does not exist. ```ts // Main data model schema export const companySchema = Type.Object( { id: Type.String({ format: 'uuid' }), name: Type.String(), ownerUser: Type.Ref(userSchema) }, { $id: 'Company', additionalProperties: false } ) // Schema for allowed query properties export const companyQueryProperties = Type.Pick(companySchema, ['id']) export const companyQuerySchema = Type.Intersect( [ querySyntax(companyQueryProperties), // Add additional query properties here Type.Object({}, { additionalProperties: false }) ], { additionalProperties: false } ) export type CompanyQuery = Static export const companyQueryValidator = getValidator(companyQuerySchema, queryValidator) export const companyQueryResolver = resolve({}) export const companyFilterQueryResolver = resolve({ ownerUser: (value, obj, context) => { if (context.params.user) { return context.params.user.id } return value } }) ``` ================================================ FILE: docs/api/schema/schema.md ================================================ --- outline: deep --- # JSON Schema As an alternative to [TypeBox](./typebox.md), `@feathersjs/schema` also provides the ability to define plain JSON schemas as objects. It uses [json-schema-to-ts](https://github.com/thomasaribart/json-schema-to-ts) to turn those schemas into TypeScript types.
You can find an introduction in the [JSON schema official getting started guide](https://json-schema.org/learn/getting-started-step-by-step) and a lot of type-specific JSON Schema examples in the [json-schema-to-ts docs](https://github.com/ThomasAribart/json-schema-to-ts).
## Creating Schemas ### Definitions If you are not familiar with JSON schema have a look at the [official getting started guide](https://json-schema.org/learn/getting-started-step-by-step). Here is an example for a possible user schema: ```ts import type { FromSchema } from '@feathersjs/schema' export const userSchema = { $id: 'User', type: 'object', additionalProperties: false, required: ['email', 'password'], properties: { id: { type: 'number' }, email: { type: 'string' }, password: { type: 'string' } } } as const export type User = FromSchema ``` ### Generating Correct Types For correct TypeScript types, the definition always **needs to be declared `as const`**. This first example will not produce correct types because the definition is not immediately followed by `as const`: ```ts // Will not produce correct types. const definition = { type: 'object' } // `as const` is missing, here. ``` This next example does declare `as const` after the `definition`, so the types will be generated correctly: ```ts // Produces correct types. const definition = { type: 'object' } as const ``` ## Extending Schemas To create a new schema that extends an existing one, combine the schema properties (and `schema.required`, if used) with the new properties: ```ts import type { FromSchema } from '@feathersjs/schema' export const userDataSchema = { $id: 'User', type: 'object', additionalProperties: false, required: ['email', 'password'], properties: { email: { type: 'string' }, password: { type: 'string' } } } as const export type UserData = FromSchema export const userSchema = { $id: 'UserResult', type: 'object', additionalProperties: false, required: [...userDataSchema.required, 'id'], properties: { ...userDataSchema.properties, id: { type: 'number' } } } as const export type User = FromSchema ``` ## References Associated schemas can be initialized via the `$ref` keyword referencing the `$id` set during schema definition. In TypeScript, the referenced type needs to be added explicitly. ```ts import type { FromSchema } from '@feathersjs/schema' export const userSchema = { $id: 'User', type: 'object', additionalProperties: false, required: ['email', 'password'], properties: { id: { type: 'number' }, email: { type: 'string' }, password: { type: 'string' } } } as const export type User = FromSchema export const messageSchema = { $id: 'Message', type: 'object', additionalProperties: false, required: ['text'], properties: { text: { type: 'string' }, user: { $ref: 'User' } } } as const export type Message = FromSchema< typeof messageSchema, { // All schema references need to be passed to get the correct type references: [typeof userSchema] } > ``` ## Query Helpers Schema ships with a few helpers to automatically create schemas that comply with the [Feathers query syntax](../databases/querying.md) (like `$gt`, `$ne` etc.): ### querySyntax `querySyntax(schema.properties, extensions)` initializes all properties the additional query syntax properties `$limit`, `$skip`, `$select` and `$sort`. `$select` and `$sort` will be typed so they only allow existing schema properties. ```ts import { querySyntax } from '@feathersjs/schema' import type { FromSchema } from '@feathersjs/schema' export const userQuerySchema = { $id: 'UserQuery', type: 'object', additionalProperties: false, properties: { ...querySyntax(userSchema.properties) } } as const export type UserQuery = FromSchema const userQuery: UserQuery = { $limit: 10, $select: ['email', 'id'], $sort: { email: 1 } } ``` Additional special query properties [that are not already included in the query syntax](../databases/querying.md) like `$ilike` can be added like this: ```ts import { querySyntax } from '@feathersjs/schema' import type { FromSchema } from '@feathersjs/schema' export const userQuerySchema = { $id: 'UserQuery', type: 'object', additionalProperties: false, properties: { ...querySyntax(userSchema.properties, { email: { $ilike: { type: 'string' } } } as const) } } as const export type UserQuery = FromSchema const userQuery: UserQuery = { $limit: 10, $select: ['email', 'id'], $sort: { email: 1 }, email: { $ilike: '%@example.com' } } ``` ### queryProperty `queryProperty` helper takes a definition for a single property and returns a schema that allows the default query operators. This helper supports the operators listed, below. Learn what each one means in the [common query operator](/api/databases/querying#operators) documentation. - `$gt` - `$gte` - `$lt` - `$lte` - `$ne` - `$in` - `$nin` The `name` property in the example, below, shows how `queryProperty` wraps a single property's definition. ```ts import { queryProperty } from '@feathersjs/schema' export const userQuerySchema = { $id: 'UserQuery', type: 'object', additionalProperties: false, properties: { name: queryProperty({ type: 'string' }) } } as const ``` With the `queryProperty` utility in place, the schema will allow querying on `name` using any of the above-listed operators. With it in place, the query in the following example will not throw an error: ```ts const query = { name: { $in: ['Marco', 'Polo'] } } app.service('users').find({ query }) ``` You can learn how it works, [here](https://github.com/feathersjs/feathers/blob/dove/packages/schema/src/query.ts#L29-L55). ### queryProperties `queryProperties(schema.properties)` takes the all properties of a schema and converts them into query schema properties (using `queryProperty`) ## Validators The following functions are available to get a [validator function](./validators.md) from a JSON schema definition.
See the [validators](./validators.md) chapter for more information on validators and validator functions.
### getDataValidator `getDataValidator(definition, validator)` returns validators for the data of `create`, `update` and `patch` service methods. You can either pass a single definition in which case all properties of the `patch` schema will be optional or individual validators for `create`, `update` and `patch`. ```ts import { getDataValidator, Ajv } from '@feathersjs/schema' import type { FromSchema } from '@feathersjs/schema' const userDataSchema = { $id: 'User', type: 'object', additionalProperties: false, required: ['email', 'password'], properties: { email: { type: 'string' }, password: { type: 'string' } } } as const type UserData = FromSchema const dataValidator = new Ajv() const dataValidator = getDataValidator(userDataSchema, dataValidator) ``` ### getValidator `getValidator(definition, validator)` returns a single validator function for a JSON schema. ```ts import { querySyntax, Ajv, getValidator } from '@feathersjs/schema' import type { FromSchema } from '@feathersjs/schema' export const userQuerySchema = { $id: 'UserQuery', type: 'object', additionalProperties: false, properties: { ...querySyntax(userSchema.properties) } } as const export type UserQuery = FromSchema // Since queries can be only strings we can to coerce them const queryValidator = new Ajv({ coerceTypes: true }) const messageValidator = getValidator(userQuerySchema, queryValidator) ``` ================================================ FILE: docs/api/schema/typebox.md ================================================ --- outline: deep --- # TypeBox `@feathersjs/typebox` allows to define JSON schemas with [TypeBox](https://github.com/sinclairzx81/typebox), a JSON schema type builder with static type resolution for TypeScript. [[toc]]
For additional information also see the [TypeBox documentation](https://github.com/sinclairzx81/typebox/blob/master/readme.md#contents).
## Usage The module exports all of TypeBox functionality with additional support for [query schemas](#query-schemas) and [validators](#validators). The following is an example for defining the message schema [from the guide](../../guides/basics/schemas.md#handling-messages) using TypeBox: ```ts import { Type } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' const messageSchema = Type.Object( { id: Type.Number(), text: Type.String(), createdAt: Type.Number(), userId: Type.Number() }, { $id: 'Message', additionalProperties: false } ) type Message = Static ``` ## Result and data schemas A good approach to define schemas in a Feathers application is to create the main schema first. This is usually the properties that are in the database and things like associated entries. Then we can get the data schema by e.g. picking the properties a client submits using `Type.Pick` ```ts import { Type } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' const userSchema = Type.Object( { id: Type.Number(), email: Type.String(), password: Type.String(), avatar: Type.Optional(Type.String()) }, { $id: 'User', additionalProperties: false } ) type User = Static // Pick the data for creating a new user const userDataSchema = Type.Pick(userSchema, ['email', 'password']) type UserData = Static const messageSchema = Type.Object( { id: Type.Number(), text: Type.String(), createdAt: Type.Number(), userId: Type.Number(), // Reference the user user: Type.Ref(userSchema) }, { $id: 'Message', additionalProperties: false } ) type Message = Static // Pick the data for creating a new message const messageDataSchema = Type.Pick(messageSchema, ['text']) type MessageData = Static ``` ## Query schemas ### querySyntax `querySyntax(definition, extensions, options)` returns a schema to validate the [Feathers query syntax](../databases/querying.md) for all properties in a TypeBox definition. ```ts import { querySyntax } from '@feathersjs/typebox' // Schema for allowed query properties const messageQueryProperties = Type.Pick(messageSchema, ['id', 'text', 'createdAt', 'userId'], { additionalProperties: false }) const messageQuerySchema = querySyntax(messageQueryProperties) type MessageQuery = Static ``` Additional special query properties [that are not already included in the query syntax](../databases/querying.md) like `$ilike` can be added like this: ```ts import { querySyntax } from '@feathersjs/typebox' // Schema for allowed query properties const messageQueryProperties = Type.Pick(messageSchema, ['id', 'text', 'createdAt', 'userId'], { additionalProperties: false }) const messageQuerySchema = Type.Intersect( [ // This will additionally allow querying for `{ name: { $ilike: 'Dav%' } }` querySyntax(messageQueryProperties, { name: { $ilike: Type.String() } }), // Add additional query properties here Type.Object({}) ], { additionalProperties: false } ) ``` To allow additional query properties outside of the query syntax use the intersection type: ```ts import { querySyntax } from '@feathersjs/typebox' // Schema for allowed query properties const messageQueryProperties = Type.Pick(messageSchema, ['id', 'text', 'createdAt', 'userId'], { additionalProperties: false }) const messageQuerySchema = Type.Intersect( [ querySyntax(messageQueryProperties), Type.Object({ isActive: Type.Boolean() }) ], { additionalProperties: false } ) type MessageQuery = Static ``` ### queryProperty `queryProperty(definition)` returns a schema for the [Feathers query syntax](../databases/querying.md) for a single property. ## Validators The following functions are available to get a [validator function](./validators.md) from a TypeBox schema.
See the [validators](./validators.md) chapter for more information on validators and validator functions.
### getDataValidator `getDataValidator(definition, validator)` returns validators for the data of `create`, `update` and `patch` service methods. You can either pass a single definition in which case all properties of the `patch` schema will be optional or individual validators for `create`, `update` and `patch`. ```ts import { Ajv } from '@feathersjs/schema' import { Type, getDataValidator } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' const userSchema = Type.Object( { id: Type.Number(), email: Type.String(), password: Type.String(), avatar: Type.Optional(Type.String()) }, { $id: 'User', additionalProperties: false } ) type User = Static // Pick the data for creating a new user const userDataSchema = Type.Pick(userSchema, ['email', 'password']) const dataValidator = new Ajv() const userDataValidator = getDataValidator(userDataSchema, dataValidator) // For more granular control const userDataValidator = getDataValidator( { create: userDataSchema, update: userDataSchema, patch: Type.Partial(userDataSchema) }, dataValidator ) ``` ### getValidator `getValidator(definition, validator)` returns a single validator function for a TypeBox schema. ```ts import { Ajv } from '@feathersjs/schema' import { Type, getValidator } from '@feathersjs/typebox' // Schema for allowed query properties const messageQueryProperties = Type.Pick(messageSchema, ['id', 'text', 'createdAt', 'userId'], { additionalProperties: false }) const messageQuerySchema = querySyntax(messageQueryProperties) type MessageQuery = Static // Since queries can be only strings we can to coerce them const queryValidator = new Ajv({ coerceTypes: true }) const messageQueryValidator = getValidator(messageQuerySchema, queryValidator) ``` ## Validating Dates When validating dates sent from the client, the most spec-compliant solution is to use the [ISO8601 format](https://www.rfc-editor.org/rfc/rfc3339#section-5.6). For example, SQLite date values are strings in the [ISO8601 format](https://www.rfc-editor.org/rfc/rfc3339#section-5.6), which is `YYYY-MM-DDTHH:MM:SS.SSS`. The character between the date and time formats is generally specified as the letter `T`, as in `2016-01-01T10:20:05.123`. For date values, you implement this spec with `Type.String` and not `Type.Date`. When using AJV you can validate this format with the `ajv-formats` package, which the Feathers CLI installs for you. Using it with `@feathersjs/typebox` looks like this: ```ts const userSchema = Type.Object( { createdAt: Type.String({ format: 'date-time' }) }, { $id: 'User', additionalProperties: false } ) ``` See the `@feathersjs/mongodb` docs for more information on [validating dates with MongoDB](/api/databases/mongodb#dates). ## Types TypeBox provides a set of functions that allow you to compose JSON Schema similar to how you would compose static types with TypeScript. Each function creates a JSON schema fragment which can compose into more complex types. The schemas produced by TypeBox can be passed directly to any JSON Schema-compliant validator, or used to reflect runtime metadata for a type. ### Standard These are the standard TypeBox types. Each section shows equivalent code in three formats: - TypeBox - TypeScript type - JSON Schema The following information comes from the TypeBox documentation. It has been formatted to make it easier to copy/paste examples. #### Primitive Types Primitive type utilities create schemas for individual values. ##### Any Creates a schema that will always pass validation. It's the equivalent of TypeScript's [any](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any) type. ```js const T = Type.Any() ``` ```js type T = any ``` ```js const T = {} ``` ##### Unknown Similar to [any](#any), it creates a schema that will always pass validation. It's the equivalent of TypeScript's [unknown](https://www.typescriptlang.org/docs/handbook/2/functions.html#unknown) type. ```js const T = Type.Unknown() ``` ```js type T = unknown ``` ```js const T = {} ``` ##### String Creates a string schema and type. `Type.String` will generally be used for validating dates sent from clients, as well. See [Validating Dates](#validating-dates). ```js const T = Type.String() ``` ```js type T = string ``` ```js const T = { type: 'string' } ``` ###### String Formats Bundled Strings are the most versatile, serializable type which can be transmitted from clients. Because of their versatility, several custom string formatters are supported, by default, in Feathers CLI-generated applications. [Additional formats](#additional-formats) can be manually enabled.
###### `date-time` ```ts Type.String({ format: 'date-time' }) ``` Validates against the [date-time](https://www.rfc-editor.org/rfc/rfc3339#section-5.6) described in RFC3339/ISO8601, which is the following format: ``` YYYY-MM-DDTHH:MM:SS.SSS+HH:MM 2022-11-30T11:21:44.000-08:00 ``` The sections of this format are described as follows: - **full-date**: `YYYY-MM-DD` - **partial-time**: `HH:MM:SS.SSS` (where `.SSS` represents optional milliseconds) - **time-offset**: `+HH:MM` (where `+` can be `-` and which value represents UTC offset or "time zone") **required**
###### `time` ```ts Type.String({ format: 'time' }) ``` Validates against the following format: ``` HH:MM:SS.SSS+HH:MM 11:21:44.000-08:00 ``` The sections of this format are described as follows: - **partial-time**: `HH:MM:SS.SSS` (where `.SSS` represents optional milliseconds) - **time-offset**: `+HH:MM` (where `+` can be `-` and which value represents UTC offset or "time zone") **optional**
###### `date` ```ts Type.String({ format: 'date' }) ``` Validates against the [full date](https://www.rfc-editor.org/rfc/rfc3339#section-5.6) described in RFC3339/ISO8601, which is the following format: ``` YYYY-MM-DD 2022-11-30 ```
###### `email` ```ts Type.String({ format: 'email' }) ``` Validates email addresses against the format specified by [RFC 1034](https://rumkin.com/software/email/rules/).
###### `hostname` ```ts Type.String({ format: 'hostname' }) ``` Validates hostnames against the format specified by [RFC 1034](https://rumkin.com/software/email/rules/).
###### `ipv4` ```ts Type.String({ format: 'ipv4' }) ``` Validates an IPV4-formatted IP Address. ``` 0.0.0.0 to 255.255.255.255 ```
###### `ipv6` ```ts Type.String({ format: 'ipv6' }) ``` Validates an IPV6-formatted IP Address.
###### `uri` ```ts Type.String({ format: 'uri' }) ``` Validates a full URI.
###### `uri-reference` ```ts Type.String({ format: 'uri-reference' }) ```
###### `uuid` ```ts Type.String({ format: 'uuid' }) ``` Validates a Universally Unique Identifier according to [rfc4122](https://www.rfc-editor.org/rfc/rfc4122).
###### `uri-template` ```ts Type.String({ format: 'uri-template' }) ``` Validates a URI Template according to [rfc6570](https://www.rfc-editor.org/rfc/rfc6570).
###### `json-pointer` ```ts Type.String({ format: 'json-pointer' }) ``` Validates a JSON Pointer, according to [RFC6901](https://www.rfc-editor.org/rfc/rfc6901).
###### `relative-json-pointer` ```ts Type.String({ format: 'relative-json-pointer' }) ``` Validates a Relative JSON Pointer, according to [this draft](https://datatracker.ietf.org/doc/html/draft-luff-relative-json-pointer-00).
###### `regex` ```ts Type.String({ format: 'regex' }) ``` Tests whether a string is a valid regular expression by passing it to RegExp constructor.
###### Additional Formats The `ajv-formats` package bundled with CLI-generated apps includes additional utilities, listed below, which can be manually enabled by modifying the array of formats in `src/schema/validators.ts`. The additional formats are highlighted in this code example: ```ts{16-25} const formats: FormatsPluginOptions = [ 'date-time', 'time', 'date', 'email', 'hostname', 'ipv4', 'ipv6', 'uri', 'uri-reference', 'uuid', 'uri-template', 'json-pointer', 'relative-json-pointer', 'regex', 'iso-time', 'iso-date-time', 'duration', 'byte', 'int32', 'int64', 'float', 'double', 'password', 'binary', ] ``` Be aware that there is also an [ajv-formats-draft2019 package](https://github.com/luzlab/ajv-formats-draft2019) which can be manually installed. The package allows use of several international formats for urls, domains, and emails. The formats are included in [JSON Schema draft-07](https://json-schema.org/draft-07/json-schema-release-notes.html).
###### iso-time Must be manually enabled. See [Additional Formats](#additional-formats). ```ts Type.String({ format: 'iso-time' }) ``` Validates against UTC-based time format: ``` HH:MM:SS.SSSZ 11:21:44.000Z HH:MM:SSZ 11:21:44Z ``` The sections of this format are described as follows: - **partial-time**: `HH:MM:SS.SSS` (where `.SSS` represents optional milliseconds) - **Z**: `Z` (where Z represents UTC time zone, or time offset 00:00)
###### `iso-date-time` ```ts Type.String({ format: 'iso-date-time' }) ``` Validates against the [date-time](https://www.rfc-editor.org/rfc/rfc3339#section-5.6) described in RFC3339/ISO8601, which is the following format: ``` YYYY-MM-DDTHH:MM:SS.SSSZ 2022-11-30T11:21:44.000Z YYYY-MM-DDTHH:MM:SSZ 2022-11-30T11:21:44Z ``` The sections of this format are described as follows: - **full-date**: `YYYY-MM-DD` - **partial-time**: `HH:MM:SS.SSS` (where `.SSS` represents optional milliseconds) - **Z**: `Z` (where Z represents UTC time zone, or time offset 00:00)
###### Duration Must be manually enabled. See [Additional Formats](#additional-formats). ```ts Type.String({ format: 'duration' }) ``` A duration string representing a period of time, as specified in [rfc3339 appendix-A](https://www.rfc-editor.org/rfc/rfc3339#appendix-A) undder the "Durations" heading. Here's an excerpt of the spec. ``` Durations: dur-second = 1*DIGIT "S" dur-minute = 1*DIGIT "M" [dur-second] dur-hour = 1*DIGIT "H" [dur-minute] dur-time = "T" (dur-hour / dur-minute / dur-second) dur-day = 1*DIGIT "D" dur-week = 1*DIGIT "W" dur-month = 1*DIGIT "M" [dur-day] dur-year = 1*DIGIT "Y" [dur-month] dur-date = (dur-day / dur-month / dur-year) [dur-time] duration = "P" (dur-date / dur-time / dur-week) ```
###### Byte Must be manually enabled. See [Additional Formats](#additional-formats). ```ts Type.String({ format: 'byte' }) ``` Validates base64-encoded data according to the [openApi 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0#data-types).
###### int32 Must be manually enabled. See [Additional Formats](#additional-formats). ```ts Type.String({ format: 'int32' }) ``` Validates signed (+/-), 32-bit integers according to the [openApi 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0#data-types).
###### int64 Must be manually enabled. See [Additional Formats](#additional-formats). ```ts Type.String({ format: 'int64' }) ``` Validates signed (+/-), 64-bit integers according to the [openApi 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0#data-types).
###### float Must be manually enabled. See [Additional Formats](#additional-formats). ```ts Type.String({ format: 'float' }) ``` Validates floats according to the [openApi 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0#data-types).
###### double Must be manually enabled. See [Additional Formats](#additional-formats). ```ts Type.String({ format: 'double' }) ``` Validates doubles according to the [openApi 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0#data-types).
###### password Must be manually enabled. See [Additional Formats](#additional-formats). ```ts Type.String({ format: 'password' }) ``` Validates passwords according to the [openApi 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0#data-types).
###### binary Must be manually enabled. See [Additional Formats](#additional-formats). ```ts Type.String({ format: 'binary' }) ``` Validates a binary string according to the [openApi 3.0.0 specification](https://spec.openapis.org/oas/v3.0.0#data-types).
##### Number Creates a number schema and type. ```js const T = Type.Number() ``` ```js type T = number ``` ```js const T = { type: 'number' } ``` ##### Integer Creates a number schema and type. The number has to be an integer (not a float). ```js const T = Type.Integer() ``` ```js type T = number ``` ```js const T = { type: 'integer' } ``` ##### Boolean Creates a boolean schema and type. ```js const T = Type.Boolean() ``` ```js type T = boolean ``` ```js const T = { type: 'boolean' } ``` ##### Null Creates a schema and type only allowing `null`. ```js const T = Type.Null() ``` ```js type T = null ``` ```js const T = { type: 'null' } ``` ##### Literal Creates a schema and type that must match the provided value. ```js const T = Type.Literal(42) ``` ```js type T = 42 ``` ```js const T = { const: 42, type: 'number' } ``` #### Object & Array Types These utilities creates schemas and types for objects and arrays. ##### RegEx Creates a string schema that validates against a regular expression object. The TypeScript type will be `string`. ```js const T = Type.RegEx(/foo/) ``` ```js type T = string ``` ```js const T = { type: 'string', pattern: 'foo' } ``` ##### Array Creates an array of the provided type. You can use any of the utility types to specify what can go in the array, even complex types using [union](#union) and [intersect](#intersect). ```js const T = Type.Array(Type.Number()) ``` ```js type T = number[] ``` ```js const T = { type: 'array', items: { type: 'number' } } ``` ##### Object Creates an object schema where all properties are required by default. You can use the [Type.Optional](#optional) utility to mark a key as optional. ```js const T = Type.Object({ x: Type.Number(), y: Type.Number() }) ``` ```js type T = { x: number, y: number } ``` ```js const T = { type: 'object', properties: { x: { type: 'number' }, y: { type: 'number' } }, required: ['x', 'y'] } ``` ##### Tuple Creates an array type with exactly two items matching the specified types. ```js const T = Type.Tuple([Type.Number(), Type.Number()]) ``` ```js type T = [number, number] ``` ```js const T = { type: 'array', items: [{ type: 'number' }, { type: 'number' }], additionalItems: false, minItems: 2, maxItems: 2 } ``` ##### StringEnum `StringEnum` is a standalone utility to for specifying an array of allowed string values on a property. It is directly exported from `@feathersjs/typebox`: ```js // import the module, first import { StringEnum } from '@feathersjs/typebox' const T = StringEnum(['crow', 'dove', 'eagle']) // Add additional options const T = StringEnum(['crow', 'dove', 'eagle'], { default: 'crow' }) ``` To obtain the TypeScript type, use the `Static` utility: ```js import { Static } from '@feathersjs/typebox' type T = Static ``` ```js const T = { enum: ['crow', 'dove', 'eagle'] } ``` ##### Enum
For string values, use [StringEnum](#stringenum).
```js enum Foo { A, B, } const T = Type.Enum(Foo) ``` ```js enum Foo { A, B, } type T = Foo ``` ```js const T = { anyOf: [ { type: 'number', const: 0 }, { type: 'number', const: 1 } ] } ``` #### Utility Types The utility types create types which are derived from other types. ##### KeyOf Creates a schema for a string that can be any of the keys of a provided `Type.Object`. It's similar to TypeScript's [KeyOf](https://www.typescriptlang.org/docs/handbook/2/keyof-types.html#handbook-content) operator. ```js const T = Type.KeyOf( Type.Object({ x: Type.Number(), y: Type.Number() }) ) ``` ```js type T = keyof { x: number, y: number, } ``` ```js const T = { anyOf: [ { type: 'string', const: 'x' }, { type: 'string', const: 'y' } ] } ``` ##### Union Creates a type which can be one of the types in the provided array. It's the equivalent to using `|` to form a TypeScript [Union](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes-func.html#unions). ```js const T = Type.Union([Type.String(), Type.Number()]) ``` ```js type T = string | number ``` ```js const T = { anyOf: [{ type: 'string' }, { type: 'number' }] } ``` ##### Intersect Creates an object type by combining two or more other object types. ```js const T = Type.Intersect([ Type.Object({ x: Type.Number() }), Type.Object({ y: Type.Number() }) ]) ``` ```js type T = { x: number } & { y: number } ``` ```js const T = { type: 'object', properties: { x: { type: 'number' }, y: { type: 'number' } }, required: ['x', 'y'] } ``` ##### Never Creates a type that will never validate if the attribute is present. This is useful if you are allowing [additionalProperties](#additionalproperties) but need to prevent using specific keys. ```js const T = Type.Never() ``` ```js type T = never ``` ```js const T = { allOf: [ { type: 'boolean', const: false }, { type: 'boolean', const: true } ] } ``` ##### Record Creates the JSON Schema equivalent of TypeScript's [Record](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type) utility type. ```js const T = Type.Record(Type.String(), Type.Number()) ``` ```js type T = Record ``` ```js const T = { type: 'object', patternProperties: { '^.*$': { type: 'number' } } } ``` ##### Partial Creates a schema for an object where all keys are optional. It's the opposite of [Required](#required), and the JSON Schema equivalent of TypeScript's [Partial](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype) utility type. ```js const T = Type.Partial( Type.Object({ x: Type.Number(), y: Type.Number() }) ) ``` ```js type T = Partial<{ x: number, y: number }> ``` ```js const T = { type: 'object', properties: { x: { type: 'number' }, y: { type: 'number' } } } ``` ##### Required Creates a schema for an object where all keys are required, even ignoring if keys are marked with `Type.Optional`. It's the opposite of [Partial](#partial), and the JSON Schema equivalent of TypeScript's [Required](https://www.typescriptlang.org/docs/handbook/utility-types.html#requiredtype) utility type. ```js const T = Type.Required( Type.Object({ x: Type.Optional(Type.Number()), y: Type.Optional(Type.Number()) }) ) ``` ```js type T = Required<{ x?: number, y?: number }> ``` ```js const T = { type: 'object', properties: { x: { type: 'number' }, y: { type: 'number' } }, required: ['x', 'y'] } ``` ##### Pick Forms a new object containing only the array of keys provided in the second argument. It's the JSON Schema equivalent of TypeScript's [Pick](https://www.typescriptlang.org/docs/handbook/utility-types.html#picktype-keys) utility type. ```js const T = Type.Pick( Type.Object({ x: Type.Number(), y: Type.Number() }), ['x'] ) ``` ```js type T = Pick< { x: number, y: number }, 'x' > ``` ```js const T = { type: 'object', properties: { x: { type: 'number' } }, required: ['x'] } ``` ##### Omit Forms a new object containing all keys except those provided in the second argument. It's the JSON Schema equivalent of TypeScript's [Omit](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys) utility type. ```js const T = Type.Omit( Type.Object({ x: Type.Number(), y: Type.Number() }), ['x'] ) ``` ```js type T = Omit< { x: number, y: number }, 'x' > ``` ```js const T = { type: 'object', properties: { y: { type: 'number' } }, required: ['y'] } ``` ### Modifiers TypeBox provides modifiers that can be applied to an objects properties. This allows for `optional` and `readonly` to be applied to that property. The following table illustrates how they map between TypeScript and JSON Schema. #### Optional Allows marking a key in [Type.Object](#object) as optional. ```js const T = Type.Object({ name: Type.Optional(Type.String()) }) ``` ```js type T = { name?: string } ``` ```js const T = { type: 'object', properties: { name: { type: 'string' } } } ``` #### Readonly Allows marking a key in [Type.Object](#object) as readonly. It's the equivalent of TypeScript's [Readonly](https://www.typescriptlang.org/docs/handbook/utility-types.html#readonlytype) utility type. ```js const T = Type.Object({ name: Type.Readonly(Type.String()) }) ``` ```js type T = { readonly name: string } ``` ```js const T = { type: 'object', properties: { name: { type: 'string' } }, required: ['name'] } ``` #### ReadonlyOptional Allows marking a key in [Type.Object](#object) as both [readonly](#readonly) and [optional](#optional). ```js const T = Type.Object({ name: Type.ReadonlyOptional(Type.String()) }) ``` ```js type T = { readonly name?: string } ``` ```js const T = { type: 'object', properties: { name: { type: 'string' } } } ``` ### Options by Type You can pass additional JSON schema options on the last argument of any given type. The [JSON Schema specification](https://json-schema.org/draft/2020-12/json-schema-validation.html#name-a-vocabulary-for-structural) describes options for each data type. Descriptions from the specification are copied here for easy reference. #### For Numbers Number types support the following options, which can be used simultaneously. ##### `multipleOf` The value of "multipleOf" MUST be a number, strictly greater than 0. Values are valid only if division by this keyword's value results in an integer. ```ts const T = Type.Number({ multipleOf: 2 }) ``` ##### `maximum` The value of "maximum" MUST be a number, representing an inclusive upper limit for a numeric instance. If the instance is a number, then this keyword validates only if the instance is less than or exactly equal to "maximum". ```ts const T = Type.Number({ maximum: 20 }) ``` ##### `exclusiveMaximum` The value of "exclusiveMaximum" MUST be a number, representing an exclusive upper limit for a numeric instance. If the instance is a number, then the instance is valid only if it has a value strictly less than (not equal to) "exclusiveMaximum". ```ts const T = Type.Number({ exclusiveMaximum: 20 }) ``` ##### `minimum` The value of "minimum" MUST be a number, representing an inclusive lower limit for a numeric instance. If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to "minimum". ```ts const T = Type.Number({ minimum: 20 }) ``` ##### `exclusiveMinimum` The value of "exclusiveMinimum" MUST be a number, representing an exclusive lower limit for a numeric instance. If the instance is a number, then the instance is valid only if it has a value strictly greater than (not equal to) "exclusiveMinimum". ```ts const T = Type.Number({ exclusiveMinimum: 20 }) ``` #### For Strings String types support the following options, which can be used simultaneously. ##### `maxLength` The value of this keyword MUST be a non-negative integer. A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword. The length of a string instance is defined as the number of its characters as defined by RFC 8259 [RFC8259]. ##### `minLength` The value of this keyword MUST be a non-negative integer. A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword. The length of a string instance is defined as the number of its characters as defined by RFC 8259 [RFC8259]. Omitting this keyword has the same behavior as a value of 0. ##### `pattern` Use `Type.Regex`, instead of this option. ##### With AJV Formats There are four custom options which are only available for certain formats when using the `ajv-formats` package: - [formatMinimum](#formatminimum) - [formatMaximum](#formatmaximum) - [formatExclusiveMinimum](#formatexclusiveminimum) - [formatExclusiveMaximum](#formatexclusivemaximum) The above-listed options are only available when using the following [string formats](#string-formats). - [date](#date) - [time](#time) - [date-time](#date-time) - [iso-time](#iso-time) - [iso-date-time](#iso-date-time) ##### `formatMinimum` Allows defining minimum constraints when the `format` keyword defines ordering (using the compare function in format definition). Available when using [ajv-formats](#with-ajv-formats). The following example validates that the provided date is on or after November 13, 2022. ```ts Type.String({ format: 'date', formatMinimum: '2022-11-13' }) ``` ##### `formatMaximum` Allows defining maximum constraints when the `format` keyword defines ordering (using the compare function in format definition). Available when using [ajv-formats](#with-ajv-formats). The following example validates that the provided date is on or before November 13, 2022. ```ts Type.String({ format: 'date', formatMaximum: '2022-11-13' }) ``` ##### `formatExclusiveMinimum` Allows defining exclusive minimum constraints when the `format` keyword defines ordering (using the compare function in format definition). Available when using [ajv-formats](#with-ajv-formats). The following example validates that the provided date is after (and not on) November 13, 2022. ```ts Type.String({ format: 'date', formatExclusiveMinimum: '2022-11-13' }) ``` ##### `formatExclusiveMaximum` Allows defining exclusive maximum constraints when the `format` keyword defines ordering (using the compare function in format definition). Available when using [ajv-formats](#with-ajv-formats). The following example validates that the provided date is before (and not on) November 13, 2022. ```ts Type.String({ format: 'date', formatExclusiveMaximum: '2022-11-13' }) ``` #### For Arrays Array types support the following options, which can be used simultaneously. ##### `maxItems` The value of this keyword MUST be a non-negative integer. An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword. ##### `minItems` The value of this keyword MUST be a non-negative integer. An array instance is valid against "minItems" if its size is greater than, or equal to, the value of this keyword. Omitting this keyword has the same behavior as a value of 0. ##### `uniqueItems` The value of this keyword MUST be a boolean. If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique. Omitting this keyword has the same behavior as a value of false. ##### `maxContains` The value of this keyword MUST be a non-negative integer. If "contains" is not present within the same schema object, then this keyword has no effect. An instance array is valid against "maxContains" in two ways, depending on the form of the annotation result of an adjacent "contains" [json-schema] keyword. The first way is if the annotation result is an array and the length of that array is less than or equal to the "maxContains" value. The second way is if the annotation result is a boolean "true" and the instance array length is less than or equal to the "maxContains" value. ##### `minContains` The value of this keyword MUST be a non-negative integer. If "contains" is not present within the same schema object, then this keyword has no effect. An instance array is valid against "minContains" in two ways, depending on the form of the annotation result of an adjacent "contains" [json-schema] keyword. The first way is if the annotation result is an array and the length of that array is greater than or equal to the "minContains" value. The second way is if the annotation result is a boolean "true" and the instance array length is greater than or equal to the "minContains" value. A value of 0 is allowed, but is only useful for setting a range of occurrences from 0 to the value of "maxContains". A value of 0 causes "minContains" and "contains" to always pass validation (but validation can still fail against a "maxContains" keyword). Omitting this keyword has the same behavior as a value of 1. #### For Objects Array types support the following options, which can be used simultaneously. ##### `additionalProperties` Specifies if keys other than the ones specified in the schema are allowed to be present in the object. ##### `maxProperties` The value of this keyword MUST be a non-negative integer. An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword. ##### `minProperties` The value of this keyword MUST be a non-negative integer. An object instance is valid against "minProperties" if its number of properties is greater than, or equal to, the value of this keyword. Omitting this keyword has the same behavior as a value of 0. ##### `required` All TypeBox types are required unless you wrap them in [Type.Optional](#optional), so you don't need to use this option, manually. ##### `dependentRequired` The value of this keyword MUST be an object. Properties in this object, if any, MUST be arrays. Elements in each array, if any, MUST be strings, and MUST be unique. This keyword specifies properties that are required if a specific other property is present. Their requirement is dependent on the presence of the other property. Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value, every item in the corresponding array is also the name of a property in the instance. Omitting this keyword has the same behavior as an empty object. ### Extended In addition to JSON schema types, TypeBox provides several extended types that allow for the composition of `function` and `constructor` types. These additional types are not valid JSON Schema and will not validate using typical JSON Schema validation. However, these types can be used to frame JSON schema and describe callable interfaces that may receive JSON validated data. Since these are nonstandard types, most applications will not need them. Consider using the [Standard Types](#standard), instead, as using these types may make it difficult to upgrade your application in the future. #### Extended Configuration Utilities in this section require updating `src/schemas/validators.ts` to the Extended Ajv Configuration, as shown here: ```ts import { TypeGuard } from '@sinclair/typebox' import { Value } from '@sinclair/typebox/value' import addFormats from 'ajv-formats' import type { Options } from 'ajv' import Ajv from 'ajv' function schemaOf(schemaOf: string, value: unknown, schema: unknown) { switch (schemaOf) { case 'Constructor': return TypeGuard.IsConstructor(schema) && Value.Check(schema, value) // not supported case 'Function': return TypeGuard.IsFunction(schema) && Value.Check(schema, value) // not supported case 'Date': return TypeGuard.IsDate(schema) && Value.Check(schema, value) case 'Promise': return TypeGuard.IsPromise(schema) && Value.Check(schema, value) // not supported case 'Uint8Array': return TypeGuard.IsUint8Array(schema) && Value.Check(schema, value) case 'Undefined': return TypeGuard.IsUndefined(schema) && Value.Check(schema, value) // not supported case 'Void': return TypeGuard.IsVoid(schema) && Value.Check(schema, value) default: return false } } export function createAjv(options: Options = {}) { return addFormats(new Ajv(options), [ 'date-time', 'time', 'date', 'email', 'hostname', 'ipv4', 'ipv6', 'uri', 'uri-reference', 'uuid', 'uri-template', 'json-pointer', 'relative-json-pointer', 'regex', ]) .addKeyword({ type: 'object', keyword: 'instanceOf', validate: schemaOf }) .addKeyword({ type: 'null', keyword: 'typeOf', validate: schemaOf }) .addKeyword('exclusiveMinimumTimestamp') .addKeyword('exclusiveMaximumTimestamp') .addKeyword('minimumTimestamp') .addKeyword('maximumTimestamp') .addKeyword('minByteLength') .addKeyword('maxByteLength') } export const dataValidator: Ajv = createAjv({}) export const queryValidator: Ajv = createAjv({ coerceTypes: true }) ``` If you see an error stating `Error: strict mode: unknown keyword: "instanceOf"`, it's likely because you need to extend your configuration, as shown above. #### Constructor Verifies that the value is a constructor with typed arguments and return value. Requires [Extended Ajv Configuration](#extended-configuration). ```js const T = Type.Constructor([Type.String(), Type.Number()], Type.Boolean()) ``` ```js type T = new ( arg0: string, arg1: number, ) => boolean ``` ```js const T = { type: 'constructor', parameters: [ { type: 'string' }, { type: 'number' }, ], return { type: 'boolean', }, } ``` #### Function Verifies that the value is a function with typed arguments and return value. Requires [Extended Ajv Configuration](#extended-configuration). ```js const T = Type.Function([Type.String(), Type.Number()], Type.Boolean()) ``` ```js type T = ({ arg0: string, arg1: number }) => boolean ``` ```js const T = { type: 'function', parameters: [ { type: 'string' }, { type: 'number' }, ], return { type: 'boolean', }, } ``` #### Promise Verifies that the value is an instanceof Promise which resolves to the provided type. Requires [Extended Ajv Configuration](#extended-configuration). ```js const T = Type.Promise(Type.String()) ``` ```js type T = Promise ``` ```js const T = { type: 'promise', item: { type: 'string' } } ``` #### Uint8Array Verifies that the value is an instanceof Uint8Array. Requires [Extended Ajv Configuration](#extended-configuration). ```js const T = Type.Uint8Array() ``` ```js type T = Uint8Array ``` ```js const T = { type: 'object', instanceOf: 'Uint8Array' } ``` #### Date Verifies that the value is an instanceof Date. This is likely not the validator to use for storing dates in a database. See [Validating Dates](#validating-dates). Requires [Extended Ajv Configuration](#extended-configuration). ```js const T = Type.Date() ``` ```js type T = Date ``` ```js const T = { type: 'object', instanceOf: 'Date' } ``` #### Undefined Verifies that the value is `undefined`. Requires [Extended Ajv Configuration](#extended-configuration). ```js const T = Type.Undefined() ``` ```js type T = undefined ``` ```js const T = { type: 'object', specialized: 'Undefined' } ``` #### Symbol Verifies that the value is of type `Symbol`. Requires [Extended Ajv Configuration](#extended-configuration). ```js const T = Type.Symbol() ``` ```js type T = symbol ``` ```js const T = { type: 'null', typeOf: 'Symbol' } ``` #### BigInt Verifies that the value is of type `BigInt`. Requires [Extended Ajv Configuration](#extended-configuration). ```js const T = Type.BigInt() ``` ```js type T = bigint ``` ```js const T = { type: 'null', typeOf: 'BigInt' } ``` #### Void Verifies that the value is `null`. Requires [Extended Ajv Configuration](#extended-configuration). ```js const T = Type.Void() ``` ```js type T = void ``` ```js const T = { type: 'null' } ``` ### Reference Use `Type.Ref(...)` to create referenced types. The target type must specify an `$id`. ```ts const T = Type.String({ $id: 'T' }) const R = Type.Ref(T) ``` For a more detailed example see the [result and data schema](#result-and-data-schemas) section. ================================================ FILE: docs/api/schema/validators.md ================================================ --- outline: deep --- # Validators [Ajv](https://ajv.js.org/) is the default JSON Schema validator used by `@feathersjs/schema`. We chose it because it's fully compliant with the JSON Schema spec and it's the fastest JSON Schema validator because it has its own compiler. It pre-compiles code for each validator, instead of dynamically creating validators from schemas during runtime.
Ajv and most other validation libraries are only used for ensuring data is valid and are not designed to convert data to different types. Type conversions and populating data can be done using [resolvers](./resolvers.md). This ensures a clean separation of concern between validating and populating data.
## Usage The following is the standard `validators.ts` file that sets up a validator for data and queries (for which string types will be coerced automatically). It also sets up a collection of additional formats using [ajv-formats](https://ajv.js.org/packages/ajv-formats.html). The validators in this file can be customized according to the [Ajv documentation](https://ajv.js.org/) and [its plugins](https://ajv.js.org/packages/). You can find the available Ajv options in the [Ajv class API docs](https://ajv.js.org/options.html). ```ts import { Ajv, addFormats } from '@feathersjs/schema' import type { FormatsPluginOptions } from '@feathersjs/schema' const formats: FormatsPluginOptions = [ 'date-time', 'time', 'date', 'email', 'hostname', 'ipv4', 'ipv6', 'uri', 'uri-reference', 'uuid', 'uri-template', 'json-pointer', 'relative-json-pointer', 'regex' ] export const dataValidator = addFormats(new Ajv({}), formats) export const queryValidator = addFormats( new Ajv({ coerceTypes: true }), formats ) ``` ## Validation functions A validation function takes data and validates them against a schema using a validator. They can be used with any validation library. Currently the `getValidator` functions are available for: - [TypeBox schema](./typebox.md#validators) to validate a TypeBox definition using an Ajv validator instance - [JSON schema](./schema.md#validators) to validate a JSON schema object using an Ajv validator instance ## Hooks The following hooks take a [validation function](#validation-functions) and validate parts of the [hook context](../hooks.md#hook-context). ### validateData `schemaHooks.validateData` takes a [validation function](#validation-functions) and allows to validate the `data` in a `create`, `update` and `patch` request as well as [custom service methods](../services.md#custom-methods). It can be used as an `around` or `before` hook. ```ts import { Ajv, hooks as schemaHooks } from '@feathersjs/schema' import { Type, getValidator } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' import { dataValidator } from '../validators' const userSchema = Type.Object( { id: Type.Number(), email: Type.String(), password: Type.String(), avatar: Type.Optional(Type.String()) }, { $id: 'User', additionalProperties: false } ) type User = Static const userDataSchema = Type.Pick(userSchema, ['email', 'password']) // Returns validation functions for `create`, `update` and `patch` const userDataValidator = getValidator(userDataSchema, dataValidator) app.service('users').hooks({ before: { all: [schemaHooks.validateData(userDataValidator)] } }) ``` ### validateQuery `schemaHooks.validateQuery` takes a [validation function](#validation-functions) and validates the `query` of a request. It can be used as an `around` or `before` hook. When using the `queryValidator` from the [usage](#usage) section, strings will automatically be converted to the right type using [Ajv's type coercion rules](https://ajv.js.org/coercion.html). ```ts import { Ajv, schemaHooks } from '@feathersjs/schema' import { Type, getValidator } from '@feathersjs/typebox' import { queryValidator } from '../validators' // Schema for allowed query properties const messageQueryProperties = Type.Pick(messageSchema, ['id', 'text', 'createdAt', 'userId'], { additionalProperties: false }) const messageQuerySchema = querySyntax(messageQueryProperties) type MessageQuery = Static const messageQueryValidator = getValidator(messageQuerySchema, queryValidator) app.service('messages').hooks({ around: { all: [schemaHooks.validateQuery(messageQueryValidator)] } }) ``` ### Using validators with custom methods You can optionally create validators for your custom methods. For example we will create a custom method in our `user` service that simply says "Hello ${name}" to the requestor. For the example we can use this TypeBox schema ```ts //Our request object, we expect something like {name: "Bob"} export const sayHelloRequest = Type.Object( { name: Type.String({ description: "Who are we saying hello to!", examples: ["Bob"], minLength: 2, }), }, { $id: "sayHelloRequest", additionalProperties: false }, ); //We intend on returning an object with a string response property export const sayHelloResponse = Type.Object( { response: Type.String() }, { $id: "sayHelloResponse", additionalProperties: false }, ); export const sayHelloValidator = getValidator(sayHelloRequest, dataValidator); ``` In our user class file, we can define our custom method ```ts async sayHello(data: Static): Promise> { const { name } = data return { response: `Hello ${name}` } } ``` Finally, we can add our validator in our service hooks ```ts sayHello: [schemaHooks.validateData(sayHelloValidator)] ``` ================================================ FILE: docs/api/services.md ================================================ --- outline: deep --- # Services Services are the heart of every Feathers application. Services are objects or instances of [classes](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes) that implement [certain methods](#service-methods). Feathers itself will also add some [additional methods and functionality](#feathers-functionality) to its services. ## Service methods Service methods are pre-defined [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) and [custom methods](#custom-methods) that your service provides or that have already been implemented by one of the [database adapters](./databases/common.md). Below is an example of a Feathers service as a class or object. ```ts import { feathers } from '@feathersjs/feathers' import type { Params, Id, NullableId } from '@feathersjs/feathers' class MyServiceClass { async find(params: Params) { return [] } async get(id: Id, params: Params) {} async create(data: any, params: Params) {} async update(id: NullableId, data: any, params: Params) {} async patch(id: NullableId, data: any, params: Params) {} async remove(id: NullableId, params: Params) {} async setup(app: Application, path: string) {} async teardown(app: Application, path: string) {} } const myServiceObject = { async find(params: Params) { return [] }, async get(id: Id, params: Params) {}, async create(data: any, params: Params) {}, async update(id: NullableId, data: any, params: Params) {}, async patch(id: NullableId, data: any, params: Params) {}, async remove(id: NullableId, params: Params) {}, async setup(app: Application, path: string) {}, async teardown(app: Application, path: string) {} } type ServiceTypes = { 'my-service': MyServiceClass 'my-service-object': typeof myServiceObject } const app = feathers() app.use('my-service', new MyServiceClass()) app.use('my-service-object', myServiceObject) ```
Always use the service returned by `app.service(path)` not the service object or class directly or you will not get any of the [Feathers service functionality](services.md#feathers-functionality)
Methods are optional and if a method is not implemented Feathers will automatically emit a `NotImplemented` error. At least one standard service method must be implemented to be considered a service. If you used `methods` option when registering the service via [app.use](./application.md#usepath-service--options), all methods listed must be available.
Service methods must use [async/await](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) or return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) and have the following parameters: - `id` — The identifier for the resource. A resource is the data identified by a unique id. - `data` — The resource data. - `params` - Additional parameters for the method call (see [params](#params)) Once registered, the service can be retrieved and used via [app.service()](./application.md#servicepath): ```js const myService = app.service('my-service') const items = await myService.find() const item = await app.service('my-service').get(1) console.log('.get(1)', item) ```
Although probably the most common use case, a service does not necessarily have to connect to a database. A custom service can implement any functionality like talking to another API or send an email etc.
This section describes the general usage of service methods and how to implement them. They are already implemented by the official Feathers database adapters. For specifics on how to use the database adapters, see the [database adapters documentation](./databases/common.md).
### params `params` contain additional information for the service method call. Some properties in `params` can be set by Feathers already. Commonly used are: - `params.query` - the query parameters from the client, either passed as URL query parameters (see the [REST](./express.md) chapter) or through websockets (see [Socket.io](./socketio.md)). - `params.provider` - The transport (`rest` or `socketio`) used for this service call. Will be `undefined` for internal calls from the server (unless passed explicitly). - `params.authentication` - The authentication information to use for the [authentication service](./authentication/service.md) - `params.user` - The authenticated user, either set by [Feathers authentication](./authentication/) or passed explicitly. - `params.connection` - If the service call has been made by a real-time transport (e.g. through websockets), `params.connection` is the connection object that can be used with [channels](./channels.md). - `params.headers` - The HTTP headers connected to this service call if available. This is either the headers of the REST call or the headers passed when initializing a websocket connection.
For external calls only `params.query` will be sent between the client and server. This is because other parameters in `params` on the server often contain security critical information (like `params.user` or `params.authentication`).
### .find(params) `service.find(params) -> Promise` - Retrieves a list of all resources from the service. `params.query` can be used to filter and limit the returned data. ```ts class MessageService { async find(params: Params) { return [ { id: 1, text: 'Message 1' }, { id: 2, text: 'Message 2' } ] } } app.use('messages', new MessageService()) ```
`find` does not have to return an array. It can also return an object. The database adapters already do this for [pagination](./databases/common.md#pagination).
### .get(id, params) `service.get(id, params) -> Promise` - Retrieves a single resource with the given `id` from the service. ```ts import type { Id, Params } from '@feathersjs/feathers' class TodoService { async get(id: Id, params: Params) { return { id, text: `You have to do ${id}!` } } } app.use('todos', new TodoService()) ``` ### .create(data, params) `service.create(data, params) -> Promise` - Creates a new resource with `data`. The method should return with the newly created data. `data` may also be an array. A successful `create` method call emits the [`created` service event](./events.md#created) with the returned data or a separate event for every item if the returned data is an array. ```ts import type { Id, Params } from '@feathersjs/feathers' type Message = { text: string } class MessageService { messages: Message[] = [] async create(data: Message, params: Params) { this.messages.push(data) return data } } app.use('messages', new MessageService()) ```
Note that `data` may also be an array. When using a [database adapters](./databases/adapters.md) the [`multi` option](./databases/common.md) has to be set to allow arrays.
### .update(id, data, params) `service.update(id, data, params) -> Promise` - Replaces the resource identified by `id` with `data`. The method should return with the complete, updated resource data. `id` can also be `null` when updating multiple records. A successful `update` method call emits the [`updated` service event](./events.md#updated-patched). If an array is returned, it will send an individual `updated` event for every item.
The [database adapters](./databases/adapters.md) do not support completely replacing multiple entries.
### .patch(id, data, params) `patch(id, data, params) -> Promise` - Merges the existing data of the resource identified by `id` with the new `data`. `id` can also be `null` indicating that multiple resources should be patched with `params.query` containing the query criteria. A successful `patch` method call emits the [`patched` service event](./events.md#updated-patched) with the returned data. When an array is returned when patching mutiple items, it will send an individual `patched` event for every item in the array. The method should return with the complete, updated resource data. Implement `patch` additionally (or instead of) `update` if you want to distinguish between partial and full updates and support the `PATCH` HTTP method.
With [database adapters](./databases/adapters.md) the [`multi` option](./databases/common.md) has to be set explicitly to support patching multiple entries.
### .remove(id, params) `service.remove(id, params) -> Promise` - Removes the resource with `id`. The method should return with the removed data. `id` can also be `null`, which indicates the deletion of multiple resources, with `params.query` containing the query criteria. A successful `remove` method call emits the [`removed` service event](./events.md#removed) with the returned data or a separate event for every item if the returned data is an array.
With [database adapters](./databases/adapters.md) the [`multi` option](./databases/common.md) has to be set explicitly to support removing multiple entries.
### .setup(app, path) `service.setup(app, path) -> Promise` is a special method that initializes the service, passing an instance of the Feathers application and the path it has been registered on. When calling [app.listen](application.md#listenport) or [app.setup](application.md#setupserver) all registered services `setup` methods will be called. If a service is registered afterwards, the `setup` method will be called immediately. ### .teardown(app, path) `service.teardown(app, path) -> Promise` is a special method that shuts down the service, passing an instance of the Feathers application and the path it has been registered on. If a service implements a `teardown` method, it will be called during [app.teardown()](application.md#teardownserver) or when unregistering the service via [app.unuse](./application.md#unusepath). ## Custom Methods A custom method is any other service method you want to expose publicly. A custom method **must have** the signature of `(data, params)` with the same semantics as standard service methods (`data` is the payload, `params` is the service [params](#params)). They can be used with [hooks](./hooks.md) (including authentication) and must be `async` or return a Promise. In order to register a public custom method, the names of _all methods_ have to be passed as the `methods` option when registering the service with [app.use()](./application.md#usepath-service--options) ```ts import type { Id, Params } from '@feathersjs/feathers' type CustomData = { name: string } class MyService { async get(id: Id, params: Params) { return { id, message: `You have to do ${id}` } } async myCustomMethod(data: CustomData, params: Params) { return data } } type ServiceTypes = { 'my-service': MyService } const app = feathers() .configure(rest()) .use('my-service', new MyService(), { // Pass all methods you want to expose methods: ['get', 'myCustomMethod'] }) ``` See the [REST client](./client/rest.md) and [Socket.io client](./client/socketio.md) chapters on how to use those custom methods on the client.
When passing the `methods` option **all methods** you want to expose, including standard service methods, must be listed. This allows to completely disable standard service method you might not want to expose. The `methods` option only applies to external access (via a transport like HTTP or websockets). All methods continue to be available internally on the server.
## Feathers functionality When registering a service, Feathers (or its plugins) can also add its own methods to a service. Most notably, every service will automatically become an instance of a [NodeJS EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter). ### .hooks(hooks) Register [hooks](./hooks.md) for this service. ### .publish([event, ] publisher) Register an event publishing callback. For more information, see the [channels chapter](./channels.md). ### .on(eventname, listener) Provided by the core [NodeJS EventEmitter .on](https://nodejs.org/api/events.html#events_emitter_on_eventname_listener). Registers a `listener` method (`function(data) {}`) for the given `eventname`.
For more information about service events, see the [Events chapter](./events.md).
### .emit(eventname, data) Provided by the core [NodeJS EventEmitter .emit](https://nodejs.org/api/events.html#events_emitter_emit_eventname_args). Emits the event `eventname` to all event listeners. ### .removeListener(eventname) Provided by the core [NodeJS EventEmitter .removeListener](https://nodejs.org/api/events.html#events_emitter_removelistener_eventname_listener). Removes all listeners, or the given listener, for `eventname`. ================================================ FILE: docs/api/socketio.md ================================================ --- outline: deep --- # Socket.io [![npm version](https://img.shields.io/npm/v/@feathersjs/socketio.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/socketio) [![Changelog](https://img.shields.io/badge/changelog-.md-blue.svg?style=flat-square)](https://github.com/feathersjs/feathers/blob/dove/packages/socketio/CHANGELOG.md) ``` npm install @feathersjs/socketio --save ``` The [@feathersjs/socketio](https://github.com/feathersjs/socketio) module allows to call [service methods](./services.md) and receive [real-time events](./events.md) via [Socket.io](http://socket.io/), a NodeJS library which enables real-time bi-directional, event-based communication.
This page describes how to set up a Socket.io server. The [Socket.io client chapter](./client/socketio.md) shows how to connect to this server on the client and the message format for service calls and real-time events.
## Configuration `@feathersjs/socketio` can be used standalone or together with a Feathers framework integration like [Express](./express.md). ### socketio() `app.configure(socketio())` sets up the Socket.io transport with the default configuration using either the server provided by [app.listen](./application.md#listenport) or passed in [app.setup(server)](./application.md#setupserver). ```ts import { feathers } from '@feathersjs/feathers' import socketio from '@feathersjs/socketio' const app = feathers() app.configure(socketio()) app.listen(3030) ```
Once the server has been started with `app.listen()` or `app.setup(server)` the Socket.io object is available as `app.io`. Usually you should not have to send or listen to events on `app.io` directly.
### socketio(callback) `app.configure(socketio(callback))` sets up the Socket.io transport with the default configuration and call `callback` with the [Socket.io server object](http://socket.io/docs/server-api/). ```ts import { feathers } from '@feathersjs/feathers' import socketio from '@feathersjs/socketio' const app = feathers() app.configure( socketio((io) => { io.on('connection', (socket) => { // Do something here }) // Registering Socket.io middleware io.use(function (socket, next) { // Exposing a request property to services and hooks socket.feathers.referrer = socket.request.referrer next() }) }) ) app.listen(3030) ```
Try to avoid listening and sending events on the `socket` directly since it circumvents Feathers secure dispatch mechanisms available through [channels](./channels.md) and [hooks](./hooks.md).
#### Using uWebSockets.js uWS can be used as a drop in replacement for socket handling. As a result you'll see lower latencies, a better memory footprint and even slightly less overall resource usage. You will on the other hand need to install the following extra package to get things working. ``` npm install uNetworking/uWebSockets.js#20.31.0 --save ``` Now you can use the `io.attachApp` function to attach uWS as a replacement. ```ts import { feathers } from '@feathersjs/feathers' import socketio from '@feathersjs/socketio' import { App } from 'uWebSockets.js' const app = feathers() app.configure( socketio((io) => { io.attachApp(App()) }) ) app.listen(3030) ``` ### socketio(options [, callback]) `app.configure(socketio(options [, callback]))` sets up the Socket.io transport with the given [Socket.io options object](https://github.com/socketio/engine.io#methods-1) and optionally calls the callback described above. This can be used to e.g. configure the path where Socket.io is initialize (`socket.io/` by default). The following changes the path to `ws/`: ```ts import { feathers } from '@feathersjs/feathers' import socketio from '@feathersjs/socketio' const app = feathers() app.configure( socketio( { path: '/ws/' }, (io) => { // Do something here // This function is optional } ) ) app.listen(3030) ``` ### socketio(port, [options], [callback]) `app.configure(socketio(port, [options], [callback]))` creates a new Socket.io server on a separate port. Options and a callback are optional and work as described above. ```ts import { feathers } from '@feathersjs/feathers' import socketio from '@feathersjs/socketio' const app = feathers() app.configure(socketio(3031)) app.listen(3030) ``` ## params [Socket.io middleware](https://socket.io/docs/v4/middlewares/) can modify the `feathers` property on the `socket` which will then be used as the service call `params`: ```ts app.configure( socketio((io) => { io.use((socket, next) => { socket.feathers.user = { name: 'David' } next() }) }) ) app.use('messages', { async create(data, params, callback) { // When called via SocketIO: params.provider // -> socketio params.user // -> { name: 'David' } return data } }) ```
`socket.feathers` is the same object as the `connection` in a [channel](./channels.md). `socket.request` and `socket.handshake` contains information the HTTP request that initiated the connection (see the [Socket.io documentation](https://socket.io/docs/server-api/#socket-request)).
### params.provider For any [service method call](./services.md) made through Socket.io `params.provider` will be set to `socketio`. In a [hook](./hooks.md) this can for example be used to prevent external users from making a service method call: ```js app.service('users').hooks({ before: { remove(context) { // check for if(context.params.provider) to prevent any external call if (context.params.provider === 'socketio') { throw new Error('You can not delete a user via Socket.io') } } } }) ``` ### params.query `params.query` will contain the query parameters sent from the client.
Only `params.query` is passed between the server and the client, other parts of `params` are not. This is for security reasons so that a client can't set things like `params.user` or the database options. You can always map from `params.query` to `params` in a before [hook](./hooks.md).
### params.connection `params.connection` is the connection object that can be used with [channels](./channels.md). It is the same object as `socket.feathers` in a Socket.io middleware as [shown in the `params` section](#params). ### params.headers `params.headers` contains the headers from the original handshake. This is usually sent with the `extraHeaders` option when initialising the connection on the client: ```ts const socket = io('http://localhost:9777', { extraHeaders: { MyHeader: 'somevalue' } }) ``` ================================================ FILE: docs/auto-imports.d.ts ================================================ /* eslint-disable */ /* prettier-ignore */ // @ts-nocheck // noinspection JSUnusedGlobalSymbols // Generated by unplugin-auto-import // biome-ignore lint: disable export {} declare global { } ================================================ FILE: docs/comparison.md ================================================ # Feathers vs others The following sections compare Feathers to other software choices that seem similar or may overlap with the use cases of Feathers. Due to the bias of these comparisons being on the Feathers website, we attempt to only use facts. Below you can find a feature comparison table and in each section you can get more detailed comparisons. If you find something invalid or out of date in the comparisons, please create an issue and we'll address it as soon as possible. - [Feathers vs Firebase](/feathers-vs-firebase) - [Feathers vs Meteor](/feathers-vs-meteor) - [Feathers vs Sails](/feathers-vs-sails) - [Feathers vs Loopback](/feathers-vs-loopback) - [Feathers vs Nest](/feathers-vs-nest) ================================================ FILE: docs/components/CTAButton.vue ================================================ ================================================ FILE: docs/components/Footer.vue ================================================ ================================================ FILE: docs/components/FooterList.vue ================================================ ================================================ FILE: docs/components/HomeCTATextSection.vue ================================================ ================================================ FILE: docs/components/HomeCreateFirstApp.vue ================================================ ================================================ FILE: docs/components/HomeFeature1.vue ================================================ ================================================ FILE: docs/components/HomeFeature1Content.vue ================================================ ================================================ FILE: docs/components/HomeFeature2.vue ================================================ ================================================ FILE: docs/components/HomeFeature2Content.vue ================================================ ================================================ FILE: docs/components/HomeFeatureGrid.vue ================================================ ================================================ FILE: docs/components/HomeFeatureGridCard.vue ================================================ ================================================ FILE: docs/components/HomeHero.vue ================================================ ================================================ FILE: docs/components/HomeIndustryPartners.vue ================================================ ================================================ FILE: docs/components/HomeQuickStart.vue ================================================ ================================================ FILE: docs/cookbook/authentication/_discord.md ================================================ --- outline: deep --- # Discord Discord login can be initialized like any other [OAuth provider](../../api/authentication/oauth.md) by adding the app id and secret to `config/default.json`: ```js { "authentication": { "oauth": { "discord": { "key": "", "secret": "", "scope": ["identify email"] } } } } ``` > __Protip:__ A list of all available Discord scopes can be found [here](https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes) ## Application client and secret The client id (App ID) and secret can be found [here](https://discord.com/developers/applications/): ![Discord App](https://cdn.discordapp.com/attachments/468897350807453706/722369856317423656/unknown.png) Now add this to your src/authentication.ts: ```ts import {OAuthProfile, OAuthStrategy} from "@feathersjs/authentication-oauth"; import {AuthenticationRequest} from "@feathersjs/authentication"; import axios, {AxiosRequestConfig} from 'axios' import {ServiceAddons} from '@feathersjs/feathers'; import {AuthenticationService, JWTStrategy} from '@feathersjs/authentication'; import {LocalStrategy} from '@feathersjs/authentication-local'; import {oauth} from '@feathersjs/authentication-oauth'; import {Application} from './declarations'; export default function (app: Application) { const authentication = new AuthenticationService(app); authentication.register('jwt', new JWTStrategy()); authentication.register('local', new LocalStrategy()); authentication.register('discord', new DiscordStrategy()); app.use('/authentication', authentication); app.configure(oauth()); } export class DiscordStrategy extends OAuthStrategy { async getProfile(authResult: AuthenticationRequest) { // This is the OAuth access token that can be used // for Discord API requests as the Bearer token const accessToken = authResult.access_token; const userOptions: AxiosRequestConfig = { method: 'GET', headers: {'Authorization': `Bearer ${accessToken}`}, url: `https://discord.com/api/users/@me`, }; const {data} = await axios(userOptions); return data; } async getEntityData(profile: OAuthProfile) { // `profile` is the data returned by getProfile const baseData = await super.getEntityData(profile); if (profile.avatar == null) { profile.avatar = 'https://cdn.discordapp.com/embed/avatars/0.png' } else { const isGif = profile.avatar.startsWith('a_'); profile.avatar = `https://cdn.discordapp.com/avatars/${profile['id']}/${profile['avatar']}.${isGif ? 'gif' : 'png'}` } return { ...baseData, username: profile.username, email: profile.email, avatar: profile.avatar, }; } } ``` If you don't need the avatar then you can simply remove the lines of code. If the user doesn't have an avatar then we will set it to Discord's default avatar. ================================================ FILE: docs/cookbook/authentication/anonymous.md ================================================ --- outline: deep --- # Anonymous authentication Anonymous authentication can be allowed by creating a [custom strategy](../../api/authentication/strategy.md) that returns the `params` that you would like to use to identify an authenticated user. ```ts import { Params } from '@feathersjs/feathers'; import { AuthenticationBaseStrategy, AuthenticationResult, AuthenticationService } from '@feathersjs/authentication'; class AnonymousStrategy extends AuthenticationBaseStrategy { async authenticate(authentication: AuthenticationResult, params: Params) { return { anonymous: true } } } export default function(app: Application) { const authentication = new AuthenticationService(app); // ... authentication service setup authentication.register('anonymous', new AnonymousStrategy()); } ``` In `src/authentication.js`: ```js const { AuthenticationBaseStrategy, AuthenticationService } = require('@feathersjs/authentication'); class AnonymousStrategy extends AuthenticationBaseStrategy { async authenticate(authentication, params) { return { anonymous: true } } } module.exports = app => { const authentication = new AuthenticationService(app); // ... authentication service setup authentication.register('anonymous', new AnonymousStrategy()); } ``` Next, we create a hook called `allow-anonymous` that sets `params.authentication` if it does not exist and if `params.provider` exists (which means it is an external call) to use that `anonymous` strategy: ```ts import { Hook, HookContext } from '@feathersjs/feathers'; export default (): Hook => { return async (context: HookContext, next?: NextFunction) => { const { params } = context; if (params.provider && !params.authentication) { context.params = { ...params, authentication: { strategy: 'anonymous' } } } if (next) { await next(); } return context; } } ``` ```js /* eslint-disable require-atomic-updates */ module.exports = function (options = {}) { // eslint-disable-line no-unused-vars return async context => { const { params } = context; if(params.provider && !params.authentication) { context.params = { ...params, authentication: { strategy: 'anonymous' } } } return context; }; }; ``` This hook should be added __before__ the [authenticate hook](../../api/authentication/hook.md) wherever anonymous authentication should be allowed: ```js all: [ allowAnonymous(), authenticate('jwt', 'anonymous') ], ``` If an anonymous user now accesses the service externally, the service call will succeed and have `params.anonymous` set to `true`. ================================================ FILE: docs/cookbook/authentication/apiKey.md ================================================ # API Key Authentication We will start by providing the required configuration for this strategy. You should change all of these values as per your requirement. ```js { "authentication": { ...otherConfig, "authStrategies": [ ...otherStrategies, "apiKey" ], "apiKey": { "allowedKeys": [ "API_KEY_1", "API_KEY_2" ], "header": "x-access-token" } } } ``` Note: if all you want is api key authentication, it is still necessary to register a secret, service and entity. Since no other authentication method is used, entity can be `null`. A fully working example with just API key authentication: ```json { "host": "localhost", "port": 3030, "public": "../public/", "paginate": { "default": 10, "max": 50 }, "authentication": { "secret": "some-secret", "service": "users", "entity": null, "authStrategies": ["apiKey"], "apiKey": { "allowedKeys": [ "API_KEY_1", "API_KEY_2" ], "header": "x-access-token" } } } ``` Next we will be creating a [custom strategy](../../api/authentication/strategy.md) that returns the `params` that you would like to use to identify an authenticated user/request. ```ts import { AuthenticationBaseStrategy, AuthenticationResult, AuthenticationService } from '@feathersjs/authentication'; import { NotAuthenticated } from '@feathersjs/errors'; import { ServiceAddons } from '@feathersjs/feathers'; import { Application } from './declarations'; declare module './declarations' { interface ServiceTypes { 'authentication': AuthenticationService & ServiceAddons; } } class ApiKeyStrategy extends AuthenticationBaseStrategy { app: Application; constructor(app: Application) { super(); this.app = app; } async authenticate(authentication: AuthenticationResult) { const { token } = authentication; const config = this.app.get('authentication').apiKey; const match = config.allowedKeys.includes(token); if (!match) throw new NotAuthenticated('Incorrect API Key'); return { apiKey: true } } } export default function (app: Application) { const authentication = new AuthenticationService(app); // This can have multiple .register calls if multiple strategies have been added authentication.register('apiKey', new ApiKeyStrategy(app)); app.use('/authentication', authentication); } ``` In `src/authentication.js`: ```js const { AuthenticationBaseStrategy, AuthenticationService } = require('@feathersjs/authentication'); const { NotAuthenticated } = require('@feathersjs/errors'); class ApiKeyStrategy extends AuthenticationBaseStrategy { async authenticate(authentication) { const { token } = authentication; const config = this.authentication.configuration[this.name]; const match = config.allowedKeys.includes(token); if (!match) throw new NotAuthenticated('Incorrect API Key'); return { apiKey: true } } } module.exports = app => { const authentication = new AuthenticationService(app); // ... authentication service setup authentication.register('apiKey', new ApiKeyStrategy()); } ``` Next, we create a hook called `allow-apiKey` that sets `params.authentication` if it does not exist and if `params.provider` exists (which means it is an external call) to use that `apiKey` strategy. We will also provide the capability for the apiKey to be read from the request header: (you could also read the token as a query parameter but you will have to filter it out before it's passed to Feathers calls like `get` and `find`. ```ts import { HookContext, NextFunction } from '@feathersjs/feathers'; export default () => async (context: HookContext, next: NextFunction) => { const { params, app } = context; const headerField = app.get('authentication').apiKey.header; const token = params.headers ? params.headers[headerField] : null; if (token && params.provider && !params.authentication) { context.params = { ...params, authentication: { strategy: 'apiKey', token } }; } return next(); } ``` ```js /* eslint-disable require-atomic-updates */ module.exports = function (options = {}) { // eslint-disable-line no-unused-vars return async context => { const { params, app } = context; const headerField = app.get('authentication').apiKey.header; const token = params.headers[headerField]; if (token && params.provider && !params.authentication) { context.params = { ...params, authentication: { strategy: 'apiKey', token } }; } return context; }; }; ``` This hook should be added __before__ the [authenticate hook](../../api/authentication/hook.md) wherever API Key authentication should be allowed: ```js import { authenticate } from '@feathersjs/authentication/lib/hooks'; import allowApiKey from './hooks/allow-api-key'; all: [ allowApiKey(), authenticate('jwt', 'apiKey') ], ``` If a user now accesses the service externally with the correct apiKey, the service call will succeed and have `params.apiKey` set to `true`. ================================================ FILE: docs/cookbook/authentication/auth0.md ================================================ --- outline: deep --- # Auth0 To enable OAuth logins with [Auth0](http://auth0.com), we need the following settings after creating an application: ![Auth0 application](../assets/auth0-app.png) This should be added in your configuration (usually `config/default.json`) as follows: ```json "authentication": { "oauth": { "redirect": "/", "auth0": { "key": "", "secret": "", "subdomain": " __Important:__ `subdomain` should be the "Domain" from the application settings __without__ the `auth0.com` part. So, in the screenshot above, the subdomain for `dev-6gqkmpt6.auth0.com` would be `dev-6gqkmpt6`. If the subdomain includes a region, it needs to be included as well so the subdomain for `dev-6gqkmpt6.us.auth0.com` would be `dev-6gqkmpt6.us` ## Strategy To use Auth0 in the chat application from the [Feathers guide](../../guides/) we have to do the same modifications as already shown [for the GitHub login in the authentication guide](../../guides/basics/authentication.md). In `src/authentication.ts` like this: ```ts import { ServiceAddons, Params } from '@feathersjs/feathers'; import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'; import { LocalStrategy } from '@feathersjs/authentication-local'; import { oauth, OAuthStrategy, OAuthProfile } from '@feathersjs/authentication-oauth'; import { Application } from './declarations'; declare module './declarations' { interface ServiceTypes { 'authentication': AuthenticationService & ServiceAddons; } } class Auth0Strategy extends OAuthStrategy { async getEntityData(profile: OAuthProfile, existing: any, params: Params) { const baseData = await super.getEntityData(profile, existing, params); return { ...baseData, email: profile.email }; } } export default function(app: Application) { const authentication = new AuthenticationService(app); authentication.register('jwt', new JWTStrategy()); authentication.register('local', new LocalStrategy()); authentication.register('auth0', new Auth0Strategy()); app.use('/authentication', authentication); app.configure(oauth()); } ``` In `src/authentication.js` like this: ```js const { AuthenticationService, JWTStrategy } = require('@feathersjs/authentication'); const { LocalStrategy } = require('@feathersjs/authentication-local'); const { expressOauth, OAuthStrategy } = require('@feathersjs/authentication-oauth'); class Auth0Strategy extends OAuthStrategy { async getEntityData(profile) { const baseData = await super.getEntityData(profile); return { ...baseData, email: profile.email }; } } module.exports = app => { const authentication = new AuthenticationService(app); authentication.register('jwt', new JWTStrategy()); authentication.register('local', new LocalStrategy()); authentication.register('auth0', new Auth0Strategy()); app.use('/authentication', authentication); app.configure(expressOauth()); }; ``` Additionally, `auth0Id` needs to be included in the data in the users service class. ================================================ FILE: docs/cookbook/authentication/facebook.md ================================================ --- outline: deep --- # Facebook Facebook login can be initialized like any other [OAuth provider](../../api/authentication/oauth.md) by adding the app id and secret to `config/default.json`: ```js { "authentication": { "oauth": { "facebook": { "key": "", "secret": "" } } } } ``` Requesting the email property requires adding additional `scope` to the oauth configuration: ```js { "authentication": { "oauth": { "facebook": { "key": "", "secret": "", "scope": ["email, public_profile"] } } } } ``` ## Application client and secret The client id (App ID) and secret can be found in the Settings of the [Facebook app](https://developers.facebook.com/apps): ![Facebook app settings](../assets/facebook-app.png) ## Getting profile data The standard OAuth strategy only returns the default profile fields (`id` and `name`). To get other fields, like the email or profile picture, the [getProfile](../../api/authentication/oauth.md#getprofile-data-params) method of the [OAuth strategy needs to be customized](../../api/authentication/oauth.md#customization) to call the Graph API profile endpoint `https://graph.facebook.com/me` with an HTTP request library like [Axios](https://developers.facebook.com/tools/explorer/) requesting the additional fields. > __Pro tip:__ Facebook API requests can be tested via the [Graph API explorer](https://developers.facebook.com/tools/explorer/). The following example allows to log in with Facebook in the [chat application from the guide](../../guides/index.md): ```ts import { Params } from '@feathersjs/feathers'; import { AuthenticationService, JWTStrategy, AuthenticationRequest } from '@feathersjs/authentication'; import { LocalStrategy } from '@feathersjs/authentication-local'; import { expressOauth, OAuthStrategy, OAuthProfile } from '@feathersjs/authentication-oauth'; import axios from 'axios'; import { Application } from './declarations'; declare module './declarations' { interface ServiceTypes { 'authentication': AuthenticationService & ServiceAddons; } } class FacebookStrategy extends OAuthStrategy { async getProfile (authResult: AuthenticationRequest, _params: Params) { // This is the OAuth access token that can be used // for Facebook API requests as the Bearer token const accessToken = authResult.access_token; const { data } = await axios.get('https://graph.facebook.com/me', { headers: { authorization: `Bearer ${accessToken}` }, params: { // There are fields: 'id,name,email' } }); return data; } async getEntityData(profile: OAuthProfile, existing: any, params: Params) { // `profile` is the data returned by getProfile const baseData = await super.getEntityData(profile, existing, params); return { ...baseData, email: profile.email }; } } export default function(app: Application) { const authentication = new AuthenticationService(app); authentication.register('jwt', new JWTStrategy()); authentication.register('local', new LocalStrategy()); authentication.register('facebook', new FacebookStrategy()); app.use('/authentication', authentication); app.configure(expressOauth()); } ``` In `src/authentication.js`: ```js const axios = require('axios'); const { AuthenticationService, JWTStrategy } = require('@feathersjs/authentication'); const { LocalStrategy } = require('@feathersjs/authentication-local'); const { expressOauth, OAuthStrategy } = require('@feathersjs/authentication-oauth'); class FacebookStrategy extends OAuthStrategy { async getProfile (authResult) { // This is the OAuth access token that can be used // for Facebook API requests as the Bearer token const accessToken = authResult.access_token; const { data } = await axios.get('https://graph.facebook.com/me', { headers: { authorization: `Bearer ${accessToken}` }, params: { // There are fields: 'id,name,email,picture' } }); return data; } async getEntityData(profile) { // `profile` is the data returned by getProfile const baseData = await super.getEntityData(profile); return { ...baseData, name: profile.name, email: profile.email }; } } module.exports = app => { const authentication = new AuthenticationService(app); authentication.register('jwt', new JWTStrategy()); authentication.register('local', new LocalStrategy()); authentication.register('facebook', new FacebookStrategy()); app.use('/authentication', authentication); app.configure(expressOauth()); }; ``` > __Pro tip:__ [See all available Facebook user options here](https://developers.facebook.com/docs/graph-api/reference/user/). ================================================ FILE: docs/cookbook/authentication/firebase.md ================================================ --- outline: deep --- # Firebase [Firebase](https://firebase.google.com/docs/auth) requires a custom [OAuth Authentication Strategy](../../api/authentication/oauth.html#oauthstrategy). This is because one is not provided to us, by the default [Grant](https://github.com/simov/grant) configuration Feathers uses for [OAuth](https://docs.feathersjs.com/api/authentication/oauth.html#oauth). Since Firebase does not provide a UI for us to redirect to, we use flow #2 outlined in [OAuth Flow](../../api/authentication/oauth.html#flow). ## Authentation Setup Update `config/default.json`: ```json { "authentication": { "oauth": {} }, "firebase": { "type": "THIS SHOULD BE YOUR SERVICE ACCOUNT", "project_id": "GENERATED UNDER FIREBASE CONSOLE", "...": "..." } } ``` > Note: Since Firebase can be used for more than just authentication, we'll store our service account in the root of our config. Otherwise, if preferred, you can store under `authentication.oauth`. ## Authentication Strategy Create a file under `src/firebase.js`: ```js const firebase = require('firebase-admin'); const { OAuthStrategy } = require('@feathersjs/authentication-oauth'); const { NotAuthenticated } = require('@feathersjs/errors'); const logger = require('./logger'); function initialize(app){ const firebaseConfig = app.get('firebase'); // Initialize app try { firebase.initializeApp({ credential: firebase.credential.cert(firebaseConfig) }); } catch (e) { console.log('erorr initializing firebase', e); } } class FirebaseStrategy extends OAuthStrategy { async authenticate(authentication, params){ logger.debug('firebase:strategy:authenticate'); return super.authenticate(authentication, params); } async getProfile(data, _params){ const firebase = require('firebase-admin'); let user; try { user = await firebase.auth().verifyIdToken(data.access_token); } catch(e){ logger.error(e); throw new NotAuthenticated(); } logger.debug(`firebase:strategy:getProfile:successful ${user.user_id}`); return { email: user.email, id: user.user_id }; } async getEntityData(profile) { const baseData = await super.getEntityData(profile); return { ...baseData, email: profile.email }; } } module.exports = { initialize, FirebaseStrategy }; ``` Now we can edit `src/authentication.js` ```js const { AuthenticationService, JWTStrategy } = require('@feathersjs/authentication'); const { expressOauth } = require('@feathersjs/authentication-oauth'); const { FirebaseStrategy } = require('./firebase'); module.exports = app => { const authentication = new AuthenticationService(app); authentication.register('firebase', new FirebaseStrategy()); app.use('/authentication', authentication); app.configure(expressOauth()); }; ``` ## Building frontend To save time, you can leverage the pre-built UI provided by [Firebase UI](https://firebase.google.com/docs/auth/web/firebaseui). ### Create auth page First, create a `public/firebase_auth.html` file that initializes everything we'll need for our different auth components. ```html Firebase Authentication Example

Welcome to My Awesome App

``` ### Initialize client w/Firebase auth Now, let's make a `public/client.js` file where all of our JavaScript will live. > Be sure to update `firebaseConfig` with the one provided from your [Firebase Console](https://console.firebase.google.com/). Additionally, checkout [Firebase UI](https://firebase.google.com/docs/auth/web/firebaseui) docs for more information on customizing `ui.start`. This includes theming options, all providers supported by Firebase & more. ```js let client, ui; init(); function init(){ initializeFeathers(); initializeAuth(); initializeFirebase(); } function initializeFeathers(){ // Establish a Socket.io connection const socket = io(); // Initialize our Feathers client application through Socket.io // with hooks and authentication. client = feathers(); client.configure(feathers.socketio(socket)); // Use localStorage to store our login token client.configure(feathers.authentication()); } // Either re-authenticate existing session, or start Firebase UI async function initializeAuth(){ try { await client.reAuthenticate(); showMemberApp(); } catch(e){ // Error re-authenticating, so let's start Firebase UI showGuestApp(); } // No longer need to prepare anything document.getElementById('app-preparing').style.display = 'none'; } function initializeFirebase(){ // Your web app's Firebase configuration // For Firebase JS SDK v7.20.0 and later, measurementId is optional var firebaseConfig = { // Copy this from your Firebase Console // Under Project Settings -> Web App }; // Initialize Firebase firebase.initializeApp(firebaseConfig); // Initialize the FirebaseUI Widget using Firebase. ui = new firebaseui.auth.AuthUI(firebase.auth()); } async function showMemberApp(){ // Get user information const { user } = await client.get('authentication'); // Hide Guest App document.getElementById('app-guest').style.display = 'none'; // Show member app document.getElementById('app-member').style.display = 'block'; document.getElementById('app-member').innerHTML = `Logged in as, ${user.email}. Logout`; } function showGuestApp(){ // Hide & clear member app document.getElementById('app-member').style.display = 'none'; document.getElementById('app-member').innerHTML = ''; // Show Guest app document.getElementById('app-guest').style.display = 'block'; startFirebaseUI(); } function startFirebaseUI(){ ui.start('#firebaseui-auth-container', { callbacks: { signInSuccessWithAuthResult: function(authResult, redirectUrl) { // User successfully signed in. // Return type determines whether we continue the redirect automatically // or whether we leave that to developer to handle. firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(async function(idToken) { await client.authenticate({ strategy: 'firebase', access_token: idToken, }); showMemberApp(); }); return false; }, uiShown: function() { // The widget is rendered. // Hide the loader. document.getElementById('loader').style.display = 'none'; } }, // Will use popup for IDP Providers sign-in flow instead of the default, redirect. signInFlow: 'popup', credentialHelper: firebaseui.auth.CredentialHelper.NONE, // disable accountchooter.com helper signInOptions: [ firebase.auth.EmailAuthProvider.PROVIDER_ID, firebase.auth.FacebookAuthProvider.PROVIDER_ID, firebase.auth.TwitterAuthProvider.PROVIDER_ID, ], // Other config options... }); } const addEventListener = (selector, event, handler) => { document.addEventListener(event, async ev => { if (ev.target.closest(selector)) { handler(ev); } }); }; // "Logout" button click handler addEventListener('#logout', 'click', async () => { await client.logout(); showGuestApp(); }); ``` Now you should be able to visit your Firebase auth at the ``` http://localhost:3030/firebase_auth.html ``` page locally and authenticate w/any Firebase Providers you've set up in your Firebase Project 🔥 ================================================ FILE: docs/cookbook/authentication/google.md ================================================ --- outline: deep --- # Google To enable Google login, add the app id, app secret and scope property to `config/default.json`: ```js { "authentication": { "oauth": { "google": { "key": "", "secret": "", "scope": ["openid"] } } } } ``` According to the [documentation of Google](https://developers.google.com/identity/protocols/OpenIDConnect#scope-param): "The scope value must begin with the string openid and then include profile or email or both.". To also request the email address, add the string "email" to the array of the 'scope' property: ```js { "authentication": { "oauth": { "google": { "key": "", "secret": "", "scope": ["openid", "email"], "nonce": true } } } } ``` The property 'nonce', according to the documentation: "A random value generated by your app that enables replay protection.". ## Application client and secret The client id (App ID) and secret can be acquired by creating a [OAuth client ID](https://console.developers.google.com/apis/credentials): 1. Click on 'OAuth client ID' ![Creating OAuth client ID - step 1](https://bartduisters.com/img/feathers/oauth-client-id-1.png) 2. Select 'web application', fill in the information and click 'Create' ![Creating OAuth client ID - step 2](https://bartduisters.com/img/feathers/oauth-client-id-2.png) **Important**: Fill in the callback url, in a default Feathers setup it will be /oauth/google/callback. 3. Replace `` and `` with the id and secret of the created OAuth client ID application ```js { "authentication": { "oauth": { "google": { "key": ".apps.googleusercontent.com", "secret": "", "scope": ["openid", "email"], "nonce": true } } } } ``` Note: Use the generated credentials of the OAuth client ID. Note: `` will be replaced by a string similar to **481298021138-hv27glb811ocr7pdon5lsg8hh5a6pgjv**.apps.googleusercontent.com. Note: `` will be replaced by a string similar to **XkWl0witdP4ogeNIgyOi-CeS**. ## Using the data returned from the Google App through a custom OAuth Strategy In `src/authentication.js`: ```js const axios = require('axios'); const { OAuthStrategy } = require('@feathersjs/authentication-oauth'); class GoogleStrategy extends OAuthStrategy { async getEntityData(profile) { // this will set 'googleId' const baseData = await super.getEntityData(profile); // this will grab the picture and email address of the Google profile return { ...baseData, profilePicture: profile.picture, email: profile.email }; } } module.exports = app => { const authentication = new AuthenticationService(app); authentication.register('jwt', new JWTStrategy()); authentication.register('local', new LocalStrategy()); authentication.register('google', new GoogleStrategy()); app.use('/authentication', authentication); app.configure(expressOauth()); }; ``` **Important**: googleId, profilePicture and email are properties that should exist on the database model! ================================================ FILE: docs/cookbook/authentication/revoke-jwt.md ================================================ --- outline: deep --- # Revoking JWTs By default a valid JWT can be used for as long as it is valid. To do a normal logout the client just "forgets" their JWT (usually by removing it from localStorage). To add the ability to revoke an access token so that it can be no longer used even if it is still valid [the authentication service](../../api/authentication/service.md) can be customized as follows. ## Basic example The following example shows the basic flow of how a JWT can be revoked by storing it in a plain object. In a normal application you would use something like the [Redis storage shown below](#using-redis). ```js const { AuthenticationService } = require('@feathersjs/authentication'); const { NotAuthenticated } = require('@feathersjs/errors'); const revokedTokens = {}; class RevokableAuthService extends AuthenticationService { async revokeAccessToken (accessToken) { // First make sure the access token is valid const verified = await this.verifyAccessToken(accessToken); revokedTokens[accessToken] = true; return verified; } async verifyAccessToken(accessToken) { // First check if the token has been revoked if (revokedTokens[accessToken]) { throw new NotAuthenticated('Token revoked'); } return super.verifyAccessToken(accessToken); } async remove (id, params) { const authResult = await super.remove(id, params); const { accessToken } = authResult; if (accessToken) { // If there is an access token, revoke it await this.revokeAccessToken(accessToken); } return authResult; } } app.use('/authentication', new RevokableAuthService(app)); ``` ## Using Redis [Redis](https://redis.io/) is a great storage mechanism for revoked JWTs because it allows to remove keys after a certain time. A revoked JWT does not have to be stored forever and can be removed from storage after it has expired since it will no longer be valid anyway. The flow is the same as shown above but using the NodeJS Redis adapter instead: ``` npm install redis ``` ```js const redis = require('redis'); const { AuthenticationService } = require('@feathersjs/authentication'); const { NotAuthenticated } = require('@feathersjs/errors'); class RedisAuthService extends AuthenticationService { constructor (app, configKey) { super(app, configKey); const client = redis.createClient(); this.redis = { client, get: client.get.bind(client), set: client.set.bind(client), exists: client.exists.bind(client), expireat: client.exists.bind(client) } (async () => { await this.redis.client.connect(); })() } async revokeAccessToken (accessToken) { // First make sure the access token is valid const verified = await this.verifyAccessToken(accessToken); // Calculate the remaining valid time for the token (in seconds) const expiry = verified.exp - Math.floor(Date.now() / 1000); // Add the revoked token to Redis and set expiration await this.redis.set(accessToken, 1, { EX: expiry }); return verified; } async verifyAccessToken(accessToken) { if (await this.redis.exists(accessToken)) { throw new NotAuthenticated('Token revoked'); } return super.verifyAccessToken(accessToken); } async remove (id, params) { const authResult = await super.remove(id, params); const { accessToken } = authResult; if (accessToken) { // If there is an access token, revoke it await this.revokeAccessToken(accessToken); } return authResult; } } app.use('/authentication', new RedisAuthService(app)); ``` ================================================ FILE: docs/cookbook/authentication/stateless.md ================================================ --- outline: deep --- # Stateless JWT By default, an authentication token is associated to an entity (usually a user). It is also possible to issue tokens that are stateless and not tied to an entity lookup. This can be useful when all the information necessary can be contained in the token payload. The drawback is that the token information can not be changed and will always be valid until the token expires so it is e.g. not possible to disable a user or change their permissions before the token expires. ## Configuration Stateless tokens can be issued by setting the `entity` option in the [JWT strategy authentication configuration](../../api/authentication/jwt.md#configuration) to `null` (in which case `service` option also won't be used): ```json { "authentication": { "secret": "CHANGE_ME", "entity": null, "authStrategies": [ "jwt", "local" ], "jwtOptions": { "header": { "typ": "access" }, "audience": "https://yourdomain.com", "issuer": "feathers", "algorithm": "HS256", "expiresIn": "1d" } } } ``` > __Note:__ When still using other built-in strategies (like the [local strategy](../../api/authentication/local.md)) with an entity, the option can be set for each strategy (e.g. `{ "authentication": { "local": { "entity": "user" } } }`). ## Customizing the payload In order for the token to contain information, the `getPayload` method needs to be customize by [extending the authentication service](../../api/authentication/service.md#customization): ```js const { AuthenticationService } = require('@feathersjs/authentication'); class MyAuthService extends AuthenticationService { async getPayload(authResult, params) { // Call original `getPayload` first const payload = await super.getPayload(authResult, params); const { user } = authResult; if (user && user.permissions) { payload.permissions = user.permissions; } return payload; } } app.use('/authentication', new MyAuthService(app)); ``` ================================================ FILE: docs/cookbook/deploy/docker.md ================================================ --- outline: deep --- # Dockerize a Feathers application A Feathers application can be [dockerized like any other Node.js application](https://nodejs.org/en/docs/guides/nodejs-docker-webapp/). ## Create an app ```sh mkdir feathers-app cd feathers-app/ feathers generate app ``` ### Dockerfile Add the following `Dockerfile` to the project directory: ``` FROM node:lts-alpine WORKDIR /usr/src/app COPY package*.json ./ RUN npm install COPY . . EXPOSE 3030 CMD ["npm", "run", "start"] ``` ## Build the image ```sh docker build -t my-feathers-image . ``` ## Start the container ```sh docker run -d -p 3030:3030 --name my-feathers-container my-feathers-image ``` ================================================ FILE: docs/cookbook/express/file-uploading.md ================================================ --- outline: deep --- # File uploads in FeathersJS Over the last months we at [ciancoders.com](https://ciancoders.com/) have been working in a new SPA project using Feathers and React, the combination of those two turns out to be **just amazing**. Recently we were struggling to find a way to upload files without having to write a separate Express middleware or having to (re)write a complex Feathers service. ## Our Goals We want to implement an upload service to accomplish a few important things: 1. It has to handle large files (+10MB). 2. It needs to work with the app's authentication and authorization. 3. The files need to be validated. 4. At the moment there is no third party storage service involved, but this will change in the near future, so it has to be prepared. 5. It has to show the upload progress. The plan is to upload the files to a feathers service so we can take advantage of hooks for authentication, authorization and validation, and for service events. Fortunately, there exists a file storage service: [feathers-blob](https://github.com/feathersjs/feathers-blob). With it we can meet our goals, but (spoiler alert) it isn't an ideal solution. We discuss some of its problems below. ## Basic upload with feathers-blob and feathers-client For the sake of simplicity, we will be working over a very basic feathers server, with just the upload service. Lets look at the server code: ```javascript /* --- server.js --- */ const feathers = require('@feathersjs/feathers'); const express = require('@feathersjs/express'); const socketio = require('@feathersjs/socketio'); // feathers-blob service const blobService = require('feathers-blob'); // Here we initialize a FileSystem storage, // but you can use feathers-blob with any other // storage service like AWS or Google Drive. const fs = require('fs-blob-store'); const blobStorage = fs(__dirname + '/uploads'); // Feathers app const app = express(feathers()); // Parse HTTP JSON bodies app.use(express.json()); // Parse URL-encoded params app.use(express.urlencoded({ extended: true })); // Add REST API support app.configure(express.rest()); // Configure Socket.io real-time APIs app.configure(socketio()); // Upload Service app.use('/uploads', blobService({Model: blobStorage})); // Register a nicer error handler than the default Express one app.use(express.errorHandler()); // Start the server app.listen(3030, function(){ console.log('Feathers app started at localhost:3030') }); ``` Let's look at this implemented in the `@feathersjs/cli` generated server code: ```javascript /* --- /src/services/uploads/uploads.service.js --- */ // Initializes the `uploads` service on path `/uploads' const createModel = require('../../models/uploads.model'); const hooks = require('./uploads.hooks'); const filters = require('./uploads.filters'); // feathers-blob service const blobService = require('feathers-blob'); // Here we initialize a FileSystem storage, // but you can use feathers-blob with any other // storage service like AWS or Google Drive. const fs = require('fs-blob-store'); // File storage location. Folder must be created before upload. // Example: './uploads' will be located under feathers app top level. const blobStorage = fs('./uploads'); module.exports = function() { const app = this; const Model = createModel(app); const paginate = app.get('paginate'); // Initialize our service with any options it requires app.use('/uploads', blobService({ Model: blobStorage})); // Get our initialized service so that we can register hooks and filters const service = app.service('uploads'); service.hooks(hooks); if (service.filter) { service.filter(filters); } }; ``` `feathers-blob` works over abstract-blob-store, which is an abstract interface to various storage backends, such as filesystem, AWS, or Google Drive. It only accepts and retrieves files encoded as dataURI strings. Just like that we have our backend ready, go ahead and POST something to localhost:3030/uploads`, for example with postman: ```json { 'uri': 'data:image/gif;base64,R0lGODlhEwATAPcAAP/+//7/////+////fvzYvryYvvzZ/fxg/zxWfvxW/zwXPrtW/vxXvfrXv3xYvrvYvntYvnvY/ruZPrwZPfsZPjsZfjtZvfsZvHmY/zxavftaPrvavjuafzxbfnua/jta/ftbP3yb/zzcPvwb/zzcfvxcfzxc/3zdf3zdv70efvwd/rwd/vwefftd/3yfPvxfP70f/zzfvnwffvzf/rxf/rxgPjvgPjvgfnwhPvzhvjvhv71jfz0kPrykvz0mv72nvblTPnnUPjoUPrpUvnnUfnpUvXlUfnpU/npVPnqVPfnU/3uVvvsWPfpVvnqWfrrXPLiW/nrX/vtYv7xavrta/Hlcvnuf/Pphvbsif3zk/zzlPzylfjuk/z0o/LqnvbhSPbhSfjiS/jlS/jjTPfhTfjlTubUU+/iiPPokfrvl/Dll/ftovLWPfHXPvHZP/PbQ/bcRuDJP/PaRvjgSffdSe3ddu7fge7fi+zkuO7NMvPTOt2/Nu7SO+3OO/PWQdnGbOneqeneqvDqyu3JMuvJMu7KNfHNON7GZdnEbejanObXnOW8JOa9KOvCLOnBK9+4Ku3FL9ayKuzEMcenK9e+XODOiePSkODOkOW3ItisI9yxL+a9NtGiHr+VH5h5JsSfNM2bGN6rMJt4JMOYL5h4JZl5Jph3Jpl4J5h5J5h3KJl4KZp5Ks+sUN7Gi96lLL+PKMmbMZt2Jpp3Jpt3KZl4K7qFFdyiKdufKsedRdm7feOpQN2QKMKENrpvJbFfIrNjJL1mLMBpLr9oLrFhK69bJFkpE1kpFYNeTqFEIlsoFbmlnlsmFFwpGFkoF/////7+/v///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAANAALAAAAAATABMAAAj/AKEJHCgokKJKlhThGciQYSIva7r8SHPFzqGGAwPd4bKlh5YsPKy0qFLnT0NAaHTcsIHDho0aKkaAwGCGEkM1NmSkIjWLBosVJT6cOjUrzsBKPl54KmYsACoTMmk1WwaA1CRoeM7siJEqmTIAsjp40ICK2bEApfZcsoQlxwxRzgI8W8XhgoVYA+Kq6sMK0QEYKVCUkoVqQwQJFTwFEAAAFZ9PlFy4OEEiRIYJD55EodDA1ClTbPp0okRFxBQDBRgskAKhiRMlc+Sw4SNpFCIoBBwkUMBkCBIiY8qAgcPG0KBHrBTFQbCEV5EjQYQACfNFjp5CgxpxagVtUhIjwzaJYSHzhQ4cP3ryQHLEqJbASnu+6EIW6o2b2X0ISXK0CFSugazs0YYmwQhziyuE2PLLIv3h0hArkRhiCCzAENOLL7tgAoqDGLXSSSaPMLIIJpmAUst/GA3UCiuv1PIKLtw1FBAAOw==' } ``` The service will respond with something like this: ```json { 'id': '6454364d8facd7a88e627e4c4b11b032d2f83af8f7f9329ffc2b7a5c879dc838.gif', 'uri': 'the-same-uri-we-uploaded', 'size': 1156 } ``` Or we can implement a very basic frontend with `feathers-client` and `jQuery`: ```html Feathersjs File Upload

Let's upload some files!

``` This code watches for file selection, then encodes it and does an ajax post to upload it, watching the upload progress via the xhr object. Everything works as expected. Every file we select gets uploaded and saved to the `./uploads` directory. Work done!, let's call it a day, shall we? ... But hey, there is something that doesn't feel quite right ...right? ### DataURI upload problems It doesn't feel right because it is not. Let's imagine what would happen if we try to upload a large file, say 25MB or more: The entire file (plus some extra MB due to the encoding) has to be kept in memory for the entire upload process, this could look like nothing for a normal computer but for mobile devices it's a big deal. We have a big RAM consumption problem. Not to mention we have to encode the file before sending it... The solution would be to modify the service, adding support for splitting the dataURI into small chunks, then uploading one at a time, collecting and reassembling everything on the server. But hey, it's not that the same thing browsers and web servers have been doing since maybe the very early days of the web? Maybe since Netscape Navigator? Well, actually it is, and doing a `multipart/form-data` post is still the easiest way to upload a file. ## Feathers-blob with multipart support. Back with the backend, in order to accept multipart uploads, we need a way to handle the `multipart/form-data` received by the web server. Given that Feathers behaves like Express, let's just use `multer` and a custom middleware to handle that. ``` javascript /* --- server.js --- */ const multer = require('multer'); const multipartMiddleware = multer(); // Upload Service with multipart support app.use('/uploads', // multer parses the file named 'uri'. // Without extra params the data is // temporarely kept in memory multipartMiddleware.single('uri'), // another middleware, this time to // transfer the received file to feathers function(req,res,next){ req.feathers.file = req.file; next(); }, blobService({Model: blobStorage}) ); ``` Notice we kept the file field name as *uri* just to maintain uniformity, as the service will always work with that name anyways, but you can change it if you prefer. Feathers-blob only understands files encoded as dataURI, so we need to convert them first. Let's make a Hook for that: ```javascript /* --- server.js --- */ const dauria = require('dauria'); // before-create Hook to get the file (if there is any) // and turn it into a datauri, // transparently getting feathers-blob to work // with multipart file uploads app.service('/uploads').before({ create: [ function(context) { if (!context.data.uri && context.params.file){ const file = context.params.file; const uri = dauria.getBase64DataURI(file.buffer, file.mimetype); context.data = {uri: uri}; } } ] }); ``` *Et voilà!*. Now we have a FeathersJS file storage service working, with support for traditional multipart uploads, and a variety of storage options to choose. **Simply awesome.** ## Further improvements The service always returns the dataURI back to us, which may not be necessary as we just uploaded the file. We also need to validate the file and check for authorization. All those things can be easily done with more Hooks, and that's the benefit of keeping all inside FeathersJS services. I leave that to you. For the frontend, there is a problem with the client: in order to show the upload progress it's stuck with only REST functionality and not real-time with socket.io. The solution is to switch `feathers-client` from REST to `socket.io`, and just use wherever you like for uploading the files, that's an easy task now that we are able to do a traditional `form-multipart` upload. Here is an example using dropzone: ```html Feathersjs File Upload

Let's upload some files!

``` All the code is available via github here: https://github.com/CianCoders/feathers-example-fileupload Hope you have learned something today, as I learned a lot writing this. Cheers! ================================================ FILE: docs/cookbook/express/view-engine.md ================================================ --- outline: deep --- # Server Side Rendering Since Feathers is just an extension of Express it's really simple to render templated views on the server with data from your Feathers services. There are a few different ways that you can structure your app so this guide will show you 3 typical ways you might have your Feathers app organized. ## Rendering views from services You probably already know that when you register a Feathers service, Feathers creates RESTful endpoints for that service automatically. Well, really those are just Express routes, so you can define your own as well. > **ProTip:** Your own defined REST endpoints won't work with hooks and won't emit socket events. If you find you need that functionality it's probably better for you to turn your endpoints into a minimal Feathers service. Let's say you want to render a list of messages from most recent to oldest using the [Pug](https://pugjs.org/) template engine. ```js // You've set up your main Feathers app already // Register your view engine app.set('view engine', 'pug'); // Register your message service app.use('/api/messages', memory()); // Inside your main Feathers app app.get('/messages', function(req, res, next){ // You namespace your feathers service routes so that // don't get route conflicts and have nice URLs. app.service('api/messages') .find({ query: {$sort: { updatedAt: -1 } } }) .then(result => res.render('message-list', result.data)) .catch(next); }); ``` Simple right? We've now rendered a list of messages using the `/views/message-list.pug` view template. All your hooks will get triggered just like they would normally so you can use hooks to pre-filter your data and keep your template rendering routes super tight. See [Using Template Engines with Express](https://expressjs.com/en/guide/using-template-engines.html) for more information. > **ProTip:** If you call a Feathers service "internally" (ie. not over sockets or REST) you won't have a `context.params.provider` attribute. This allows you to have hooks only execute when services are called externally vs. from your own code. ## Using authentication Feathers is by default stateless and does not use any sessions. You already can protect Express endpoints with the [express.authenticate](../../api/express.md#express-authenticate) middleware, however this will only work when passing the `Authorization` header (usually with a JWT) which a normal browser request does not support. In order to render authenticated pages, [express-session](https://www.npmjs.com/package/express-session) can be used to add the authentication information to the (browser) session: > npm i express-session --save Now you can add the following to `src/middleware/index.js|ts`: ```js const session = require('express-session'); const { authenticate } = require('@feathersjs/express'); // This sets `req.authentication` from the information added to the session const setSessionAuthentication = (req, res, next) => { req.authentication = req.session.authentication; next(); }; module.exports = function (app) { // Initialize Express-session - might have to be configured // with a persisten storage adapter (like Redis) app.use(session({ secret: 'session-secret', saveUninitialized: false, resave: true })); // An endpoint that you can POST to with `email` and `password` that // will then perform a local user authentication // e.g
app.post('/login', async (req, res, next) => { try { const { email, password } = req.body; // Run normal local authentication through our service const { accessToken } = await app.service('authentication').create({ strategy: 'local', email, password }); // Register the JWT authentication information on the session req.session.authentication = { strategy: 'jwt', accessToken }; // Redirect to an authenticated page res.redirect('/hello'); } catch (error) { next(error); } }); // Remove the authentication information from the session to log out app.get('logout', (req, res) => { delete req.session.authentication; res.end('You are now logged out'); }); // Renders an authenticated page or an 401 error page // Always needs `setSessionAuthentication, authenticate('jwt')` middleware first app.get('/hello', setSessionAuthentication, authenticate('jwt'), (req, res) => { res.end(`Authenticated page with user ${req.user.email}`); }); }; ``` ================================================ FILE: docs/cookbook/general/client-test.md ================================================ --- outline: deep --- # Client/server testing You can write tests which start up both a server for your app, and a Feathers client which your test can use to call the server. Such tests can expose faults in the interaction between the client and the server. They are also useful in testing the authentication of requests from the client. Install it as a development dependency: ``` npm install @feathersjs/client --save-dev ``` Test `test/services/users.test.js` from above runs on the server. We convert it, in the following `tests/services/client-users.test.js`, so the tests are run on the client instead of on the server. This also causes client authentication to be tested. ```js const assert = require('assert'); const feathersClient = require('@feathersjs/client'); const io = require('socket.io-client'); const app = require('../../src/app'); const host = app.get('host'); const port = app.get('port'); const email = 'login@example.com'; const password = 'login'; describe('\'users\' service - client', function () { this.timeout(10000); let server; let client; before(async () => { await app.service('users').create({ email, password }); server = app.listen(port); server.on('listening', async () => { // eslint-disable-next-line no-console console.log('Feathers application started on http://%s:%d', host, port); }); client = await makeClient(host, port, email, password); }); after(() => { client.logout(); server.close(); }); describe('Run tests using client and server', () => { it('registered the service', () => { const service = client.service('users'); assert.ok(service, 'Registered the service'); }); it('creates a user, encrypts password and adds gravatar', async () => { const user = await client.service('users').create({ email: 'testclient@example.com', password: 'secret' }); // Verify Gravatar has been set to what we'd expect assert.equal(user.avatar, 'https://s.gravatar.com/avatar/1b9c869fa7a93e59463c31a377fe0cf6?s=60'); // Makes sure the password got encrypted assert.ok(user.password !== 'secret'); }); it('removes password for external requests', async () => { // Setting `provider` indicates an external request const params = { provider: 'rest' }; const user = await client.service('users').create({ email: 'testclient2@example.com', password: 'secret' }, params); // Make sure password has been removed assert.ok(!user.password); }); }); }); async function makeClient(host, port, email, password) { const client = feathersClient(); const socket = io(`http://${host}:${port}`, { transports: ['websocket'], forceNew: true, reconnection: false, extraHeaders: {} }); client.configure(feathersClient.socketio(socket)); client.configure(feathersClient.authentication({ storage: localStorage() })); await client.authenticate({ strategy: 'local', email, password, }); return client; } function localStorage () { const store = {}; return { setItem (key, value) { store[key] = value; }, getItem (key) { return store[key]; }, removeItem (key) { delete store[key]; } }; } ``` We first make a call on the *server* to create a new user. We then start up a server for our app. Finally the function `makeClient` is called to create a Feathers client and authenticate it using the newly created user. The individual tests remain unchanged except that the service calls are now made on the client (`client.service(...).create`) instead of on the server (`app.service(...).create`). The `describe('Run tests using client and server',` statement stops a new server and client from being created for each test. This results in the test module running noticeably faster, though the tests are now exposed to potential interactions. You can remove the statement to isolate the tests from one another. ================================================ FILE: docs/cookbook/general/scaling.md ================================================ --- outline: deep --- # Scaling Depending on your requirements, your feathers application may need to provide high availability. Feathers is designed to scale. The types of transports used in a feathers application will impact the scaling configuration. For example, a feathers app that uses the `feathers-rest` adapter exclusively will require less scaling configuration because HTTP is a stateless protocol. If using websockets (a stateful protocol) through the `feathers-socketio` or `feathers-primus` adapters, configuration may be more complex to ensure websockets work properly. ## Horizontal Scaling Scaling horizontally refers to either: - setting up a [cluster](https://nodejs.org/api/cluster.html), or - adding more machines to support your application To achieve high availability, varying combinations of both strategies may be used. ## Cluster configuration [Cluster](https://nodejs.org/api/cluster.html) support is built into core NodeJS. Since NodeJS is single threaded, clustering allows you to easily distribute application requests among multiple child processes (and multiple threads). Clustering is a good choice when running feathers in a multi-core environment. Below is an example of adding clustering to feathers with the `feathers-socketio` provider. By default, websocket connections begin via a handshake of multiple HTTP requests and are upgraded to the websocket protocol. However, when clustering is enabled, the same worker will not process all HTTP requests for a handshake, leading to HTTP 400 errors. To ensure a successful handshake, force a single worker to process the handshake by disabling the http transport and exclusively using the `websocket` transport. ```js import cluster from 'cluster'; import feathers from '@feathersjs/feathers'; import socketio from '@feathersjs/socketio'; const CLUSTER_COUNT = 4; if (cluster.isMaster) { for (let i = 0; i < CLUSTER_COUNT; i++) { cluster.fork(); } } else { const app = feathers(); // ensure the same worker handles websocket connections app.configure(socketio({ transports: ['websocket'] })); app.listen(4000); } ``` In your feathers client code, limit the socket.io-client to the `websocket` transport and disable `upgrade`. ```js import feathers from '@feathersjs/client'; import socketio from '@feathersjs/socketio-client'; import io from 'socket.io-client'; const app = feathers() .configure(socketio( io('http://api.feathersjs.com', { transports: ['websocket'], upgrade: false }) )); ``` ## Multiple instances When running multiple instances of your Feathers application (e.g. on several Heroku Dynos), service events (created, updated, patched, removed and any custom defined events) do not get propagated to other instances for such cases you may want to use: https://github.com/feathersjs-ecosystem/feathers-sync Which will use a messaging mechanism to propagate all events to all application instances like redis or RabbitMQ ================================================ FILE: docs/cookbook/index.md ================================================ --- outline: deep --- # The Feathers cookbook This cookbook contains a growing collection of recipes for common tasks you might run into with Feathers. Make sure you have [followed the Feathers guide first](../guides/) before jumping into the cookbook. Have a recipe idea? [Submit an issue with a suggestion](https://github.com/feathersjs/docs/issues/new?title=Cookbook%20Suggestion:). ================================================ FILE: docs/ecosystem/PackageCard.vue ================================================ ================================================ FILE: docs/ecosystem/Packages.vue ================================================ ================================================ FILE: docs/ecosystem/helpers.ts ================================================ export function nFormatter(num: number, digits?: number) { const lookup = [ { value: 1, symbol: '' }, { value: 1e3, symbol: 'k' }, { value: 1e6, symbol: 'M' }, { value: 1e9, symbol: 'G' }, { value: 1e12, symbol: 'T' }, { value: 1e15, symbol: 'P' }, { value: 1e18, symbol: 'E' } ] const rx = /\.0+$|(\.[0-9]*[1-9])0+$/ const item = lookup .slice() .reverse() .find(function (item) { return num >= item.value }) return item ? (num / item.value).toFixed(digits).replace(rx, '$1') + item.symbol : '0' } export const uniqBy = (arr: T[], selector: (item: T) => V) => { const map = new Map() arr.forEach((item) => { const prop = selector(item) if (!map.has(prop)) map.set(prop, item) }) return [...map.values()] } ================================================ FILE: docs/ecosystem/index.md ================================================ --- lastUpdated: false --- # FeathersJS Ecosystem ## The Feathers Flightpath Blog Catch up on the latest FeathersJS news and community-contributed articles on the [Feathers Flightpath Blog](https://blog.feathersjs.com/). ## YouTube Playlist Watch the [FeathersJS Playlist on YouTube](https://www.youtube.com/playlist?list=PLwSdIiqnDlf_lb5y1liQK2OW5daXYgKOe). ## Awesome Packages This is a curated list of feathers packages. You can sort by various criteria. Core packages are hidden by default. ================================================ FILE: docs/ecosystem/types.ts ================================================ export type PackageInput = { npm: string repo: string } export type PackagesInput = Record export type PackageOutput = { id: string name: string description: string keywords: string[] /** npm license */ license: string /** npm version */ version: string /** npm monthly downloads */ downloads: number /** npm last published Date */ lastPublish: Date /** npm last published Date as unix */ lastPublishUnix: number /** github: stars count */ stars: number /** github: open issues count */ issues: number /** github: age of repo */ createdAt: Date /** github: name of the owner */ ownerName: string /** github: url of the users avatar */ ownerAvatar: string /** github: url of the repo */ ghLink: string hasNPM: boolean /** npm: url of the package */ npmLink: string repository: { name: string directory: string } } ================================================ FILE: docs/ecosystem/useQuery.ts ================================================ import { Ref, watch } from 'vue' import queryString from 'query-string' type MaybeArray = T | T[] type FieldType = MaybeArray<'string' | 'number' | 'boolean'> export const useQuery = (reference: Ref, field: string) => { function getQuery() { return queryString.parse(window.location.search, { parseNumbers: true, parseBooleans: true, arrayFormat: 'none' }) } function getFromUrl() { const q = getQuery() const result = q[field] // explicitly return false instead of undefined if (typeof reference.value === 'boolean' && !result) { return false } if (result == null) return if (Array.isArray(reference.value)) { return Array.isArray(result) ? result : [result] } return result } const fromUrl = getFromUrl() if (fromUrl != null) { // @ts-expect-error arbitrary type reference.value = fromUrl } function setToUrl(val: any) { const q = getQuery() if (val && (!Array.isArray(reference.value) || (Array.isArray(val) && val.length > 0))) { q[field] = val } else { delete q[field] } const prepend = Object.keys(q).length ? '?' : '' const newQuery = `${prepend}${queryString.stringify(q, { skipNull: true })}` window.history.replaceState(null, '', newQuery) } watch( reference, (val) => { setToUrl(val) }, { immediate: true } ) } ================================================ FILE: docs/feathers-vs-firebase.md ================================================ # Feathers vs Firebase Firebase is a hosted platform for mobile or web applications. Just like Feathers, Firebase provides REST and real-time APIs but also includes CDN support. Feathers on the other hand leaves setting up a CDN and hosting your Feathers app up to the developer. Firebase is a closed-source, paid hosted service starting at $5/month with the next plan level starting at $49/month. Feathers is open source and can run on any hosting platform like Heroku, Modulus or on your own servers like Amazon AWS, Microsoft Azure, Digital Ocean and your local machine. Because Firebase can't be run locally you typically need to pay for both a shared development environment on top of any production and testing environment. Firebase has JavaScript and mobile clients and also provides framework specific bindings. Feathers currently focuses on universal usage in JavaScript environments and does not have any framework specific bindings. Mobile applications can use Feathers REST and websocket endpoints directly but at the moment there are no Feathers specific iOS and Android SDKs. Firebase currently supports offline mode whereas that is currently left up to the developer with Feathers. Both Firebase and Feathers support email/password, token, and OAuth authentication. Firebase has not publicly disclosed the database technology they use to store your data behind their API but it seems to be an SQL variant. Feathers supports multiple databases, NoSQL and SQL alike. For more technical details on the difference and how to potentially migrate an application you can read [how to use Feathers as an open source alternative to Firebase](https://medium.com/all-about-feathersjs/using-feathersjs-as-an-open-source-alternative-to-firebase-b5d93c200cee#.olu25brld). ================================================ FILE: docs/feathers-vs-loopback.md ================================================ # Feathers vs LoopBack Both LoopBack, and Feathers are frameworks primarily meant for building APIs, and mediating between front-end clients, and backend data sources. LoopBack is maintained by StrongLoop (an IBM company); while Feathers is community maintained. Folks behind StrongLoop are also the current maintainers of the Express framework atop of which both Feathers, and LoopBack are built. While LoopBack is a MVC framework bringing in its own set of conventions/concepts, with route-based CRUD config for its entities, Feathers propagates a service-oriented thinking model, where in you can build lightweight services to define entities — **"you're no longer thinking CRUD routes for an entity; but a corresponding service, which represents an entity, and the CRUD methods for it"** — and it gets out of your way allowing you to set your own conventions. Feathers has support for multiple databases and ORMs. LoopBack only supports its inbuilt ORM (based on Juggler). It should be noted, that LoopBack v4, which is under heavy development as of this writing would open support for multiple ORMs. Feathers core is engine-agnostic; meaning it works on both client, server sides. LoopBack comes with a separate in-built client. Feathers has official libraries which can be integrated with Feathers to support multiple transport layers apart from rest; like sockets, primus, etc... This can be achieved in LoopBack via various community libraries. LoopBack comes with in-built support for generating ACLs and an in-built API explorer, which makes it easier to analyse the built APIs, via auto-generated docs. Thanks to a rich ecosystem of libraries around Feathers, this can be achieved in Feathers via third party libraries like [feathers-permissions](https://github.com/feathersjs-ecosystem/feathers-permissions), and [feathers-swagger](https://github.com/feathersjs-ecosystem/feathers-swagger), respectively. The conveniences brought in by LoopBack come with a tradeoff of a large knowledge surface area. While LoopBack is a "convention-over-configuration" framework, Feathers (core) is a really small/lightweight library which gets out of your way, without enforcing any specific way of building your service-oriented APIs. ================================================ FILE: docs/feathers-vs-meteor.md ================================================ # Feathers vs Meteor Both Feathers and Meteor are open source real-time JavaScript platforms that provide front end and back end support. They both allow clients to send and receive messages over websockets. Feathers lets you choose which real-time transport(s) you want to use via Socket.io or Primus, while Meteor relies on SockJS. Feathers is community supported, whereas Meteor is venture backed and has raised 31.2 million dollars to date. Meteor only has official support for MongoDB but there are some community modules of various levels of quality that support other databases. Meteor has it's own package manager and package ecosystem. They have their own template engine called Blaze which is based off of Mustache along with their own build system, but also have guides for Angular and React. Feathers has official support for many more databases and supports any front-end framework or view engine that you want by working seamlessly on the client. Feathers uses the defacto JavaScript package manager npm. As a result you can utilize the hundreds of thousands of modules published to npm. Feathers lets you decide whether you want to use Gulp, Grunt, Browserify, Webpack or any other build tool. Meteor has optimistic UI rendering and oplog tailing whereas currently Feathers leaves that up to the developer. However, we've found that being universal and utilizing websockets for both sending and receiving data alleviates the need for optimistic UI rendering and complex data diffing in most cases. Both Meteor and Feathers provide support for email/password and OAuth authentication. Once authenticated Meteor uses sessions to maintain a logged in state, whereas Feathers keeps things stateless and uses [JSON Web Tokens](https://jwt.io/) (JWT) to assess authentication state. One big distinction is how Feathers and Meteor provide real-time across a cluster of apps. Feathers does it at the service layer or using another pub-sub service like Redis whereas Meteor relies on having access to and monitoring MongoDB operation logs as the central hub for real-time communication. ================================================ FILE: docs/feathers-vs-nest.md ================================================ # Feathers vs Nest Nest is a backend framework that have similar capabilities with Feathers. Nest uses dependency injection system and a module based architecture, Feathers uses service based architecture with a more functional approach. Nest can only be written in TypeScript whereas Feathers supports JavaScript and TypeScript. Feathers can generate client code for its server, Nest can't. Nest uses RxJS for running interceptors, guards, filters or validation pipes. Feathers uses before, after and around hooks. For more details on the difference between them you can read more here: [FeathersJS vs NestJS - Compared In 3 Key Areas](https://blog.feathersjs.com/feathersjs-vs-nestjs-compared-in-3-key-areas-427def783555) ================================================ FILE: docs/feathers-vs-sails.md ================================================ # Feathers vs Sails From a feature standpoint, Feathers and Sails are probably the most similar of the comparisons offered here. Both provide real-time REST API's, multiple DB support, and are client-agnostic. Sails is bound to the server whereas Feathers can also be used in the browser and in React Native apps. Both frameworks use Express, with Feathers supporting the latest Express 4, while Sails supports Express 3. Sails follows the MVC pattern while Feathers provides lightweight services to define your resources. Feathers uses hooks to define your business logic including validations, security policies, and serialization in reusable, chainable modules, whereas with Sails, these reside in more of a configuration file format. Feathers supports multiple ORMs while Sails only supports its own Waterline ORM. Sails allows you to receive messages via websockets on the client, but, unlike Feathers, does not directly support data being sent from the client to the server over websockets. Additionally, Sails uses Socket.io for its websocket transport. Feathers also supports Socket.io but also many other socket implementations and transports. Even though the features are very similar, Feathers achieves this with much less code. Feathers also doesn't assume how you want to manage your assets or that you even have any (because you might be making a JSON API). Instead of coming bundled with Grunt, Feathers lets you use your build tool of choice. Sails doesn't come with any built-in authentication support. Instead, it offers guides on how to configure Passport. By contrast, Feathers supports an official authentication plugin that is a drop-in, minimal configuration, module that provides email/password, token, and OAuth authentication much more like Meteor. Using this you can authenticate using those providers over ANY transport - HTTP, Websockets, and others. Scaling a Sails app is as simple as deploying your large app multiple times behind a load balancer with some pub-sub mechanism like Redis. With Feathers you can do the same but you also have the option to mount sub-apps more like Express, spin up additional services in the same app, or split your services into small standalone microservice applications. ================================================ FILE: docs/guides/basics/authentication.md ================================================ --- outline: deep --- # Authentication Authentication is an important aspect of any web application that involves user accounts. It allows users to log in and prove their identity, which is critical for keeping the application secure and ensuring that only authorized users can access sensitive information or perform certain actions. The Feathers CLI allows to easily add authentication to our application, including features such as creating and verifying tokens, storing and retrieving user credentials securely, and implementing OAuth-based authentication with third-party providers. The following authentication strategies are included: - __JWT__ for authenticating a request with a [JSON Web Token](https://jwt.io/). It is an access token that is issued by the Feathers server for a limited time (one day by default). When someone logs in, Feathers issues a JWT that they need to include with every request they make to the application. - __Local Authentication__ allows someone to log in and create a JWT using a username (usually an email address) and password that they have already registered with our application. The CLI will also help you set up a database to store this information securely. - __OAuth Authentication__ allows someone to log in using their account from a third-party provider like Google, GitHub, or Twitter. The Feathers CLI can set this up too. ## Generating authentication To initialize a standard authentication setup we can run ``` npx feathers generate authentication ``` For the first prompt, let's select GitHub in addition to _Email + Password_ by navigating to it with the arrow down key and then pressing space. All other questions can be answered with the default by pressing enter: ![feathers generate authentication prompts](./assets/generate-authentication.png) ![feathers generate authentication prompts](./assets/generate-authentication-mongodb.png) ## What's next? By running this command we set up a `users` endpoint to register and store users and an `authentication` endpoint to log them in. It also generated everything necessary for a log in via GitHub. If you're not familiar with how the authentication process works, don't worry. We'll cover that in the [Logging In](./login.md) chapter of this guide but first let's look at Feathers [core concepts of services](./services.md) that our new `users` endpoint already uses. ================================================ FILE: docs/guides/basics/generator.md ================================================ --- outline: deep --- # Creating an app In the [quick start](./starting.md) we created a Feathers application in a single file to get a better understanding of how Feathers itself works. Getting started The [Feathers CLI](../cli/index.md) allows us to initialize a new Feathers server with a recommended structure and generate things we commonly need like authentication, a database connection or new services. In this guide we will create a Feathers HTTP and real-time API for a chat application using the Feathers CLI. Using it, for example with [a JavaScript frontend](../frontend/javascript.md), looks like this: ![The Feathers chat application](../basics/assets/feathers-chat.png) You can find the complete example in the [feathers-chat repository](https://github.com/feathersjs/feathers-chat). ## Generating the application You can create a new Feathers application by running `npm create feathers `. To create a new Feathers application called `feathers-chat` we can run: ```sh npm create feathers@latest feathers-chat ``` If you never ran the command before you might be asked to confirm the package installation by pressing enter. The `@latest` in the command makes sure that the most recent released version of the CLI is used.
Since the generated application is using modern features like ES modules, the Feathers CLI requires __Node 16 or newer__.
First, choose if you want to use JavaScript or TypeScript. When presented with the project name, just hit enter, or enter a name (no spaces). Next, write a short description for your application. Confirm the next questions with the default selection by pressing Enter. If you choose a database other than __SQLite__, make sure it is reachable at the connection string. For following this guide using MongoDB, change the database selection in the dropdown below.
Once you confirm the last prompt, the final selection should look similar to this: ![feathers generate app prompts](./assets/generate-app.png)
`SQLite` creates an SQL database in a file so we don't need to have a database server running.
![feathers generate app prompts](./assets/generate-app-mongodb.png) Sweet! We generated our first Feathers application in a new folder called `feathers-chat` so we need to go there. ```sh cd feathers-chat ```
Most generated files have a page in the [CLI guide](../cli/index.md) which contains more information about the file and what it does.
## Running the server and tests The server can be started by running ```sh npm run compile npm run migrate npm start ``` ```sh npm run compile npm start ``` ```sh npm start ``` After that, you will see the Feathers logo at ``` http://localhost:3030 ```
You can exit the running process by pressing **CTRL + C**
The app also comes with a set of basic tests which can be run with ```sh npm test ``` There is also a handy development command that restarts the server automatically whenever we make a code change: ```sh npm run dev ```
Keep this command running throughout the rest of this guide so it will reload all our changes automatically.
## What's next? In this chapter, we've created a new Feathers application. To learn more about the generated files and what you can do with the CLI, have a look at the [CLI guide](../cli/index.md) after finishing the Getting Started guide. In [the next chapter](./authentication.md) we will set up user authentication. ================================================ FILE: docs/guides/basics/hooks.md ================================================ --- outline: deep --- # Hooks When we created our messages service in [the services chapter](./services.md), we saw that Feathers services are a great way to implement data storage and modification. Technically, we could write our entire app with services but very often we need similar functionality across multiple services. For example, we might want to check for all services if a user is allowed to access it. With just services, we would have to write this every time. This is where Feathers hooks come in. Hooks are pluggable middleware functions that can be registered **around**, **before**, **after** or on **errors** of a service method without changing the original code. Just like services themselves, hooks are _transport independent_. They are usually also service independent, meaning they can be used with ​*any*​ service. This pattern keeps your application logic flexible, composable, and much easier to trace through and debug. Hooks are commonly used to handle things like validation, authorization, logging, sending emails and more.
A full overview of the hook API can be found in the [hooks API documentation](../../api/hooks.md). For the general design pattern behind hooks see [this blog post](https://blog.feathersjs.com/design-patterns-for-modern-web-apis-1f046635215).
## Generating a hook Let's generate a hook that logs the total runtime of a service method to the console. ```sh npx feathers generate hook ``` We call our hook `log-runtime` and confirm the type with enter to make it an `around` hook. ![feathers generate hook prompts](./assets/generate-hook.png) Now update `src/hooks/log-runtime.ts` as follows: Now update `src/hooks/log-runtime.js` as follows: ```ts{2,5-10} import type { HookContext, NextFunction } from '../declarations' import { logger } from '../logger' export const logRuntime = async (context: HookContext, next: NextFunction) => { const startTime = Date.now() // Run everything else (other hooks and service call) await next() const duration = Date.now() - startTime logger.info(`Calling ${context.method} on ${context.path} took ${duration}ms`) } ``` In this hook, we store the start time and then run all other hooks and the service method by calling `await next()`. After that we can calculate the duration in milliseconds by subtracting the start time from the current time and log the information using the application [logger](../cli/logger.md). ## Hook functions A hook function is an `async` function that takes the [hook `context`](#hook-context) and a `next` function as the parameter. If the hook should only run on **error**, **before** or **after** the service method, it does not need a `next` function. However since we need to do both, get the start time before and the end time after, we created an `around` hook. Hooks run in the order they are registered and if a hook function throws an error, all remaining hooks (and the service call if it didn't run yet) will be skipped and the error will be returned. ## Hook context The hook `context` is an object which contains information about the service method call. It has read-only and writable properties. Read-only properties are: - `context.app` - The Feathers application object. This commonly used to call other services - `context.service` - The service object this hook is currently running on - `context.path` - The path (name) of the service - `context.method` - The name of the service method being called - `context.type` - The hook type (around, before, etc) Writeable properties are: - `context.params` - The service method call `params`. For external calls, `params` usually contains: - `context.params.query` - The query filter (e.g. from the REST query string) for the service call - `context.params.provider` - The name of the transport the call has been made through. Usually `"rest"` or `"socketio"`. Will be `undefined` for internal calls. - `context.params.user` - _If authenticated_, the data of the user making the service method call. - `context.id` - The `id` of the record if the service method call is a `get`, `remove`, `update` or `patch` - `context.data` - The `data` sent by the user in a `create`, `update` and `patch` and custom service method call - `context.error` - The error that was thrown (in `error` hooks) - `context.result` - The result of the service method call (available after calling `await next()` or in `after` hooks)
For more information about the hook context see the [hooks API documentation](../../api/hooks.md).
## Registering hooks In a Feathers application, hooks are being registered in the [<servicename>](../cli/service.md) file. The hook registration object is an object with `{ around, before, after, error }` and a list of hooks per method like `{ all: [], find: [], create: [] }`. To log the runtime of our `messages` service calls we can update `src/services/messages/messages.ts` like this: To log the runtime of all `messages` service calls we can update `src/services/messages/messages.js` like this: ```ts{20,38} // For more information about this file see https://dove.feathersjs.com/guides/cli/service.html import { authenticate } from '@feathersjs/authentication' import { hooks as schemaHooks } from '@feathersjs/schema' import { messageDataValidator, messagePatchValidator, messageQueryValidator, messageResolver, messageExternalResolver, messageDataResolver, messagePatchResolver, messageQueryResolver } from './messages.schema' import type { Application } from '../../declarations' import { MessageService, getOptions } from './messages.class' import { messagePath, messageMethods } from './messages.shared' import { logRuntime } from '../../hooks/log-runtime' export * from './messages.class' export * from './messages.schema' // A configure function that registers the service and its hooks via `app.configure` export const message = (app: Application) => { // Register our service on the Feathers application app.use(messagePath, new MessageService(getOptions(app)), { // A list of all methods this service exposes externally methods: messageMethods, // You can add additional custom events to be sent to clients here events: [] }) // Initialize hooks app.service(messagePath).hooks({ around: { all: [ logRuntime, authenticate('jwt'), schemaHooks.resolveExternal(messageExternalResolver), schemaHooks.resolveResult(messageResolver) ] }, before: { all: [schemaHooks.validateQuery(messageQueryValidator), schemaHooks.resolveQuery(messageQueryResolver)], find: [], get: [], create: [schemaHooks.validateData(messageDataValidator), schemaHooks.resolveData(messageDataResolver)], patch: [schemaHooks.validateData(messagePatchValidator), schemaHooks.resolveData(messagePatchResolver)], remove: [] }, after: { all: [] }, error: { all: [] } }) } // Add this service to the service type index declare module '../../declarations' { interface ServiceTypes { [messagePath]: MessageService } } ``` Now every time our messages service is accessed successfully, the name, method and runtime will be logged.
`all` is a special keyword which means those hooks will run before the method specific hooks. Method specific hooks can be registered based on their name, e.g. to only log the runtime for `find` and `get`: ```ts app.service('messages').hooks({ around: { all: [authenticate('jwt')], find: [logRuntime], get: [logRuntime] } // ... }) ```
## What's next? In this chapter we learned how Feathers hooks can be used as middleware for service method calls without having to change our service. Here we just logged the runtime of a service method to the console but you can imagine that hooks can be useful for many other things like more advanced logging, sending notifications or checking user permissions. You may also have noticed above that there are already some hooks like `schemaHooks.validateQuery` or `schemaHooks.resolveResult` registered on our service. This brings us to the next chapter on how to define our data model with [schemas and resolvers](./schemas.md). ================================================ FILE: docs/guides/basics/login.md ================================================ # Logging in We now have a fully functional chat application consisting of [services](./services.md) and [schemas](./schemas.md). In the [authentication chapter](./authentication.md) we generated everything necessary for using Feathers authentication so let's look at how to register users and add a log in with GitHub to our chat. ## Registering a user The HTTP REST API can be used directly to register a new user. We can do this by sending a POST request to `http://localhost:3030/users` with JSON data like this as the body: ```js // POST /users { "email": "hello@feathersjs.com", "password": "supersecret" } ``` Try it: ```sh curl 'http://localhost:3030/users/' \ -H 'Content-Type: application/json' \ --data-binary '{ "email": "hello@feathersjs.com", "password": "supersecret" }' ``` [![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/6bcea48aac6c7494c2ad)
For SQL databases, creating a user with the same email address will only work once, then fail since it already exists. With the default database selection, you can reset your database by removing the `feathers-chat.sqlite` file and running `npm run migrate` to initialise it again.
This will return something like this: ```json { "id": 123, "email": "hello@feathersjs.com", "avatar": "https://s.gravatar.com/avatar/ffe2a09df37d7c646e974a2d2b8d3e03?s=60" } ``` ```json { "_id": "63c00098502debdeec31bd77", "email": "hello@feathersjs.com", "avatar": "https://s.gravatar.com/avatar/ffe2a09df37d7c646e974a2d2b8d3e03?s=60" } ``` Which means our user has been created successfully.
The password has been hashed and stored securely in the database but will never be included in an external response.
## Logging in By default, Feathers uses [JSON Web Tokens](https://jwt.io/) for authentication. It is an access token that is issued by the Feathers server for a limited time (one day by default) and needs to be sent with every API request that requires authentication. Usually a token is issued for a specific user. Let's see if we can issue a JWT for the user that we just created.
If you are wondering why Feathers is using JWT for authentication, have a look at [this FAQ](../../help/faq.md#why-are-you-using-jwt-for-sessions).
Tokens can be created by sending a POST request to the `/authentication` endpoint (which is the same as calling the `create` method on the `authentication` service set up in `src/authentication`) and passing the authentication strategy you want to use along with any other relevant data. To get a JWT for an existing user through a username (email) and password login, we can use the built-in `local` authentication strategy with a request like this: ```js // POST /authentication { "strategy": "local", "email": "hello@feathersjs.com", "password": "supersecret" } ``` Try it: ```sh curl 'http://localhost:3030/authentication/' \ -H 'Content-Type: application/json' \ --data-binary '{ "strategy": "local", "email": "hello@feathersjs.com", "password": "supersecret" }' ``` [![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/6bcea48aac6c7494c2ad) This will return something like this: ```json { "accessToken": "", "authentication": { "strategy": "local" }, "user": { "id": 123, "email": "hello@feathersjs.com", "avatar": "https://s.gravatar.com/avatar/ffe2a09df37d7c646e974a2d2b8d3e03?s=60" } } ``` ```json { "accessToken": "", "authentication": { "strategy": "local" }, "user": { "_id": "63c00098502debdeec31bd77", "email": "hello@feathersjs.com", "avatar": "https://s.gravatar.com/avatar/ffe2a09df37d7c646e974a2d2b8d3e03?s=60" } } ``` The `accessToken` can now be used for other REST requests that require authentication by sending the `Authorization: Bearer ` HTTP header. For example to create a new message: ```sh curl 'http://localhost:3030/messages/' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer ' \ --data-binary '{ "text": "Hello from the console" }' ```
Make sure to replace the `` in the above request. For more information about the direct usage of the REST API see the [REST client API](../../api/client/rest.md) and for websockets the [Socket.io client API](../../api/client/socketio.md).
That's pretty neat, but emails and passwords are boring, let's spice things up a bit. ## Login with GitHub OAuth is an open authentication standard supported by almost every major social platform and what gets us the log in with Facebook, Google, GitHub etc. buttons. From the Feathers perspective, the authentication flow with OAuth is pretty similar. Instead of authenticating with the `local` strategy by sending a username and password, Feathers directs the user to authorize the application with the login provider. If it is successful, Feathers authentication finds or creates the user in the `users` service with the information it got back from the provider and then issues a token for them. To allow login with GitHub, we first have to [create a new OAuth application on GitHub](https://github.com/settings/applications/new). You can put anything in the name, homepage and description fields. The callback URL **must** be set to ```sh http://localhost:3030/oauth/github/callback ``` ![Screenshot of the GitHub application screen](./assets/github-app.png)
You can find your existing applications in the [GitHub OAuth apps developer settings](https://github.com/settings/developers).
Once you've clicked "Register application", we need to update our Feathers app configuration with the client id and secret copied from the GitHub application settings. Find the `authentication` section in `config/default.json` replace the `` and `` in the `github` section with the proper values: ```js { "authentication": { "oauth": { "github": { "key": "", "secret": "" } }, // Other authentication configuration is here // ... } } ```
In a production environment you would set those values as [custom environment variables](../cli/custom-environment-variables.md).
This tells the OAuth strategy to redirect back to our index page after a successful login and already makes a basic login with GitHub possible. Because of the changes we made in the `users` service in the [services chapter](./services.md) we do need a small customization though. Instead of only adding `githubId` to a new user when they log in with GitHub we also include their email and the avatar image from the profile we get back. We can do this by extending the standard OAuth strategy and registering it as a GitHub specific one and overwriting the `getEntityData` method: Update `src/authentication.ts` as follows: ```ts{1,5,14-26,33} import type { Params } from '@feathersjs/feathers' import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication' import { LocalStrategy } from '@feathersjs/authentication-local' import { oauth, OAuthStrategy } from '@feathersjs/authentication-oauth' import type { OAuthProfile } from '@feathersjs/authentication-oauth' import type { Application } from './declarations' declare module './declarations' { interface ServiceTypes { authentication: AuthenticationService } } class GitHubStrategy extends OAuthStrategy { async getEntityData(profile: OAuthProfile, existing: any, params: Params) { const baseData = await super.getEntityData(profile, existing, params) return { ...baseData, // The GitHub profile image avatar: profile.avatar_url, // The user email address (if available) email: profile.email || profile.login } } } export const authentication = (app: Application) => { const authentication = new AuthenticationService(app) authentication.register('jwt', new JWTStrategy()) authentication.register('local', new LocalStrategy()) authentication.register('github', new GitHubStrategy()) app.use('authentication', authentication) app.configure(oauth()) } ```
For more information about the OAuth flow and strategy see the [OAuth API documentation](../../api/authentication/oauth.md).
To log in with GitHub, visit ``` http://localhost:3030/oauth/github ``` It will redirect to GitHub and ask to authorize our application. If everything went well, we get redirected to our homepage with the Feathers logo with the token information in the location hash. This will be used by the Feathers authentication client to authenticate our user. ## What's next? Sweet! We now have an API that can register new users with email/password and GitHub. This means we have everything we need for a frontend for our chat application. See the [JavaScript frontend guide](../frontend/javascript.md) on how to create a plain JavaScript chat application. ================================================ FILE: docs/guides/basics/schemas.md ================================================ # Schemas and resolvers In Feathers, schemas and resolvers allow us to define, validate and secure our data model and types. Professor bird at work As we've briefly seen in the [previous chapter about hooks](./hooks.md), there were a few hooks registered already to validate schemas and resolve data. Schema validators and resolvers are used with those hooks to modify data in the hook context. Similar to how Feathers services are transport independent, schemas and resolvers are database independent. It comes in two main parts: - [TypeBox](../../api/schema/typebox.md) or [JSON schema](../../api/schema/schema.md) to define a schema. This allows us to do things like: - Ensure data is valid and always in the right format - Automatically get up to date TypeScript types from schema definitions - Create a typed client that can be used in React, Vue etc. apps - Automatically generate API documentation - Validate query string filters and convert them to the correct types - [Resolvers](../../api/schema/resolvers.md) - Resolve schema properties based on a context (usually the [hook context](./hooks.md)). This can be used for many different things like: - Populating associations - Securing queries and limiting the type of requests the logged in user can perform - Safely hiding sensitive data for external clients - Adding read and write permissions on the property field level - Hashing passwords and validating dynamic password policies In this chapter we will look at the generated schemas and resolvers and update them with the information we need for our chat application. ## Feathers schemas While schemas and resolvers can be used outside of a Feathers application, you will usually encounter them in a Feathers context where they come in four kinds: - **Result** schemas and resolvers that define the data that is being returned. This is also where associated data would be fetched - **Data** schemas and resolvers handle the data from a `create`, `update`, `patch`, or custom service method and can be used to add/replace things like default or calculated values (e.g. the `createdAt` or `updatedAt` date) before saving it to the database - **Query** schemas and resolvers validate and convert the query string and can also be used for additional limitations like only allowing a user to see and modify their own data - **External** resolvers return a safe version of the data (by e.g. hiding a users password) that can be sent to external clients While it may initially look like a bit more code, schema driven development is a great way to have the data models and how data is modified in a single place. ## Adding a user avatar Let's extend our existing users schema to add an `avatar` property so that our users can have a profile image. First we need to update the `src/services/users/users.schema.ts` file with the schema property for the avatar and a resolver property that sets a default avatar using the [Gravatar](https://en.gravatar.com/) based on the email address: First we need to update the `src/services/users/users.schema.js` file with the schema property for the avatar and a resolver property that sets a default avatar using the [Gravatar](https://en.gravatar.com/) based on the email address: ```ts{2,17-18,34,44-54,68,82-86} // For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html import crypto from 'crypto' import { resolve } from '@feathersjs/schema' import { Type, getValidator, querySyntax } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' import { passwordHash } from '@feathersjs/authentication-local' import type { HookContext } from '../../declarations' import { dataValidator, queryValidator } from '../../validators' // Main data model schema export const userSchema = Type.Object( { id: Type.Number(), email: Type.String(), password: Type.Optional(Type.String()), githubId: Type.Optional(Type.Number()), avatar: Type.Optional(Type.String()) }, { $id: 'User', additionalProperties: false } ) export type User = Static export const userValidator = getValidator(userSchema, dataValidator) export const userResolver = resolve({}) export const userExternalResolver = resolve({ // The password should never be visible externally password: async () => undefined }) // Schema for creating new users export const userDataSchema = Type.Pick( userSchema, ['email', 'password', 'githubId', 'avatar'], { $id: 'UserData', additionalProperties: false } ) export type UserData = Static export const userDataValidator = getValidator(userDataSchema, dataValidator) export const userDataResolver = resolve({ password: passwordHash({ strategy: 'local' }), avatar: async (value, user) => { // If the user passed an avatar image, use it if (value !== undefined) { return value } // Gravatar uses MD5 hashes from an email address to get the image const hash = crypto.createHash('md5').update(user.email.toLowerCase()).digest('hex') // Return the full avatar URL return `https://s.gravatar.com/avatar/${hash}?s=60` } }) // Schema for updating existing users export const userPatchSchema = Type.Partial(userSchema, { $id: 'UserPatch' }) export type UserPatch = Static export const userPatchValidator = getValidator(userPatchSchema, dataValidator) export const userPatchResolver = resolve({ password: passwordHash({ strategy: 'local' }) }) // Schema for allowed query properties export const userQueryProperties = Type.Pick(userSchema, ['id', 'email', 'githubId']) export const userQuerySchema = Type.Intersect( [ querySyntax(userQueryProperties), // Add additional query properties here Type.Object({}, { additionalProperties: false }) ], { additionalProperties: false } ) export type UserQuery = Static export const userQueryValidator = getValidator(userQuerySchema, queryValidator) export const userQueryResolver = resolve({ // If there is a user (e.g. with authentication), they are only allowed to see their own data id: async (value, user, context) => { // We want to be able to get a list of all users but // only let a user modify their own data otherwise if (context.params.user && context.method !== 'find') { return context.params.user.id } return value } }) ``` ```ts{2,18-19,35,44-54,82-87} // // For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html import crypto from 'crypto' import { resolve } from '@feathersjs/schema' import { Type, getValidator, querySyntax } from '@feathersjs/typebox' import { ObjectIdSchema } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' import { passwordHash } from '@feathersjs/authentication-local' import type { HookContext } from '../../declarations' import { dataValidator, queryValidator } from '../../validators' // Main data model schema export const userSchema = Type.Object( { _id: ObjectIdSchema(), email: Type.String(), password: Type.Optional(Type.String()), githubId: Type.Optional(Type.Number()), avatar: Type.Optional(Type.String()) }, { $id: 'User', additionalProperties: false } ) export type User = Static export const userValidator = getValidator(userSchema, dataValidator) export const userResolver = resolve({}) export const userExternalResolver = resolve({ // The password should never be visible externally password: async () => undefined }) // Schema for creating new entries export const userDataSchema = Type.Pick( userSchema, ['email', 'password', 'githubId', 'avatar'], { $id: 'UserData' } ) export type UserData = Static export const userDataValidator = getValidator(userDataSchema, dataValidator) export const userDataResolver = resolve({ password: passwordHash({ strategy: 'local' }), avatar: async (value, user) => { // If the user passed an avatar image, use it if (value !== undefined) { return value } // Gravatar uses MD5 hashes from an email address to get the image const hash = crypto.createHash('md5').update(user.email.toLowerCase()).digest('hex') // Return the full avatar URL return `https://s.gravatar.com/avatar/${hash}?s=60` } }) // Schema for updating existing entries export const userPatchSchema = Type.Partial(userSchema, { $id: 'UserPatch' }) export type UserPatch = Static export const userPatchValidator = getValidator(userPatchSchema, dataValidator) export const userPatchResolver = resolve({ password: passwordHash({ strategy: 'local' }) }) // Schema for allowed query properties export const userQueryProperties = Type.Pick(userSchema, ['_id', 'email', 'githubId']) export const userQuerySchema = Type.Intersect( [ querySyntax(userQueryProperties), // Add additional query properties here Type.Object({}, { additionalProperties: false }) ], { additionalProperties: false } ) export type UserQuery = Static export const userQueryValidator = getValidator(userQuerySchema, queryValidator) export const userQueryResolver = resolve({ // If there is a user (e.g. with authentication), they are only allowed to see their own data _id: async (value, user, context) => { // We want to be able to get a list of all users but // only let a user modify their own data otherwise if (context.params.user && context.method !== 'find') { return context.params.user._id } return value } }) ``` What happened here? - We are adding an optional `avatar` field to our user object. This is where we store a user image to show in the chat. - The `userDataSchema` is updated to include the `avatar` so that a new user can be created with a custom avatar - In the `userDataResolver`, if an `avatar` is not set, we set a default image using the [Gravatar avatar](https://en.gravatar.com/) for the email address - The `userQueryResolver` for the user id property allows for a user to `find` all other users but only change (`patch`, `remove`) their own data ## Handling messages Next we can look at the messages service schema. We want to include the date when the message was created as `createdAt` and the id of the user who sent it as `userId`. When we get a message back, we also want to populate the `user` with the user data from `userId` so that we can show their avatar and email. Update the `src/services/messages/messages.schema.ts` file like this: Update the `src/services/messages/messages.schema.js` file like this: ```ts{2,8,15-17,24-27,39-45,58-61,74-82} // For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html import { resolve, virtual } from '@feathersjs/schema' import { Type, getValidator, querySyntax } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' import type { HookContext } from '../../declarations' import { dataValidator, queryValidator } from '../../validators' import { userSchema } from '../users/users.schema' // Main data model schema export const messageSchema = Type.Object( { id: Type.Number(), text: Type.String(), createdAt: Type.Number(), userId: Type.Number(), user: Type.Ref(userSchema) }, { $id: 'Message', additionalProperties: false } ) export type Message = Static export const messageValidator = getValidator(messageSchema, dataValidator) export const messageResolver = resolve({ user: virtual(async (message, context) => { // Associate the user that sent the message return context.app.service('users').get(message.userId) }) }) export const messageExternalResolver = resolve({}) // Schema for creating new entries export const messageDataSchema = Type.Pick(messageSchema, ['text'], { $id: 'MessageData' }) export type MessageData = Static export const messageDataValidator = getValidator(messageDataSchema, dataValidator) export const messageDataResolver = resolve({ userId: async (_value, _message, context) => { // Associate the record with the id of the authenticated user return context.params.user.id }, createdAt: async () => { return Date.now() } }) // Schema for updating existing entries export const messagePatchSchema = Type.Partial(messageSchema, { $id: 'MessagePatch' }) export type MessagePatch = Static export const messagePatchValidator = getValidator(messagePatchSchema, dataValidator) export const messagePatchResolver = resolve({}) // Schema for allowed query properties export const messageQueryProperties = Type.Pick(messageSchema,[ 'id', 'text', 'createdAt', 'userId' ]) export const messageQuerySchema = Type.Intersect( [ querySyntax(messageQueryProperties), // Add additional query properties here Type.Object({}, { additionalProperties: false }) ], { additionalProperties: false } ) export type MessageQuery = Static export const messageQueryValidator = getValidator(messageQuerySchema, queryValidator) export const messageQueryResolver = resolve({ userId: async (value, user, context) => { // We want to be able to find all messages but // only let a user modify their own messages otherwise if (context.params.user && context.method !== 'find') { return context.params.user.id } return value } }) ``` ```ts{2,9,16-18,25-28,40-46,59-62,75-83} // // For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html import { resolve, virtual } from '@feathersjs/schema' import { Type, getValidator, querySyntax } from '@feathersjs/typebox' import { ObjectIdSchema } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' import type { HookContext } from '../../declarations' import { dataValidator, queryValidator } from '../../validators' import { userSchema } from '../users/users.schema' // Main data model schema export const messageSchema = Type.Object( { _id: ObjectIdSchema(), text: Type.String(), createdAt: Type.Number(), userId: Type.String({ objectid: true }), user: Type.Ref(userSchema) }, { $id: 'Message', additionalProperties: false } ) export type Message = Static export const messageValidator = getValidator(messageSchema, dataValidator) export const messageResolver = resolve({ user: virtual(async (message, context) => { // Associate the user that sent the message return context.app.service('users').get(message.userId) }) }) export const messageExternalResolver = resolve({}) // Schema for creating new entries export const messageDataSchema = Type.Pick(messageSchema, ['text'], { $id: 'MessageData' }) export type MessageData = Static export const messageDataValidator = getValidator(messageDataSchema, dataValidator) export const messageDataResolver = resolve({ userId: async (_value, _message, context) => { // Associate the record with the id of the authenticated user return context.params.user._id }, createdAt: async () => { return Date.now() } }) // Schema for updating existing entries export const messagePatchSchema = Type.Partial(messageSchema, { $id: 'MessagePatch' }) export type MessagePatch = Static export const messagePatchValidator = getValidator(messagePatchSchema, dataValidator) export const messagePatchResolver = resolve({}) // Schema for allowed query properties export const messageQueryProperties = Type.Pick(messageSchema, ['_id', 'text', 'createdAt', 'userId']) export const messageQuerySchema = Type.Intersect( [ querySyntax(messageQueryProperties), // Add additional query properties here Type.Object({}, { additionalProperties: false }) ], { additionalProperties: false } ) export type MessageQuery = Static export const messageQueryValidator = getValidator(messageQuerySchema, queryValidator) export const messageQueryResolver = resolve({ userId: async (value, user, context) => { // We want to be able to find all messages but // only let a user modify their own messages otherwise if (context.params.user && context.method !== 'find') { return context.params.user._id } return value } }) ```
The `virtual()` in the `messageResolver` `user` property is a [virtual property](../../api/schema/resolvers.md#virtual-property-resolvers) and indicates that the value does not come from the messages database table.
## Creating a migration Now that our schemas and resolvers have everything we need, we also have to update the database with those changes. For SQL databases this is done with migrations. Migrations are a best practice for SQL databases to roll out and undo changes to the data model. Every change we make in a schema will need its corresponding migration step. Initially, every database service will automatically add a migration that creates a table for it with an `id` and `text` property. Our users service also already added a migration to add the email and password fields for logging in. The migration for the changes we made in this chapter needs to - Add the `avatar` string field to the `users` table - Add the `createdAt` number field to the `messages` table - Add the `userId` number field to the `messages` table and reference it with the `id` in the `users` table To create a new migration with the name `chat` run ``` npm run migrate:make -- chat ``` You should see something like ``` Created Migration: /path/to/feathers-chat/migrations/20220622012334_chat.(ts|js) ``` Open that file and update it as follows ```ts{4-11,15-22} import type { Knex } from 'knex' export async function up(knex: Knex): Promise { await knex.schema.alterTable('users', (table) => { table.string('avatar') }) await knex.schema.alterTable('messages', (table) => { table.bigint('createdAt') table.bigint('userId').references('id').inTable('users') }) } export async function down(knex: Knex): Promise { await knex.schema.alterTable('users', (table) => { table.dropColumn('avatar') }) await knex.schema.alterTable('messages', (table) => { table.dropColumn('createdAt') table.dropColumn('userId') }) } ``` We can run the migrations on the current database with ``` npm run migrate ```
For MongoDB no migrations are necessary.
## What's next? In this chapter we learned about schemas and implemented all the things we need for our chat application. In the next chapter we will learn about [authentication](./authentication.md) and add a "Login with GitHub" button. ================================================ FILE: docs/guides/basics/services.md ================================================ --- outline: deep --- # Services Services are the heart of every Feathers application. You probably remember the service we made in the [quick start](./starting.md) to create and find messages. In this chapter we will dive more into services and create a database backed service for our chat messages. ## Feathers services In Feathers, a service is an object or instance of a class that implements certain methods. Services provide a way for Feathers to interact with different kinds of data sources in a uniform, protocol-independent way. For example, you could use services to read and/or write data to one of the supported databases, interact with the file system, call a third-party API/service (such as MailGun for sending emails, Stripe for processing payments, or OpenWeatherMap for returning weather information), or even read and/or write to a completely different type of database. A standardized interface allows us to interact with the Database/API/Gnomes inside in a uniform manner across any transport protocol, be it REST, websockets, internally within the application, or Carrier Pigeon 🕊️ Once you write a service method, which usually does not do anything Feathers-specific, you can automatically use it as a REST endpoint or call it through a websocket. Feathers takes care of all the necessary boilerplate, so you can focus on writing the service method itself. ### Service methods Service methods are [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) methods that a service can implement. Feathers offers a set of general methods that a service can implement, these are: - `find` - Find all data (potentially matching a query) - `get` - Get a single data entry by its unique identifier - `create` - Create new data - `update` - Update an existing data entry by completely replacing it - `patch` - Update one or more data entries by merging with the new data - `remove` - Remove one or more existing data entries - `setup` - Called when the application is started - `teardown` - Called when the application is shut down Below is an example of Feathers service interface as a class and basic registration on a Feathers application via [app.use(name, service[, options])](../../api/application.md#use-path-service): ```ts import { feathers } from '@feathersjs/feathers' import type { Application, Id, NullableId, Params } from '@feathersjs/feathers' class MyService { async find(params: Params) {} async get(id: Id, params: Params) {} async create(data: any, params: Params) {} async update(id: NullableId, data: any, params: Params) {} async patch(id: NullableId, data: any, params: Params) {} async remove(id: NullableId, params: Params) {} async setup(path: string, app: Application) {} async teardown(path: string, app: Application) {} } const app = feathers<{ myservice: MyService }>() app.use('myservice', new MyService()) ``` The parameters for service methods are: - `id` - The unique identifier for the data - `data` - The data sent by the user (for `create`, `update`, `patch` and custom methods) - `params` - Additional parameters, for example the authenticated user or the query For `setup` and `teardown` (which are only called once on application startup and shutdown) we have - `path` - The path the service is registered on - `app` - The [Feathers application](./../../api/application.md) Usually those methods can be used for most API functionality but it is also possible to add your own [custom service methods](../../api/services.md#custom-methods).
A service does not have to implement all those methods but must have at least one. For more information about services, service methods, and parameters see the [Service API documentation](../../api/services.md).
When used as a REST API, incoming requests get mapped automatically to their corresponding service method like this: | Service method | HTTP method | Path | | ------------------------------------------- | ----------- | --------------------- | | `service.find({ query: {} })` | GET | /messages | | `service.find({ query: { unread: true } })` | GET | /messages?unread=true | | `service.get(123)` | GET | /messages/123 | | `service.create(body)` | POST | /messages | | `service.update(123, body)` | PUT | /messages/123 | | `service.patch(123, body)` | PATCH | /messages/123 | | `service.remove(123)` | DELETE | /messages/123 | ### Service events A registered service will automatically become a [NodeJS EventEmitter](https://nodejs.org/api/events.html) that sends events with the new data when a service method that modifies data (`create`, `update`, `patch` and `remove`) returns. Events can be listened to with `app.service('messages').on('eventName', data => {})`. Here is a list of the service methods and their corresponding events: | Service method | Service event | | ------------------ | ----------------------- | | `service.create()` | `service.on('created')` | | `service.update()` | `service.on('updated')` | | `service.patch()` | `service.on('patched')` | | `service.remove()` | `service.on('removed')` | This is how Feathers does real-time. ```js app.service('myservice').on('created', (data) => { console.log('Got created event', data) }) ``` ## Database adapters Now that we have all those service methods, we could go ahead and implement any kind of custom logic using any backend, similar to what we did in the [quick start guide](./starting.md). Very often, this means creating, reading, updating and removing data from a database. Writing all that code yourself for every service is pretty repetitive and cumbersome, which is why Feathers has a collection of pre-built services for different databases. They offer most of the basic functionality and can always be customized to your needs. Feathers database adapters support a common [usage API](../../api/databases/common.md), pagination and [querying syntax](../../api/databases/querying.md) for many popular databases. The following database adapters are maintained as part of Feathers core: - [SQL](../../api/databases/knex.md) for databases like PostgreSQL, SQLite, MySQL, MariaDB, MSSQL - [MongoDB](../../api/databases/mongodb.md) for MongoDB - [Memory](../../api/databases/memory.md) for in-memory data
There are also many other community maintained database integrations which you can explore on the [ecosystem page](/ecosystem/?cat=Database&sort=downloads). Since they are not part of Feathers core, they are outside the scope of these guides.
If you went with the default selection, we will use **SQLite** which writes the database to a file and does not require any additional setup. The user service that was created when we [generated authentication](./authentication.md) is already using it. ## Generating a service In our new `feathers-chat` application, we can create database backed services with the following command: ```sh npx feathers generate service ``` The name for our service is `message` (this is used for variable names etc.) and for the path we use `messages`. Anything else we can confirm with the default: ![feathers generate service prompts](./assets/generate-service.png) ![feathers generate service prompts](./assets/generate-service-mongodb.png) This is it, we now have a database backed messages service with authentication enabled. ## What's next? In this chapter we learned about services as a Feathers core concept for abstracting data operations. We also saw how a service sends events which we will use later to create real-time applications. After that, we generated a messages service. Next, we will [look at Feathers hooks](./hooks.md) as a way to create middleware for services. ================================================ FILE: docs/guides/basics/starting.md ================================================ --- outline: deep --- # Quick start Alright then! Let's learn Feathers. In this quick start guide we'll create our first Feathers app, an API server and a simple website to use it. You'll see how easy it is to get started with Feathers in just a single file without additional boilerplate or tooling. If you want to jump right into creating a complete application you can go to the [Creating An App](./generator.md) chapter. Getting started Feathers works with all [currently active NodeJS releases](https://github.com/nodejs/Release#release-schedule). All guides are assuming the languages features from the most current stable NodeJS release which you can get from the [NodeJS website](https://nodejs.org/en/).
You can follow this guide on your own computer in the terminal or try the steps out live without installing anything in the [Feathers Quick Start on Stackblitz](https://stackblitz.com/@daffl/collections/feathers-quick-start).
After successful installation, the `node` and `npm` commands should be available on the terminal: ``` node --version ``` ``` npm --version ```
Running NodeJS and npm should not require admin or root privileges.
Let's create a new folder for our application: ```sh mkdir feathers-basics cd feathers-basics ``` Since any Feathers application is a Node application, we can create a default [package.json](https://docs.npmjs.com/files/package.json) using `npm`: ```sh npm init --yes # Install TypeScript and its NodeJS wrapper npm i typescript ts-node @types/node --save-dev # Also initialize a TS configuration file that uses modern JavaScript npx tsc --init --target es2020 ``` ```sh npm init --yes ``` ## Installing Feathers Feathers can be installed like any other Node module by installing the [@feathersjs/feathers](https://www.npmjs.com/package/@feathersjs/feathers) package through [npm](https://www.npmjs.com). The same package can also be used with module loaders like Vite, Webpack, and in React Native. ```sh npm install @feathersjs/feathers --save ```
All Feathers core modules are in the `@feathersjs` namespace.
## Our first app Now we can create a Feathers application with a simple `messages` service that allows us to create new messages and find all existing ones. Create a file called `app.ts` with the following content: Create a file called `app.mjs` with the following content: ```ts import { feathers } from '@feathersjs/feathers' // This is the interface for the message data interface Message { id?: number text: string } // A messages service that allows us to create new // and return all existing messages class MessageService { messages: Message[] = [] async find() { // Just return all our messages return this.messages } async create(data: Pick) { // The new message is the data text with a unique identifier added // using the messages length since it changes whenever we add one const message: Message = { id: this.messages.length, text: data.text } // Add new message to the list this.messages.push(message) return message } } // This tells TypeScript what services we are registering type ServiceTypes = { messages: MessageService } const app = feathers() // Register the message service on the Feathers application app.use('messages', new MessageService()) // Log every time a new message has been created app.service('messages').on('created', (message: Message) => { console.log('A new message has been created', message) }) // A function that creates messages and then logs // all existing messages on the service const main = async () => { // Create a new message on our message service await app.service('messages').create({ text: 'Hello Feathers' }) // And another one await app.service('messages').create({ text: 'Hello again' }) // Find all existing messages const messages = await app.service('messages').find() console.log('All messages', messages) } main() ``` We can run it with ```sh npx ts-node app.ts ``` We can run it with ```sh node app.mjs ``` [Try it out live >](https://stackblitz.com/edit/node-mupbmh?embed=1&file=app.ts&view=editor) We will see something like this in the terminal: ```sh A new message has been created { id: 0, text: 'Hello Feathers' } A new message has been created { id: 1, text: 'Hello again' } All messages [ { id: 0, text: 'Hello Feathers' }, { id: 1, text: 'Hello again' } ] ``` Here we implemented only `find` and `create`, but a service can also have a few other methods, specifically `get`, `update`, `patch` and `remove`. We will learn more about service methods and events throughout this guide, but this sums up some of the most important concepts upon which Feathers is built. ## An API Server So far we've created a Feathers application, a message service, and are listening to events. However, this is only a simple NodeJS script that prints some output and then exits. What we really want is to host it as an API server. This is where Feathers transports come in. A transport takes a service like the one we created above and turns it into a server that other clients can talk to, like a website or mobile application. In the following example we will take our existing service and use: - `@feathersjs/koa` which uses [KoaJS](https://koajs.com/) to automatically turn our services into a REST API - `@feathersjs/socketio` which uses Socket.io to do the same as a WebSocket, real-time API (as we will see in a bit this is where the `created` event we saw above comes in handy). Run: ```sh npm install @feathersjs/socketio @feathersjs/koa --save ``` Then update `app.ts` with the following content: ```sh npm install @feathersjs/socketio @feathersjs/koa koa-static --save ``` Then update `app.mjs` with the following content: ```ts{2-4,42-55,58-65} import { feathers } from '@feathersjs/feathers' import { koa, rest, bodyParser, errorHandler, serveStatic } from '@feathersjs/koa' import socketio from '@feathersjs/socketio' // This is the interface for the message data interface Message { id?: number text: string } // A messages service that allows us to create new // and return all existing messages class MessageService { messages: Message[] = [] async find() { // Just return all our messages return this.messages } async create(data: Pick) { // The new message is the data text with a unique identifier added // using the messages length since it changes whenever we add one const message: Message = { id: this.messages.length, text: data.text } // Add new message to the list this.messages.push(message) return message } } // This tells TypeScript what services we are registering type ServiceTypes = { messages: MessageService } // Creates an KoaJS compatible Feathers application const app = koa(feathers()) // Use the current folder for static file hosting app.use(serveStatic('.')) // Register the error handle app.use(errorHandler()) // Parse JSON request bodies app.use(bodyParser()) // Register REST service handler app.configure(rest()) // Configure Socket.io real-time APIs app.configure(socketio()) // Register our messages service app.use('messages', new MessageService()) // Add any new real-time connection to the `everybody` channel app.on('connection', (connection) => app.channel('everybody').join(connection)) // Publish all events to the `everybody` channel app.publish((_data) => app.channel('everybody')) // Start the server app .listen(3030) .then(() => console.log('Feathers server listening on localhost:3030')) // For good measure let's create a message // So our API doesn't look so empty app.service('messages').create({ text: 'Hello world from the server' }) ``` [Try it out live >](https://stackblitz.com/edit/node-zfinli?embed=1&file=app.ts) We can start the server with ```sh npx ts-node app.ts ``` We can start the server with ```sh node app.mjs ```
The server will stay running until you stop it by pressing **Control + C** in the terminal.
And in the browser visit ``` http://localhost:3030/messages ``` to see an array with the one message we created on the server.
The built-in [JSON viewer in Firefox](https://developer.mozilla.org/en-US/docs/Tools/JSON_viewer) or a browser plugin like [JSON viewer for Chrome](https://chrome.google.com/webstore/detail/json-viewer/gbmdgpbipfallnflgajpaliibnhdgobh) makes it nicer to view JSON responses in the browser.
This is the basic setup of a Feathers API server. - The `app.use` calls probably look familiar if you have used something like Koa or Express before. - `app.configure` calls set up the Feathers transport to host the API. - `app.on('connection')` and `app.publish` are used to set up event channels, which send real-time events to the proper clients (everybody that is connected to our server in this case). You can learn [more about the channels API](../../api/channels.md) after finishing this guide. ## In the browser Now we can look at one of the really cool features of Feathers: **It works the same in a web browser!** This means that we could take [our first app example](#our-first-app) from above and run it just the same in a website. Since we already have a server running, however, let's go a step further and create a Feathers app that talks to our `messages` service on the server using a real-time Socket.io connection. In the same folder, add the following `index.html` page: ```html Feathers Example

Welcome to Feathers

Messages

``` [Try it out live >](https://stackblitz.com/edit/node-m7cjfd?embed=1&file=index.html) Now in the browser if you go to ``` http://localhost:3030 ``` you will see a simple website that allows creating new messages. It is possible to open the page in two tabs and see new messages show up on either side in real-time. You can verify that the messages got created by visiting ``` http://localhost:3030/messages ``` You'll see the JSON response including all current messages. ## What's next? In this chapter we created our first Feathers application and a service that allows creating new messages, storing them in memory, and retrieving them. We then hosted that service as a REST and real-time API server and used Feathers in the browser to connect to that server and create a website that can send new messages and show all existing messages in real-time. Even though we are using just NodeJS and Feathers from scratch without any additional tools, we didn't write a lot of code. In the [next chapter](./generator.md) we will look at the Feathers CLI which can create a similar Feathers application with a recommended file structure, models, database connections, authentication and more. ================================================ FILE: docs/guides/basics/testing.md ================================================ --- outline: deep --- # Writing tests The best way to test an application is by writing tests that make sure it behaves to clients as we would expect. Feathers makes testing your application a lot easier because the services we create can be tested directly instead of having to fake HTTP requests and responses. In this chapter we will implement unit tests for our users and messages services. You can run code linting and Mocha tests with: ```sh npm test ``` This should already pass but it won't be testing any of the functionality we added in the guide so far. ## Test database setup When testing database functionality, we want to make sure that the tests use a different database. We can achieve this by updating the test environment configuration in `config/test.json` with the following content: ```json { "nedb": "../test/data" } ``` This will set up the NeDB database to use `test/data` as the base directory instead of `data/` when the `NODE_ENV` environment variable is set to `test`. The same thing can be done with connection strings for other databases.
When using Git for version control, the `data/` and `test/data` folders should be added to `.gitignore`.
We also want to make sure that the database is cleaned up before every test run. To make that possible across platforms, first run: ```sh npm install shx --save-dev ``` Now we can update the `scripts` section of our `package.json` to the following: ```json "scripts": { "test": "npm run compile && npm run mocha", "dev": "ts-node-dev --no-notify src/", "start": "npm run compile && node lib/", "clean": "shx rm -rf test/data/", "mocha": "npm run clean && NODE_ENV=test ts-mocha \"test/**/*.ts\" --recursive --exit", "compile": "shx rm -rf lib/ && tsc" }, ``` ```json "scripts": { "test": "npm run eslint && npm run mocha", "eslint": "eslint src/. test/. --config .eslintrc.json", "start": "node src/", "clean": "shx rm -rf test/data/", "mocha": "npm run clean && NODE_ENV=test mocha test/ --recursive --exit" } ``` On Windows the `mocha` command should look like this: ```sh npm run clean & SET NODE_ENV=test& mocha test/ --recursive --exit ``` This will make sure that the `test/data` folder is removed before every test run and `NODE_ENV` is set properly. ## Testing services To test the `messages` and `users` services (with all hooks wired up), we could use any REST API testing tool to make requests and verify that they return correct responses. There is a much faster, easier and complete approach. Since everything on top of our own hooks and services is already provided (and tested) by Feathers, we can require the [application](../../api/application.md) object and use the [service methods](../../api/services.md) directly. We "fake" authentication by setting `params.user` manually. By default, the generator creates a service test file that only tests that the service exists. E.g. like this in `test/services/users.test.ts`: ```ts import assert from 'assert'; import app from '../../src/app'; describe('\'users\' service', () => { it('registered the service', () => { const service = app.service('users'); assert.ok(service, 'Registered the service'); }); }); ``` E.g. like this in `test/services/users.test.js`: ```js const assert = require('assert'); const app = require('../../src/app'); describe('\'users\' service', () => { it('registered the service', () => { const service = app.service('users'); assert.ok(service, 'Registered the service'); }); }); ``` We can then add similar tests that use the service. In this case we are: 1. verifying that users can be created, the default profile image gets set and the password is encrypted 2. ensuring that the password does not get sent to external requests Replace `test/services/users.test.ts` with the following: ```ts import assert from 'assert'; import app from '../../src/app'; describe('\'users\' service', () => { it('registered the service', () => { const service = app.service('users'); assert.ok(service, 'Registered the service'); }); it('creates a user, encrypts password and adds gravatar', async () => { const user = await app.service('users').create({ email: 'test@example.com', password: 'secret' }); // Verify Gravatar has been set as we'd expect assert.equal(user.avatar, 'https://s.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=60'); // Makes sure the password got encrypted assert.ok(user.password !== 'secret'); }); it('removes password for external requests', async () => { // Setting `provider` indicates an external request const params = { provider: 'rest' }; const user = await app.service('users').create({ email: 'test2@example.com', password: 'secret' }, params); // Make sure password has been removed assert.ok(!user.password); }); }); ``` Replace `test/services/users.test.js` with the following: ```js const assert = require('assert'); const app = require('../../src/app'); describe('\'users\' service', () => { it('registered the service', () => { const service = app.service('users'); assert.ok(service, 'Registered the service'); }); it('creates a user, encrypts password and adds gravatar', async () => { const user = await app.service('users').create({ email: 'test@example.com', password: 'secret' }); // Verify Gravatar has been set as we'd expect assert.equal(user.avatar, 'https://s.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=60'); // Makes sure the password got encrypted assert.ok(user.password !== 'secret'); }); it('removes password for external requests', async () => { // Setting `provider` indicates an external request const params = { provider: 'rest' }; const user = await app.service('users').create({ email: 'test2@example.com', password: 'secret' }, params); // Make sure password has been removed assert.ok(!user.password); }); }); ``` We take a similar approach for the messages service test by creating a test-specific user from the `users` service, then pass it as `params.user` when creating a new message and validates that message's content: Update `test/services/messages.test.ts` as follows: ```ts import assert from 'assert'; import app from '../../src/app'; describe('\'messages\' service', () => { it('registered the service', () => { const service = app.service('messages'); assert.ok(service, 'Registered the service'); }); it('creates and processes message, adds user information', async () => { // Create a new user we can use for testing const user = await app.service('users').create({ email: 'messagetest@example.com', password: 'supersecret' }); // The messages service call params (with the user we just created) const params = { user }; const message = await app.service('messages').create({ text: 'a test', additional: 'should be removed' }, params); assert.equal(message.text, 'a test'); // `userId` should be set to passed users it assert.equal(message.userId, user._id); // Additional property has been removed assert.ok(!message.additional); // `user` has been populated assert.deepEqual(message.user, user); }); }); ``` Update `test/services/messages.test.js` as follows: ```js const assert = require('assert'); const app = require('../../src/app'); describe('\'messages\' service', () => { it('registered the service', () => { const service = app.service('messages'); assert.ok(service, 'Registered the service'); }); it('creates and processes message, adds user information', async () => { // Create a new user we can use for testing const user = await app.service('users').create({ email: 'messagetest@example.com', password: 'supersecret' }); // The messages service call params (with the user we just created) const params = { user }; const message = await app.service('messages').create({ text: 'a test', additional: 'should be removed' }, params); assert.equal(message.text, 'a test'); // `userId` should be set to the provided user's id assert.equal(message.userId, user._id); // Additional property has been removed assert.ok(!message.additional); // `user` has been populated assert.deepEqual(message.user, user); }); }); ``` Run `npm test` one more time, to verify that all tests are passing. ## Code coverage Code coverage is a great way to get some insights into how much of our code is actually executed during the tests. Using [Istanbul](https://github.com/gotwarlost/istanbul) we can add it easily: ```sh npm install nyc --save-dev ``` For TypeScript we also have to install the TypeScript reporter: ```sh npm install @istanbuljs/nyc-config-typescript --save-dev ``` Add the following `.nycrc` file: ```json { "extends": "@istanbuljs/nyc-config-typescript", "include": [ "src/**/*.ts", "src/**/*.tsx" ] } ``` And then update the `scripts` section of our `package.json` to: ```json "scripts": { "test": "npm run compile && npm run coverage", "dev": "ts-node-dev --no-notify src/", "start": "npm run compile && node lib/", "clean": "shx rm -rf test/data/", "coverage": "nyc npm run mocha", "mocha": "npm run clean && NODE_ENV=test ts-mocha \"test/**/*.ts\" --recursive --exit", "compile": "shx rm -rf lib/ && tsc" }, ``` Now we have to update the `scripts` section of our `package.json` to: ```js "scripts": { "test": "npm run eslint && npm run coverage", "coverage": "nyc npm run mocha", "eslint": "eslint src/. test/. --config .eslintrc.json", "dev": "nodemon src/", "start": "node src/", "clean": "shx rm -rf test/data/", "mocha": "npm run clean && NODE_ENV=test mocha test/ --recursive --exit" }, ``` On Windows, the `coverage` command looks like this: ```sh npm run clean & SET NODE_ENV=test& nyc mocha ``` Now run: ```sh npm test ``` This will print out some additional coverage information.
When using Git for version control, the `.nyc_output/` folder should be added to `.gitignore`.
## What's next? That’s it! Our chat guide is completed! We now have a fully-tested REST and real-time API, with a plain JavaScript frontend including login and signup. Follow up in the [Feathers API documentation](../../api/) for more details about using Feathers, or start building your own first Feathers application! ================================================ FILE: docs/guides/cli/app.md ================================================ --- outline: deep --- # Application The `src/app.ts` file is the main file where the [Feathers application](../../api/application.md) gets initialized and wired up with a Feathers transport. ## Transports The available transports are [Koa](../../api/koa.md) or [Express](../../api/express.md) for HTTP and [Socket.io](../../api/socketio.md) for real-time functionality. For both, Koa and Express, the Feathers application (`app` object) will also be fully compatible with the respective framework. For both frameworks, additional required middleware will be registered in the application file. More information can be found in the linked API documentation. ## Configure functions The Feathers application does not use a complicated dependency injection mechanism. Instead, the application is wired together using _configure functions_ to split things up into individual files. They are functions that are exported from a file and that take the Feathers [app object](../../api/application.md) and then use it to e.g. register services. Those functions are then passed to [app.configure](../../api/application.md#configurecallback). For example, have a look at the following files: `src/services/index.ts` looks like this: ```ts import type { Application } from '../declarations' import { user } from './users/users' export const services = (app: Application) => { app.configure(user) // All services will be registered here } ``` It uses another configure function exported from `src/services/users/users.ts`. The export from `src/services/index.js` is in turn used in `src/app.ts` as: ```ts // ... import { services } from './services' // ... app.configure(authentication) app.configure(services) // ... ``` This is how the generator splits things up into separate files and any documentation example that uses the `app` object can be used in a configure function. You can create your own files that export a configure function and `require`/`import` and `app.configure` them.
Keep in mind that the order in which configure functions are called might matter, e.g. if it is using a service, that service has to be registered first. Configure functions are not asynchronous. Any asynchronous operations should be done in [application setup hooks](#application-hooks).
## Application hooks The application file also includes a section to set up [application hooks](../../api/hooks.md#application-hooks) which are hooks that run for every service. In our case, the `logErrorHook` to log any service errors has already been registered: ```ts // Register hooks that run on all service methods app.hooks({ around: { all: [logErrorHook] }, before: {}, after: {}, error: {} }) ``` Following that is the special [setup and teardown](../../api/hooks.md#setup-and-teardown) hook section to register hooks that run once when the application starts or shuts down. This can be used to e.g. set dynamic configuration values. ```ts // Register application setup and teardown hooks here app.hooks({ setup: [], teardown: [] }) ``` ## Tests, jobs and SSR The `app` file can be imported like any other Node module. This means it can be used directly in tests, scheduled jobs or server side rendering without having to start a separate server instance. For example, the unit tests import the application like this: ```ts import assert from 'assert' import { app } from '../../src/app' describe('messages service', () => { it('registered the service', () => { const service = app.service('messages') assert.ok(service, 'Registered the service') }) }) ``` ================================================ FILE: docs/guides/cli/app.test.md ================================================ --- outline: deep --- # Application tests The `app.test` file starts the server and then tests that it shows the index page and that 404 (Not Found) JSON errors are being returned. It uses the [Axios HTTP](https://axios-http.com/) library to make the calls. This file can e.g. be used to test application [setup](../../api/application.md#setupserver) and [teardown](../../api/application.md#teardownserver). All tests are using [MochaJS](https://mochajs.org/) but will be moving to the [NodeJS test runner](https://nodejs.org/api/test.html) in the future. ================================================ FILE: docs/guides/cli/authentication.md ================================================ --- outline: deep --- # Authentication The file in `src/authentication.ts` sets up an [authentication service](../../api/authentication/service.md) and registers [authentication strategies](../../api/authentication/strategy.md). Depending on the strategies you selected it looks similar to this: ```ts import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication' import { LocalStrategy } from '@feathersjs/authentication-local' import type { Application } from './declarations' declare module './declarations' { interface ServiceTypes { authentication: AuthenticationService } } export const authentication = (app: Application) => { const authentication = new AuthenticationService(app) authentication.register('jwt', new JWTStrategy()) authentication.register('local', new LocalStrategy()) app.use('authentication', authentication) } ``` ## oAuth Note that when selecting oAuth logins (Google, Facebook, GitHub etc.), the standard registered oAuth strategy only uses the `Id` property to create a new user. This will fail validation against the default user [schema](./service.schemas.md) which requires an `email` property to exist. If the provider (and user) allows fetching the email, you can customize the oAuth strategy like shown for GitHub in the [oAuth authentication guide](../basics/authentication.md#login-with-github). You can also make the email in the schema optional with `email: Type.Optional(Type.String())`. ================================================ FILE: docs/guides/cli/channels.md ================================================ # Channels > This page is currently a work in progress For more information see the [channel API](../../api/channels.md). ================================================ FILE: docs/guides/cli/client.md ================================================ --- outline: deep --- # Client A generated application can be used as an npm module that provides a [Feathers client](../../api/client.md). It gives you a fully typed client that can be installed in any TypeScript (e.g. React, VueJS, React Native etc.) application. ## Local installation The application can be linked into a client application by running ``` npm run bundle:client npm link ``` Then go to your client side app ``` cd path/to/client npm link my-app ``` ## Creating a package To create an installable SDK package that does not include any of the server code (other than the shared types) you can run ``` npm run bundle:client ``` By default this will create an `appname-x.x.x.tgz` npm package in the `public/` folder. This package can be installed from a running server via ``` npm install https://myapp.com/appname-x.x.x.tgz ``` ## Usage Once installed, the application can be used as follows with Socket.io: ```ts import io from 'socket.io-client' import socketio from '@feathersjs/socketio-client' import { createClient } from 'my-app' const connection = socketio(io('https://myapp.com')) const client = createClient(connection) ``` And like this with a REST client: ```ts import rest from '@feathersjs/rest-client' import { createClient } from 'my-app' const connection = rest('https://myapp.com').fetch(window.fetch.bind(window)) const client = createClient(connection) ``` ================================================ FILE: docs/guides/cli/client.test.md ================================================ # Client test The `client.test` file contains end-to-end integration tests for the [generated client](./client.md). ## Authentication If you selected a local strategy, `src/client.ts` will be updated with a client side integration test that looks similar to this: ```ts it('creates and authenticates a user with email and password', async () => { const userData: userData = { email: 'someone@example.com', password: 'supersecret' } await client.service('users').create(userData) const { user, accessToken } = await client.authenticate({ strategy: 'local', ...userData }) assert.ok(accessToken, 'Created access token for user') assert.ok(user, 'Includes user in authentication data') assert.strictEqual(user.password, undefined, 'Password is hidden to clients') await client.logout() // Remove the test user on the server await app.service('users').remove(user.id) }) ``` This test will create a new user with the generated client, log in, verify a user was returned and log out again. To keep the test self-contained it will then remove the test user on the server
Note that you can use `client` for client side interactions and the server side [application](./app.md#application) `app` object for server side calls in the same file. For example, if the user required an email verification but you don't want to test sending out emails you can call something like `app.service('users').patch(user.id, { isVerified: true })` to enable the new user on the server.
================================================ FILE: docs/guides/cli/configuration.md ================================================ --- outline: deep --- ### Configuration Schemas A generated application comes with a schema that validates the initial configuration when the application is started. This makes it much easier to catch configuration errors early which can otherwise be especially difficult to debug in remote environments. The configuration [schema definition](../../api/schema/index.md) can be found in `configuration.ts`. It is used as a [configuration schema](../../api/configuration.md#configuration-validation) and loads some default schemas for authentication and database connection configuration and adds values for `host`, `port` and the `public` hosted file folder. The types of this schema are also used for `app.get()` and `app.set()` [typings](./declarations.md). The initial configuration schema will be validated on application startup when calling [`app.listen()`](../../api/application.md#listenport) or [`app.setup()`](../../api/application.md#setupserver). ================================================ FILE: docs/guides/cli/custom-environment-variables.md ================================================ # Custom Environment Variables While `node-config` used for [application configuration](./default.json.md) recommends to pass environment based configuration as a JSON string in a single `NODE_CONFIG` environment variable, it is also possible to use other environment variables via the `config/custom-environment-variables.json` file which looks like this by default: ```json { "port": { "__name": "PORT", "__format": "number" }, "host": "HOSTNAME", "authentication": { "secret": "FEATHERS_SECRET" } } ``` This sets `app.get('port')` using the `PORT` environment variable (if it is available) parsing it as a number and `app.get('host')` from the `HOSTNAME` environment variable and the authentication secret to the `FEATHERS_SECRET` environment variable.
See the [node-config custom environment variable](https://github.com/node-config/node-config/wiki/Environment-Variables#custom-environment-variables) documentation for more information.
## Dotenv To add support for [dotenv](https://www.dotenv.org/) `.env` files run ``` npm install dotenv --save ``` And update `src/app.ts` as follows: ```ts // dotenv replaces all environmental variables from ~/.env in ~/config/custom-environment-variables.json import * as dotenv from 'dotenv' dotenv.config() // or for ES6 import 'dotenv/config'; import configuration from '@feathersjs/configuration' ```
`dotenv.config()` needs to run _before_ `import configuration from '@feathersjs/configuration'`
================================================ FILE: docs/guides/cli/databases.md ================================================ --- outline: deep --- # Databases
## Connection Depending on the SQL database you selected, a `src/.ts` file will be created that sets up a connection using [KnexJS](../../api/databases/knex.md). It uses the connection settings from the `` [configuration value](./default.json.md) and exports a [configure function](./app.md#configure-functions) that initializes the database connection. The Knex connection object is then accessible wherever you have access to the [app object](./app.md) via ```ts const knex = app.get('Client') ``` The database pool size can be set in the [configuration](./default.json.md) like this: ```json "postgresql": { "client": "pg", "connection": "", "pool": { "min": 0, "max": 7 } }, ``` `connection` can also be an object instead of a connection string: ```json "postgresql": { "client": "pg", "connection": { "host": "localhost", "port": 5432, "user": "postgres", "password": "postgres", "database": "pgtest" } } ``` `src/mongodb.ts` exports a [configure function](./app.md#configure-functions) that connects to the MongoDB connection string set as `mongodb` in your [configuration](./default.json.md). The [MongoDB NodeJS client](https://www.mongodb.com/languages/mongodb-with-nodejs) is then accessible wherever you have access to the [app object](./app.md) via ```ts const db = await app.get('mongodbClient') ``` The default connection string tries to connect to a local MongoDB instance with no password. To use e.g. [MongoDB Atlas](https://www.mongodb.com/cloud) change the `mongodb` property in `config/default.json` or add it as an [environment variable](./configuration.md#environment-variables) with the connection string that will look similar to this: ``` mongodb+srv://:@cluster0.xyz.mongodb.net/?retryWrites=true&w=majority ``` ## Models KnexJS does not have a concept of models. Instead a new service is initialized with the table name and `app.get('Client')` as the connection. For more information on how to create custom queries and more, see the [SQL database adapter API documentation](../../api/databases/knex.md). The collection for a MongoDB service can be accessed via ```ts const userCollection = await app.service('users').getModel() ``` See the [MongoDB service API documentation](../../api/databases/mongodb.md) for more information. ================================================ FILE: docs/guides/cli/declarations.md ================================================ --- outline: deep --- # TypeScript The main file for application specific TypeScript declarations can be found at `src/declarations.ts`. ## Compilation In order to compile and start the application use ``` npm run compile npm start ``` For development with live reload use ``` npm run dev ```
To get the latest types in the [client](./client.md) and any time before `npm start`, `npm run compile` needs to run.
## Configuration Types The `Configuration` interface defines the types for [app.get](../../api/application.md#getname) and [app.set](../../api/application.md#setname-value). It is extended from the type inferred from the [configuration schema](./configuration.md#configuration-schemas). Since you can store anything global to the application in `app.get` and `app.set`, you can add additional types that are not part of the initial application configuration here. ```ts // The types for app.get(name) and app.set(name) // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface Configuration extends ApplicationConfiguration { startupTime: Date } ```
Both `Configuration` and `ServiceTypes` need to be declared as an `interface` (even if it is empty) so they can be extended via `declare module` in other files. Do not remove the `eslint-disable-next-line` comments.
## Service Types The `ServiceTypes` interface contains a mapping of all service paths to their service type so that [app.use](../../api/application.md#usepath-service--options) and [app.service](../../api/application.md#servicepath) use the correct type. ```ts // A mapping of service names to types. Will be extended in service files. // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface ServiceTypes {} ``` Usually the `ServiceTypes` interface is not modified directly in this file but instead extended via `declare module` in the files where the services are registered. This usually looks like this: ```ts // Add this service to the service type index declare module '../../declarations' { interface ServiceTypes { users: UserService } } ``` ## Application The `Application` interface is the type for the main [app object](./app.md) using the [ServiceTypes](#service-types) interface as the service index and [ConfigurationTypes](#configuration-types) for `app.get` and `app.set`. ```ts // The application instance type that will be used everywhere else export type Application = FeathersApplication ```
Always use `import { Application } from './declarations'` to get the proper service and configuration typings. You normally do **not** need to use `import { Application } from '@feathersjs/feathers'` directly.
## Hook Context The `HookContext` type exports a [hook context](../../api/hooks.md) type with the `Application` and a generic service type `S`. ```ts // The context for hook functions - can be typed with a service class export type HookContext = FeathersHookContext ``` Use `HookContext` to get the full hook context for a service. ## Services and Params See the [services chapter](./service.md) for more information on service and parameter typings.
Please pick **TypeScript** as the Code language in the main menu dropdown.
================================================ FILE: docs/guides/cli/default.json.md ================================================ --- outline: deep --- # Application configuration A generated application uses the **[configuration module](../../api/configuration.md)** to load configuration information based on the environment. It is based on the battle-tested and widely used [node-config](https://github.com/node-config/node-config) and loads configuration settings so that they are available via [app.get()](../../api/application.md#getname). On application startup, the configuration will be validated against the [configuration schema](./configuration.md).
For more information on application configuration and schemas see the [configuration API documentation](../../api/configuration.md).
## Environments The `NODE_ENV` environment variable determines which configuration file is used. For example, setting `NODE_ENV=development` (in a single command e.g. as `NODE_ENV=development npm run dev`) will first load `config/default.json` and then merge it with `config/development.json`. If no environment is set, `config/default.json` will be used. ## Default configuration The application uses the following configuration values. ### host, port, public These options are used directly in the generated application - `host` - Is the hostname of the API server - `port` - The port it listens on - `public` - The name of the folder static assets are hosted in ### paginate `paginate` sets the default and maximum page size when using [pagination](../../api/databases/common.md#pagination) with a [database service](../../api/databases/adapters.md). ```json { "paginate": { "default": 10, "max": 100 } } ``` ### origins `origins` contains a list of frontend URLs that requests can be made from. This is used to configure cross origin (CORS) policies and oAuth (Twitter, Facebook etc.) login redirects. For example to develop locally with a [create-react-app](https://create-react-app.dev/) frontend and deploy to `app.feathersjs.com`: ```json { "origins": ["http://localhost:3030", "http://localhost:5000", "https://app.feathersjs.com"] } ``` ### authentication `authentication` contains the configuration for the authentication service and strategies. See the [authentication service configuration](../../api/authentication/service.md#configuration) for more information. For strategy specific settings refer to the [jwt](../../api/authentication/jwt.md#options), [local](../../api/authentication/local.md#options) and [oAuth](../../api/authentication/oauth.md#options) API documentation. ### Databases Depending on the SQL database selected the `` setting contains a `connection` with the database driver package name and a `client` option with the database connection string. ```json { "postgresql": { "connection": "pg", "client": "postgres://postgres:@localhost:5432/feathers-chat" } } ``` For additional configuration see the [database connection guide](./databases.md#connection). When selecting MongoDB, the `mongodb` setting contains the MongoDB connection string. ================================================ FILE: docs/guides/cli/hook.md ================================================ --- outline: deep --- # Hooks ## Generating a hook A new hook can be generated via ``` npx feathers generate hook ``` ## Hook name The hook generator will first ask for a name. Based on the name it will create a kebab-cased filename in the `hooks/` folder that exports a camelCased hook function. For example a name of `my fancy Hook` will create a `src/my-fancy-hook.ts` file that exports a `myFancyHook` [hook function](../../api/hooks.md#hook-functions). ## Hook types There are two hook types that can be generated.
For more information see the [hooks API documentation](../../api/hooks.md).
### Around hooks [Around hooks](../../api/hooks.md#around) allow to control the entire `before`, `after` and `error` flow in a single function. An `around` hook is an `async` function that accepts two arguments: - The [hook context](../../api/hooks.md#hook-context) - An asynchronous `next` function. Somewhere in the body of the hook function, there is a call to `await next()`, which calls the `next` hooks OR the original function if all other hooks have run. ```ts import type { HookContext, NextFunction } from '../declarations' export const myFancyHook = async (context: HookContext, next: NextFunction) => { console.log(`Running hook ${name} on ${context.path}.${context.method}`) await next() // Do things after here } ``` You can wrap the `await next()` in a `try/catch` block to also handle errors. ### Before, after, error [Before, after or error hooks](../../api/hooks.md#before-after-and-error) are `async` functions that take the [hook context](#hook-context) as the parameter. ```ts import type { HookContext } from '../declarations' export const myFancyHook = async (context: HookContext) => { console.log(`Running hook ${name} on ${context.path}.${context.method}`) } ``` ## Context types If the hook is for a specific service, you can pass the service as a generic to the [HookContext](./declarations.md#hook-context) type which will give you the correct types for [context.data](../../api/hooks.md#contextdata), [context.result](../../api/hooks.md#contextresult) and [context.params](../../api/hooks.md#contextparams): ```ts import type { UserService } from '../services/users/users' import type { HookContext } from '../declarations' export const myFancyUserHook = async (context: HookContext) => { console.log(`Running hook ${name} on ${context.path}.${context.method}`) } ``` ## Registering hooks A generated hook can be registered as an [application hook](./app.md#application-hooks) or as a [service hook](./service.md#registering-hooks). Also see the [hook registration API documentation](../../api/hooks.md#registering-hooks). ## Profiling example To log some basic profiling information like which method was called and how long it took to run you can create a new _around_ hook called `profiler` via ``` npx feathers generate hook ``` Then update `src/hooks/profiler.ts` as follows: ```ts import type { HookContext, NextFunction } from '../declarations' import { logger } from '../logger' export const profiler = async (context: HookContext, next: NextFunction) => { const startTime = Date.now() await next() const runtime = Date.now() - startTime console.log(`Calling ${context.method} on service ${context.path} took ${runtime}ms`) } ``` And add it in `src/app.ts` as an application hook after the `logError` hook as follows: ```ts{1,8} import { profiler } from './hooks/profiler' //... // Register hooks that run on all service methods app.hooks({ around: { all: [ logError, profiler ] }, before: {}, after: {}, error: {} }) ``` ================================================ FILE: docs/guides/cli/index.md ================================================ --- outline: deep --- # The Feathers CLI The Feathers generator allows you to quickly scaffold a Feathers app with the latest standardized file structure. ## Install the CLI When creating an application (e.g. `my-app`) with ``` npm create feathers@latest my-app ``` the Feathers CLI will be installed locally into your new project. This is preferred over global installation so that everybody working on your project has the same version and commands available by running `npx feathers`. ## CLI Commands In a generated application you should be able to run the `generate` command with no arguments: ```bash npx feathers generate ``` You'll see the following output: ```bash Usage: feathers generate|g [options] [command] Run a generator. Currently available: app: Generate a new application service: Generate a new service hook: Generate a hook connection: Add a new database connection authentication: Add authentication to the application Options: -h, --help display help for command Commands: app [options] Generate a new application service [options] Generate a new service hook [options] Generate a hook connection Add a new database connection authentication Add authentication to the application help [command] display help for command ``` ### Authentication ``` npx feathers generate authentication ``` Will set up Feathers authentication and a users service. This is required for any other service that needs authentication. ### Service ``` npx feathers generate service ``` Generates a service connected to a database or a custom service. ### Connection ``` npx feathers generate connection ``` Sets up a new database connection. This is already done when creating a new application but you can still set up other databases. ### Hook ``` npx feathers generate hook ``` Generates a new hook in the `hooks` folder that can then be registered in your services. ### App This is the command that runs automatically when calling ``` npm create feathers@latest my-app ``` ================================================ FILE: docs/guides/cli/knexfile.md ================================================ # Knexfile ## Migrations Migrations are a best practise for SQL databases to roll out and undo changes to the data model and are set up automatically with an SQL database connection. The generated `knexfile.ts` imports the [app object](./app.md) to establish the connection to the database. To run migration scripts for the connection from the [configuration environment](./configuration.md#environment-variables) use: ``` npm run migrate ``` To create a new migration, run ``` npm run migrate:make -- ``` and replace `` with the name of the migration you want to create. This will create a new file in the `migrations/` folder.
For more information on what is available in migration files, see the [Knex migrations documentation](https://knexjs.org/guide/migrations.html).
================================================ FILE: docs/guides/cli/log-error.md ================================================ # Error logging hook The `src/hooks/log-error.ts` file exports a `logError` hook that uses the [logger](./logger.md) to log any error for a service method, including validation error details (when they are available). It is registered as an [application hook](./app.md#application-hooks) `all` hook, meaning it will log errors for any service method. ================================================ FILE: docs/guides/cli/logger.md ================================================ --- outline: deep --- # Logging ## Logger The `src/logger.ts` file initialises the widely used [Winston logger](https://github.com/winstonjs/winston) library, by default with the `info` log level, logging to the console. ```ts import { createLogger, format, transports } from 'winston' // Configure the Winston logger. For the complete documentation see https://github.com/winstonjs/winston export const logger = createLogger({ // To see more detailed errors, change this to 'debug' level: 'info', format: format.combine(format.splat(), format.simple()), transports: [new transports.Console()] }) ``` You can import the logger directly in any file where you want to add logging information. ```ts import { logger } from './logger' logger.info('Log some information here') ``` ================================================ FILE: docs/guides/cli/package.md ================================================ # package.json ## Folders The source and test folders to which files are generated is set in the `package.json`. To change them, rename the `src/` or `test/` folder to what you want it to and then update `package.json` `directories` section accordingly: ```json { "directories": { "lib": "api/src", "test": "api/test" } } ``` ================================================ FILE: docs/guides/cli/prettierrc.md ================================================ # Prettier The Feathers CLI uses [Prettier](https://prettier.io/) for code formatting and generates a configuration for it in a new application. To change the options, like the use of semicolons, quotes etc, edit the `.prettierrc` file with the [options available](https://prettier.io/docs/en/options.html). To update all existing source files with the new code style run ``` npm run prettier ``` When new files are generated, they will use the current Prettier configuration. See the [Prettier Integration with Linters](https://prettier.io/docs/en/integrating-with-linters.html) documentation for how to integrate with tools like ESLint. ================================================ FILE: docs/guides/cli/service.class.md ================================================ --- outline: deep --- # Service classes The `.class` file exports the [service class or object](../../api/services.md). ## Database services When using a database, the service class will be extended from the [Feathers database adapter service](../../api/databases/common.md). Like any class, existing methods can be overriden or you can add your own methods (which can also be made available externally [as custom methods when registering the service](./service.md#registration)).
The generic types for a database service are always `AdapterService`. The `MessageService` generic is used to change the parameter type when using this service interface as a [client side service](./client.md).
### Overriding methods When overriding an existing [service method](../../api/services.md#service-methods) on a database adapter the method and overload signatures have to match. The following example shows how to override every service method. Only the methods you want to customize have to be added. The [SQL Knex service](../../api/databases/knex.md) methods can be customized like this: ```ts import { Id, NullableId, Paginated } from '@feathersjs/feathers' export interface MessageParams extends KnexAdapterParams {} // By default calls the standard Knex adapter service methods but can be customized with your own functionality. export class MessageService extends KnexService< Message, MessageData, MessageParams, MessagePatch > { async find( params?: MessageParams & { paginate?: { default?: number; max?: number } } ): Promise> async find(params?: ServiceParams & { paginate: false }): Promise async find(params?: ServiceParams): Promise | Message[]> async find(params?: ServiceParams): Promise | Message[]> { return super.find(params) } async get(id: Id, params?: ServiceParams): Promise { return super.get(id, params) } async create(data: MessageData, params?: ServiceParams): Promise async create(data: MessageData[], params?: ServiceParams): Promise async create(data: MessageData | MessageData[], params?: ServiceParams): Promise { return super.create(data, params) } async update(id: Id, data: Data, params?: ServiceParams): Promise { return super.update(id, data, params) } async patch(id: Id, data: MessagePatch, params?: ServiceParams): Promise async patch(id: null, data: MessagePatch, params?: ServiceParams): Promise async patch(id: NullableId, data: MessagePatch, params?: ServiceParams): Promise { return super.patch(id, data, params) } async remove(id: Id, params?: ServiceParams): Promise async remove(id: null, params?: ServiceParams): Promise async remove(id: NullableId, params?: ServiceParams): Promise { return super.remove(id, params) } } ``` The [MongoDB service](../../api/databases/mongodb.md) methods can be customized like this: ```ts import { Paginated } from '@feathersjs/feathers' import { AdapterId } from '@feathersjs/mongodb' export interface MessageParams extends MongoDBAdapterParams {} // By default calls the standard MongoDB adapter service methods but can be customized with your own functionality. export class MessageService extends MongoDBService< Message, MessageData, MessageParams, MessagePatch > { async find( params?: ServiceParams & { paginate?: { paginate?: { default?: number; max?: number } } } ): Promise> async find(params?: ServiceParams & { paginate: false }): Promise async find(params?: ServiceParams): Promise | Message[]> async find(params?: ServiceParams): Promise | Message[]> { return super.find(params) } async get(id: AdapterId, params?: ServiceParams): Promise { return super.get(id, params) } async create(data: MessageData, params?: ServiceParams): Promise async create(data: MessageData[], params?: ServiceParams): Promise async create(data: MessageData | MessageData[], params?: ServiceParams): Promise { return super.create(data, params) } async update(id: AdapterId, data: MessageData, params?: ServiceParams): Promise { return super.update(id, data, params) } async patch(id: null, data: MessagePatch, params?: ServiceParams): Promise async patch(id: AdapterId, data: MessagePatch, params?: ServiceParams): Promise async patch( id: NullableAdapterId, data: MessagePatch, params?: ServiceParams ): Promise { return super.patch(id, data, params) } async remove(id: AdapterId, params?: ServiceParams): Promise async remove(id: null, params?: ServiceParams): Promise async remove(id: NullableAdapterId, params?: ServiceParams): Promise { return super.remove(id, params) } } ``` ### Other service methods It is also possible to write your own service methods where the signatures don't have to match by extending from the `KnexAdapter` (instead of the `KnexService`) class. It does not have any of the service methods implemented but you can use the internal `_find`, `_get`, `_update`, `_patch` and `_remove` [adapter methods](../../api/databases/common.md#methods-without-hooks) to work with the database and implement the service method in the way you need. ```ts import { Id } from '@feathersjs/feathers' import { KnexAdapter } from '@feathersjs/knex' export interface MessageParams extends KnexAdapterParams {} // By default calls the standard Knex adapter service methods but can be customized with your own functionality. export class MessageService extends KnexAdapter< Message, MessageData, MessageParams, MessagePatch > { async find(params: ServiceParams) { const page = this._find(params) return { status: 'ok', ...page } } async get(id: Id, params: ServiceParams) { return { message: `Hello ${id}` } } } ``` It is also possible to write your own service methods where the signatures don't have to match by extending from the `MongoDbAdapter` (instead of the `MongoDBService`) class. It does not have any of the service methods implemented but you can use the internal `_find`, `_get`, `_update`, `_patch` and `_remove` [adapter methods](../../api/databases/common.md#methods-without-hooks) to work with the database and implement the service method the way you need. ```ts import { Id } from '@feathersjs/feathers' import { MongoDbAdapter } from '@feathersjs/mongodb' export interface MessageParams extends MongoDBAdapterParams {} // By default calls the standard MongoDB adapter service methods but can be customized with your own functionality. export class MessageService extends MongoDbAdapter< Message, MessageData, MessageParams, MessagePatch > { async find(params: ServiceParams) { const page = this._find(params) return { status: 'ok', ...page } } async get(id: Id, params: ServiceParams) { return { message: `Hello ${id}` } } } ``` ### Custom methods [Custom service methods](../../api/services.md#custom-methods) can be added to an [SQL Knex service](../../api/databases/knex.md) as follows: ```ts export interface MessageParams extends KnexAdapterParams {} export type MyMethodData = { greeting: string } // By default calls the standard Knex adapter service methods but can be customized with your own functionality. export class MessageService extends KnexService< Message, MessageData, MessageParams, MessagePatch > { async myMethod(data: MyMethodData, params: ServiceParams) { return { message: `${data.greeting || 'Hello'} ${params.user.name}!` } } } ``` [Custom service methods](../../api/services.md#custom-methods) can be added to a [MongoDB service](../../api/databases/mongodb.md) like this: ```ts export interface MessageParams extends MongoDBAdapterParams {} export type MyMethodData = { name: string } // By default calls the standard MongoDB adapter service methods but can be customized with your own functionality. export class MessageService extends MongoDBService< Message, MessageData, MessageParams, MessagePatch > { async myMethod(data: MyMethodData, params: ServiceParams) { return { message: `${data.greeting || 'Hello'} ${params.user.name}!` } } } ``` ## Custom services As shown in the [Quick start](../basics/starting.md), Feathers can work with any database, third party API or custom functionality by implementing your own [services](../../api/services.md). When generating a custom service, a basic skeleton service will be created. You can remove the methods you don't need and add others you need. While service methods still have to follow the [standard](../../api/services.md#service-methods) or [custom](../../api/services.md#custom-methods) method signatures, the parameter and return types can be whatever works best for the service you are implementing. If a service method is only for internal use (and not for clients to call) there are no method signature or return value restrictions. ```ts import type { Id, NullableId, Params } from '@feathersjs/feathers' interface MyParams extends Params {} class MyService { async find(params: MyParams) { return { message: 'This type is inferred' } } async get(id: Id) { return [ { id } ] } async create(data: Message, params: MyParams) { return data } // Custom method made available to clients needs to have `data` and `params` async customMethod(data: CustomMethodData, params: MyParams) {} // A method that is only available internally can do anything async anyOtherMethod() { const [entry] = await this.get('david') return entry.id } } ``` ## getOptions The `getOptions` function is a function that returns the options based on the [application](./app.md) that will be passed to the service class constructor. This is where you can pass [common adapter options](../../api/databases/common.md#options) as well as [MongoDB](../../api/databases/mongodb.md#serviceoptions) or [SQL](../../api/databases/knex.md#serviceoptions) specific or custom service options. ================================================ FILE: docs/guides/cli/service.md ================================================ --- outline: deep --- # Service The main service file registers the service on the [application](./app.md) as well as the hooks used on this service. ## Registration The service is added to the main application via [app.use](../../api/application.md#usepath-service--options) under the path you chose when creating the service. It usses the following options: - `methods` - A list of methods available for external clients. You can remove methods that are not used or add your own [custom methods](../../api/services.md#custom-methods). Not that this list also has to be updated in the [client file](./client.md). - `events` - A list of additional [custom events](../../api/events.md#custom-events) sent to clients. In TypeScript the `ServiceTypes` interface defined in the [declarations](./declarations.md) will also be extended with the correct service class type using the [shared path](./service.shared.md) as a key: ```ts declare module '../../../declarations' { interface ServiceTypes { [testingPath]: TestingService } } ``` ## Registering hooks This file is also where service [hooks](../../api/hooks.md) are registered on the service. Depending on the selection, it commonly includes the [authentication hook](../../api/authentication/hook.md) and hooks that validate and resolve the schemas from the [service.schemas file](./service.schemas.md). ```ts // Initialize hooks app.service(messagePath).hooks({ around: { all: [ authenticate('jwt'), schemaHooks.resolveExternal(messageExternalResolver), schemaHooks.resolveResult(messageResolver) ] }, before: { all: [schemaHooks.validateQuery(messageQueryValidator), schemaHooks.resolveQuery(messageQueryResolver)], find: [], get: [], create: [schemaHooks.validateData(messageDataValidator), schemaHooks.resolveData(messageDataResolver)], patch: [schemaHooks.validateData(messagePatchValidator), schemaHooks.resolveData(messagePatchResolver)], remove: [] }, after: { all: [] }, error: { all: [] } }) ``` Note that you can add hooks to a specific method as documented in the [hook registration API](../../api/hooks.md#registering-hooks). For example, to use the [profiling hook](./hook.md#profiling-example) only for `find` and `get` the registration can be updated like this: ```ts{12-13} import { profiler } from '../../hooks/profiler' // ... // Initialize hooks app.service(messagePath).hooks({ around: { all: [ authenticate('jwt'), schemaHooks.resolveExternal(messageExternalResolver), schemaHooks.resolveResult(messageResolver) ], find: [profiler], get: [profiler] }, before: { all: [schemaHooks.validateQuery(messageQueryValidator), schemaHooks.resolveQuery(messageQueryResolver)], find: [], get: [], create: [schemaHooks.validateData(messageDataValidator), schemaHooks.resolveData(messageDataResolver)], patch: [schemaHooks.validateData(messagePatchValidator), schemaHooks.resolveData(messagePatchResolver)], remove: [] }, after: { all: [] }, error: { all: [] } }) ``` This also applies to any hook plugins like [feathers-hooks-common](https://hooks-common.feathersjs.com/). ================================================ FILE: docs/guides/cli/service.schemas.md ================================================ --- outline: deep --- # Service Schemas and Resolvers The `.schemas` file contains the [schemas and resolvers](../../api/schema/index.md) for this service.
The examples on this page are using [TypeBox](../../api/schema/typebox.md). For more information on plain JSON schema see the [JSON schema API documentation](../../api/schema/schema.md).
## Patterns There a four main types of schemas and resolvers. The schemas, resolvers and types are declared as follows: ```ts // The schema definition export const nameSchema = Type.Object({ text: Type.String() }) // The TypeScript type inferred from the schema export type Name = Static // The validator for the schema export const nameValidator = getValidator(nameSchema, dataValidator) // The resolver for the schema export const nameResolver = resolve({}) ``` ## Main schema and resolvers This schema defines the main data model of all properties and is normally the shape of the data that is returned. This includes database properties as well as associations and other computed properties. ```ts // Main data model schema export const messageSchema = Type.Object( { id: Type.Number(), text: Type.String() }, { $id: 'Message', additionalProperties: false } ) export type Message = Static export const messageValidator = getValidator(messageSchema, dataValidator) export const messageResolver = resolve({}) ``` ## External Resolvers The external resolver defines the data that is sent to a client and is often use to e.g. hide protected properties they should not see: ```ts export const messagesExternalResolver = resolve({ someSecretProperty: async () => undefined }) ``` ## Data schema and resolvers The data schema validates the data when creating a new entry calling [service.create](../../api/services.md#createdata-params). It usually picks its properties from the [main schema](#main-schemas-and-resolvers) but can be changed to whatever is needed. ```ts // Schema for creating new entries export const messageDataSchema = Type.Pick(messageSchema, ['text'], { $id: 'MessageData' }) export type MessageData = Static export const messageDataValidator = getValidator(messageDataSchema, dataValidator) export const messageDataResolver = resolve({}) ``` ## Patch schema and Resolvers The patch schema is used for updating existing entries calling [service.patch](../../api/services.md#patchid-data-params). This is often different then the data schema for new entries and by default is a partial of the [main schema](#main-schemas-and-resolvers). ```ts // Schema for updating existing entries export const messagePatchSchema = Type.Partial(messageSchema, { $id: 'MessagePatch' }) export type MessagePatch = Static export const messagePatchValidator = getValidator(messagePatchSchema, dataValidator) export const messagePatchResolver = resolve({}) ``` ## Query Schema and Resolvers The query schema defines what can be sent in queries in [params.query](../../api/services.md#params) and also converts strings to the correct type. ```ts // Schema for allowed query properties export const messageQueryProperties = Type.Pick(messageSchema, ['id', 'text', 'createdAt', 'userId']) export const messageQuerySchema = Type.Intersect( [ querySyntax(messageQueryProperties), // Add additional query properties here Type.Object({}, { additionalProperties: false }) ], { additionalProperties: false } ) export type MessageQuery = Static export const messageQueryValidator = getValidator(messageQuerySchema, queryValidator) export const messageQueryResolver = resolve({}) ``` To add additional operators like `$like` see the [querySyntax](../../api/schema/typebox.md#querysyntax) documentation. You can also add your own query parameters in the `Type.Object({}, { additionalProperties: false })` definition.
Note that references (`Type.Ref`) can not be used in a query schema. Association querying is usually done by dot separated properties which have to be added manually in [MongoDB](../../api/databases/mongodb.md#querying) and [SQL](../../api/databases/knex.md#associations).
================================================ FILE: docs/guides/cli/service.shared.md ================================================ --- outline: deep --- # Service Shared The `.shared` file contains variables and type declarations that are shared between the [client](./client.md) and the [server application](./app.md). It can also be used for shared utility functions or schemas (e.g. for client side validation). ## Variables By default two shared variables are exported: - `Path` - The path of the service. Changing this will change the path for the service in all places like the application, the client and types - `Methods` - The list of service methods available to the client. This can be updated with service and custom methods a client should be able to use. ## Client setup This file also includes the client side service registration which will be included in the [client](./client.md). It will register a client side service based on the shared path and methods. ================================================ FILE: docs/guides/cli/service.test.md ================================================ --- outline: deep --- # Service tests The `.test` file contains tests for a specific service. By default it just checks if the service has been registered. ## Testing the service Services can be tested by using the [application](./app.md) object through Feathers standard APIs: ```ts // For more information about this file see https://dove.feathersjs.com/guides/cli/service.test.html import assert from 'assert' import { app } from '../../../src/app' describe('users service', () => { it('registered the service', () => { const service = app.service('users') assert.ok(service, 'Registered the service') }) it('finds all users', async () => { const users = await app.service('users').find({ paginate: false }) assert.ok(Array.isArray(users)) }) }) ``` ## Authenticated tests To test service internals that require a logged in user, it is not necessary to go through the full authentication flow. Instead a test user can be created and then passed as `params.user` just like it would when authenticated: ```ts // For more information about this file see https://dove.feathersjs.com/guides/cli/service.test.html import assert from 'assert' import { app } from '../../../src/app' describe('messages service', () => { it('registered the service', () => { const service = app.service('messages') assert.ok(service, 'Registered the service') }) it('can create a new message for a user', async () => { const user = await app.service('users').create({ email: 'test@feathersjs.com', password: 'supersecret' }) const message = await app.service('messages').create( { text: 'Hello world' }, { user } ) assert.strictEqual(message.userId, user.id) await app.service('messages').remove(message.id) await app.service('users').remove(user.id) }) }) ```
If you want to test the full authentication and external access flow the [client.test](./client.test.md) can be used.
================================================ FILE: docs/guides/cli/tsconfig.md ================================================ # tsconfig.json ================================================ FILE: docs/guides/cli/validators.md ================================================ --- outline: deep --- # Validators For all currently supported schema types, AJV is used as the default validator. See the [validators API documentation](../../api/schema/validators.md) for more information. ## AJV validators The `src/validators.ts` file sets up two Ajv instances for data and querys (for which string types will be coerced automatically). It also sets up a collection of additional formats using [ajv-formats](https://ajv.js.org/packages/ajv-formats.html). The validators in this file can be customized according to the [Ajv documentation](https://ajv.js.org/) and [its plugins](https://ajv.js.org/packages/). You can find the available Ajv options in the [Ajs class API docs](https://ajv.js.org/options.html). ```ts import { Ajv, addFormats } from '@feathersjs/schema' import type { FormatsPluginOptions } from '@feathersjs/schema' const formats: FormatsPluginOptions = [ 'date-time', 'time', 'date', 'email', 'hostname', 'ipv4', 'ipv6', 'uri', 'uri-reference', 'uuid', 'uri-template', 'json-pointer', 'relative-json-pointer', 'regex' ] export const dataValidator = addFormats(new Ajv({}), formats) export const queryValidator = addFormats( new Ajv({ coerceTypes: true }), formats ) ``` ## MongoDB ObjectIds When choosing MongoDB, the validators file will also register the [`objectid` keyword](../../api/databases/mongodb.md#ajv-keyword) to convert strings to MongoDB Object ids. ================================================ FILE: docs/guides/frameworks.md ================================================ # Frontend Frameworks Feathers works the same on the server and on the client and is front-end framework agnostic. You can use it with Vue, React, React Native, Angular, or whatever other front-end tech stack you choose. ## Client Side Docs If you want to learn how to use Feathers as a client in Node.js, React Native, or in the browser with a module loader like Webpack refer to the [client API docs](../api/client.md). ## The Feathers chat The [Feathers Chat application](../guides/) from guide gives a basic intro to using the Feathers Client in a vanilla JavaScript environment. That's a good place to start to see how things fit together. Framework specific repositories can be found at: - JavaScript + plain JS frontend: [feathersjs/feathers-chat](https://github.com/feathersjs/feathers-chat) - TypeScript + plain JS frontend: [feathersjs/feathers-chat-ts](https://github.com/feathersjs/feathers-chat-ts) - React: [feathersjs-ecosystem/feathers-chat-react](https://github.com/feathersjs-ecosystem/feathers-chat-react) - React Native: [feathersjs-ecosystem/feathers-react-native-chat](https://github.com/feathersjs-ecosystem/feathers-react-native-chat) - Angular: [feathersjs-ecosystem/feathers-chat-angular](https://github.com/feathersjs-ecosystem/feathers-chat-angular) - VueJS with Vuex: [feathersjs-ecosystem/feathers-chat-vuex](https://github.com/feathersjs-ecosystem/feathers-chat-vuex) ## Examples Beyond the basics, see [this list](https://github.com/feathersjs/awesome-feathersjs#examples) of Feathers examples in [awesome-feathersjs](https://github.com/feathersjs/awesome-feathersjs). ## Framework Integrations See [this list](https://github.com/feathersjs/awesome-feathersjs#frontend-frameworks) of Feathers front-end framework integrations if you are looking for something that makes Feathers even easier to use with things like React, Vue or others. ================================================ FILE: docs/guides/frontend/javascript.md ================================================ --- outline: deep --- # JavaScript web app As we have seen [in the quick start guide](../basics/starting.md), Feathers works great in the browser and comes with client services that allow it to easily connect to a Feathers server. In this chapter we will create a real-time chat web application with signup and login using modern plain JavaScript that connects to the API server we built in the [getting started guide](../basics/generator.md). It is mobile friendly and will work in the latest versions of Chrome, Firefox, Safari and Edge. We won't be be using a transpiler like Webpack or Babel which is also why there is no TypeScript option. The final version can be found in `public/` folder of the [feathers-chat repository](https://github.com/feathersjs/feathers-chat/tree/dove/public). ![The Feathers chat application](../basics/assets/feathers-chat.png)
We will not be using a frontend framework so we can focus on what Feathers is all about. Feathers is framework agnostic and can be used with any frontend framework like React, VueJS or Angular. For more information see the [frameworks section](../frameworks.md).
## Set up the page First, let's update `public/index.html` to initialize everything we need for the chat frontend: ```html feathers-chat
``` This will load our chat CSS style, add a container div `#app` and load several libraries: - The browser version of Feathers (since we are not using a module loader like Webpack or Browserify) - Socket.io provided by the chat API - [daisyUI](https://daisyui.com/) for a collection of CSS components - A `client.js` for our code to live in Let’s create `public/client.js` where all the following code will live. Each of the following code samples should be added to the end of that file. ## Connect to the API We’ll start with the most important thing first, the connection to our Feathers API that connects to our server using websockets and initializes the [authentication client](../basics/authentication.md): ```js /* global io, feathers, moment */ // Establish a Socket.io connection const socket = io() // Initialize our Feathers client application through Socket.io // with hooks and authentication. const client = feathers() client.configure(feathers.socketio(socket)) // Use localStorage to store our login token client.configure(feathers.authentication()) ``` ## Base HTML Next, we have to define some static and dynamic HTML that we can insert into the page when we want to show the login page (which also doubles as the signup page) and the actual chat interface: ```js // Login screen const loginTemplate = (error) => `` // Main chat view const chatTemplate = () => `
` // Helper to safely escape HTML const escapeHTML = (str) => str.replace(/&/g, '&').replace(//g, '>') const formatDate = (timestamp) => new Intl.DateTimeFormat('en-US', { timeStyle: 'short', dateStyle: 'medium' }).format(new Date(timestamp)) // Add a new user to the list const addUser = (user) => { const userList = document.querySelector('.user-list') if (userList) { // Add the user to the list userList.innerHTML += `
  • ${user.email}
    ${user.email}
  • ` // Update the number of users const userCount = document.querySelectorAll('.user-list li.user').length document.querySelector('.online-count').innerHTML = userCount } } // Renders a message to the page const addMessage = (message) => { // The user that sent this message (added by the populate-user hook) const { user = {} } = message const chat = document.querySelector('#chat') // Escape HTML to prevent XSS attacks const text = escapeHTML(message.text) if (chat) { chat.innerHTML += `
    ${user.email}
    ${text}
    ` // Always scroll to the bottom of our message list chat.scrollTop = chat.scrollHeight - chat.clientHeight } } ``` This will add the following variables and functions: - `loginTemplate` - A function that returns static HTML for the login/signup page. We can also pass an error to render an additional error message - `chatTemplate` - Returns the HTML for the main chat page content (once a user is logged in) - `addUser(user)` is a function to add a new user to the user list on the left - `addMessage(message)` is a function to add a new message to the list. It will also make sure that we always scroll to the bottom of the message list as messages get added ## Displaying pages Next, we'll add two functions to display the login and chat page, where we'll also add a list of the 25 newest chat messages and the registered users. ```js // Show the login page const showLogin = () => { document.getElementById('app').innerHTML = loginTemplate() } // Shows the chat page const showChat = async () => { document.getElementById('app').innerHTML = chatTemplate() // Find the latest 25 messages. They will come with the newest first const messages = await client.service('messages').find({ query: { $sort: { createdAt: -1 }, $limit: 25 } }) // We want to show the newest message last messages.data.reverse().forEach(addMessage) // Find all users const users = await client.service('users').find() // Add each user to the list users.data.forEach(addUser) } ``` - `showLogin(error)` will either show the content of loginTemplate or, if the login page is already showing, add an error message. This will happen when you try to log in with invalid credentials or sign up with a user that already exists. - `showChat()` does several things. First, we add the static chatTemplate to the page. Then we get the latest 25 messages from the messages Feathers service (this is the same as the `/messages` endpoint of our chat API) using the Feathers query syntax. Since the list will come back with the newest message first, we need to reverse the data. Then we add each message by calling our `addMessage` function so that it looks like a chat app should — with old messages getting older as you scroll up. After that we get a list of all registered users to show them in the sidebar by calling addUser. ## Login and signup Alright. Now we can show the login page (including an error message when something goes wrong) and if we are logged in, call the `showChat` we defined above. We’ve built out the UI, now we have to add the functionality to actually allow people to sign up, log in and also log out. ```js // Retrieve email/password object from the login/signup page const getCredentials = () => { const user = { email: document.querySelector('[name="email"]').value, password: document.querySelector('[name="password"]').value } return user } // Log in either using the given email/password or the token from storage const login = async (credentials) => { try { if (!credentials) { // Try to authenticate using an existing token await client.reAuthenticate() } else { // Otherwise log in with the `local` strategy using the credentials we got await client.authenticate({ strategy: 'local', ...credentials }) } // If successful, show the chat page showChat() } catch (error) { // If we got an error, show the login page showLogin(error) } } ``` - `getCredentials()` gets us the values of the username (email) and password fields from the login/signup page to be used directly with Feathers authentication. - `login(credentials)` will either authenticate the credentials returned by getCredentials against our Feathers API using the local authentication strategy (e.g. username and password) or, if no credentials are given, try to use the JWT stored in localStorage. This will try and get the JWT from localStorage first where it is put automatically once you log in successfully so that we don’t have to log in every time we visit the chat. Only if that doesn’t work will it show the login page. Finally, if the login was successful it will show the chat page. ## Event listeners and real-time In the last step we will add event listeners for all buttons and functionality to send new messages and make the user and message list update in real-time. ```js const addEventListener = (selector, event, handler) => { document.addEventListener(event, async (ev) => { if (ev.target.closest(selector)) { handler(ev) } }) } // "Signup and login" button click handler addEventListener('#signup', 'click', async () => { // For signup, create a new user and then log them in const credentials = getCredentials() // First create the user await client.service('users').create(credentials) // If successful log them in await login(credentials) }) // "Login" button click handler addEventListener('#login', 'click', async () => { const user = getCredentials() await login(user) }) // "Logout" button click handler addEventListener('#logout', 'click', async () => { await client.logout() document.getElementById('app').innerHTML = loginTemplate() }) // "Send" message form submission handler addEventListener('#send-message', 'submit', async (ev) => { // This is the message text input field const input = document.querySelector('[name="text"]') ev.preventDefault() // Create a new message and then clear the input field await client.service('messages').create({ text: input.value }) input.value = '' }) // Listen to created events and add the new message in real-time client.service('messages').on('created', addMessage) // We will also see when new users get created in real-time client.service('users').on('created', addUser) // Call login right away so we can show the chat window // If the user can already be authenticated login() ``` - `addEventListener` is a helper function that lets us add listeners to elements that get added or removed dynamically - We also added click event listeners for three buttons. `#login` will get the credentials and just log in with those. Clicking `#signup` will signup and log in at the same time. It will first create a new user on our API and then log in with that same user information. Finally, `#logout` will forget the JWT and then show the login page again. - The `#submit` button event listener gets the message text from the input field, creates a new message on the messages service and then clears out the field. - Next, we added two `created` event listeners. One for `messages` which calls the `addMessage` function to add the new message to the list and one for `users` which adds the user to the list via `addUser`. This is how Feathers does real-time and everything we need to do in order to get everything to update automatically. - To kick our application off, we call `login()` which as mentioned above will either show the chat application right away (if we signed in before and the token hasn’t expired) or the login page. ## Using the chat application That’s it. We now have a plain JavaScript real-time chat frontend with login and signup. This example demonstrates many of the basic principles of how you interact with a Feathers API. You can log in with the email (`hello@feathersjs.com`) and password (`supersecret`) from the user we registered in the [authentication chapter](../basics/authentication.md) or sign up and log in with a different email address. If you run into an issue, remember you can find the complete working example at the [feathersjs/feathers-chat](https://github.com/feathersjs/feathers-chat) repository. ================================================ FILE: docs/guides/index.md ================================================ --- outline: deep --- # Getting started with Feathers Welcome to the Feathers guides! This is the place to find all the resources to get started with Feathers. Setting up ## The Feathers guide The Feathers guide will walk you through all the important parts of Feathers. The [quick start](./basics/starting.md) gets you up and running with a Feathers API and real-time website in less than 15 minutes from scratch to give you an idea what Feathers is about. In the next parts we will [generate an application](./basics/generator.md) and then walk through Feathers core concepts like services, hooks and authentication by building a complete real-time chat application with an API and a website that can register users and send and receive messages in real-time. We will also add a login with GitHub and write unit tests for our API. [Get started with the Feathers guide >](./basics/starting.md) ## Follow up with [The API documentation >](../api/) [The cookbook for common tasks and patterns >](../cookbook/) [The Awesome FeathersJS Ecosystem >](https://github.com/feathersjs/awesome-feathersjs) [Feathers on YouTube >](https://www.youtube.com/playlist?list=PLwSdIiqnDlf_lb5y1liQK2OW5daXYgKOe) ## More about Feathers how and why [Read about the philosophy behind Feathers and where it came from >](https://blog.feathersjs.com/why-we-built-the-best-web-framework-you-ve-probably-never-heard-of-until-now-176afc5c6aac) [Learn about the high level design patterns behind Feathers >](https://blog.feathersjs.com/design-patterns-for-modern-web-apis-1f046635215) [See how Feathers compares to others >](https://feathersjs.com/comparison) ================================================ FILE: docs/guides/migrating.md ================================================ --- outline: deep --- # Migrating to v5 This guide explains the new features and changes necessary to migrate to the Feathers v5 (Dove) release. It expects applications to be using the previous Feathers v4 (Crow). See the [v4 (Crow) migration guide](https://crow.docs.feathersjs.com/guides/migrating.html) for upgrading to the previous version. ## Testing the prerelease You can run the following to upgrade all Feathers core packages: ``` npx npm-check-updates --upgrade --filter /@feathersjs/ npm install ``` You can see the migration steps necessary for the Feathers chat [here for Javascript](https://github.com/feathersjs/feathers-chat/compare/dove-pre) and [here for TypeScript](https://github.com/feathersjs/feathers-chat-ts/compare/dove-pre). ## New Features There are so many new features in this release that they got their own page! Read about the new features on the [What's New in v5](./whats-new.md) page. ## Core SQL and MongoDB The new [schemas and resolvers](../api/schema/index.md) cover most use cases previously provided by higher level ORMs like Sequelize or Mongoose in a more flexible and Feathers friendly way. This allows for a better database integration into Feathers without the overhead of a full ORM which is why the more low level [MongoDB](../api/databases/mongodb.md) and [Knex](../api/databases/knex.md) (SQL) database adapters have been moved into Feathers core for first-class SQL and MongoDB database support. ## TypeScript You have selected JavaScript as the language which does not have type information. The new version comes with major improvements in TypeScript support from improved service typings, fully typed hook context and typed configuration. You can see the changes necessary in the Feathers chat [here](https://github.com/feathersjs/feathers-chat-ts/compare/dove-pre). ### Application and hook context To get the typed hook context and application configuration update your `declarations.ts` as follows: ```ts import '@feathersjs/transport-commons' import { Application as ExpressFeathers } from '@feathersjs/express' import { HookContext as FeathersHookContext } from '@feathersjs/feathers' export interface Configuration { // Put types for app.get and app.set here port: number } // A mapping of service names to types. Will be extended in service files. export interface ServiceTypes {} // The application instance type that will be used everywhere else export type Application = ExpressFeathers export type HookContext = FeathersHookContext ``` Now `import { HookContext } from './declarations'` can be used as the context in hooks. ### Service types Service types now only need the actual service class type and should no longer include the `& ServiceAddons`. E.g. for the messages service like this: ```ts // Add this service to the service type index declare module '../../declarations' { interface ServiceTypes { messages: Messages } } ``` ### Configuration types A Feathers application can now also include types for the values of `app.set` and `app.get`. The configuration can also be validated and the type inferred from a [Feathers schema](../api/schema/index.md). ### Typed params and query Service `Params` no longer include a catchall property type and need to be explicitly declared for services that use extended `params`. It is also possible to pass your own query type to use with `params.query`: ```ts import { Params } from '@feathersjs/feathers' export type MyQuery = { name: string } export interface MyServiceParams extends Params { user: User } ``` You can revert to the previous behaviour by overriding he `Params` declaration: ```ts declare module '@feathersjs/feathers/lib/declarations' { interface Params { [key: string]: any } } ``` ## Deprecations and breaking changes ### Express middleware order The Express `rest` adapter now needs to be configured in the correct order, usually right after the `json()` middleware and before any services are registered. This is already the case in generated applications but it may have to be adjusted in a custom setup. ### Core named export The import of `feathers` has changed from ```ts const feathers = require('@feathersjs/feathers') import feathers from '@feathersjs/feathers' ``` To ```ts const { feathers } = require('@feathersjs/feathers') import { feathers } from '@feathersjs/feathers' ``` The Express exports for TypeScript have changed from ```ts import express from '@feathersjs/express' app.use(express.json()) app.use(express.urlencoded()) app.use(express.notFound()) app.use(express.errorHandler()) ``` To ```ts import express, { json, urlencoded, notFound, errorHandler } from '@feathersjs/express' app.use(json()) app.use(urlencoded()) app.use(notFound()) app.use(errorHandler()) ``` ### Custom Filters & Operators
    We are exploring the best migration strategy to replace "whitelisting" options with a solution based on [Feathers schema](/api/schema/index). We'll update this guide once the solution is in place.
    The `whitelist` option is now split into two options: `operators` and `filters`. To migrate, you need to figure out how you're using each item from your old `whitelist`, then move them to the correct option. You can determine if each one is a filter or an operator based on where it is used in a query. - `filters` are top-level query properties. - `operators` are positioned under an attribute. In the below example, `$customFilter` would be a filter, `$regex` and `$options` would be operators. ```ts const query = { $customFilter: 'value', name: { $regex: /pattern/, $options: 'igm' } } ``` For v5 service adapters, split the `whitelist` options into the `filters` object or the `operators` array. ```ts // 👎`whitelist` and `allow are unsupported. const oldServiceOptions = { whitelist: ['$customFilter', '$ignoreCase', '$regex', '$options'] } // 👍 Separate items into `filters` and `operators` for v5 service adapters const serviceOptions = { filters: { // Map a custom filter to a converter function $ignoreCase: (value: any) => (value === 'true' ? true : false), // Enable a custom param without converting $customQueryOperator: true } as const, operators: ['$regex', '$options'] } ``` If you're using TypeScript, notice the `as const` after the `filters` object in the options, above. That will keep type errors from happening when passing the `serviceOptions` to the service.
    This change only affects service adapters that have been upgraded to v5, like [@feathersjs/mongodb](/api/databases/mongodb), [@feathersjs/knex](/api/databases/knex), and [@feathersjs/memory](/api/databases/memory). This also applies to any community-supported adapters which have been upgraded to v5. If you use a v4 adapter for a service in your v5 app, you do not need to make this change for that service.
    ### Asynchronous setup `service.setup`, `app.setup` and `app.listen` return a Promise: ```js // Before const server = app.listen(3030) // Now app.listen(3030).then((server) => {}) ``` Usually you would call `app.listen`. In case you are calling `app.setup` instead (e.g. for internal jobs or seed scripts) it is now also asynchronous: ```js // Before app.setup() // Do something here // Now await app.setup() // Do something here ``` ### Socket.io 4 and Grant 5 The Socket.io and Grant (oAuth) dependencies have been updated to their latest versions. For more information on breaking changes see: - The Socket.io [version 3](https://socket.io/docs/v3/migrating-from-2-x-to-3-0/index.html#How-to-upgrade-an-existing-production-deployment) and [version 4](https://socket.io/docs/v3/migrating-from-3-x-to-4-0/) upgrade guide. Important points to note are a new improved [CORS policy](https://socket.io/docs/v3/migrating-from-2-x-to-3-0/index.html#CORS-handling) and an [explicit v2 client compatibility opt-in](https://socket.io/docs/v3/migrating-from-2-x-to-3-0/index.html#How-to-upgrade-an-existing-production-deployment) - For oAuth authentication the Grant standard configuration should continue to work as is. If you customized any other settings, see the [Grant v4 to v5 migration guide](https://github.com/simov/grant/blob/master/MIGRATION.md) for the changes necessary. ### Configuration The automatic environment variable substitution in `@feathersjs/configuration` was causing subtle and hard to debug issues. It has been removed to instead rely on the functionality already provided and battle tested by the underlying [node-config](https://github.com/lorenwest/node-config). To update your configuration: - Relative paths are no longer relative to the configuration file, but instead to where the application runs. This normally (when running from the application folder) means that paths starting with `../` and `./` have to be replaced with `./` and `./config/`. - Configuration through environment variables should be included via the `NODE_CONFIG` JSON string or as [Custom Environment Variable support](https://github.com/lorenwest/node-config/wiki/Environment-Variables#custom-environment-variables). To use existing environment variables add the following configuration file in `config/custom-environment-variables.json` like this: ```json // config/custom-environment-variables.json { "hostname": "HOSTNAME", "port": "PORT", "someSetting": { "apiKey": "MY_CUSTOM_API_KEY" } } ``` ### Debugging The `debug` module has been removed as a direct dependency. This reduces the the client bundle size and allows to support other platforms (like Deno). The original `debug` functionality can now be initialized as follows: ```ts import { feathers } from '@feathersjs/feathers' import debug from 'debug' feathers.setDebug(debug) ``` It is also possible to set a custom logger like this: ```ts import { feathers } from '@feathersjs/feathers' const customDebug = (name) => (...args) => { console.log(name, ...args) } feathers.setDebug(customDebug) ``` Setting the debugger will apply to all `@feathersjs` modules. ### Client - The `request` library has been deprecated and request support has been removed from the REST client. - Since all modern browsers now support built-in [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), the Angular and jQuery REST clients have been removed as well. - The `@feathersjs/client` package now only comes with a full (`dist/feathers.js`) and core (`dist/core.js`) browser build. Using Feathers [with a module loader](../api/client.md#module-loaders) is recommended for all other use cases. ### Removed Primus Transport Due to low usage `@feathersjs/primus` and `@feathers/primus-client` have been removed from Feathers core. ### Changes to WebSockets #### Legacy Socket Format The legacy `servicename::method` socket message format has been deprecated since Feathers 3 and has now been removed. Use a v3 or later [Feathers client](../api/client.md) or the [current Socket.io direct connection API](../api/client/socketio.md). #### Timeouts The `timeout` setting for socket services has been removed. It was mainly intended as a fallback for the old message format and interfered with the underlying timeout and retry mechanism provided by the websocket libraries themselves. ### NotFound for `app.service` By default, when getting a non existing service via `app.service('something')` on the server, it will now throw a `NotFound` error instead of returning `undefined`. The previous behaviour can be restored by setting [app.defaultService](../api/application.md#defaultservice): ```js app.defaultService = () => { return null // undefined } ``` ### Removed `service.mixin()` Services are no longer Uberproto (an ES5 inheritance utility) objects and instead rely on modern JavaScript classes and extension. This means `app.service(name).mixin(data)` is no longer available which can be replaced with a basic `Object.assign(app.service(name), data)`: ```js // Before app.mixins.push((service, path) => { service.mixin({ create(data, params) { // do something here return this._super(data, params) } }) }) // Now app.mixins.push((service, path) => { const { create } = service Object.assign(service, { create(data, params) { // do something here, then invoke the old method // through normal JavaScript functionality return create.call(this, data, params) } }) }) ``` ### `finally` hook The undocumented `finally` hook type is no longer available and should be replaced by the new `around` hooks which offer the same functionality using plain JavaScript: ```js app.service('myservice').hooks([ async (context, next) => { try { await next() } finally { // Do finally hook stuff here } } ]) ``` ### Other internal changes - The undocumented `service._setup` method introduced in v1 will no longer be called. It was used to circumvent middleware inconsistencies from Express 3 and is no longer necessary. - The undocumented `app.providers` has been removed since it provided the same functionality as [`app.mixins`](../api/application.md#mixins) - `app.disable`, `app.disabled`, `app.enable` and `app.enabled` have been removed from basic Feathers applications. It will still be available in an Express-compatible Feathers application. `app.get()` and `app.set()` should be used instead. - The `req.authentication` property is no longer set on the express requests, use `req.feathers.authentication` instead. ================================================ FILE: docs/guides/security.md ================================================ # Security We take security very seriously at Feathers. We welcome any peer review of our 100% open source code to ensure nobody's Feathers app is ever compromised or hacked. However, as a web application developer, you are responsible for the security of your application. We do our very best to make sure Feathers is as secure as possible. ## Reporting security issues In order to give the community time to respond and upgrade, we strongly urge you report all security issues to us. Send us a PM on [Discord](https://discord.gg/qa8kez8QBx) or email us at [hello@feathersjs.com](mailto:hello@feathersjs.com) with details, and we will respond ASAP. Security issues always take precedence over bug fixes and feature work; so, we'll work with you to come up with a resolution and plan and document the issue on Github in the appropriate repo. Issuing releases is typically very quick. Once an issue is resolved it is usually released immediately with the appropriate semantic version. ## Security considerations Here are some things that you should be aware of when writing your app to make sure it is secure. - Make sure to set up proper [event channels](../api/channels.md) so that only clients that are allowed to see them can see real-time updates - Use hooks to check security roles to make sure users can only access data they should be permitted to. You can find useful hook utilities in [feathers-hooks-common](https://hooks-common.feathersjs.com/) and [feathers-authentication-hooks](https://github.com/feathersjs-ecosystem/feathers-authentication-hooks/). - Restrict the [allowed database queries](../api/databases/querying.md) to only the use cases your application requires by sanitizing `params.query` in a hook. - When you explicitly allow multiple element changes, make sure queries are secured properly to limit the items that can be changed. - Escape any HTML and JavaScript to avoid XSS attacks. - Escape any SQL (typically done by the SQL library) to avoid SQL injection. - JSON Web Tokens (JWT's) are only signed. They are **not** encrypted. Therefore, the payload can be examined on the client. This is by design. **DO NOT** put anything that should be private in the JWT `payload` unless you encrypt it first. - Don't use a weak `secret` for your token service. The generator creates a strong one for you automatically. No need to change it. ## Technologies used - Password storage inside `@feathers/authentication-local` uses [bcrypt](https://github.com/dcodeIO/bcrypt.js). We don't store the salts separately since they are included in the bcrypt hashes. - By default, [JWT](https://jwt.io/)'s are stored in Local Storage (instead of cookies) to avoid CSRF attacks. For JWT, we use the `HS256` algorithm by default (HMAC using SHA-256 hash algorithm). If you choose to store JWT's in cookies, your app may have CSRF vulnerabilities. ## XSS attacks As with any web application **you** need to guard against XSS attacks. Since Feathers persists the JWT in localstorage in the browser, if your app falls victim to a XSS attack your JWT could be used by an attacker to make malicious requests on your behalf. This is far from ideal. Therefore you need to take extra care in preventing XSS attacks. Our stance on this particular attack vector is that if you are susceptible to XSS attacks, then a compromised JWT is the least of your worries because keystrokes could be logged and attackers can just steal passwords, credit card numbers, or anything else your users type directly. For more information see [this issue](https://github.com/feathersjs/authentication/issues/132) ================================================ FILE: docs/guides/whats-new.md ================================================ --- outline: deep --- # What's New in v5 Feathers Dove (v5) is a super-ambitious release which adds some really great tools and APIs. We don't have to mince words. This release is awesome with so many useful features. Here is an overview of each new feature, followed by links to learn more. ## New TypeScript Benefits Feathers has been a TypeScript-friendly framework for years, but TypeScript support took a huge leap forward with Feathers Dove. ### Complete TypeScript Rewrite We've completely rewritten all of Feathers in TypeScript. And we're not talking about a lightweight TypeScript implementation. It's TypeScript all the way down. Everything from the official database adapters, built-in hooks, and utilities, right down to Feathers core. The newly-rebuilt [v5 CLI and generator](#rebuilt-cli) even produces a TypeScript application, by default. You can find the shiny new TypeScript packages on GitHub, [here](https://github.com/feathersjs/feathers/tree/dove/packages). ### Typed Client Feathers has had an isomorphic API - working equally well in browser and server - since 2016. Now with Dove, our [new CLI](#rebuilt-cli) generates **shared types for the Feathers server and client**. We even integrated the types with our new [schemas feature](#official-schemas), so you define your types once, in a single location, and use them everywhere. Everything still uses Feathers tried and proven [standard HTTP and websocket](../api/client.md) communication mechanism. There is no custom protocol or the slow parsing of a domain specific language (like GraphQL) necessary and since it is all plain TypeScript with type information removed at compile time, there is also no bundle size overhead. Thanks to FeathersJS's clean, modular, loosely-coupled architecture, it was pleasantly simple to add this feature. This is another one of the benefits we get from building a pattern-driven framework. You can learn more about the Feathers Client, [here](../guides/cli/client.md). ## New Documentation The new docs are built on [Vitepress](https://vitepress.vuejs.org/). It had become difficult to maintain all of the examples in two languages: JavaScript and TypeScript. To simplify, we now ONLY write documentation examples in TypeScript. You can still switch languages in the sidebar thanks to our custom highlighter for Vitepress, which transpiles TypeScript examples to JavaScript. You can find the `docs` folder, [here](https://github.com/feathersjs/feathers/tree/dove/docs). ## Framework Agnostic API In 2016, we realized that we could decouple Feathers from the underlying HTTP transport, resulting in our first framework-agnostic, isomorphic build. As of Feathers v5, we now support three ways of using Feathers: - The Feathers client, which provides the same API in the browser, React Native and in Node.js. - The [KoaJS transport](../api/koa.md) (new in Feathers Dove) - The [ExpressJS transport](../api/express.md) ### KoaJS Support The CLI's official HTTP integration has always been built on the Express adapter. Lately, Express has been "showing its age", so we've made some inviting changes. - We've released the [`@feathersjs/koa`](../api/koa.md) adapter and utilities. Now Feathers apps can use [KoaJS](https://koajs.com/) as an API base. - The Feathers CLI now uses KoaJS as the default transport. - The Express adapter will continue to function alongside KoaJS. FeathersJS has its own, isomorphic middleware layer, based on [hooks](../api/hooks.md), so you likely won't need to tap into the middleware layer of any framework adapter. But, in those cases that you need framework middleware, it's available to you. Read about the KoaJS adapter, [here](../api/koa.md). ### Lightning-Fast Routing Feathers just got a huge speed upgrade, now including its own [Radix Trie](https://iq.opengenus.org/radix-tree/) router. This means that the algorithm behind Fastify's speed is now built into Feathers, and it works no matter which framework transport you use under the hood. The best part about the new router is that there's not another API you have to learn in order to use Feathers. It just works. For those who want to build a custom framework transport, there's a single `.lookup` method which routes requests through Feathers. Learn about the `lookup` method, [here](/api/application#lookup). ### Service De-Registration Now that Feathers comes with [its own router](#lightning-fast-routing), it's possible to de-register a service to completely remove it from the application. This allows you to build cleaner, dynamically generated applications. This is a coveted feature for those who want to build, for example, a dynamic CRUD admin application that's driven by some sort of schema. Learn about service de-registration [here](../api/application.md#unusepath). ## Custom Methods While Feathers [standard service methods](../api/services.md) cover 90% of the functionality you need to create and modify data, a service might also provide other custom functionality making custom Method creation one of the most-requested features for Feathers. Feathers Dove introduces an elegant solution for custom methods on top of the Feathers service interface. When you define your service class, you can specify additional methods on the class to create an internal-only method. To expose the method to the public API, add the method's name to the `methods` options when registering the service. Custom methods are similar to the `create` method, so you can POST to them when using HTTP-based adapters. Read more about custom methods, [here](../api/services#custom-methods). ## Official Schemas Feathers Dove (v5) introduces new, official tools for data validation in the new core package, [@feathersjs/schema](../api/schema/index.md). This same package includes schema-based resolvers, which you'll learn about in the next section. Schemas are powered by JSON Schema (an IETF standard) which makes them powerful and portable. ### Schema-Driven Types One of the problems we wanted to avoid was the need to define schemas and/or types in multiple places. If we had a motto/slogan for types, it would be **"Define it once, use it everywhere."** So in Feathers Dove, when you create a schema, it dynamically generates validation and proper TypeScript types. You can use the powerful and concise [TypeBox schema format](../api/schema/typebox.md) or [plain JSON schema](../api/schema/schema.md). ### Configuration Schemas If you've ever experienced pains of deploying to production, you'll appreciate this feature. When your app starts in production, all of your configuration and environment variables are checked against the configuration schema. The app won't start if the schema validation fails. This keeps bugs from missing environment variables from showing up in production days to weeks after deployment. Configuration schemas also produce TypeScript types, so the [TypeScript improvements](#new-typescript-benefits) in Feathers Dove include typed configuration lookup for `app.get()` and `app.set()`. It's really convenient. Read more about configuration schemas, [here](/api/configuration#configuration-schema) ## Resolvers Combined with the new [schemas](#official-schemas), resolvers allow to dynamically populate properties. It's a powerful tool that has many use cases from populating associations, securing queries or protecting secure data to easily setting values like the creation date or associated user. See the [chat guide](../guides/basics/generator.md) for an example on how to set the user avatar, populate the user associated with a message and let users only modify their own data. ### Resolver Utility Hooks Resolvers are powered by new hook utilities: - [resolveData](../api/schema/resolvers.md#data-resolvers) for incoming data. - [resolveResult](../api/schema/resolvers.md#result-resolvers) for results coming from databases or other services - [resolveDispatch](../api/schema/resolvers.md#safe-data-resolvers) for cleanly defining safe data for WebSocket / Real-time events. - [resolveQuery](../api/schema/resolvers.md#query-resolvers) for incoming query parameters Read about the new hooks using the links, above. These new hook utils allow you to - More cleanly manage properties on incoming records, query objects, and/or results - Perform advanced validation beyond what's possible with JSON Schema. - More efficiently write code for populating relational data (often faster than a normal ORM) - Save yourself a lot of boilerplate compared to writing the three features, above, manually with hooks. You can start using resolvers right away. The new [CLI](../guides/basics/services#generating-a-service) generates them with all new services. Resolvers are one of the new tools provided in the new core package: [@feathersjs/schema](../api/schema/index.md). You can read more about resolvers, [here](../api/schema/resolvers.md). ### Hooks vs Resolvers At first glance, choosing where to put logic might seem complex. Should the feature go into a hook or a resolver? Here are some general guidelines to assist you: - Data manipulation and **custom** validation probably fit best in a resolver. - Adding or pulling in data from other sources will likely fit best in a resolver. - Side effects that manipulate external data should go into a hook with few exceptions. ## More Powerful Hooks In Feathers Dove there are now two hook formats. One for `before`, `after`, and `error` hooks, and a new one for `around` hooks: - **Before, after, and error hooks** have been Feathers' most-used API for years. - Are registered as `before`, `after`, or `error` hooks in the hook object. - Continue to work fully in Feathers Dove. - Are less powerful than the new "around" hooks, but visually simpler. - **Around Hooks** are new in Feathers Dove. - Are registered in the `around` key of a hook object. - Are capable of handling before, after, and error logic, all within a single hook function. - Have a slightly different function definition than before, after, and error hooks - Are more powerful yet also more visually complex (The "after" part of each hook runs in reverse-registered order). Let's compare the signature of the two types of hooks. ### Before, After, & Error Hooks Let's look at an example of the before/after/error hook format. These hooks receive the `context` as their only argument. They return either the `context` object or `undefined`. ```ts import type { HookContext } from '../../declarations' export const myHook = async (context: HookContext) => { return context } ``` You can learn more about before/after/error hooks, [here](../api/hooks.md#before-after-and-error) ### Around Hooks Now let's see an around hook. An around hook receives two arguments: the `context` object and a `next` function. ```ts import type { HookContext, NextFunction } from '../../declarations' export const myHook = async (context: HookContext, next: NextFunction) => { await next() } ``` You can learn more about around hooks, [here](../api/hooks.md#around) ### Registering Hooks The hooks object now has a new `around` property, which is specifically for `around` hooks. Since around hooks have different function signatures, they are not interchangeable with before/after/error hooks. ```ts export const serviceHooks = { // `around` hook are new in Feathers Dove around: { all: [], find: [], get: [], create: [], update: [], patch: [], remove: [] }, // before/after/error hooks also continue to work before: {}, after: {}, error: {} } ``` Learn more about registering hooks, [here](../api/hooks.md#registering-hooks). ### When to use Around Hooks Using `around` hooks or `regular` hooks is mostly a matter of preference. There's no imminent need to rewrite all of your regular hooks into around hooks. Both hooks work together, as explained [here](/api/hooks#hook-flow). Starting with Dove, the CLI templates and new tooling features are written in `around` hooks. The around hooks simplify code in core tools because we can keep the logic for the entire hook flow (before, after, error) all in one file. Here are a couple of examples of where `around` hooks work really well:
    One great use case for `around` hooks is data caching. A caching hook typically has the following responsibilities: - Check the cache for existing results. (before the service method executes) - Push new results into the cache, once received. (after the service method executes) - Handle and report errors which occur in the hook. With regular hooks, a cache hook has to be split into three parts, one for each responsibility. Instead, a single `around` hook can handle everything on its own. Below is an example of an overly-simple cache hook using JavaScript's `Map` API. Everything before `await next()` runs before the database call. Everything afterwards runs after the database call. You could also drop in a try/catch to handle possible errors. ```ts import type { HookContext, NextFunction } from '../../declarations' export const simpleCache = new Map() export const myHook = async (context: HookContext, next: NextFunction) => { // Check the cache for an existing record const existing = simpleCache.get(context.id) // If an existing record was found, set it as context.result to skip the database call. if (existing) { context.result = existing } await next() // Cache the latest record by its id simpleCache.set(context.result.id, context.result) } ```
    ### Setup and Teardown Hooks Feathers v5 Dove adds built-in support for app-level `setup` and `teardown` hooks. They are special hooks that don't run on the service level but instead directly on [app.setup](../api/application.md#setupserver) or `app.listen` and [app.teardown](../api/application.md#teardownserver). They allow you to perform some async logic while starting and stopping the Feathers server. ```ts app.hooks({ setup: [connectMongoDB], teardown: [closeMongoDB] }) ``` Learn more about `setup` and `teardown` hooks, [here](../api/hooks.md#setup-and-teardown) ## Rebuilt CLI The new CLI is completely different under the hood, and very familiar on the surface. There are a few differences in file structure compared to apps generated with previous versions of the CLI. ### State of the Art When creating the new generator, we looked at open-source generators already available. We were very impressed with [Hygen](https://hygen.io). It's absolutely impressive work, for sure, so we even wrote a custom generator to try it out. Then [@fratzinger](https://github.com/fratzinger) came up with the idea of a 100% TypeScript generator based on JavaScript template strings. We couldn't find an existing project, so we made one! The new Feathers CLI is built on top of [Pinion](https://github.com/feathershq/pinion), our own generator with TypeScript-based templates. Instead of using some custom templating language, like Handlebars or EJS, Pinion uses Typed [Template Literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals), providing some wonderful benefits: - No more mystery context. You always know the exact context of the templates and what helpers are available. - It just works™ with existing npm packages. There's no need to make an EJS plugin for some custom helper using an obscure API. Just import the module and use it in your template. - Integrates with all existing TypeScript tooling. Hover over a variable and inspect the context like you would any TS code. Now that we have what we consider the best generator on the planet, we have some exciting plans for the Feathers CLI, which we will announce in the future. You can read more about Pinion, [here](https://github.com/feathershq/pinion) ### Fully TypeScript We have dramatically reduced the surface area for bugs to be introduced into the app. We've committed 100% to TypeScript, while making sure that you can still generate a JavaScript app. When you select `JavaScript` to generate an app, the CLI works some magic under the hood by - Compiling the `.ts` templates to JavaScript, in memory - Formatting the JavaScript code with Prettier - Writing clean `.js` to the file system. For Feathers Maintainers, committing to TypeScript means we only contribute to a single set of templates. And they get magically compiled - on the fly - to plain JavaScript when you want it. ### Shared Types We covered this [in more detail, earlier](#typed-client), but it's worth briefly mentioning again. The new generator powers Shared Types for both the Feathers server and client. You can make your public-facing API easier to use and give developers a typed client SDK. Read more about shared types, [here](#typed-client). ### New App Structure The file and folder structure of generated apps has changed a little bit. Here's an overview of the changes: - Each service has its own schema and resolver file - The service hooks are now found together with the service registration. - The `src/models` folder no longer gets created, since [Feathers schemas](#official-schemas) replace models. - Each service has its own folder inside the `tests` folder. You can learn more about the generated files in the [CLI guide](./cli/index.md). ## The Future We are self-funded and community powered. In every way, Feathers has a solid foundation for a steady, stable future. How did we ever manage to build such a great framework without millions of dollars? Really, we have a wonderful, active community of contributors who share values of good API design, boilerplate elimination, and making development fun. This is rewarding for us! We started in 2013 from a core architecture that's unique among frameworks - in **any** language. We offer the same API across multiple transports, which allows us all to build real-time, restful applications. The result is a robust, flexible framework that continues to be unique while showing its maturity. Feathers has made its way into enterprises that serve a large portion of the connected planet. With all of the new features in Feathers v5 (Dove), we're excited to build! And we're even more excited to see what you build! We have a few more things to show off in the coming months. Stay tuned! Enjoy the release! And come chat with us on [Discord](https://discord.gg/qa8kez8QBx) when you feel like it. ================================================ FILE: docs/help/faq.md ================================================ --- outline: deep --- # FAQ We've been collecting some commonly asked questions here. We'll either be updating the guide directly, providing answers here, or both. ## Why should I use Feathers? There are many other Frameworks that let you build web applications so this is definitely a justified question. The key part for Feathers is that it takes a different approach to both, traditional MVC frameworks like Rails, Sails or NestJS and low level HTTP frameworks like Sinatra, Express or Fastify. Instead of creating routes, controllers and HTTP request and response handlers, Feathers uses services and workflows (hooks) that let you focus on your application logic independently from how it is being accessed. This makes applications easier to understand and test and it allows Feathers to automatically provide REST APIs, websocket real-time APIs (which can often be quite a bit faster) and universal usage on the client and the server. It also makes it possible to add new communication protocols (like HTTP2 or GraphQL) without having to change anything in your application code. Feathers does all that while staying lightweight with a small API surface and codebase and flexible by letting you use it with the backend and frontend technology that best suits your needs. For more information - [Read about the philosophy behind Feathers and where it came from](https://blog.feathersjs.com/why-we-built-the-best-web-framework-you-ve-probably-never-heard-of-until-now-176afc5c6aac) - [Learn about the high level design patterns behind Feathers](https://blog.feathersjs.com/design-patterns-for-modern-web-apis-1f046635215) - [See how Feathers compares to others](https://feathersjs.com/comparison) ## Is Feathers production ready? Yes! Feathers had its first stable release in 2014 and is being used in production by a bunch of companies from startups to fortune 500s. For some more details see [this answer on Quora](https://www.quora.com/Is-FeathersJS-production-ready). ## What Node versions does Feathers support Feathers supports all NodeJS versions from the current Active LTS upwards. See [the Node.JS working group release schedule](https://github.com/nodejs/Release#release-schedule) for more information. ## How do I create custom methods? Feathers is built around the [REST architectural constraints](https://en.wikipedia.org/wiki/Representational_state_transfer#Architectural_constraints) reflected by its standard service methods. There are many benefits using those methods like security, predictability and sending pre-defined real-time events so you should try to structure your application with the [standard service methods](../api/services.md#service-methods). For example: > Send email action that does not store mail message in database. Resources (services) don't have to be database records. It can be any kind of resource (like the current weather for a city or creating an email which will send it). Sending emails is usually done with either a separate email [service](../api/services.md): ```ts class EmailService { async create(data: EmailData) { return sendEmail(data) } } app.use('/email', new EmailService()) ``` > Place an order in e-commerce web site. Behind the scenes, there are many records will be inserted in one transaction: order_item, order_header, voucher_tracking etc. This is what [Feathers hooks](../api/hooks.md) are used for. When creating a new order you also have a well defined hook chain: ```ts app.service('orders').hooks({ before: { create: [validateData(), checkStock(), checkVoucher()] }, after: { create: [ chargePayment(), // hook that calls `app.service('payment').create()` sendEmail(), // hook that calls `app.service('email').create()` updateStock() // Update product stock here ] } }) ``` However, there are some use cases where you might still want to allow additional methods for a client to call (like re-sending a verification email or resetting a password on the user service) and this is what [custom service method](../api/services.md#custom-methods) can be used for. ## How do I do nested or custom routes? Normally we find that they actually aren't needed and that it is much better to keep your routes as flat as possible. For example something like `users/:userId/posts` is - although nice to read for humans - actually not as easy to parse and process as the equivalent `/posts?userId=` that is already [supported by Feathers database adapters](../api/databases/querying.md). Additionally, this will also work much better when using Feathers through websocket connections which do not have a concept of routes at all. However, nested routes for services can still be created by registering an existing service on the nested route and mapping the route parameter to a query parameter like this: ```ts app.use('/posts', postService) app.use('/users', userService) // re-export the posts service on the /users/:userId/posts route app.use('/users/:userId/posts', app.service('posts')) // A hook that updates `data` with the route parameter async function mapUserIdToData(context: HookContext) { if (context.data && context.params.route.userId) { context.data.userId = context.params.route.userId } } // For the new route, map the `:userId` route parameter to the query in a hook app.service('users/:userId/posts').hooks({ before: { find: [ async (context: HookContext) => { // Map the `userId` route parameter to the query context.params.query = { ...context.params.query, userId: context.params.route.userId } } ], create: mapUserIdToData, update: mapUserIdToData, patch: mapUserIdToData } }) ``` Now going to `/users/123/posts` will call `postService.find({ query: { userId: 123 } })` and return all posts for that user. For more information about URL routing and parameters, refer to [the Express chapter](../api/express.md).
    URLs should never contain actions that change data (like `post/publish` or `post/delete`). This has always been an important part of the HTTP protocol and Feathers enforces this more strictly than most other frameworks. For example to publish a post you would call `.patch(id, { published: true })`.
    ## Why are you using JWT for sessions Feathers is using [JSON web tokens (JWT)](https://jwt.io/) for its standard authentication mechanism. Some articles like [Stop using JWT for sessions](http://cryto.net/~joepie91/blog/2016/06/13/stop-using-jwt-for-sessions/) promotes using standard cookies and HTTP sessions. While it brings up some valid points, not all of them apply to Feathers and there are other good reasons why Feathers relies on JWT: - Feathers is designed to support many different transport mechanisms, most of which do not rely on HTTP but do work well with JWT as the authentication mechanism. This is even already the case for websockets where an established connection normally is not secured by a traditional HTTP session. - By default the only thing that Feathers stored in the JWT payload is the user id. It is a stateful token. You can change this and make the token stateless by putting more data into the JWT payload but this is at your discretion. Currently the user is looked up on every request after the JWT is verified to not be expired or tampered with. - You need to make sure that you revoke JWT tokens or set a low expiration date or add custom logic to verify that a user’s account is still valid/active. Currently the default expiration is 1 day. We chose a reasonable default for most apps but depending on your application this might be too long or too short. Additionally, it is still possible to use Feathers with existing _traditional_ Express session mechanism by using [custom Express middleware](../api/express.md). For example, `params.user` for all service calls from a traditional Express session can be passed like this: ```ts app.use(function (req, res, next) { // Set service call `param.user` from `session.user` req.feathers.user = req.session.user }) ``` ## Can you support another database? Feathers [database adapters](../api/databases/adapters.md) implement 90% of the functionality you may need to use Feathers with certain databases. You can also find a wide variety of community maintained database adapters [in the ecosystem](/ecosystem/?cat=Database&sort=lastPublish). However, even if your favourite database or ORM is not on the list or the adapter does not support specific functionality you are looking for, Feathers can still accommodate all your needs by [writing your own services](../api/services.md).
    To use Feathers properly it is very important to understand how services work and that all existing database adapters are just services that talk to the database themselves.
    The why and how to write your own services is covered [in the Feathers guide](../guides/). A custom service can be generated by running `npx feathers generate service`, choosing "A custom service" and then editing the `/.class.js` file to make the database calls. If you would like to publish your own database adapter, first make sure there isn't already a [community maintained adapter](/ecosystem/?cat=Database&sort=lastPublish) for that database. If one exists, many maintainers are happy to get some help. If not, you can find a database adapter reference implementation in the [@feathersjs/memory module](https://github.com/feathersjs/feathers/tree/dove/packages/memory). It is always possible for community maintained adapters to graduate into an _official_ Feathers adapter, at the moment there are however no plans to add support for any new databases from the Feathers team directly. ## How do I watch for database changes? In order to get real-time updates for a change, all requests have to go through your Feathers application or API server. Feathers **does not** watch the database for changes so if changes in the database are made outside of the Feathers application and clients should be notified, the notification needs to be sent manually. ## How do I do search? This depends on the database adapter you are using. See [the search querying chapter](../api/databases/querying.md#search) for more information. ## Why am I not getting JSON errors? If you get a plain text error and a 500 status code for errors that should return different status codes, make sure you have the `express.errorHandler()` from the `@feathersjs/express` module configured as described in the [Express errors](../api/express.md#expresserrorhandler) chapter. ## Why am I not getting the correct HTTP error code See the above answer. ## How can I do custom methods like `findOrCreate`? Custom functionality can almost always be mapped to an existing service method using hooks. For example, `findOrCreate` can be implemented as a before-hook on the service's `get` method. [See this gist](https://gist.github.com/marshallswain/9fa3b1e855633af00998) for an example of how to implement this in a before-hook. It is also possible to implement [custom methods](../api/services.md#custom-methods) on the service for functionality that can't be implemented in a hook. ## How do I create channels or rooms In Feathers [channels](../api/channels.md) are the way to send [real-time events](../api/events.md) to only certain clients. ## How do I do validation? [Schemas](../api/schema/index.md) and [validator](../api/schema/validators.md) are the recommended way to implement basic validations based on JSON schema. [Resolvers](../api/schema/resolvers.md) can be used for advanced validation like dynamic password policies. Schemas and resolvers are then used as [validation hooks](../api/schema/validators.md#hooks) and [resolver hooks](../api/schema/resolvers.md#hooks). Hooks are also the place to perform validation without schemas and resolvers. ## How do I do associations? The preferred way for associations are [resolvers](../api/schema/resolvers.md). See [the guide](../guides/basics/schemas.md) for an example on how to do associations. ## How do I access the request object in hooks or services? In short, you shouldn't need to. If you look at the [hooks chapter](../api/hooks.md) you'll see all the params that are available on a hook. If you still need something from the request object (for example, the requesting IP address) you can tack it on to the `req.feathers` object as described [here for Express](../api/express.md#params), here [for Koa](../api/koa.md#params) or `socket.feathers` when using web sockets as [described here](../api/socketio.md#appconfiguresocketiocallback). ## How do I mount sub apps? It's pretty much exactly the same as Express. More information can be found [here](../api/express.md#sub-apps). ## How do I do some processing after sending the response to the user? The hooks workflow allows you to handle these situations quite gracefully. It depends if you `await` or not in your hook. Here's an example of a hook that sends an email, but doesn't wait for a success message. ```ts ;async (context: HookContext) => { // Send an email by calling to the email service. context.app.service('emails').create({ to: 'user@email.com', body: 'You are so great!' }) // Send a message to some logging service. context.app.service('logging').create(context.data) return context } ``` ## How do I debug my app It's really no different than debugging any other NodeJS app but you can refer to [this blog post](https://blog.feathersjs.com/debugging-feathers-with-visual-studio-code-406e6adf2882) for more Feathers specific tips and tricks. ## Why can't I pass `params` from the client? When you make a call like: ```ts const params = { foo: 'bar' } const user = await client.service('users').patch(1, { admin: true }, params) ``` on the client the `context.params` object will only be available in your client side hooks. It will not be provided to the server. The reason for this is because `context.params` on the server usually contains information that should be server-side only. This can be database options, whether a request is authenticated, etc. If we passed those directly from the client to the server this would be a big security risk. **Only the client side** `context.params.query` and `context.params.headers` objects are provided to the server. If you need to pass info from the client to the server that is not part of the query you need to add it to `context.params.query` on the client side and explicitly pull it out of `context.params.query` on the server side. This can be achieved like so: ```ts // client side client.hooks({ before: { all: [ async (context: HookContext) => { context.params.query = { ...context.params.query, $client: { platform: 'ios', version: '1.0' } } } ] } }) ``` On the server in `src/app`: ```ts app.hooks({ before: { all: [ async (context: HookContext) => { // Pull out `$client` parameter and create a new `query` object const { $client: { platform, version }, ...query } = params.query // Update context.params with the new information context.params = { ...context.params, platform, version, query } } ] } }) ```
    Make sure to validate and sanitize any client side values to prevent security issues.
    ## My queries with null values aren't working
    Query values will be converted to the correct type automatically when using a [query schema](../api/schema/index.md). This issue also does not happen when using websockets since it retains all type information.
    When making a request using REST (HTTP) query _string_ values don't have any type information and will always be strings. Some database adapters that have a schema (like `feathers-mongoose` or `feathers-sequelize`) will try to convert values to the correct type but others (like `feathers-mongodb`) can't. Additionally, `null` will always be a string and always has to be converted if you want to query for `null`. This can be done in a `before` [hook](../api/hooks.md): ```ts app.service('myservice').hooks({ before: { find: [ async (context: HookContext) => { const { params: { query = {} } } = context if (query.phone === 'null') { query.phone = null } context.params.query = query return context } ] } }) ``` Also see [this issue](https://github.com/feathersjs/feathers/issues/894). ## Why are queries with arrays failing? If you are using REST and queries with larger arrays (more than 21 items to be exact) are failing, you are probably running into an issue with the [querystring](https://github.com/ljharb/qs) module which [limits the size of arrays to 21 items](https://github.com/ljharb/qs#parsing-arrays) by default. The recommended solution is to implement a custom query string parser function via `app.set('query parser', parserFunction)` with the `arrayLimit` option set to a higher value: ```js var qs = require('qs') app.set('query parser', function (str) { return qs.parse(str, { arrayLimit: 100 }) }) ``` For more information see the [Express application settings](http://expressjs.com/en/4x/api.html#app.set) [@feathersjs/rest#88](https://github.com/feathersjs/feathers-rest/issues/88) and [feathers-mongoose#205](https://github.com/feathersjs-ecosystem/feathers-mongoose/issues/205). ## I always get a 404 for my custom middleware Just like in Express itself, the order of middleware matters. If you registered a custom middleware outside of the generator, you have to make sure that it runs before the `notFound()` error midlleware. ## My configuration isn't loaded If you are running or requiring the Feathers app from a different folder [Feathers configuration](../api/configuration.md) needs to be instructed where the configuration files for the app are located. Since it uses [node-config](https://github.com/lorenwest/node-config) this can be done by setting the [NODE_CONFIG_DIR envorinment variable](https://github.com/lorenwest/node-config/wiki/Environment-Variables#node_config_dir). ## How do I set up HTTPS? In most production environments your Feathers application should be behind an NginX proxy that handles HTTPS. It is also possible to add SSL directly to your Feathers application which is described in the [Express HTTPS docs](../api/express.md#https). ================================================ FILE: docs/help/index.md ================================================ --- outline: deep --- # Getting Help There are many ways that you can get help if you are stuck or have a question about Feathers. ## Resources Existing resources may already have an answer to your question, so it always makes sense checking them first: - [API Docs >](../api/) - [FAQ >](./faq.md) - [GitHub issues >](https://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+user%3Afeathersjs+) - [GitHub discussions](https://github.com/feathersjs/feathers/discussions) - [Cookbook](/cookbook/) - [Blog >](https://blog.feathersjs.com/) - [Stack Overflow >](http://stackoverflow.com/questions/tagged/feathersjs) ## Help channels If none of those work it's a very real possibility that we screwed something up or it's just not clear. We're sorry :disappointed_relieved: We want to hear about it and are very friendly so feel free to come talk to us: [Join our Discord server >](https://discord.gg/qa8kez8QBx) [Submit an issue to GitHub >](https://github.com/feathersjs/feathers/issues/new) [Ask on StackOverflow using the `feathersjs` tag >](http://stackoverflow.com) ## Consulting and app development [Feathers Cloud](https://feathers.cloud/) specialize in app development and consulting to get your app on the right track. [Contact us](https://feathers.cloud/consulting.html) to see how we can help. ## Support Feathers, get help By [becoming a sponsor](https://github.com/sponsors/daffl/) you support Feathers continued development and get access to a Feathers newsletter and tiers with 30 or 60 minute monthly office hour sessions to walk you through any issues you may be facing using FeathersJS. This may include architecture discussions, debug sessions, patterns, or more. ================================================ FILE: docs/index.md ================================================ --- layout: page sidebar: false title: Feathers titleTemplate: The API and Real-time Application Framework --- ================================================ FILE: docs/package.json ================================================ { "name": "docs", "private": true, "type": "module", "scripts": { "dev": "vitepress --port 3333 --open", "build": "vitepress build", "serve": "vitepress serve", "preview-https": "pnpm run build && serve .vitepress/dist", "prefetch": "esno .vitepress/scripts/fetch-avatars.ts", "start": "npm run dev" }, "dependencies": { "@vueuse/core": "^14.2.1", "date-fns": "^4.1.0", "element-plus": "^2.13.2", "query-string": "^9.3.1", "shiki": "^3.22.0", "vue": "^3.5.28" }, "devDependencies": { "@feathersjs/generators": "^5.0.40", "@iconify-json/carbon": "^1.2.18", "@types/node": "^25.3.0", "@unocss/preset-typography": "^66.6.0", "@unocss/reset": "^66.6.0", "@unocss/transformer-directives": "^66.6.0", "@vitejs/plugin-vue": "^6.0.4", "esno": "^4.8.0", "fast-glob": "^3.3.3", "flexsearch": "^0.7.31", "https-localhost": "^4.7.1", "markdown-it": "^14.1.1", "sass": "^1.97.3", "sitemap": "^9.0.0", "unocss": "^66.6.0", "unplugin-auto-import": "^21.0.0", "unplugin-vue-components": "^31.0.0", "vite-plugin-pwa": "^1.2.0", "vitepress": "^1.6.4", "vitepress-plugin-google-analytics": "^1.0.2", "vitepress-plugin-search": "^1.0.4-alpha.22", "workbox-window": "^7.4.0" } } ================================================ FILE: docs/public/_headers ================================================ / X-Frame-Options: DENY X-XSS-Protection: 1; mode=block /api/ X-Frame-Options: DENY X-XSS-Protection: 1; mode=block /config/ X-Frame-Options: DENY X-XSS-Protection: 1; mode=block /guide/ X-Frame-Options: DENY X-XSS-Protection: 1; mode=block /*.html X-Frame-Options: DENY X-XSS-Protection: 1; mode=block /* X-Content-Type-Options: nosniff Referrer-Policy: no-referrer Strict-Transport-Security: max-age=31536000; includeSubDomains /assets/* cache-control: max-age=31536000 cache-control: immutable ================================================ FILE: docs/public/_redirects ================================================ # Crow Redirects /migrating.html /guides/migrating.html /security.html /guides/security.html /help/readme.html /help/ /faq/readme.html /help/faq.html /api/authentication/oauth1.html /api/authentication/oauth.html /api/authentication/oauth2.html /api/authentication/oauth.html /api/authentication/server.html /api/authentication/ /guides/frameworks/readme.html /guides/frameworks.html /guides/basics/readme.html /guides/ /guides/basics/clients.html /guides/basics/starting.html /guides/basics/databases.html /guides/basics/services.html /guides/basics/real-time.html /guides/basics/services.html /guides/chat/readme.html /guides/ /guides/chat/authentication.html /guides/basics/authentication.html /guides/chat/creating.html /guides/basics/generator.html /guides/chat/frontend.html /guides/basics/frontend.html /guides/chat/processing.html /guides/basics/hooks.html /guides/chat/service.html /guides/basics/services.html /guides/chat/testing.html /guides/basics/testing.html /*/readme.html /:splat 301! ================================================ FILE: docs/public/feathers-chat.css ================================================ :root { font-synthesis: none; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-text-size-adjust: 100%; } body, #app { height: 100vh; width: 100vw; margin: 0; padding: 0; } /* layer: preflights */ *, ::before, ::after { --un-rotate: 0; --un-rotate-x: 0; --un-rotate-y: 0; --un-rotate-z: 0; --un-scale-x: 1; --un-scale-y: 1; --un-scale-z: 1; --un-skew-x: 0; --un-skew-y: 0; --un-translate-x: 0; --un-translate-y: 0; --un-translate-z: 0; --un-pan-x: ; --un-pan-y: ; --un-pinch-zoom: ; --un-scroll-snap-strictness: proximity; --un-ordinal: ; --un-slashed-zero: ; --un-numeric-figure: ; --un-numeric-spacing: ; --un-numeric-fraction: ; --un-border-spacing-x: 0; --un-border-spacing-y: 0; --un-ring-offset-shadow: 0 0 rgba(0, 0, 0, 0); --un-ring-shadow: 0 0 rgba(0, 0, 0, 0); --un-shadow-inset: ; --un-shadow: 0 0 rgba(0, 0, 0, 0); --un-ring-inset: ; --un-ring-offset-width: 0px; --un-ring-offset-color: #fff; --un-ring-width: 0px; --un-ring-color: rgba(147, 197, 253, 0.5); --un-blur: ; --un-brightness: ; --un-contrast: ; --un-drop-shadow: ; --un-grayscale: ; --un-hue-rotate: ; --un-invert: ; --un-saturate: ; --un-sepia: ; --un-backdrop-blur: ; --un-backdrop-brightness: ; --un-backdrop-contrast: ; --un-backdrop-grayscale: ; --un-backdrop-hue-rotate: ; --un-backdrop-invert: ; --un-backdrop-opacity: ; --un-backdrop-saturate: ; --un-backdrop-sepia: ; } ::backdrop { --un-rotate: 0; --un-rotate-x: 0; --un-rotate-y: 0; --un-rotate-z: 0; --un-scale-x: 1; --un-scale-y: 1; --un-scale-z: 1; --un-skew-x: 0; --un-skew-y: 0; --un-translate-x: 0; --un-translate-y: 0; --un-translate-z: 0; --un-pan-x: ; --un-pan-y: ; --un-pinch-zoom: ; --un-scroll-snap-strictness: proximity; --un-ordinal: ; --un-slashed-zero: ; --un-numeric-figure: ; --un-numeric-spacing: ; --un-numeric-fraction: ; --un-border-spacing-x: 0; --un-border-spacing-y: 0; --un-ring-offset-shadow: 0 0 rgba(0, 0, 0, 0); --un-ring-shadow: 0 0 rgba(0, 0, 0, 0); --un-shadow-inset: ; --un-shadow: 0 0 rgba(0, 0, 0, 0); --un-ring-inset: ; --un-ring-offset-width: 0px; --un-ring-offset-color: #fff; --un-ring-width: 0px; --un-ring-color: rgba(147, 197, 253, 0.5); --un-blur: ; --un-brightness: ; --un-contrast: ; --un-drop-shadow: ; --un-grayscale: ; --un-hue-rotate: ; --un-invert: ; --un-saturate: ; --un-sepia: ; --un-backdrop-blur: ; --un-backdrop-brightness: ; --un-backdrop-contrast: ; --un-backdrop-grayscale: ; --un-backdrop-hue-rotate: ; --un-backdrop-invert: ; --un-backdrop-opacity: ; --un-backdrop-saturate: ; --un-backdrop-sepia: ; } /* layer: icons */ .i-feather-alert-triangle { --un-icon: url("data:image/svg+xml;utf8,%3Csvg preserveAspectRatio='xMidYMid meet' viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0zM12 9v4m0 4h.01'/%3E%3C/svg%3E"); mask: var(--un-icon) no-repeat; mask-size: 100% 100%; -webkit-mask: var(--un-icon) no-repeat; -webkit-mask-size: 100% 100%; background-color: currentColor; width: 1em; height: 1em; } .i-feather-hash { --un-icon: url("data:image/svg+xml;utf8,%3Csvg preserveAspectRatio='xMidYMid meet' viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 9h16M4 15h16M10 3L8 21m8-18l-2 18'/%3E%3C/svg%3E"); mask: var(--un-icon) no-repeat; mask-size: 100% 100%; -webkit-mask: var(--un-icon) no-repeat; -webkit-mask-size: 100% 100%; background-color: currentColor; width: 1em; height: 1em; } .i-feather-log-out { --un-icon: url("data:image/svg+xml;utf8,%3Csvg preserveAspectRatio='xMidYMid meet' viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4m7 14l5-5l-5-5m5 5H9'/%3E%3C/svg%3E"); mask: var(--un-icon) no-repeat; mask-size: 100% 100%; -webkit-mask: var(--un-icon) no-repeat; -webkit-mask-size: 100% 100%; background-color: currentColor; width: 1em; height: 1em; } .i-feather-menu { --un-icon: url("data:image/svg+xml;utf8,%3Csvg preserveAspectRatio='xMidYMid meet' viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M3 12h18M3 6h18M3 18h18'/%3E%3C/svg%3E"); mask: var(--un-icon) no-repeat; mask-size: 100% 100%; -webkit-mask: var(--un-icon) no-repeat; -webkit-mask-size: 100% 100%; background-color: currentColor; width: 1em; height: 1em; } .i-feather-x { --un-icon: url("data:image/svg+xml;utf8,%3Csvg preserveAspectRatio='xMidYMid meet' viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M18 6L6 18M6 6l12 12'/%3E%3C/svg%3E"); mask: var(--un-icon) no-repeat; mask-size: 100% 100%; -webkit-mask: var(--un-icon) no-repeat; -webkit-mask-size: 100% 100%; background-color: currentColor; width: 1em; height: 1em; } .i-logos-feathersjs { background: url("data:image/svg+xml;utf8,%3Csvg preserveAspectRatio='xMidYMid meet' viewBox='0 0 256 256' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='%23333' d='M128 9.102c65.665 0 118.898 53.233 118.898 118.898c0 65.665-53.233 118.898-118.898 118.898C62.335 246.898 9.102 193.665 9.102 128C9.102 62.335 62.335 9.102 128 9.102M128 0C57.421 0 0 57.421 0 128c0 70.579 57.421 128 128 128c70.579 0 128-57.421 128-128C256 57.421 198.579 0 128 0m20.83 25.524c-10.43-1.896-35.651 36.409-43.994 59.734c-.634 1.769-2.086 8.249-2.086 9.955c0 0 6.531 14.055 8.343 17.351c-3.034-1.58-9.323-13.756-9.323-13.756c-3.034 5.784-5.942 32.34-4.994 37.271c0 0 6.762 10.062 9.387 12.578c-3.603-1.201-9.671-9.355-9.671-9.355c-1.138 3.508-.916 10.807-.379 13.274c4.551 6.637 10.619 7.396 10.619 7.396s-6.637 66.181 3.413 71.111c6.258-1.327 7.775-73.956 7.775-73.956s7.585.569 9.292-1.327c3.856-2.655 12.826-30.224 12.958-34.202c0 0-10.41 1.952-15.487 3.924c3.826-3.8 16.049-6.352 16.049-6.352c3.315-3.979 10.291-31.047 10.994-39.391c.176-2.093.583-4.657.268-8.398c0 0-9.941 2.177-12.014 1.424c2.104-.237 12.263-4.14 12.263-4.14c1.801-16.213 2.358-42.091-3.413-43.141Zm-36.38 171.691c-.795 19.496-1.294 25.004-2.115 29.601c-.379.857-.758.997-1.138-.095c-3.477-15.992-3.224-136.438 36.409-191.241c-23.05 42.092-33.535 122.861-33.156 161.735Z'/%3E%3C/svg%3E") no-repeat; background-size: 100% 100%; background-color: transparent; width: 1em; height: 1em; } /* layer: default */ .relative { position: relative; } .mx-auto { margin-left: auto; margin-right: auto; } .my-5 { margin-top: 1.25rem; margin-bottom: 1.25rem; } .ml-2 { margin-left: 0.5rem; } .mt-0 { margin-top: 0rem; } .mt-6 { margin-top: 1.5rem; } .block { display: block; } .h-10 { height: 2.5rem; } .h-2\.2 { height: 0.55rem; } .h-32 { height: 8rem; } .h-full { height: 100%; } .max-w-sm { max-width: 24rem; } .min-h-screen { min-height: 100vh; } .w-10 { width: 2.5rem; } .w-2\.2 { width: 0.55rem; } .w-32 { width: 8rem; } .w-4 { width: 1rem; } .w-6 { width: 1.5rem; } .w-60 { width: 15rem; } .w-full { width: 100%; } .flex { display: flex; } .flex-grow { flex-grow: 1; } .flex-row { flex-direction: row; } .flex-col { flex-direction: column; } .cursor-pointer { cursor: pointer; } .items-center { align-items: center; } .justify-start { justify-content: flex-start; } .justify-center { justify-content: center; } .overflow-hidden { overflow: hidden; } .overflow-y-auto { overflow-y: auto; } .border-2 { border-width: 2px; border-style: solid; } .border-neutral { border-color: hsla(var(--n)); } .rounded { border-radius: 0.25rem; } .bg-neutral { background-color: hsla(var(--n)); } .from-orange-500 { --un-gradient-from: rgba(249, 115, 22, var(--un-from-opacity, 1)); --un-gradient-to: rgba(249, 115, 22, 0); --un-gradient-stops: var(--un-gradient-from), var(--un-gradient-to); } .to-red-900 { --un-gradient-to: rgba(127, 29, 29, var(--un-to-opacity, 1)); } .bg-gradient-to-br { --un-gradient-shape: to bottom right; --un-gradient: var(--un-gradient-shape), var(--un-gradient-stops); background-image: linear-gradient(var(--un-gradient)); } .bg-clip-text { -webkit-background-clip: text; background-clip: text; } .p-0 { padding: 0rem; } .p-2 { padding: 0.5rem; } .px-3 { padding-left: 0.75rem; padding-right: 0.75rem; } .px-4 { padding-left: 1rem; padding-right: 1rem; } .py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; } .py-8 { padding-top: 2rem; padding-bottom: 2rem; } .pb-3 { padding-bottom: 0.75rem; } .pt-2 { padding-top: 0.5rem; } .text-center { text-align: center; } .text-5xl { font-size: 3rem; line-height: 1; } .text-lg { font-size: 1.125rem; line-height: 1.75rem; } .text-sm { font-size: 0.875rem; line-height: 1.25rem; } .text-xl { font-size: 1.25rem; line-height: 1.75rem; } .text-xs { font-size: 0.75rem; line-height: 1rem; } .font-bold { font-weight: 700; } .font-light { font-weight: 300; } .leading-4 { line-height: 1rem; } .tracking-tight { letter-spacing: -0.025em; } .text-error { color: hsla(var(--er)); } .text-transparent { color: transparent; } .shadow-xl { --un-shadow: var(--un-shadow-inset) 0 20px 25px -5px var(--un-shadow-color, rgba(0, 0, 0, 0.1)), var(--un-shadow-inset) 0 8px 10px -6px var(--un-shadow-color, rgba(0, 0, 0, 0.1)); box-shadow: var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow); } .invert { --un-invert: invert(1); filter: var(--un-blur) var(--un-brightness) var(--un-contrast) var(--un-drop-shadow) var(--un-grayscale) var(--un-hue-rotate) var(--un-invert) var(--un-saturate) var(--un-sepia); } .transition-colors { transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; } .duration-300 { transition-duration: 300ms; } @media (min-width: 640px) { .sm\:mt-1\.5 { margin-top: 0.375rem; } .sm\:h-12 { height: 3rem; } .sm\:w-12 { width: 3rem; } } @media (min-width: 768px) { .md\:leading-5 { line-height: 1.25rem; } } @media (min-width: 1024px) { .lg\:hidden { display: none; } } ================================================ FILE: docs/public/robots.txt ================================================ User-agent: * Allow: / ================================================ FILE: docs/tsconfig.json ================================================ { "compilerOptions": { "target": "esnext", "module": "esnext", "lib": ["esnext", "dom"], "moduleResolution": "node", "esModuleInterop": true, "strict": true, "strictNullChecks": true, "resolveJsonModule": true, "skipDefaultLibCheck": true, "skipLibCheck": true, "outDir": "./dist", "declaration": true, "inlineSourceMap": true, "paths": { "@vitest/ws-client": ["./packages/ws-client/src/index.ts"], "@vitest/ui": ["./packages/ui/node/index.ts"], "#types": ["./packages/vitest/src/index.ts"], "~/*": ["./packages/ui/client/*"], "vitest": ["./packages/vitest/src/index.ts"], "vitest/globals": ["./packages/vitest/globals.d.ts"], "vitest/node": ["./packages/vitest/src/node/index.ts"], "vitest/config": ["./packages/vitest/src/config.ts"], "vite-node": ["./packages/vite-node/src/index.ts"], "vite-node/client": ["./packages/vite-node/src/client.ts"], "vite-node/server": ["./packages/vite-node/src/server.ts"], "vite-node/utils": ["./packages/vite-node/src/utils.ts"] }, "types": [ "vite/client" ] }, "exclude": [ "**/dist/**", "./packages/vitest/dist/**", "./packages/ui/client/**", "./examples/**/*.*", "./bench/**" ] } ================================================ FILE: docs/vite.config.ts ================================================ import fs from 'fs' import type { Plugin } from 'vite' import { defineConfig } from 'vite' import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' import Unocss from 'unocss/vite' import transformerDirective from '@unocss/transformer-directives' import { presetAttributify, presetIcons, presetUno, presetTypography } from 'unocss' import { resolve } from 'pathe' import type { VitePluginPWAAPI } from 'vite-plugin-pwa' import { VitePWA } from 'vite-plugin-pwa' import fg from 'fast-glob' import { pwaFontStylesRegex, pwaFontsRegex, feathersDescription, feathersName, feathersShortName } from './.vitepress/meta' import { optimizePages } from './.vitepress/scripts/assets' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' import { SearchPlugin } from 'vitepress-plugin-search' const PWA = VitePWA({ outDir: '.vitepress/dist', registerType: 'autoUpdate', // include all static assets under public/ includeAssets: fg.sync('**/*.{png,svg,ico,txt}', { cwd: resolve(__dirname, 'public') }), manifest: { id: '/', name: feathersName, short_name: feathersShortName, description: feathersDescription, theme_color: '#ffffff', icons: [ { src: 'pwa-192x192.png', sizes: '192x192', type: 'image/png' }, { src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png' }, { src: 'logo.svg', sizes: '165x165', type: 'image/svg', purpose: 'any maskable' } ] }, workbox: { navigateFallbackDenylist: [/^\/new$/], runtimeCaching: [ { urlPattern: pwaFontsRegex, handler: 'CacheFirst', options: { cacheName: 'google-fonts-cache', expiration: { maxEntries: 10, maxAgeSeconds: 60 * 60 * 24 * 365 // <== 365 days }, cacheableResponse: { statuses: [0, 200] } } }, { urlPattern: pwaFontStylesRegex, handler: 'CacheFirst', options: { cacheName: 'gstatic-fonts-cache', expiration: { maxEntries: 10, maxAgeSeconds: 60 * 60 * 24 * 365 // <== 365 days }, cacheableResponse: { statuses: [0, 200] } } } ] } }) export default defineConfig({ plugins: [ SearchPlugin(), AutoImport({ resolvers: [ElementPlusResolver()] }), Components({ include: [/\.vue/, /\.md/], dirs: '.vitepress/components', dts: '.vitepress/components.d.ts', resolvers: [ElementPlusResolver({ ssr: false })] }), Unocss({ shortcuts: [ [ 'btn', 'px-4 py-1 rounded inline-flex justify-center gap-2 text-white leading-30px children:mya !no-underline cursor-pointer disabled:cursor-default disabled:bg-gray-600 disabled:opacity-50' ] ], presets: [ presetUno({ dark: 'media' }), presetAttributify(), presetIcons({ scale: 1.2 }), presetTypography() ], transformers: [transformerDirective()] }), IncludesPlugin(), PWA, { name: 'pwa:post', enforce: 'post', async buildEnd() { const pwaPlugin: VitePluginPWAAPI = PWA.find((i) => i.name === 'vite-plugin-pwa')?.api const pwa = pwaPlugin && !pwaPlugin.disabled await optimizePages(pwa) if (pwa) await pwaPlugin.generateSW() } } ], ssr: { noExternal: ['element-plus'] } }) function IncludesPlugin(): Plugin { return { name: 'include-plugin', enforce: 'pre', transform(code, id) { let changed = false code = code.replace(/\[@@include\]\((.*?)\)/, (_, url) => { changed = true const full = resolve(id, url) return fs.readFileSync(full, 'utf-8') }) if (changed) return code } } } ================================================ FILE: generators/package/index.tpl.ts ================================================ import { generator, renderTemplate, toFile } from '@featherscloud/pinion' import { ModuleContext } from '../package' interface Context extends ModuleContext {} const template = ({ name }: Context) => ` export function ${name}() { return 'Hello from ${name}' } ` export const generate = (context: Context) => generator(context).then(renderTemplate(template, toFile(context.packagePath, 'src', 'index.ts'))) ================================================ FILE: generators/package/license.tpl.ts ================================================ import { generator, renderTemplate, toFile } from '@featherscloud/pinion' import { ModuleContext } from '../package' interface Context extends ModuleContext {} export const generate = (context: Context) => generator(context).then( renderTemplate( `The MIT License (MIT) Copyright (c) ${new Date().getFullYear()} Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. `, toFile(context.packagePath, 'LICENSE') ) ) ================================================ FILE: generators/package/package.json.tpl.ts ================================================ import { generator, toFile, writeJSON } from '@featherscloud/pinion' import { ModuleContext } from '../package' interface Context extends ModuleContext {} export const generate = (context: Context) => generator(context).then( writeJSON( ({ moduleName, description, name }) => ({ name: moduleName, description, version: '0.0.0', homepage: 'https://feathersjs.com', keywords: ['feathers'], license: 'MIT', repository: { type: 'git', url: 'git://github.com/feathersjs/feathers.git', directory: `packages/${name}` }, author: { name: 'Feathers contributor', email: 'hello@feathersjs.com', url: 'https://feathersjs.com' }, contributors: [], bugs: { url: 'https://github.com/feathersjs/feathers/issues' }, engines: { node: '>= 20' }, files: ['CHANGELOG.md', 'LICENSE', 'README.md', 'src/**', 'lib/**', 'esm/**'], // module: './esm/index.js', main: './lib/index.js', types: './src/index.ts', exports: { '.': { // import: './esm/index.js', require: './lib/index.js', types: './src/index.ts' } }, scripts: { prepublish: 'npm run compile', pack: 'npm pack --pack-destination ../generators/test/build', compile: 'shx rm -rf lib/ && tsc && npm run pack', test: 'mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts' }, publishConfig: { access: 'public' }, dependencies: {}, devDependencies: {} }), toFile('packages', context.name, 'package.json') ) ) ================================================ FILE: generators/package/readme.md.tpl.ts ================================================ import { generator, renderTemplate, toFile } from '@featherscloud/pinion' import { ModuleContext } from '../package' const template = ({ description, moduleName }: ModuleContext) => `# ${moduleName} [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/${moduleName}.svg?style=flat-square)](https://www.npmjs.com/package/${moduleName}) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > ${description} ## Installation \`\`\` npm install ${moduleName} --save \`\`\` ## Documentation Refer to the [Feathers API documentation](https://feathersjs.com/api) for more details. ## License Copyright (c) ${new Date().getFullYear()} [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ` export const generate = (context: ModuleContext) => generator(context).then(renderTemplate(template, toFile(context.packagePath, 'README.md'))) ================================================ FILE: generators/package/test.tpl.ts ================================================ import { generator, renderTemplate, toFile } from '@featherscloud/pinion' import { ModuleContext } from '../package' interface Context extends ModuleContext {} const template = ({ moduleName, name }: Context) => /** ts */ `import { strict as assert } from 'assert' import { ${name} } from '../src/index' describe('${moduleName}', () => { it('initializes', () => { assert.equal(${name}(), 'Hello from ${name}') }) }) ` export const generate = (context: Context) => generator(context).then( renderTemplate(template, toFile(context.packagePath, 'test', 'index.test.ts')) ) ================================================ FILE: generators/package/tsconfig.json.tpl.ts ================================================ import { generator, toFile, writeJSON } from '@featherscloud/pinion' import { ModuleContext } from '../package' export const generate = (context: ModuleContext) => generator(context).then( writeJSON( { extends: '../../tsconfig', include: ['src/**/*.ts'], compilerOptions: { outDir: 'lib' } }, toFile(context.packagePath, 'tsconfig.json') ) ) ================================================ FILE: generators/package.ts ================================================ import type { Callable, PinionContext } from '@featherscloud/pinion' import { generator, install, prompt, runGenerators, toFile } from '@featherscloud/pinion' export interface ModuleContext extends PinionContext { name: string uppername: string description: string moduleName: string packagePath: Callable } export const generate = (context: ModuleContext) => generator(context) .then( prompt([ { type: 'input', name: 'name', message: 'What is the name of the module?' }, { type: 'input', name: 'description', message: 'Write a short description' } ]) ) .then((ctx) => { return { ...ctx, moduleName: `@feathersjs/${ctx.name}`, uppername: ctx.name.charAt(0).toUpperCase() + ctx.name.slice(1), packagePath: toFile('packages', ctx.name) } }) .then(runGenerators(__dirname, 'package')) .then( install( ['@types/node', 'shx', 'ts-node', 'typescript', 'mocha'], true, (context) => `npm --workspace packages/${context.name}` ) ) ================================================ FILE: lerna.json ================================================ { "ci": false, "packages": ["packages/*"], "version": "5.0.42", "command": { "bootstrap": { "hoist": true }, "publish": { "allowBranch": ["crow", "dove"], "message": "chore(release): publish %s", "conventionalCommits": true, "createRelease": "github" } }, "ignoreChanges": [ "**/changelog.md", "**/CHANGELOG.md", "**/package-lock.json", "**/yarn.lock", "**/test/**", "lerna.json", "readme.md" ] } ================================================ FILE: package.json ================================================ { "name": "@feathersjs/feathers", "private": true, "homepage": "http://feathersjs.com", "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git" }, "author": { "name": "Feathers contributor", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 20" }, "workspaces": [ "docs", "packages/*" ], "scripts": { "publish": "lerna publish --force-publish && git commit -am \"chore: Update changelog\" && git push origin", "publish:major": "lerna publish major && git commit -am \"chore: Update changelog\" && git push origin", "publish:minor": "lerna publish minor && git commit -am \"chore: Update changelog\" && git push origin", "publish:patch": "lerna publish patch && git commit -am \"chore: Update changelog\" && git push origin", "publish:premajor": "lerna publish premajor --preid pre --pre-dist-tag pre && git commit -am \"chore: Update version and changelog\" && git push origin", "publish:prerelease": "lerna publish prerelease --preid pre --pre-dist-tag pre --dist-tag pre --force-publish && git commit -am \"chore: Update version and changelog\" && git push origin", "prettier": "npx prettier \"packages/{,!(node_modules)/**/(src|test)/**/}*.ts\" --write", "eslint": "eslint \"packages/**/*.ts\" --fix", "lint": "npm run prettier && npm run eslint", "compile": "lerna run compile", "build:docs": "npm run build --workspace docs", "update-dependencies": "npm exec --workspaces --include-workspace-root -- ncu -u --dep prod,dev,optional,peer -x node-fetch,\"@sinclair/typebox\",\"@types/express\",\"@types/express-serve-static-core\",commander,express,flexsearch,uuid,mongodb", "clean": "find . -name node_modules -exec rm -rf '{}' + && find . -name package-lock.json -exec rm -rf '{}' +", "test:deno": "deno test --config deno/tsconfig.json deno/test.ts", "test": "npm run lint && npm run compile && c8 lerna run test --ignore @feathersjs/tests", "generate:package": "pinion run generators/package.ts" }, "devDependencies": { "@featherscloud/pinion": "^0.5.4", "@typescript-eslint/eslint-plugin": "^7.8.0", "@typescript-eslint/parser": "^7.8.0", "c8": "^9.1.0", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", "lerna": "^8.1.2", "npm-check-updates": "^16.14.20", "prettier": "^3.2.5", "typescript": "^5.4.5" } } ================================================ FILE: packages/adapter-commons/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) ### Bug Fixes - **adapter-commons:** Faster sorter ([#3495](https://github.com/feathersjs/feathers/issues/3495)) ([22243e4](https://github.com/feathersjs/feathers/commit/22243e4d92edc1a7343b4cf42be6dfb22e8b86d5)) ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/adapter-commons ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) ### Bug Fixes - **core:** Add PaginationParams to general find method ([#3095](https://github.com/feathersjs/feathers/issues/3095)) ([8ebdcf5](https://github.com/feathersjs/feathers/commit/8ebdcf5107fae5fa23920390052b871033de3a0a)) - **core:** Use Symbol.for to instantiate shared symbols ([#3087](https://github.com/feathersjs/feathers/issues/3087)) ([7f3fc21](https://github.com/feathersjs/feathers/commit/7f3fc2167576f228f8183568eb52b077160e8d65)) # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) ### Features - **mongodb:** Add Object ID keyword converter and update MongoDB CLI & docs ([#3041](https://github.com/feathersjs/feathers/issues/3041)) ([ca0994e](https://github.com/feathersjs/feathers/commit/ca0994eaecb5a31f310bc980d106834e11f24f41)) # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - **databases:** Ensure that query sanitization is not necessary when using query schemas ([#3022](https://github.com/feathersjs/feathers/issues/3022)) ([dbf514e](https://github.com/feathersjs/feathers/commit/dbf514e85d1508b95c007462a39b3cadd4ff391d)) ### Features - **database:** Add and to the query syntax ([#3021](https://github.com/feathersjs/feathers/issues/3021)) ([00cb0d9](https://github.com/feathersjs/feathers/commit/00cb0d9c302ae951ae007d3d6ceba33e254edd9c)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Bug Fixes - **adapter-commons:** multiple type definition issues ([#2876](https://github.com/feathersjs/feathers/issues/2876)) ([4ff1ed0](https://github.com/feathersjs/feathers/commit/4ff1ed084eb2b2cb687de27a28c96a0dad4530b7)) ### Features - **adapter:** Add patch data type to adapters and refactor AdapterBase usage ([#2906](https://github.com/feathersjs/feathers/issues/2906)) ([9ddc2e6](https://github.com/feathersjs/feathers/commit/9ddc2e6b028f026f939d6af68125847e5c6734b4)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Features - **knex:** Add KnexJS SQL database adapter to core ([#2671](https://github.com/feathersjs/feathers/issues/2671)) ([9380fff](https://github.com/feathersjs/feathers/commit/9380fff58596e8bb90b8bb098d2795b7eadfec20)) # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Bug Fixes - **adapter-commons:** Clarify adapter query filtering ([#2607](https://github.com/feathersjs/feathers/issues/2607)) ([2dac771](https://github.com/feathersjs/feathers/commit/2dac771b0a3298d6dd25994d05186701b0617718)) ### Features - **mongodb:** Add feathers-mongodb adapter as @feathersjs/mongodb ([#2610](https://github.com/feathersjs/feathers/issues/2610)) ([6d43734](https://github.com/feathersjs/feathers/commit/6d43734a53db02c435cafc52a22dca414e5d0940)) - **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5)) - **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28)) ### BREAKING CHANGES - **adapter-commons:** Changes the common adapter base class to use `sanitizeQuery` and `sanitizeData` # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) ### Features - **core:** Add app.teardown functionality ([#2570](https://github.com/feathersjs/feathers/issues/2570)) ([fcdf524](https://github.com/feathersjs/feathers/commit/fcdf524ae1995bb59265d39f12e98b7794bed023)) - **core:** Finalize app.teardown() functionality ([#2584](https://github.com/feathersjs/feathers/issues/2584)) ([1a166f3](https://github.com/feathersjs/feathers/commit/1a166f3ded811ecacf0ae8cb67880bc9fa2eeafa)) # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Bug Fixes - **adapter-commons:** clean up in sort.ts and select function ([#2492](https://github.com/feathersjs/feathers/issues/2492)) ([c3ec8a4](https://github.com/feathersjs/feathers/commit/c3ec8a418bdc85506e3c5100015720a45454d8d3)) - **adapter-commons:** Fix sorting for embedded objects ([#2488](https://github.com/feathersjs/feathers/issues/2488)) ([9c22f70](https://github.com/feathersjs/feathers/commit/9c22f70a838cb6341775d91705a7527c8fc5590e)) - **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Bug Fixes - Update database adapter common repository urls ([#2380](https://github.com/feathersjs/feathers/issues/2380)) ([3f4db68](https://github.com/feathersjs/feathers/commit/3f4db68d6700c7d9023ecd17d0d39893f75a19fd)) ### Features - **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f)) - **typescript:** Allow to pass generic service options to adapter services ([#2392](https://github.com/feathersjs/feathers/issues/2392)) ([f9431f2](https://github.com/feathersjs/feathers/commit/f9431f242354f804cafb835519f98dd405ac4f0b)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) ### Bug Fixes - **typescript:** Move Paginated type back for better compatibility ([#2350](https://github.com/feathersjs/feathers/issues/2350)) ([2917d05](https://github.com/feathersjs/feathers/commit/2917d05fffb4716d3c4cdaa5ac6a1aee0972e8a6)) # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/adapter-commons # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) ### Bug Fixes - **dependencies:** Fix transport-commons dependency and update other dependencies ([#2284](https://github.com/feathersjs/feathers/issues/2284)) ([05b03b2](https://github.com/feathersjs/feathers/commit/05b03b27b40604d956047e3021d8053c3a137616)) ### Features - **adapter-commons:** Added mongoDB like search in embedded objects ([687e3c7](https://github.com/feathersjs/feathers/commit/687e3c7c36904221b2707d0220c0893e3cb1faa9)) # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - **adapter-commons:** Always respect paginate.max ([#2267](https://github.com/feathersjs/feathers/issues/2267)) ([f588257](https://github.com/feathersjs/feathers/commit/f5882575536624ed3a32bb6e3ff1919fa17e366d)) - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) - **adapter-commons:** Return missing overloads ([#2203](https://github.com/feathersjs/feathers/issues/2203)) ([bbe7e2a](https://github.com/feathersjs/feathers/commit/bbe7e2a131633e9a6e7aac7f7fa02a312bca63c7)) ### Features - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) ### Features - **memory:** Move feathers-memory into @feathersjs/memory ([#2153](https://github.com/feathersjs/feathers/issues/2153)) ([dd61fe3](https://github.com/feathersjs/feathers/commit/dd61fe371fb0502f78b8ccbe1f45a030e31ecff6)) ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) **Note:** Version bump only for package @feathersjs/adapter-commons ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-10-21) ### Bug Fixes - **typescript:** Remove remaining overloads ([a29fabc](https://github.com/feathersjs/databases/commit/a29fabc9cf6050793a5e93948507ce3e19a235dd)) ## [4.5.6](https://github.com/feathersjs/feathers/compare/v4.5.5...v4.5.6) (2020-10-21) ### Bug Fixes - Revert "fix(adapter-commons): Add missing overloads ([#4](https://github.com/feathersjs/databases/issues/4))" ([dfaa850](https://github.com/feathersjs/databases/commit/dfaa8500644021f78d6234a79358f1b26ce2c8d3)) ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-10-21) ### Bug Fixes - **typescript:** Revert "fix: add overloads for `find` ([#9](https://github.com/feathersjs/databases/issues/9))" ([85c20b2](https://github.com/feathersjs/databases/commit/85c20b267e67192169ded97dd5056f116a5ad7b5)) ## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-09-27) **Note:** Version bump only for package @feathersjs/adapter-commons ## 4.5.3 (2020-09-24) ### Bug Fixes - add overloads for `find` ([#9](https://github.com/feathersjs/databases/issues/9)) ([87c7c29](https://github.com/feathersjs/databases/commit/87c7c29ef017b3cae135e7b7597a7e63fb7d0961)) - **adapter-commons:** Add missing overloads ([#4](https://github.com/feathersjs/databases/issues/4)) ([b6c80ff](https://github.com/feathersjs/databases/commit/b6c80ff39a32c1b023178f06cffbcaa6d08c554d)) - Improve Service typings for DB Common API ([#1](https://github.com/feathersjs/databases/issues/1)) ([fd3b949](https://github.com/feathersjs/databases/commit/fd3b9496b0a46f8fd9779c2603faeeb92bd1afc1)) ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) **Note:** Version bump only for package @feathersjs/adapter-commons ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/adapter-commons # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) **Note:** Version bump only for package @feathersjs/adapter-commons ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) ### Bug Fixes - **adapter-commons:** Filter arrays in queries ([#1724](https://github.com/feathersjs/feathers/issues/1724)) ([872b669](https://github.com/feathersjs/feathers/commit/872b66906a806ab92ca41b5f6f504ff0af1ce79e)) ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/adapter-commons # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) **Note:** Version bump only for package @feathersjs/adapter-commons ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) **Note:** Version bump only for package @feathersjs/adapter-commons ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/adapter-commons ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) **Note:** Version bump only for package @feathersjs/adapter-commons ## [4.3.8](https://github.com/feathersjs/feathers/compare/v4.3.7...v4.3.8) (2019-10-14) ### Bug Fixes - Remove adapter commons type alternatives ([#1620](https://github.com/feathersjs/feathers/issues/1620)) ([c9f3086](https://github.com/feathersjs/feathers/commit/c9f3086344420b57dbce7c4169cf550c97509f0d)) ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) ### Bug Fixes - improve Service and AdapterService types ([#1567](https://github.com/feathersjs/feathers/issues/1567)) ([baad6a2](https://github.com/feathersjs/feathers/commit/baad6a26f0f543b712ccb40359b3933ad3a21392)) ## [4.3.6](https://github.com/feathersjs/feathers/compare/v4.3.5...v4.3.6) (2019-10-07) ### Bug Fixes - Check query for NaN ([#1607](https://github.com/feathersjs/feathers/issues/1607)) ([f1a781f](https://github.com/feathersjs/feathers/commit/f1a781f)) ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) **Note:** Version bump only for package @feathersjs/adapter-commons ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) **Note:** Version bump only for package @feathersjs/adapter-commons ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) **Note:** Version bump only for package @feathersjs/adapter-commons ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) **Note:** Version bump only for package @feathersjs/adapter-commons # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/adapter-commons # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/adapter-commons # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) ### Bug Fixes - Update all dependencies ([7d53a00](https://github.com/feathersjs/feathers/commit/7d53a00)) # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) ### Bug Fixes - @feathersjs/adapter-commons: `update` id is non-nullable ([#1468](https://github.com/feathersjs/feathers/issues/1468)) ([43ec802](https://github.com/feathersjs/feathers/commit/43ec802)) # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/adapter-commons # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) **Note:** Version bump only for package @feathersjs/adapter-commons # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) ### Bug Fixes - @feathersjs/adapter-commons: remove data from `remove` arguments ([#1426](https://github.com/feathersjs/feathers/issues/1426)) ([fd54ae9](https://github.com/feathersjs/feathers/commit/fd54ae9)) ### Features - adapter-commons: add `allowsMulti(method)` to AdapterService ([#1431](https://github.com/feathersjs/feathers/issues/1431)) ([e688851](https://github.com/feathersjs/feathers/commit/e688851)) - Add hook-less methods and service option types to adapter-commons ([#1433](https://github.com/feathersjs/feathers/issues/1433)) ([857f54a](https://github.com/feathersjs/feathers/commit/857f54a)) # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) **Note:** Version bump only for package @feathersjs/adapter-commons # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) **Note:** Version bump only for package @feathersjs/adapter-commons # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) - **adapter-commons:** Keep Symbols when filtering a query ([#1141](https://github.com/feathersjs/feathers/issues/1141)) ([c9f55d8](https://github.com/feathersjs/feathers/commit/c9f55d8)) - **chore:** Add .npmignore to adapter-commons ([8e129d8](https://github.com/feathersjs/feathers/commit/8e129d8)) - Add whitelist and filter support to common adapter service ([#1132](https://github.com/feathersjs/feathers/issues/1132)) ([df1daaa](https://github.com/feathersjs/feathers/commit/df1daaa)) - Fix AdapterService multi option when set to true ([#1134](https://github.com/feathersjs/feathers/issues/1134)) ([40402fc](https://github.com/feathersjs/feathers/commit/40402fc)) - Throw error in `filterQuery` when query parameter is unknown ([#1131](https://github.com/feathersjs/feathers/issues/1131)) ([cd1a183](https://github.com/feathersjs/feathers/commit/cd1a183)) - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) - Update adapter common tests to check for falsy ([#1140](https://github.com/feathersjs/feathers/issues/1140)) ([2856722](https://github.com/feathersjs/feathers/commit/2856722)) ### chore - **package:** Move adapter tests into their own module ([#1164](https://github.com/feathersjs/feathers/issues/1164)) ([dcc1e6b](https://github.com/feathersjs/feathers/commit/dcc1e6b)) ### Features - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - Authentication v3 core server implementation ([#1205](https://github.com/feathersjs/feathers/issues/1205)) ([1bd7591](https://github.com/feathersjs/feathers/commit/1bd7591)) - Common database adapter utilities and test suite ([#1130](https://github.com/feathersjs/feathers/issues/1130)) ([17b3dc8](https://github.com/feathersjs/feathers/commit/17b3dc8)) ### BREAKING CHANGES - **package:** Removes adapter tests from @feathersjs/adapter-commons - Move database adapter utilities from @feathersjs/commons into its own module # [2.0.0](https://github.com/feathersjs/feathers/compare/@feathersjs/adapter-commons@1.0.7...@feathersjs/adapter-commons@2.0.0) (2019-01-10) ### chore - **package:** Move adapter tests into their own module ([#1164](https://github.com/feathersjs/feathers/issues/1164)) ([dcc1e6b](https://github.com/feathersjs/feathers/commit/dcc1e6b)) ### BREAKING CHANGES - **package:** Removes adapter tests from @feathersjs/adapter-commons ## [1.0.7](https://github.com/feathersjs/feathers/compare/@feathersjs/adapter-commons@1.0.6...@feathersjs/adapter-commons@1.0.7) (2019-01-02) ### Bug Fixes - **chore:** Add .npmignore to adapter-commons ([8e129d8](https://github.com/feathersjs/feathers/commit/8e129d8)) ## [1.0.6](https://github.com/feathersjs/feathers/compare/@feathersjs/adapter-commons@1.0.5...@feathersjs/adapter-commons@1.0.6) (2018-12-21) ### Bug Fixes - **adapter-commons:** Keep Symbols when filtering a query ([#1141](https://github.com/feathersjs/feathers/issues/1141)) ([c9f55d8](https://github.com/feathersjs/feathers/commit/c9f55d8)) ## [1.0.5](https://github.com/feathersjs/feathers/compare/@feathersjs/adapter-commons@1.0.4...@feathersjs/adapter-commons@1.0.5) (2018-12-20) ### Bug Fixes - Update adapter common tests to check for falsy ([#1140](https://github.com/feathersjs/feathers/issues/1140)) ([2856722](https://github.com/feathersjs/feathers/commit/2856722)) ## [1.0.4](https://github.com/feathersjs/feathers/compare/@feathersjs/adapter-commons@1.0.3...@feathersjs/adapter-commons@1.0.4) (2018-12-17) ### Bug Fixes - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) ## [1.0.3](https://github.com/feathersjs/feathers/compare/@feathersjs/adapter-commons@1.0.2...@feathersjs/adapter-commons@1.0.3) (2018-12-17) ### Bug Fixes - Fix AdapterService multi option when set to true ([#1134](https://github.com/feathersjs/feathers/issues/1134)) ([40402fc](https://github.com/feathersjs/feathers/commit/40402fc)) ## [1.0.2](https://github.com/feathersjs/feathers/compare/@feathersjs/adapter-commons@1.0.1...@feathersjs/adapter-commons@1.0.2) (2018-12-17) ### Bug Fixes - Add whitelist and filter support to common adapter service ([#1132](https://github.com/feathersjs/feathers/issues/1132)) ([df1daaa](https://github.com/feathersjs/feathers/commit/df1daaa)) ## [1.0.1](https://github.com/feathersjs/feathers/compare/@feathersjs/adapter-commons@1.0.0...@feathersjs/adapter-commons@1.0.1) (2018-12-17) ### Bug Fixes - Throw error in `filterQuery` when query parameter is unknown ([#1131](https://github.com/feathersjs/feathers/issues/1131)) ([cd1a183](https://github.com/feathersjs/feathers/commit/cd1a183)) # 1.0.0 (2018-12-16) ### Features - Common database adapter utilities and test suite ([#1130](https://github.com/feathersjs/feathers/issues/1130)) ([17b3dc8](https://github.com/feathersjs/feathers/commit/17b3dc8)) ### BREAKING CHANGES - Move database adapter utilities from @feathersjs/commons into its own module ================================================ FILE: packages/adapter-commons/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/adapter-commons/README.md ================================================ # Feathers Adapter Commons [![CI](https://github.com/feathersjs/feathers/workflows/Node.js%20CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3A%22Node.js+CI%22) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/adapter-commons.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/adapter-commons) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > Shared utility functions for Feathers adatabase adapters ## Installation ``` npm install @feathersjs/adapter-commons --save ``` ## Documentation Refer to the [Feathers database adapter documentation](https://feathersjs.com/api/databases/common.html) for more details. ## Authors [Feathers contributors](https://github.com/feathersjs/adapter-commons/graphs/contributors) ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/adapter-commons/package.json ================================================ { "name": "@feathersjs/adapter-commons", "version": "5.0.42", "description": "Shared database adapter utility functions", "homepage": "https://feathersjs.com", "keywords": [ "feathers" ], "license": "MIT", "funding": { "type": "opencollective", "url": "https://opencollective.com/feathers" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/adapter-commons" }, "author": { "name": "Feathers contributor", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "main": "lib/", "types": "lib/", "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**" ], "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/commons": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/feathers": "^5.0.42" }, "devDependencies": { "@types/mocha": "^10.0.10", "@types/mongodb": "^4.0.6", "@types/node": "^25.3.3", "mocha": "^11.7.5", "mongodb": "^6.19.0", "shx": "^0.4.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/adapter-commons/src/declarations.ts ================================================ import { Query, Params, Paginated, Id, PaginationParams, PaginationOptions } from '@feathersjs/feathers' export type FilterQueryOptions = { filters?: FilterSettings operators?: string[] paginate?: PaginationParams } export type QueryFilter = (value: any, options: FilterQueryOptions) => any export type FilterSettings = { [key: string]: QueryFilter | true } // re-export from @feathersjs/feathers to prevent breaking changes export { PaginationOptions, PaginationParams } export interface AdapterServiceOptions { /** * Whether to allow multiple updates for everything (`true`) or specific methods (e.g. `['create', 'remove']`) */ multi?: boolean | string[] /** * The name of the id property */ id?: string /** * Pagination settings for this service */ paginate?: PaginationParams /** * A list of additional property query operators to allow in a query * * @deprecated No longer needed when a query schema is used */ operators?: string[] /** * An object of additional top level query filters, e.g. `{ $populate: true }` * Can also be a converter function like `{ $ignoreCase: (value) => value === 'true' ? true : false }` * * @deprecated No longer needed when a query schema is used */ filters?: FilterSettings /** * @deprecated Use service `events` option when registering the service with `app.use`. */ events?: string[] /** * @deprecated No longer needed when a query schema is used */ whitelist?: string[] } export interface AdapterQuery extends Query { $limit?: number $skip?: number $select?: string[] $sort?: { [key: string]: 1 | -1 } } /** * Additional `params` that can be passed to an adapter service method call. */ export interface AdapterParams< Q = AdapterQuery, A extends Partial = Partial > extends Params { adapter?: A paginate?: PaginationParams } /** * Hook-less (internal) service methods. Directly call database adapter service methods * without running any service-level hooks or sanitization. This can be useful if you need the raw data * from the service and don't want to trigger any of its hooks. * * Important: These methods are only available internally on the server, not on the client * side and only for the Feathers database adapters. * * These methods do not trigger events. * * @see {@link https://docs.feathersjs.com/guides/migrating.html#hook-less-service-methods} */ export interface InternalServiceMethods< Result = any, Data = Result, PatchData = Partial, Params extends AdapterParams = AdapterParams, IdType = Id > { /** * Retrieve all resources from this service. * Does not sanitize the query and should only be used on the server. * * @param _params - Service call parameters {@link Params} */ _find(_params?: Params & { paginate?: PaginationOptions }): Promise> _find(_params?: Params & { paginate: false }): Promise _find(params?: Params): Promise> /** * Retrieve a single resource matching the given ID, skipping any service-level hooks. * Does not sanitize the query and should only be used on the server. * * @param id - ID of the resource to locate * @param params - Service call parameters {@link Params} * @see {@link HookLessServiceMethods} * @see {@link https://docs.feathersjs.com/api/services.html#get-id-params|Feathers API Documentation: .get(id, params)} */ _get(id: IdType, params?: Params): Promise /** * Create a new resource for this service, skipping any service-level hooks. * Does not sanitize data or checks if multiple updates are allowed and should only be used on the server. * * @param data - Data to insert into this service. * @param params - Service call parameters {@link Params} * @see {@link HookLessServiceMethods} * @see {@link https://docs.feathersjs.com/api/services.html#create-data-params|Feathers API Documentation: .create(data, params)} */ _create(data: Data, params?: Params): Promise _create(data: Data[], params?: Params): Promise _create(data: Data | Data[], params?: Params): Promise /** * Completely replace the resource identified by id, skipping any service-level hooks. * Does not sanitize data or query and should only be used on the server. * * @param id - ID of the resource to be updated * @param data - Data to be put in place of the current resource. * @param params - Service call parameters {@link Params} * @see {@link HookLessServiceMethods} * @see {@link https://docs.feathersjs.com/api/services.html#update-id-data-params|Feathers API Documentation: .update(id, data, params)} */ _update(id: IdType, data: Data, params?: Params): Promise /** * Merge any resources matching the given ID with the given data, skipping any service-level hooks. * Does not sanitize the data or query and should only be used on the server. * * @param id - ID of the resource to be patched * @param data - Data to merge with the current resource. * @param params - Service call parameters {@link Params} * @see {@link HookLessServiceMethods} * @see {@link https://docs.feathersjs.com/api/services.html#patch-id-data-params|Feathers API Documentation: .patch(id, data, params)} */ _patch(id: null, data: PatchData, params?: Params): Promise _patch(id: IdType, data: PatchData, params?: Params): Promise _patch(id: IdType | null, data: PatchData, params?: Params): Promise /** * Remove resources matching the given ID from the this service, skipping any service-level hooks. * Does not sanitize query and should only be used on the server. * * @param id - ID of the resource to be removed * @param params - Service call parameters {@link Params} * @see {@link HookLessServiceMethods} * @see {@link https://docs.feathersjs.com/api/services.html#remove-id-params|Feathers API Documentation: .remove(id, params)} */ _remove(id: null, params?: Params): Promise _remove(id: IdType, params?: Params): Promise _remove(id: IdType | null, params?: Params): Promise } ================================================ FILE: packages/adapter-commons/src/index.ts ================================================ import { _ } from '@feathersjs/commons' import { Params } from '@feathersjs/feathers' export * from './declarations' export * from './service' export * from './query' export * from './sort' // Return a function that filters a result object or array // and picks only the fields passed as `params.query.$select` // and additional `otherFields` export function select(params: Params, ...otherFields: string[]) { const queryFields: string[] | undefined = params?.query?.$select if (!queryFields) { return (result: any) => result } const resultFields = queryFields.concat(otherFields) const convert = (result: any) => _.pick(result, ...resultFields) return (result: any) => { if (Array.isArray(result)) { return result.map(convert) } return convert(result) } } ================================================ FILE: packages/adapter-commons/src/query.ts ================================================ import { _ } from '@feathersjs/commons' import { BadRequest } from '@feathersjs/errors' import { Query } from '@feathersjs/feathers' import { FilterQueryOptions, FilterSettings, PaginationParams } from './declarations' const parse = (value: any) => (typeof value !== 'undefined' ? parseInt(value, 10) : value) const isPlainObject = (value: any) => _.isObject(value) && value.constructor === {}.constructor const validateQueryProperty = (query: any, operators: string[] = []): Query => { if (!isPlainObject(query)) { return query } for (const key of Object.keys(query)) { if (key.startsWith('$') && !operators.includes(key)) { throw new BadRequest(`Invalid query parameter ${key}`, query) } const value = query[key] if (isPlainObject(value)) { query[key] = validateQueryProperty(value, operators) } } return { ...query } } const getFilters = (query: Query, settings: FilterQueryOptions) => { const filterNames = Object.keys(settings.filters) return filterNames.reduce( (current, key) => { const queryValue = query[key] const filter = settings.filters[key] if (filter) { const value = typeof filter === 'function' ? filter(queryValue, settings) : queryValue if (value !== undefined) { current[key] = value } } return current }, {} as { [key: string]: any } ) } const getQuery = (query: Query, settings: FilterQueryOptions) => { const keys = Object.keys(query).concat(Object.getOwnPropertySymbols(query) as any as string[]) return keys.reduce((result, key) => { if (typeof key === 'string' && key.startsWith('$')) { if (settings.filters[key] === undefined) { throw new BadRequest(`Invalid filter value ${key}`) } } else { result[key] = validateQueryProperty(query[key], settings.operators) } return result }, {} as Query) } /** * Returns the converted `$limit` value based on the `paginate` configuration. * @param _limit The limit value * @param paginate The pagination options * @returns The converted $limit value */ export const getLimit = (_limit: any, paginate?: PaginationParams) => { const limit = parse(_limit) if (paginate && (paginate.default || paginate.max)) { const base = paginate.default || 0 const lower = typeof limit === 'number' && !isNaN(limit) && limit >= 0 ? limit : base const upper = typeof paginate.max === 'number' ? paginate.max : Number.MAX_VALUE return Math.min(lower, upper) } return limit } export const OPERATORS = ['$in', '$nin', '$lt', '$lte', '$gt', '$gte', '$ne', '$or'] export const FILTERS: FilterSettings = { $skip: (value: any) => parse(value), $sort: (sort: any): { [key: string]: number } => { if (typeof sort !== 'object' || Array.isArray(sort)) { return sort } return Object.keys(sort).reduce( (result, key) => { result[key] = typeof sort[key] === 'object' ? sort[key] : parse(sort[key]) return result }, {} as { [key: string]: number } ) }, $limit: (_limit: any, { paginate }: FilterQueryOptions) => getLimit(_limit, paginate), $select: (select: any) => { if (Array.isArray(select)) { return select.map((current) => `${current}`) } return select }, $or: (or: any, { operators }: FilterQueryOptions) => { if (Array.isArray(or)) { return or.map((current) => validateQueryProperty(current, operators)) } return or }, $and: (and: any, { operators }: FilterQueryOptions) => { if (Array.isArray(and)) { return and.map((current) => validateQueryProperty(current, operators)) } return and } } /** * Converts Feathers special query parameters and pagination settings * and returns them separately as `filters` and the rest of the query * as `query`. `options` also gets passed the pagination settings and * a list of additional `operators` to allow when querying properties. * * @param query The initial query * @param options Options for filtering the query * @returns An object with `query` which contains the query without `filters` * and `filters` which contains the converted values for each filter. */ export function filterQuery(_query: Query, options: FilterQueryOptions = {}) { const query = _query || {} const settings = { ...options, filters: { ...FILTERS, ...options.filters }, operators: OPERATORS.concat(options.operators || []) } return { filters: getFilters(query, settings), query: getQuery(query, settings) } } ================================================ FILE: packages/adapter-commons/src/service.ts ================================================ import { Id, Paginated, Query } from '@feathersjs/feathers' import { AdapterParams, AdapterServiceOptions, InternalServiceMethods, PaginationOptions } from './declarations' import { filterQuery } from './query' export const VALIDATED = Symbol.for('@feathersjs/adapter/sanitized') const alwaysMulti: { [key: string]: boolean } = { find: true, get: false, update: false } /** * An abstract base class that a database adapter can extend from to implement the * `__find`, `__get`, `__update`, `__patch` and `__remove` methods. */ export abstract class AdapterBase< Result = any, Data = Result, PatchData = Partial, ServiceParams extends AdapterParams = AdapterParams, Options extends AdapterServiceOptions = AdapterServiceOptions, IdType = Id > implements InternalServiceMethods { options: Options constructor(options: Options) { this.options = { id: 'id', events: [], paginate: false, multi: false, filters: {}, operators: [], ...options } } get id() { return this.options.id } get events() { return this.options.events } /** * Check if this adapter allows multiple updates for a method. * @param method The method name to check. * @param params The service call params. * @returns Wether or not multiple updates are allowed. */ allowsMulti(method: string, params: ServiceParams = {} as ServiceParams) { const always = alwaysMulti[method] if (typeof always !== 'undefined') { return always } const { multi } = this.getOptions(params) if (multi === true || !multi) { return multi } return multi.includes(method) } /** * Returns the combined options for a service call. Options will be merged * with `this.options` and `params.adapter` for dynamic overrides. * * @param params The parameters for the service method call * @returns The actual options for this call */ getOptions(params: ServiceParams): Options { const paginate = params.paginate !== undefined ? params.paginate : this.options.paginate return { ...this.options, paginate, ...params.adapter } } /** * Returns a sanitized version of `params.query`, converting filter values * (like $limit and $skip) into the expected type. Will throw an error if * a `$` prefixed filter or operator value that is not allowed in `filters` * or `operators` is encountered. * * @param params The service call parameter. * @returns A new object containing the sanitized query. */ async sanitizeQuery(params: ServiceParams = {} as ServiceParams): Promise { // We don't need legacy query sanitisation if the query has been validated by a schema already if (params.query && (params.query as any)[VALIDATED]) { return params.query || {} } const options = this.getOptions(params) const { query, filters } = filterQuery(params.query, options) return { ...filters, ...query } } /** * Retrieve all resources from this service. * Does not sanitize the query and should only be used on the server. * * @param _params - Service call parameters {@link ServiceParams} */ abstract _find(_params?: ServiceParams & { paginate?: PaginationOptions }): Promise> abstract _find(_params?: ServiceParams & { paginate: false }): Promise abstract _find(params?: ServiceParams): Promise> /** * Retrieve a single resource matching the given ID, skipping any service-level hooks. * Does not sanitize the query and should only be used on the server. * * @param id - ID of the resource to locate * @param params - Service call parameters {@link ServiceParams} * @see {@link HookLessServiceMethods} * @see {@link https://docs.feathersjs.com/api/services.html#get-id-params|Feathers API Documentation: .get(id, params)} */ abstract _get(id: IdType, params?: ServiceParams): Promise /** * Create a new resource for this service, skipping any service-level hooks. * Does not check if multiple updates are allowed and should only be used on the server. * * @param data - Data to insert into this service. * @param params - Service call parameters {@link ServiceParams} * @see {@link HookLessServiceMethods} * @see {@link https://docs.feathersjs.com/api/services.html#create-data-params|Feathers API Documentation: .create(data, params)} */ abstract _create(data: Data, params?: ServiceParams): Promise abstract _create(data: Data[], params?: ServiceParams): Promise abstract _create(data: Data | Data[], params?: ServiceParams): Promise /** * Completely replace the resource identified by id, skipping any service-level hooks. * Does not sanitize the query and should only be used on the server. * * @param id - ID of the resource to be updated * @param data - Data to be put in place of the current resource. * @param params - Service call parameters {@link ServiceParams} * @see {@link HookLessServiceMethods} * @see {@link https://docs.feathersjs.com/api/services.html#update-id-data-params|Feathers API Documentation: .update(id, data, params)} */ abstract _update(id: IdType, data: Data, params?: ServiceParams): Promise /** * Merge any resources matching the given ID with the given data, skipping any service-level hooks. * Does not sanitize the query and should only be used on the server. * * @param id - ID of the resource to be patched * @param data - Data to merge with the current resource. * @param params - Service call parameters {@link ServiceParams} * @see {@link HookLessServiceMethods} * @see {@link https://docs.feathersjs.com/api/services.html#patch-id-data-params|Feathers API Documentation: .patch(id, data, params)} */ abstract _patch(id: null, data: PatchData, params?: ServiceParams): Promise abstract _patch(id: IdType, data: PatchData, params?: ServiceParams): Promise abstract _patch(id: IdType | null, data: PatchData, params?: ServiceParams): Promise /** * Remove resources matching the given ID from the this service, skipping any service-level hooks. * Does not sanitize query and should only be used on the server. * * @param id - ID of the resource to be removed * @param params - Service call parameters {@link ServiceParams} * @see {@link HookLessServiceMethods} * @see {@link https://docs.feathersjs.com/api/services.html#remove-id-params|Feathers API Documentation: .remove(id, params)} */ abstract _remove(id: null, params?: ServiceParams): Promise abstract _remove(id: IdType, params?: ServiceParams): Promise abstract _remove(id: IdType | null, params?: ServiceParams): Promise } ================================================ FILE: packages/adapter-commons/src/sort.ts ================================================ // Sorting algorithm taken from NeDB (https://github.com/louischatriot/nedb) // See https://github.com/louischatriot/nedb/blob/e3f0078499aa1005a59d0c2372e425ab789145c1/lib/model.js#L189 export function compareNSB(a: number | string | boolean, b: number | string | boolean): 0 | 1 | -1 { if (a === b) { return 0 } return a < b ? -1 : 1 } export function compareArrays(a: any[], b: any[]): 0 | 1 | -1 { for (let i = 0, l = Math.min(a.length, b.length); i < l; i++) { const comparison = compare(a[i], b[i]) if (comparison !== 0) { return comparison } } // Common section was identical, longest one wins return compareNSB(a.length, b.length) } export function compare( a: any, b: any, compareStrings: (a: any, b: any) => 0 | 1 | -1 = compareNSB ): 0 | 1 | -1 { if (a === b) { return 0 } // null or undefined if (a == null) { return -1 } if (b == null) { return 1 } // detect typeof once const typeofA = typeof a const typeofB = typeof b // Numbers if (typeofA === 'number') { return typeofB === 'number' ? compareNSB(a, b) : -1 } if (typeofB === 'number') { return 1 } // Strings if (typeofA === 'string') { return typeofB === 'string' ? compareStrings(a, b) : -1 } if (typeofB === 'string') { return 1 } // Booleans if (typeofA === 'boolean') { return typeofB === 'boolean' ? compareNSB(a, b) : -1 } if (typeofB === 'boolean') { return 1 } // Dates if (a instanceof Date) { return b instanceof Date ? compareNSB(a.getTime(), b.getTime()) : -1 } if (b instanceof Date) { return 1 } // Arrays (first element is most significant and so on) if (Array.isArray(a)) { return Array.isArray(b) ? compareArrays(a, b) : -1 } if (Array.isArray(b)) { return 1 } // Objects const aKeys = Object.keys(a).sort() const bKeys = Object.keys(b).sort() for (let i = 0, l = Math.min(aKeys.length, bKeys.length); i < l; i++) { const comparison = compare(a[aKeys[i]], b[bKeys[i]]) if (comparison !== 0) { return comparison } } return compareNSB(aKeys.length, bKeys.length) } // lodash-y get - probably want to use lodash get instead const get = (value: any, path: string[]) => path.reduce((value, key) => value[key], value) // An in-memory sorting function according to the // $sort special query parameter export function sorter($sort: { [key: string]: -1 | 1 }) { const compares = Object.keys($sort).map((key) => { const direction = $sort[key] if (!key.includes('.')) { return (a: any, b: any) => direction * compare(a[key], b[key]) } else { const path = key.split('.') return (a: any, b: any) => direction * compare(get(a, path), get(b, path)) } }) return function (a: any, b: any) { for (const compare of compares) { const comparison = compare(a, b) if (comparison !== 0) { return comparison } } return 0 } } ================================================ FILE: packages/adapter-commons/test/commons.test.ts ================================================ import assert from 'assert' import { select } from '../src' describe('@feathersjs/adapter-commons', () => { describe('select', () => { it('select', () => { const selector = select({ query: { $select: ['name', 'age'] } }) return Promise.resolve({ name: 'David', age: 3, test: 'me' }) .then(selector) .then((result) => assert.deepStrictEqual(result, { name: 'David', age: 3 }) ) }) it('select with arrays', () => { const selector = select({ query: { $select: ['name', 'age'] } }) return Promise.resolve([ { name: 'David', age: 3, test: 'me' }, { name: 'D', age: 4, test: 'you' } ]) .then(selector) .then((result) => assert.deepStrictEqual(result, [ { name: 'David', age: 3 }, { name: 'D', age: 4 } ]) ) }) it('select with no query', () => { const selector = select({}) const data = { name: 'David' } return Promise.resolve(data) .then(selector) .then((result) => assert.deepStrictEqual(result, data)) }) it('select with other fields', () => { const selector = select( { query: { $select: ['name'] } }, 'id' ) const data = { id: 'me', name: 'David', age: 10 } return Promise.resolve(data) .then(selector) .then((result) => assert.deepStrictEqual(result, { id: 'me', name: 'David' }) ) }) }) }) ================================================ FILE: packages/adapter-commons/test/fixture.ts ================================================ import { AdapterBase, AdapterParams, PaginationOptions } from '../src' import { Id, NullableId, Paginated } from '@feathersjs/feathers' import { BadRequest, MethodNotAllowed } from '@feathersjs/errors/lib' export type Data = { id: Id } export class MethodBase extends AdapterBase, AdapterParams> { async _find(_params?: AdapterParams & { paginate?: PaginationOptions }): Promise> async _find(_params?: AdapterParams & { paginate: false }): Promise async _find(params?: AdapterParams): Promise> { if (params && params.paginate === false) { return [] } return { total: 0, limit: 10, skip: 0, data: [] } } async _get(id: Id, _params?: AdapterParams): Promise { return { id } } async _create(data: Data, _params?: AdapterParams): Promise async _create(data: Data[], _params?: AdapterParams): Promise async _create(data: Data | Data[], _params?: AdapterParams): Promise async _create(data: Data | Data[], _params?: AdapterParams): Promise { if (Array.isArray(data)) { return [ { id: 'something' } ] } return { id: 'something' } } async _update(id: Id, _data: Data, _params?: AdapterParams) { return Promise.resolve({ id: id ?? _data.id }) } async _patch(id: null, _data: Partial, _params?: AdapterParams): Promise async _patch(id: Id, _data: Partial, _params?: AdapterParams): Promise async _patch(id: NullableId, _data: Partial, _params?: AdapterParams): Promise async _patch(id: NullableId, _data: Partial, _params?: AdapterParams): Promise { if (id === null) { return [] } return { id } } async _remove(id: null, _params?: AdapterParams): Promise async _remove(id: Id, _params?: AdapterParams): Promise async _remove(id: NullableId, _params?: AdapterParams): Promise async _remove(id: NullableId, _params?: AdapterParams) { if (id === null) { return [] as Data[] } return { id } } } export class MethodService extends MethodBase { find(params?: AdapterParams): Promise> { return this._find(params) } get(id: Id, params?: AdapterParams): Promise { return this._get(id, params) } async create(data: Data[], _params?: AdapterParams): Promise async create(data: Data, _params?: AdapterParams): Promise async create(data: Data | Data[], params?: AdapterParams): Promise { if (Array.isArray(data) && !this.allowsMulti('create', params)) { throw new MethodNotAllowed('Can not create multiple entries') } return this._create(data, params) } async update(id: Id, data: Data, params?: AdapterParams) { if (id === null || Array.isArray(data)) { throw new BadRequest("You can not replace multiple instances. Did you mean 'patch'?") } return this._update(id, data, params) } async patch(id: NullableId, data: Partial, params?: AdapterParams) { if (id === null && !this.allowsMulti('patch', params)) { throw new MethodNotAllowed('Can not patch multiple entries') } return this._patch(id, data, params) } async remove(id: NullableId, params?: AdapterParams) { if (id === null && !this.allowsMulti('remove', params)) { throw new MethodNotAllowed('Can not remove multiple entries') } return this._remove(id, params) } } ================================================ FILE: packages/adapter-commons/test/query.test.ts ================================================ import assert from 'assert' import { ObjectId } from 'mongodb' import { filterQuery } from '../src' describe('@feathersjs/adapter-commons/filterQuery', () => { describe('$sort', () => { it('returns $sort when present in query', () => { const originalQuery = { $sort: { name: 1 } } const { filters, query } = filterQuery(originalQuery) assert.strictEqual(filters.$sort.name, 1) assert.deepStrictEqual(query, {}) assert.deepStrictEqual( originalQuery, { $sort: { name: 1 } }, 'does not modify original query' ) }) it('returns $sort when present in query as an object', () => { const { filters, query } = filterQuery({ $sort: { name: { something: 10 } } }) assert.strictEqual(filters.$sort.name.something, 10) assert.deepStrictEqual(query, {}) }) it('converts strings in $sort', () => { const { filters, query } = filterQuery({ $sort: { test: '-1' } }) assert.strictEqual(filters.$sort.test, -1) assert.deepStrictEqual(query, {}) }) it('does not convert $sort arrays', () => { const $sort = [ ['test', '-1'], ['a', '1'] ] const { filters, query } = filterQuery({ $sort }) assert.strictEqual(filters.$sort, $sort) assert.deepStrictEqual(query, {}) }) it('throws an error when special parameter is not known', () => { try { const query = { $foo: 1 } filterQuery(query) assert.ok(false, 'Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'BadRequest') assert.strictEqual(error.message, 'Invalid filter value $foo') } }) it('returns undefined when not present in query', () => { const query = { foo: 1 } const { filters } = filterQuery(query) assert.strictEqual(filters.$sort, undefined) }) }) describe('$limit', () => { let testQuery: any beforeEach(() => { testQuery = { $limit: 1 } }) it('returns $limit when present in query', () => { const { filters, query } = filterQuery(testQuery) assert.strictEqual(filters.$limit, 1) assert.deepStrictEqual(query, {}) }) it('returns undefined when not present in query', () => { const query = { foo: 1 } const { filters } = filterQuery(query) assert.strictEqual(filters.$limit, undefined) }) it('removes $limit from query when present', () => { assert.deepStrictEqual(filterQuery(testQuery).query, {}) }) it('parses $limit strings into integers (#4)', () => { const { filters } = filterQuery({ $limit: '2' }) assert.strictEqual(filters.$limit, 2) }) it('allows $limit 0', () => { const { filters } = filterQuery({ $limit: 0 }, { paginate: { default: 10 } }) assert.strictEqual(filters.$limit, 0) }) describe('pagination', () => { it('limits with default pagination', () => { const { filters } = filterQuery({}, { paginate: { default: 10 } }) const { filters: filtersNeg } = filterQuery({ $limit: -20 }, { paginate: { default: 5, max: 10 } }) assert.strictEqual(filters.$limit, 10) assert.strictEqual(filtersNeg.$limit, 5) }) it('limits with max pagination', () => { const { filters } = filterQuery({ $limit: 20 }, { paginate: { default: 5, max: 10 } }) assert.strictEqual(filters.$limit, 10) }) it('limits with default pagination when not a number', () => { const { filters } = filterQuery({ $limit: 'something' }, { paginate: { default: 5, max: 10 } }) assert.strictEqual(filters.$limit, 5) }) it('limits to 0 when no paginate.default and not a number', () => { const { filters } = filterQuery({ $limit: 'something' }, { paginate: { max: 10 } }) assert.strictEqual(filters.$limit, 0) }) it('still uses paginate.max when there is no paginate.default (#2104)', () => { const { filters } = filterQuery({ $limit: 100 }, { paginate: { max: 10 } }) assert.strictEqual(filters.$limit, 10) }) }) }) describe('$skip', () => { let testQuery: any beforeEach(() => { testQuery = { $skip: 1 } }) it('returns $skip when present in query', () => { const { filters } = filterQuery(testQuery) assert.strictEqual(filters.$skip, 1) }) it('removes $skip from query when present', () => { assert.deepStrictEqual(filterQuery(testQuery).query, {}) }) it('returns undefined when not present in query', () => { const query = { foo: 1 } const { filters } = filterQuery(query) assert.strictEqual(filters.$skip, undefined) }) it('parses $skip strings into integers (#4)', () => { const { filters } = filterQuery({ $skip: '33' }) assert.strictEqual(filters.$skip, 33) }) }) describe('$select', () => { let testQuery: any beforeEach(() => { testQuery = { $select: 1 } }) it('returns $select when present in query', () => { const { filters } = filterQuery(testQuery) assert.strictEqual(filters.$select, 1) }) it('removes $select from query when present', () => { assert.deepStrictEqual(filterQuery(testQuery).query, {}) }) it('returns undefined when not present in query', () => { const query = { foo: 1 } const { filters } = filterQuery(query) assert.strictEqual(filters.$select, undefined) }) it('includes Symbols', () => { const TEST = Symbol('testing') const original = { [TEST]: 'message', other: true, sub: { [TEST]: 'othermessage' } } const { query } = filterQuery(original) assert.deepStrictEqual(query, { [TEST]: 'message', other: true, sub: { [TEST]: 'othermessage' } }) }) it('only converts plain objects', () => { const userId = new ObjectId() const original = { userId } const { query } = filterQuery(original) assert.deepStrictEqual(query, original) }) }) describe('arrays', () => { it('validates queries in arrays', () => { assert.throws( () => { filterQuery({ $or: [{ $exists: false }] }) }, { name: 'BadRequest', message: 'Invalid query parameter $exists' } ) }) it('allows default operators in $or', () => { const { filters } = filterQuery({ $or: [{ value: { $gte: 10 } }] }) assert.deepStrictEqual(filters, { $or: [{ value: { $gte: 10 } }] }) }) }) describe('additional filters', () => { it('throw error when not set as additionals', () => { try { filterQuery({ $select: 1, $known: 1 }) assert.ok(false, 'Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'Invalid filter value $known') } }) it('returns default and known additional filters (array)', () => { const query = { $select: ['a', 'b'], $known: 1, $unknown: 1 } const { filters } = filterQuery(query, { filters: { $known: true, $unknown: true } }) assert.strictEqual(filters.$unknown, 1) assert.strictEqual(filters.$known, 1) assert.deepStrictEqual(filters.$select, ['a', 'b']) }) it('returns default and known additional filters (object)', () => { const { filters } = filterQuery( { $known: 1, $select: 1 }, { filters: { $known: (value: any) => value.toString() } } ) assert.strictEqual(filters.$unknown, undefined) assert.strictEqual(filters.$known, '1') assert.strictEqual(filters.$select, 1) }) }) describe('additional operators', () => { it('returns query with default and known additional operators', () => { const { query } = filterQuery( { prop: { $ne: 1, $known: 1 } }, { operators: ['$known'] } ) assert.deepStrictEqual(query, { prop: { $ne: 1, $known: 1 } }) }) it('throws an error with unknown query operator', () => { assert.throws( () => filterQuery({ prop: { $unknown: 'something' } }), { message: 'Invalid query parameter $unknown' } ) }) }) }) ================================================ FILE: packages/adapter-commons/test/service.test.ts ================================================ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/ban-ts-comment */ import assert from 'assert' import { VALIDATED } from '../src' import { MethodService } from './fixture' const METHODS: ['find', 'get', 'create', 'update', 'patch', 'remove'] = [ 'find', 'get', 'create', 'update', 'patch', 'remove' ] describe('@feathersjs/adapter-commons/service', () => { describe('works when methods exist', () => { METHODS.forEach((method) => { it(`${method}`, () => { const service = new MethodService({}) const args: any[] = [] if (method !== 'find') { args.push('test') } if (method === 'update' || method === 'patch') { args.push({}) } // @ts-ignore return service[method](...args) }) }) it('does not allow multi patch', async () => { const service = new MethodService({}) await assert.rejects(() => service.patch(null, {}), { name: 'MethodNotAllowed', message: 'Can not patch multiple entries' }) }) it('does not allow multi remove', async () => { const service = new MethodService({}) await assert.rejects(() => service.remove(null, {}), { name: 'MethodNotAllowed', message: 'Can not remove multiple entries' }) }) it('does not allow multi create', async () => { const service = new MethodService({}) await assert.rejects(() => service.create([], {}), { name: 'MethodNotAllowed', message: 'Can not create multiple entries' }) }) it('multi can be set to true', async () => { const service = new MethodService({}) service.options.multi = true await service.create([]) }) }) it('sanitizeQuery', async () => { const service = new MethodService({ filters: { $something: true }, operators: ['$test'] }) assert.deepStrictEqual( await service.sanitizeQuery({ query: { $limit: '10', test: 'me' } as any }), { $limit: 10, test: 'me' } ) assert.deepStrictEqual( await service.sanitizeQuery({ adapter: { paginate: { max: 2 } }, query: { $limit: '10', test: 'me' } as any }), { $limit: 2, test: 'me' } ) await assert.rejects( () => service.sanitizeQuery({ query: { name: { $bla: 'me' } } }), { message: 'Invalid query parameter $bla' } ) assert.deepStrictEqual( await service.sanitizeQuery({ adapter: { operators: ['$bla'] }, query: { name: { $bla: 'Dave' } } }), { name: { $bla: 'Dave' } } ) const validatedQuery = { name: { $bla: 'me' } } Object.defineProperty(validatedQuery, VALIDATED, { value: true }) assert.deepStrictEqual( await service.sanitizeQuery({ query: validatedQuery }), validatedQuery, 'validated queries are not sanitized' ) }) it('getOptions', () => { const service = new MethodService({ multi: true, paginate: { default: 1, max: 10 } }) const opts = service.getOptions({ adapter: { multi: ['create'], paginate: { default: 10, max: 100 } } }) assert.deepStrictEqual(opts, { id: 'id', events: [], paginate: { default: 10, max: 100 }, multi: ['create'], filters: {}, operators: [] }) const notPaginated = service.getOptions({ paginate: false }) assert.deepStrictEqual(notPaginated, { id: 'id', events: [], paginate: false, multi: true, filters: {}, operators: [] }) }) it('allowsMulti', () => { context('with true', () => { const service = new MethodService({ multi: true }) it('does return true for multiple methodes', () => { assert.equal(service.allowsMulti('patch'), true) }) it('does return false for always non-multiple methodes', () => { assert.equal(service.allowsMulti('update'), false) }) it('does return true for unknown methods', () => { assert.equal(service.allowsMulti('other'), true) }) }) context('with false', () => { const service = new MethodService({ multi: false }) it('does return false for multiple methodes', () => { assert.equal(service.allowsMulti('remove'), false) }) it('does return true for always multiple methodes', () => { assert.equal(service.allowsMulti('find'), true) }) it('does return false for unknown methods', () => { assert.equal(service.allowsMulti('other'), false) }) }) context('with array', () => { const service = new MethodService({ multi: ['create', 'get', 'other'] }) it('does return true for specified multiple methodes', () => { assert.equal(service.allowsMulti('create'), true) }) it('does return false for non-specified multiple methodes', () => { assert.equal(service.allowsMulti('patch'), false) }) it('does return false for specified always multiple methodes', () => { assert.equal(service.allowsMulti('get'), false) }) it('does return true for specified unknown methodes', () => { assert.equal(service.allowsMulti('other'), true) }) it('does return false for non-specified unknown methodes', () => { assert.equal(service.allowsMulti('another'), false) }) }) }) }) ================================================ FILE: packages/adapter-commons/test/sort.test.ts ================================================ import assert from 'assert' import { sorter } from '../src' describe('@feathersjs/adapter-commons', () => { describe('sorter', () => { it('simple sorter', () => { const array = [ { name: 'David' }, { name: 'Eric' } ] const sort = sorter({ name: -1 }) assert.deepStrictEqual(array.sort(sort), [ { name: 'Eric' }, { name: 'David' } ]) }) it('simple sorter with arrays', () => { const array = [ { names: ['a', 'b'] }, { names: ['c', 'd'] } ] const sort = sorter({ names: -1 }) assert.deepStrictEqual(array.sort(sort), [ { names: ['c', 'd'] }, { names: ['a', 'b'] } ]) }) it('simple sorter with objects', () => { const array = [ { names: { first: 'Dave', last: 'L' } }, { names: { first: 'A', last: 'B' } } ] const sort = sorter({ names: 1 }) assert.deepStrictEqual(array.sort(sort), [ { names: { first: 'A', last: 'B' } }, { names: { first: 'Dave', last: 'L' } } ]) }) it('two property sorter', () => { const array = [ { name: 'David', counter: 0 }, { name: 'Eric', counter: 1 }, { name: 'David', counter: 1 }, { name: 'Eric', counter: 0 } ] const sort = sorter({ name: -1, counter: 1 }) assert.deepStrictEqual(array.sort(sort), [ { name: 'Eric', counter: 0 }, { name: 'Eric', counter: 1 }, { name: 'David', counter: 0 }, { name: 'David', counter: 1 } ]) }) it('two property sorter with names', () => { const array = [ { name: 'David', counter: 0 }, { name: 'Eric', counter: 1 }, { name: 'Andrew', counter: 1 }, { name: 'David', counter: 1 }, { name: 'Andrew', counter: 0 }, { name: 'Eric', counter: 0 } ] const sort = sorter({ name: -1, counter: 1 }) assert.deepStrictEqual(array.sort(sort), [ { name: 'Eric', counter: 0 }, { name: 'Eric', counter: 1 }, { name: 'David', counter: 0 }, { name: 'David', counter: 1 }, { name: 'Andrew', counter: 0 }, { name: 'Andrew', counter: 1 } ]) }) it('three property sorter with names', () => { const array = [ { name: 'David', counter: 0, age: 2 }, { name: 'Eric', counter: 1, age: 2 }, { name: 'David', counter: 1, age: 1 }, { name: 'Eric', counter: 0, age: 1 }, { name: 'Andrew', counter: 0, age: 2 }, { name: 'Andrew', counter: 0, age: 1 } ] const sort = sorter({ name: -1, counter: 1, age: -1 }) assert.deepStrictEqual(array.sort(sort), [ { name: 'Eric', counter: 0, age: 1 }, { name: 'Eric', counter: 1, age: 2 }, { name: 'David', counter: 0, age: 2 }, { name: 'David', counter: 1, age: 1 }, { name: 'Andrew', counter: 0, age: 2 }, { name: 'Andrew', counter: 0, age: 1 } ]) }) }) describe('sorter mongoDB-like sorting on embedded objects', () => { let data: any[] = [] beforeEach(() => { data = [ { _id: 1, item: { category: 'cake', type: 'chiffon' }, amount: 10 }, { _id: 2, item: { category: 'cookies', type: 'chocolate chip' }, amount: 50 }, { _id: 3, item: { category: 'cookies', type: 'chocolate chip' }, amount: 15 }, { _id: 4, item: { category: 'cake', type: 'lemon' }, amount: 30 }, { _id: 5, item: { category: 'cake', type: 'carrot' }, amount: 20 }, { _id: 6, item: { category: 'brownies', type: 'blondie' }, amount: 10 } ] }) it('straight test', () => { const sort = sorter({ amount: -1 }) assert.deepStrictEqual(data.sort(sort), [ { _id: 2, item: { category: 'cookies', type: 'chocolate chip' }, amount: 50 }, { _id: 4, item: { category: 'cake', type: 'lemon' }, amount: 30 }, { _id: 5, item: { category: 'cake', type: 'carrot' }, amount: 20 }, { _id: 3, item: { category: 'cookies', type: 'chocolate chip' }, amount: 15 }, { _id: 1, item: { category: 'cake', type: 'chiffon' }, amount: 10 }, { _id: 6, item: { category: 'brownies', type: 'blondie' }, amount: 10 } ]) }) it('embedded sort 1', () => { const sort = sorter({ 'item.category': 1, 'item.type': 1 }) assert.deepStrictEqual(data.sort(sort), [ { _id: 6, item: { category: 'brownies', type: 'blondie' }, amount: 10 }, { _id: 5, item: { category: 'cake', type: 'carrot' }, amount: 20 }, { _id: 1, item: { category: 'cake', type: 'chiffon' }, amount: 10 }, { _id: 4, item: { category: 'cake', type: 'lemon' }, amount: 30 }, { _id: 2, item: { category: 'cookies', type: 'chocolate chip' }, amount: 50 }, { _id: 3, item: { category: 'cookies', type: 'chocolate chip' }, amount: 15 } ]) }) it('embedded sort 2', () => { const sort = sorter({ 'item.category': 1, 'item.type': 1, amount: 1 }) assert.deepStrictEqual(data.sort(sort), [ { _id: 6, item: { category: 'brownies', type: 'blondie' }, amount: 10 }, { _id: 5, item: { category: 'cake', type: 'carrot' }, amount: 20 }, { _id: 1, item: { category: 'cake', type: 'chiffon' }, amount: 10 }, { _id: 4, item: { category: 'cake', type: 'lemon' }, amount: 30 }, { _id: 3, item: { category: 'cookies', type: 'chocolate chip' }, amount: 15 }, { _id: 2, item: { category: 'cookies', type: 'chocolate chip' }, amount: 50 } ]) }) it('embedded sort 3', () => { const sort = sorter({ 'item.category': 1, 'item.type': 1, amount: -1 }) assert.deepStrictEqual(data.sort(sort), [ { _id: 6, item: { category: 'brownies', type: 'blondie' }, amount: 10 }, { _id: 5, item: { category: 'cake', type: 'carrot' }, amount: 20 }, { _id: 1, item: { category: 'cake', type: 'chiffon' }, amount: 10 }, { _id: 4, item: { category: 'cake', type: 'lemon' }, amount: 30 }, { _id: 2, item: { category: 'cookies', type: 'chocolate chip' }, amount: 50 }, { _id: 3, item: { category: 'cookies', type: 'chocolate chip' }, amount: 15 } ]) }) it('embedded sort 4', () => { const sort = sorter({ amount: -1, 'item.category': 1 }) assert.deepStrictEqual(data.sort(sort), [ { _id: 2, item: { category: 'cookies', type: 'chocolate chip' }, amount: 50 }, { _id: 4, item: { category: 'cake', type: 'lemon' }, amount: 30 }, { _id: 5, item: { category: 'cake', type: 'carrot' }, amount: 20 }, { _id: 3, item: { category: 'cookies', type: 'chocolate chip' }, amount: 15 }, { _id: 6, item: { category: 'brownies', type: 'blondie' }, amount: 10 }, { _id: 1, item: { category: 'cake', type: 'chiffon' }, amount: 10 } ]) }) it('embedded sort 5', () => { const sort = sorter({ 'item.category': 1, amount: 1 }) assert.deepStrictEqual(data.sort(sort), [ { _id: 6, item: { category: 'brownies', type: 'blondie' }, amount: 10 }, { _id: 1, item: { category: 'cake', type: 'chiffon' }, amount: 10 }, { _id: 5, item: { category: 'cake', type: 'carrot' }, amount: 20 }, { _id: 4, item: { category: 'cake', type: 'lemon' }, amount: 30 }, { _id: 3, item: { category: 'cookies', type: 'chocolate chip' }, amount: 15 }, { _id: 2, item: { category: 'cookies', type: 'chocolate chip' }, amount: 50 } ]) }) }) }) ================================================ FILE: packages/adapter-commons/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/adapter-tests/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - @feathersjs/memory update with query ([#3617](https://github.com/feathersjs/feathers/issues/3617)) ([4c6caa2](https://github.com/feathersjs/feathers/commit/4c6caa27e9af1312718d0c233a0c35f7739ac553)) - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/adapter-tests ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) ### Bug Fixes - **typebox:** Revert to TypeBox 0.25 ([#3183](https://github.com/feathersjs/feathers/issues/3183)) ([cacedf5](https://github.com/feathersjs/feathers/commit/cacedf59e3d2df836777f0cd06ab1b2484ed87c5)) ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - **adapter-commons:** Support non-default import to ease use with ESM projects ([d06f2cf](https://github.com/feathersjs/feathers/commit/d06f2cfcadda7dc23f0e2bec44f64e6be8500d02)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) ### Bug Fixes - **memory/mongodb:** $select as only property & force 'id' in '$select' ([#3081](https://github.com/feathersjs/feathers/issues/3081)) ([fbe3cf5](https://github.com/feathersjs/feathers/commit/fbe3cf5199e102b5aeda2ae33828d5034df3d105)) # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - **databases:** Improve documentation for adapters and allow dynamic Knex adapter options ([#3019](https://github.com/feathersjs/feathers/issues/3019)) ([66c4b5e](https://github.com/feathersjs/feathers/commit/66c4b5e72000dd03acb57fca1cad4737c85c9c9e)) ### Features - **database:** Add and to the query syntax ([#3021](https://github.com/feathersjs/feathers/issues/3021)) ([00cb0d9](https://github.com/feathersjs/feathers/commit/00cb0d9c302ae951ae007d3d6ceba33e254edd9c)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Features - **adapter:** Add patch data type to adapters and refactor AdapterBase usage ([#2906](https://github.com/feathersjs/feathers/issues/2906)) ([9ddc2e6](https://github.com/feathersjs/feathers/commit/9ddc2e6b028f026f939d6af68125847e5c6734b4)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Bug Fixes - **adapter-commons:** Clarify adapter query filtering ([#2607](https://github.com/feathersjs/feathers/issues/2607)) ([2dac771](https://github.com/feathersjs/feathers/commit/2dac771b0a3298d6dd25994d05186701b0617718)) - **adapter-tests:** Ensure multi tests can run standalone ([#2608](https://github.com/feathersjs/feathers/issues/2608)) ([d7243f2](https://github.com/feathersjs/feathers/commit/d7243f20e84d9dde428ad8dfc7f48388ca569e6e)) ### BREAKING CHANGES - **adapter-commons:** Changes the common adapter base class to use `sanitizeQuery` and `sanitizeData` # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) ### Bug Fixes - **adapter-tests:** Add tests for pagination in multi updates ([#2472](https://github.com/feathersjs/feathers/issues/2472)) ([98a811a](https://github.com/feathersjs/feathers/commit/98a811ac605575ff812a08d0504729a5efe7a69c)) # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Bug Fixes - **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Bug Fixes - Update database adapter common repository urls ([#2380](https://github.com/feathersjs/feathers/issues/2380)) ([3f4db68](https://github.com/feathersjs/feathers/commit/3f4db68d6700c7d9023ecd17d0d39893f75a19fd)) ### Features - **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/adapter-tests # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) ### Bug Fixes - **adapter-tests:** Add test that verified paginated total ([#2273](https://github.com/feathersjs/feathers/issues/2273)) ([879bd6b](https://github.com/feathersjs/feathers/commit/879bd6b24f42e04eeeeba110ddddda3e1e1dea34)) # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Features - **core:** Remove Uberproto ([#2178](https://github.com/feathersjs/feathers/issues/2178)) ([ddf8821](https://github.com/feathersjs/feathers/commit/ddf8821f53317e6a378657f7d66acb03a037ee47)) ### BREAKING CHANGES - **core:** Services no longer extend Uberproto objects and `service.mixin()` is no longer available. # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) ### Features - **memory:** Move feathers-memory into @feathersjs/memory ([#2153](https://github.com/feathersjs/feathers/issues/2153)) ([dd61fe3](https://github.com/feathersjs/feathers/commit/dd61fe371fb0502f78b8ccbe1f45a030e31ecff6)) ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) **Note:** Version bump only for package @feathersjs/adapter-tests ## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-09-27) **Note:** Version bump only for package @feathersjs/adapter-tests ## 4.5.3 (2020-09-24) ### Bug Fixes - **adapter-tests:** Update multi patch + query tests ([#5](https://github.com/feathersjs/databases/issues/5)) ([84f1fe4](https://github.com/feathersjs/databases/commit/84f1fe4f13dc3a26891e43b965f75d08243f6c6f)) ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) **Note:** Version bump only for package @feathersjs/adapter-tests ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/adapter-tests # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) **Note:** Version bump only for package @feathersjs/adapter-tests ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/adapter-tests ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/adapter-tests # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) **Note:** Version bump only for package @feathersjs/adapter-tests ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) **Note:** Version bump only for package @feathersjs/adapter-tests ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/adapter-tests ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) **Note:** Version bump only for package @feathersjs/adapter-tests ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) **Note:** Version bump only for package @feathersjs/adapter-tests ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) **Note:** Version bump only for package @feathersjs/adapter-tests ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) **Note:** Version bump only for package @feathersjs/adapter-tests ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) **Note:** Version bump only for package @feathersjs/adapter-tests ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) **Note:** Version bump only for package @feathersjs/adapter-tests # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/adapter-tests # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/adapter-tests # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) **Note:** Version bump only for package @feathersjs/adapter-tests # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) **Note:** Version bump only for package @feathersjs/adapter-tests # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/adapter-tests # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) ### Bug Fixes - Fix feathers-memory dependency that did not get updated ([9422b13](https://github.com/feathersjs/feathers/commit/9422b13)) # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) **Note:** Version bump only for package @feathersjs/adapter-tests # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) **Note:** Version bump only for package @feathersjs/adapter-tests # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) **Note:** Version bump only for package @feathersjs/adapter-tests # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Add test to make sure different id in adapter query works ([#1165](https://github.com/feathersjs/feathers/issues/1165)) ([0ba4580](https://github.com/feathersjs/feathers/commit/0ba4580)) - Update adapter tests to not rely on error instance ([#1202](https://github.com/feathersjs/feathers/issues/1202)) ([6885e0e](https://github.com/feathersjs/feathers/commit/6885e0e)) - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) ### chore - **package:** Move adapter tests into their own module ([#1164](https://github.com/feathersjs/feathers/issues/1164)) ([dcc1e6b](https://github.com/feathersjs/feathers/commit/dcc1e6b)) ### Features - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - Authentication v3 core server implementation ([#1205](https://github.com/feathersjs/feathers/issues/1205)) ([1bd7591](https://github.com/feathersjs/feathers/commit/1bd7591)) ### BREAKING CHANGES - **package:** Removes adapter tests from @feathersjs/adapter-commons ## [1.0.1](https://github.com/feathersjs/feathers/compare/@feathersjs/adapter-tests@1.0.0...@feathersjs/adapter-tests@1.0.1) (2019-01-10) ### Bug Fixes - Add test to make sure different id in adapter query works ([#1165](https://github.com/feathersjs/feathers/issues/1165)) ([0ba4580](https://github.com/feathersjs/feathers/commit/0ba4580)) # 1.0.0 (2019-01-10) ### chore - **package:** Move adapter tests into their own module ([#1164](https://github.com/feathersjs/feathers/issues/1164)) ([dcc1e6b](https://github.com/feathersjs/feathers/commit/dcc1e6b)) ### BREAKING CHANGES - **package:** Removes adapter tests from @feathersjs/adapter-commons ================================================ FILE: packages/adapter-tests/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/adapter-tests/README.md ================================================ # Feathers Adapter Tests [![CI](https://github.com/feathersjs/feathers/workflows/Node.js%20CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3A%22Node.js+CI%22) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/adapter-commons.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/adapter-commons) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > Feathers shared database adapter test suite ## About This is a repository that contains the test suite for the common database adapter syntax. See the [API documentation](https://docs.feathersjs.com/api/databases/common.html) for more information. ## Authors [Feathers contributors](https://github.com/feathersjs/adapter-tests/graphs/contributors) ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/adapter-tests/package.json ================================================ { "name": "@feathersjs/adapter-tests", "version": "5.0.42", "description": "Feathers shared database adapter test suite", "homepage": "https://feathersjs.com", "keywords": [ "feathers" ], "license": "MIT", "funding": { "type": "opencollective", "url": "https://opencollective.com/feathers" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/adapter-tests" }, "author": { "name": "Feathers contributor", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "main": "lib/", "types": "lib/", "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**" ], "publishConfig": { "access": "public" }, "devDependencies": { "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "mocha": "^11.7.5", "shx": "^0.4.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/adapter-tests/src/basic.ts ================================================ import assert from 'assert' import { AdapterBasicTest } from './declarations' export default (test: AdapterBasicTest, app: any, _errors: any, serviceName: string, idProp: string) => { describe('Basic Functionality', () => { let service: any beforeEach(() => { service = app.service(serviceName) }) it('.id', () => { assert.strictEqual(service.id, idProp, 'id property is set to expected name') }) test('.options', () => { assert.ok(service.options, 'Options are available in service.options') }) test('.events', () => { assert.ok(service.events.includes('testing'), 'service.events is set and includes "testing"') }) describe('Raw Methods', () => { test('._get', () => { assert.strictEqual(typeof service._get, 'function') }) test('._find', () => { assert.strictEqual(typeof service._find, 'function') }) test('._create', () => { assert.strictEqual(typeof service._create, 'function') }) test('._update', () => { assert.strictEqual(typeof service._update, 'function') }) test('._patch', () => { assert.strictEqual(typeof service._patch, 'function') }) test('._remove', () => { assert.strictEqual(typeof service._remove, 'function') }) }) }) } ================================================ FILE: packages/adapter-tests/src/declarations.ts ================================================ export type AdapterTest = (name: AdapterTestName, runner: any) => void export type AdapterBasicTest = (name: AdapterBasicTestName, runner: any) => void export type AdapterMethodsTest = (name: AdapterMethodsTestName, runner: any) => void export type AdapterSyntaxTest = (name: AdapterSyntaxTestName, runner: any) => void export type AdapterTestName = AdapterBasicTestName | AdapterMethodsTestName | AdapterSyntaxTestName export type AdapterBasicTestName = | '.id' | '.options' | '.events' | '._get' | '._find' | '._create' | '._update' | '._patch' | '._remove' | '.$get' | '.$find' | '.$create' | '.$update' | '.$patch' | '.$remove' export type AdapterMethodsTestName = | '.get' | '.get + $select' | '.get + id + query' | '.get + NotFound' | '.get + NotFound (integer)' | '.get + id + query id' | '.find' | '.remove' | '.remove + $select' | '.remove + id + query' | '.remove + NotFound' | '.remove + NotFound (integer)' | '.remove + multi' | '.remove + multi no pagination' | '.remove + id + query id' | '.update' | '.update + $select' | '.update + id + query' | '.update + NotFound' | '.update + NotFound (integer)' | '.update + query + NotFound' | '.update + id + query id' | '.patch' | '.patch + $select' | '.patch + id + query' | '.patch multiple' | '.patch multiple no pagination' | '.patch multi query same' | '.patch multi query changed' | '.patch + NotFound' | '.patch + NotFound (integer)' | '.patch + query + NotFound' | '.patch + id + query id' | '.create' | '.create + $select' | '.create multi' | '.create ignores query' | 'internal .find' | 'internal .get' | 'internal .create' | 'internal .update' | 'internal .patch' | 'internal .remove' export type AdapterSyntaxTestName = | '.find + equal' | '.find + equal multiple' | '.find + $sort' | '.find + $sort + string' | '.find + $limit' | '.find + $limit 0' | '.find + $skip' | '.find + $select' | '.find + $or' | '.find + $in' | '.find + $nin' | '.find + $lt' | '.find + $lte' | '.find + $gt' | '.find + $gte' | '.find + $ne' | '.find + $gt + $lt + $sort' | '.find + $or nested + $sort' | '.find + $and' | '.find + $and + $or' | 'params.adapter + paginate' | 'params.adapter + multi' | '.find + paginate' | '.find + paginate + query' | '.find + paginate + $limit + $skip' | '.find + paginate + $limit 0' | '.find + paginate + params' ================================================ FILE: packages/adapter-tests/src/index.ts ================================================ /* eslint-disable no-console */ import basicTests from './basic' import { AdapterTestName } from './declarations' import methodTests from './methods' import syntaxTests from './syntax' export const adapterTests = (testNames: AdapterTestName[]) => { return (app: any, errors: any, serviceName: any, idProp = 'id') => { if (!serviceName) { throw new Error('You must pass a service name') } const skippedTests: AdapterTestName[] = [] const allTests: AdapterTestName[] = [] const test = (name: AdapterTestName, runner: any) => { const skip = !testNames.includes(name) const its = skip ? it.skip : it if (skip) { skippedTests.push(name) } allTests.push(name) its(name, runner) } describe(`Adapter tests for '${serviceName}' service with '${idProp}' id property`, () => { after(() => { testNames.forEach((name) => { if (!allTests.includes(name)) { console.error(`WARNING: '${name}' test is not part of the test suite`) } }) if (skippedTests.length) { console.log( `\nSkipped the following ${skippedTests.length} Feathers adapter test(s) out of ${allTests.length} total:` ) console.log(JSON.stringify(skippedTests, null, ' ')) } }) basicTests(test, app, errors, serviceName, idProp) methodTests(test, app, errors, serviceName, idProp) syntaxTests(test, app, errors, serviceName, idProp) }) } } export * from './declarations' export default adapterTests if (typeof module !== 'undefined') { module.exports = Object.assign(adapterTests, module.exports) } ================================================ FILE: packages/adapter-tests/src/methods.ts ================================================ import assert from 'assert' import { AdapterMethodsTest } from './declarations' export default (test: AdapterMethodsTest, app: any, _errors: any, serviceName: string, idProp: string) => { describe(' Methods', () => { let doug: any let service: any beforeEach(async () => { service = app.service(serviceName) doug = await app.service(serviceName).create({ name: 'Doug', age: 32 }) }) afterEach(async () => { try { await app.service(serviceName).remove(doug[idProp]) } catch (error: any) {} }) describe('get', () => { test('.get', async () => { const data = await service.get(doug[idProp]) assert.strictEqual(data[idProp].toString(), doug[idProp].toString(), `${idProp} id matches`) assert.strictEqual(data.name, 'Doug', 'data.name matches') assert.strictEqual(data.age, 32, 'data.age matches') }) test('.get + $select', async () => { const data = await service.get(doug[idProp], { query: { $select: ['name'] } }) assert.strictEqual(data[idProp].toString(), doug[idProp].toString(), `${idProp} id property matches`) assert.strictEqual(data.name, 'Doug', 'data.name matches') assert.ok(!data.age, 'data.age is falsy') }) test('.get + id + query', async () => { try { await service.get(doug[idProp], { query: { name: 'Tester' } }) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error') } }) test('.get + NotFound', async () => { try { await service.get('568225fbfe21222432e836ff') throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error') } }) test('.get + NotFound (integer)', async () => { try { await service.get(123456789) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error') } }) test('.get + id + query id', async () => { const alice = await service.create({ name: 'Alice', age: 12 }) try { await service.get(doug[idProp], { query: { [idProp]: alice[idProp] } }) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error') } await service.remove(alice[idProp]) }) }) describe('find', () => { test('.find', async () => { const data = await service.find() assert.ok(Array.isArray(data), 'Data is an array') assert.strictEqual(data.length, 1, 'Got one entry') }) }) describe('remove', () => { test('.remove', async () => { const data = await service.remove(doug[idProp]) assert.strictEqual(data.name, 'Doug', 'data.name matches') }) test('.remove + $select', async () => { const data = await service.remove(doug[idProp], { query: { $select: ['name'] } }) assert.strictEqual(data[idProp].toString(), doug[idProp].toString(), `${idProp} id property matches`) assert.strictEqual(data.name, 'Doug', 'data.name matches') assert.ok(!data.age, 'data.age is falsy') }) test('.remove + id + query', async () => { try { await service.remove(doug[idProp], { query: { name: 'Tester' } }) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error') } }) test('.remove + NotFound', async () => { try { await service.remove('568225fbfe21222432e836ff') throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error') } }) test('.remove + NotFound (integer)', async () => { try { await service.remove(123456789) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error') } }) test('.remove + multi', async () => { try { await service.remove(null) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual( error.name, 'MethodNotAllowed', 'Removing multiple without option set throws MethodNotAllowed' ) } service.options.multi = ['remove'] await service.create({ name: 'Dave', age: 29, created: true }) await service.create({ name: 'David', age: 3, created: true }) const data = await service.remove(null, { query: { created: true } }) assert.strictEqual(data.length, 2) const names = data.map((person: any) => person.name) assert.ok(names.includes('Dave'), 'Dave removed') assert.ok(names.includes('David'), 'David removed') }) test('.remove + multi no pagination', async () => { try { await service.remove(doug[idProp]) } catch (error: any) {} const count = 14 const defaultPaginate = 10 assert.ok(count > defaultPaginate, 'count is bigger than default pagination') const multiBefore = service.options.multi const paginateBefore = service.options.paginate try { service.options.multi = true service.options.paginate = { default: defaultPaginate, max: 100 } const emptyItems = await service.find({ paginate: false }) assert.strictEqual(emptyItems.length, 0, 'no items before') const createdItems = await service.create( Array.from(Array(count)).map((_, i) => ({ name: `name-${i}`, age: 3, created: true })) ) assert.strictEqual(createdItems.length, count, `created ${count} items`) const foundItems = await service.find({ paginate: false }) assert.strictEqual(foundItems.length, count, `created ${count} items`) const foundPaginatedItems = await service.find({}) assert.strictEqual(foundPaginatedItems.data.length, defaultPaginate, 'found paginated items') const allItems = await service.remove(null, { query: { created: true } }) assert.strictEqual(allItems.length, count, `removed all ${count} items`) } finally { await service.remove(null, { query: { created: true }, paginate: false }) service.options.multi = multiBefore service.options.paginate = paginateBefore } }) test('.remove + id + query id', async () => { const alice = await service.create({ name: 'Alice', age: 12 }) try { await service.remove(doug[idProp], { query: { [idProp]: alice[idProp] } }) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error') } await service.remove(alice[idProp]) }) }) describe('update', () => { test('.update', async () => { const originalData = { [idProp]: doug[idProp], name: 'Dougler' } const originalCopy = Object.assign({}, originalData) const data = await service.update(doug[idProp], originalData) assert.deepStrictEqual(originalData, originalCopy, 'data was not modified') assert.strictEqual(data[idProp].toString(), doug[idProp].toString(), `${idProp} id matches`) assert.strictEqual(data.name, 'Dougler', 'data.name matches') assert.ok(!data.age, 'data.age is falsy') }) test('.update + $select', async () => { const originalData = { [idProp]: doug[idProp], name: 'Dougler', age: 10 } const data = await service.update(doug[idProp], originalData, { query: { $select: ['name'] } }) assert.strictEqual(data[idProp].toString(), doug[idProp].toString(), `${idProp} id property matches`) assert.strictEqual(data.name, 'Dougler', 'data.name matches') assert.ok(!data.age, 'data.age is falsy') }) test('.update + id + query', async () => { try { await service.update( doug[idProp], { name: 'Dougler' }, { query: { name: 'Tester' } } ) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error') } const updatedDoug = await service.get(doug[idProp]) assert.strictEqual(updatedDoug.name, 'Doug', 'Doug was not updated') }) test('.update + NotFound', async () => { try { await service.update('568225fbfe21222432e836ff', { name: 'NotFound' }) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error') } }) test('.update + NotFound (integer)', async () => { try { await service.update(123456789, { name: 'NotFound' }) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error') } }) test('.update + query + NotFound', async () => { const dave = await service.create({ name: 'Dave' }) try { await service.update(dave[idProp], { name: 'UpdatedDave' }, { query: { name: 'NotDave' } }) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error') } await service.remove(dave[idProp]) }) test('.update + id + query id', async () => { const alice = await service.create({ name: 'Alice', age: 12 }) try { await service.update( doug[idProp], { name: 'Dougler', age: 33 }, { query: { [idProp]: alice[idProp] } } ) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error') } await service.remove(alice[idProp]) }) }) describe('patch', () => { test('.patch', async () => { const originalData = { [idProp]: doug[idProp], name: 'PatchDoug' } const originalCopy = Object.assign({}, originalData) const data = await service.patch(doug[idProp], originalData) assert.deepStrictEqual(originalData, originalCopy, 'original data was not modified') assert.strictEqual(data[idProp].toString(), doug[idProp].toString(), `${idProp} id matches`) assert.strictEqual(data.name, 'PatchDoug', 'data.name matches') assert.strictEqual(data.age, 32, 'data.age matches') }) test('.patch + $select', async () => { const originalData = { [idProp]: doug[idProp], name: 'PatchDoug' } const data = await service.patch(doug[idProp], originalData, { query: { $select: ['name'] } }) assert.strictEqual(data[idProp].toString(), doug[idProp].toString(), `${idProp} id property matches`) assert.strictEqual(data.name, 'PatchDoug', 'data.name matches') assert.ok(!data.age, 'data.age is falsy') }) test('.patch + id + query', async () => { try { await service.patch( doug[idProp], { name: 'id patched doug' }, { query: { name: 'Tester' } } ) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error') } }) test('.patch multiple', async () => { try { await service.patch(null, {}) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual( error.name, 'MethodNotAllowed', 'Removing multiple without option set throws MethodNotAllowed' ) } const params = { query: { created: true } } const dave = await service.create({ name: 'Dave', age: 29, created: true }) const david = await service.create({ name: 'David', age: 3, created: true }) service.options.multi = ['patch'] const data = await service.patch( null, { age: 2 }, params ) assert.strictEqual(data.length, 2, 'returned two entries') assert.strictEqual(data[0].age, 2, 'First entry age was updated') assert.strictEqual(data[1].age, 2, 'Second entry age was updated') await service.remove(dave[idProp]) await service.remove(david[idProp]) }) test('.patch multiple no pagination', async () => { try { await service.remove(doug[idProp]) } catch (error: any) {} const count = 14 const defaultPaginate = 10 assert.ok(count > defaultPaginate, 'count is bigger than default pagination') const multiBefore = service.options.multi const paginateBefore = service.options.paginate let ids: any[] try { service.options.multi = true service.options.paginate = { default: defaultPaginate, max: 100 } const emptyItems = await service.find({ paginate: false }) assert.strictEqual(emptyItems.length, 0, 'no items before') const createdItems = await service.create( Array.from(Array(count)).map((_, i) => ({ name: `name-${i}`, age: 3, created: true })) ) assert.strictEqual(createdItems.length, count, `created ${count} items`) ids = createdItems.map((item: any) => item[idProp]) const foundItems = await service.find({ paginate: false }) assert.strictEqual(foundItems.length, count, `created ${count} items`) const foundPaginatedItems = await service.find({}) assert.strictEqual(foundPaginatedItems.data.length, defaultPaginate, 'found paginated data') const allItems = await service.patch(null, { age: 4 }, { query: { created: true } }) assert.strictEqual(allItems.length, count, `patched all ${count} items`) } finally { service.options.multi = multiBefore service.options.paginate = paginateBefore if (ids) { await Promise.all(ids.map((id) => service.remove(id))) } } }) test('.patch multi query same', async () => { const service = app.service(serviceName) const multiBefore = service.options.multi service.options.multi = true const params = { query: { age: { $lt: 10 } } } const dave = await service.create({ name: 'Dave', age: 8, created: true }) const david = await service.create({ name: 'David', age: 4, created: true }) const data = await service.patch( null, { age: 2 }, params ) assert.strictEqual(data.length, 2, 'returned two entries') assert.strictEqual(data[0].age, 2, 'First entry age was updated') assert.strictEqual(data[1].age, 2, 'Second entry age was updated') await service.remove(dave[idProp]) await service.remove(david[idProp]) service.options.multi = multiBefore }) test('.patch multi query changed', async () => { const service = app.service(serviceName) const multiBefore = service.options.multi service.options.multi = true const params = { query: { age: 10 } } const dave = await service.create({ name: 'Dave', age: 10, created: true }) const david = await service.create({ name: 'David', age: 10, created: true }) const data = await service.patch( null, { age: 2 }, params ) assert.strictEqual(data.length, 2, 'returned two entries') assert.strictEqual(data[0].age, 2, 'First entry age was updated') assert.strictEqual(data[1].age, 2, 'Second entry age was updated') await service.remove(dave[idProp]) await service.remove(david[idProp]) service.options.multi = multiBefore }) test('.patch + NotFound', async () => { try { await service.patch('568225fbfe21222432e836ff', { name: 'PatchDoug' }) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error') } }) test('.patch + NotFound (integer)', async () => { try { await service.patch(123456789, { name: 'PatchDoug' }) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error') } }) test('.patch + query + NotFound', async () => { const dave = await service.create({ name: 'Dave' }) try { await service.patch(dave[idProp], { name: 'PatchedDave' }, { query: { name: 'NotDave' } }) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error') } await service.remove(dave[idProp]) }) test('.patch + id + query id', async () => { const alice = await service.create({ name: 'Alice', age: 12 }) try { await service.patch( doug[idProp], { age: 33 }, { query: { [idProp]: alice[idProp] } } ) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error') } await service.remove(alice[idProp]) }) }) describe('create', () => { test('.create', async () => { const originalData = { name: 'Bill', age: 40 } const originalCopy = Object.assign({}, originalData) const data = await service.create(originalData) assert.deepStrictEqual(originalData, originalCopy, 'original data was not modified') assert.ok(data instanceof Object, 'data is an object') assert.strictEqual(data.name, 'Bill', 'data.name matches') await service.remove(data[idProp]) }) test('.create ignores query', async () => { const originalData = { name: 'Billy', age: 42 } const data = await service.create(originalData, { query: { name: 'Dave' } }) assert.strictEqual(data.name, 'Billy', 'data.name matches') await service.remove(data[idProp]) }) test('.create + $select', async () => { const originalData = { name: 'William', age: 23 } const data = await service.create(originalData, { query: { $select: ['name'] } }) assert.ok(idProp in data, 'data has id') assert.strictEqual(data.name, 'William', 'data.name matches') assert.ok(!data.age, 'data.age is falsy') await service.remove(data[idProp]) }) test('.create multi', async () => { try { await service.create([], {}) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual( error.name, 'MethodNotAllowed', 'Removing multiple without option set throws MethodNotAllowed' ) } const items = [ { name: 'Gerald', age: 18 }, { name: 'Herald', age: 18 } ] service.options.multi = ['create', 'patch'] const data = await service.create(items) assert.ok(Array.isArray(data), 'data is an array') assert.ok(typeof data[0][idProp] !== 'undefined', 'id is set') assert.strictEqual(data[0].name, 'Gerald', 'first name matches') assert.ok(typeof data[1][idProp] !== 'undefined', 'id is set') assert.strictEqual(data[1].name, 'Herald', 'second name macthes') await service.remove(data[0][idProp]) await service.remove(data[1][idProp]) }) }) describe("doesn't call public methods internally", () => { let throwing: any before(() => { throwing = Object.assign(Object.create(app.service(serviceName)), { get store() { return app.service(serviceName).store }, find() { throw new Error('find method called') }, get() { throw new Error('get method called') }, create() { throw new Error('create method called') }, update() { throw new Error('update method called') }, patch() { throw new Error('patch method called') }, remove() { throw new Error('remove method called') } }) }) test('internal .find', () => app.service(serviceName).find.call(throwing)) test('internal .get', () => service.get.call(throwing, doug[idProp])) test('internal .create', async () => { const bob = await service.create.call(throwing, { name: 'Bob', age: 25 }) await service.remove(bob[idProp]) }) test('internal .update', () => service.update.call(throwing, doug[idProp], { name: 'Dougler' })) test('internal .patch', () => service.patch.call(throwing, doug[idProp], { name: 'PatchDoug' })) test('internal .remove', () => service.remove.call(throwing, doug[idProp])) }) }) } ================================================ FILE: packages/adapter-tests/src/syntax.ts ================================================ import assert from 'assert' import { AdapterSyntaxTest } from './declarations' export default (test: AdapterSyntaxTest, app: any, _errors: any, serviceName: string, idProp: string) => { describe('Query Syntax', () => { let bob: any let alice: any let doug: any let service: any beforeEach(async () => { service = app.service(serviceName) bob = await app.service(serviceName).create({ name: 'Bob', age: 25 }) doug = await app.service(serviceName).create({ name: 'Doug', age: 32 }) alice = await app.service(serviceName).create({ name: 'Alice', age: 19 }) }) afterEach(async () => { await service.remove(bob[idProp]) await service.remove(alice[idProp]) await service.remove(doug[idProp]) }) test('.find + equal', async () => { const params = { query: { name: 'Alice' } } const data = await service.find(params) assert.ok(Array.isArray(data)) assert.strictEqual(data.length, 1) assert.strictEqual(data[0].name, 'Alice') }) test('.find + equal multiple', async () => { const data = await service.find({ query: { name: 'Alice', age: 20 } }) assert.strictEqual(data.length, 0) }) describe('special filters', () => { test('.find + $sort', async () => { let data = await service.find({ query: { $sort: { name: 1 } } }) assert.strictEqual(data.length, 3) assert.strictEqual(data[0].name, 'Alice') assert.strictEqual(data[1].name, 'Bob') assert.strictEqual(data[2].name, 'Doug') data = await service.find({ query: { $sort: { name: -1 } } }) assert.strictEqual(data.length, 3) assert.strictEqual(data[0].name, 'Doug') assert.strictEqual(data[1].name, 'Bob') assert.strictEqual(data[2].name, 'Alice') }) test('.find + $sort + string', async () => { const data = await service.find({ query: { $sort: { name: '1' } } }) assert.strictEqual(data.length, 3) assert.strictEqual(data[0].name, 'Alice') assert.strictEqual(data[1].name, 'Bob') assert.strictEqual(data[2].name, 'Doug') }) test('.find + $limit', async () => { const data = await service.find({ query: { $limit: 2 } }) assert.strictEqual(data.length, 2) }) test('.find + $limit 0', async () => { const data = await service.find({ query: { $limit: 0 } }) assert.strictEqual(data.length, 0) }) test('.find + $skip', async () => { const data = await service.find({ query: { $sort: { name: 1 }, $skip: 1 } }) assert.strictEqual(data.length, 2) assert.strictEqual(data[0].name, 'Bob') assert.strictEqual(data[1].name, 'Doug') }) test('.find + $select', async () => { const data = await service.find({ query: { name: 'Alice', $select: ['name'] } }) assert.strictEqual(data.length, 1) assert.ok(idProp in data[0], 'data has id') assert.strictEqual(data[0].name, 'Alice') assert.strictEqual(data[0].age, undefined) }) test('.find + $or', async () => { const data = await service.find({ query: { $or: [{ name: 'Alice' }, { name: 'Bob' }], $sort: { name: 1 } } }) assert.strictEqual(data.length, 2) assert.strictEqual(data[0].name, 'Alice') assert.strictEqual(data[1].name, 'Bob') }) test('.find + $in', async () => { const data = await service.find({ query: { name: { $in: ['Alice', 'Bob'] }, $sort: { name: 1 } } }) assert.strictEqual(data.length, 2) assert.strictEqual(data[0].name, 'Alice') assert.strictEqual(data[1].name, 'Bob') }) test('.find + $nin', async () => { const data = await service.find({ query: { name: { $nin: ['Alice', 'Bob'] } } }) assert.strictEqual(data.length, 1) assert.strictEqual(data[0].name, 'Doug') }) test('.find + $lt', async () => { const data = await service.find({ query: { age: { $lt: 30 } } }) assert.strictEqual(data.length, 2) }) test('.find + $lte', async () => { const data = await service.find({ query: { age: { $lte: 25 } } }) assert.strictEqual(data.length, 2) }) test('.find + $gt', async () => { const data = await service.find({ query: { age: { $gt: 30 } } }) assert.strictEqual(data.length, 1) }) test('.find + $gte', async () => { const data = await service.find({ query: { age: { $gte: 25 } } }) assert.strictEqual(data.length, 2) }) test('.find + $ne', async () => { const data = await service.find({ query: { age: { $ne: 25 } } }) assert.strictEqual(data.length, 2) }) }) test('.find + $gt + $lt + $sort', async () => { const params = { query: { age: { $gt: 18, $lt: 30 }, $sort: { name: 1 } } } const data = await service.find(params) assert.strictEqual(data.length, 2) assert.strictEqual(data[0].name, 'Alice') assert.strictEqual(data[1].name, 'Bob') }) test('.find + $or nested + $sort', async () => { const params = { query: { $or: [ { name: 'Doug' }, { age: { $gte: 18, $lt: 25 } } ], $sort: { name: 1 } } } const data = await service.find(params) assert.strictEqual(data.length, 2) assert.strictEqual(data[0].name, 'Alice') assert.strictEqual(data[1].name, 'Doug') }) test('.find + $and', async () => { const params = { query: { $and: [{ age: 19 }], $sort: { name: 1 } } } const data = await service.find(params) assert.strictEqual(data.length, 1) assert.strictEqual(data[0].name, 'Alice') }) test('.find + $and + $or', async () => { const params = { query: { $and: [{ $or: [{ name: 'Alice' }] }], $sort: { name: 1 } } } const data = await service.find(params) assert.strictEqual(data.length, 1) assert.strictEqual(data[0].name, 'Alice') }) describe('params.adapter', () => { test('params.adapter + paginate', async () => { const page = await service.find({ adapter: { paginate: { default: 3 } } }) assert.strictEqual(page.limit, 3) assert.strictEqual(page.skip, 0) }) test('params.adapter + multi', async () => { const items = [ { name: 'Garald', age: 200 }, { name: 'Harald', age: 24 } ] const multiParams = { adapter: { multi: ['create'] } } const users = await service.create(items, multiParams) assert.strictEqual(users.length, 2) await service.remove(users[0][idProp]) await service.remove(users[1][idProp]) await assert.rejects(() => service.patch(null, { age: 2 }, multiParams), { message: 'Can not patch multiple entries' }) }) }) describe('paginate', function () { beforeEach(() => { service.options.paginate = { default: 1, max: 2 } }) afterEach(() => { service.options.paginate = {} }) test('.find + paginate', async () => { const page = await service.find({ query: { $sort: { name: -1 } } }) assert.strictEqual(page.total, 3) assert.strictEqual(page.limit, 1) assert.strictEqual(page.skip, 0) assert.strictEqual(page.data[0].name, 'Doug') }) test('.find + paginate + query', async () => { const page = await service.find({ query: { $sort: { name: -1 }, name: 'Doug' } }) assert.strictEqual(page.total, 1) assert.strictEqual(page.limit, 1) assert.strictEqual(page.skip, 0) assert.strictEqual(page.data[0].name, 'Doug') }) test('.find + paginate + $limit + $skip', async () => { const params = { query: { $skip: 1, $limit: 4, $sort: { name: -1 } } } const page = await service.find(params) assert.strictEqual(page.total, 3) assert.strictEqual(page.limit, 2) assert.strictEqual(page.skip, 1) assert.strictEqual(page.data[0].name, 'Bob') assert.strictEqual(page.data[1].name, 'Alice') }) test('.find + paginate + $limit 0', async () => { const page = await service.find({ query: { $limit: 0 } }) assert.strictEqual(page.total, 3) assert.strictEqual(page.data.length, 0) }) test('.find + paginate + params', async () => { const page = await service.find({ paginate: { default: 3 } }) assert.strictEqual(page.limit, 3) assert.strictEqual(page.skip, 0) const results = await service.find({ paginate: false }) assert.ok(Array.isArray(results)) assert.strictEqual(results.length, 3) }) }) }) } ================================================ FILE: packages/adapter-tests/test/index.test.ts ================================================ import { strict as assert } from 'assert' import adapterTests from '../src' const testSuite = adapterTests([ '.events', '._get', '._find', '._create', '._update', '._patch', '._remove', '.$get', '.$find', '.$create', '.$update', '.$patch', '.$remove', '.get', '.get + $select', '.get + id + query', '.get + NotFound', '.find', '.remove', '.remove + $select', '.remove + id + query', '.remove + multi', '.remove + multi no pagination', '.update', '.update + $select', '.update + id + query', '.update + NotFound', '.patch', '.patch + $select', '.patch + id + query', '.patch multiple', '.patch multiple no pagination', '.patch multi query changed', '.patch multi query same', '.patch + NotFound', '.create', '.create + $select', '.create multi', 'internal .find', 'internal .get', 'internal .create', 'internal .update', 'internal .patch', 'internal .remove', '.find + equal', '.find + equal multiple', '.find + $sort', '.find + $sort + string', '.find + $limit', '.find + $limit 0', '.find + $skip', '.find + $select', '.find + $or', '.find + $in', '.find + $nin', '.find + $lt', '.find + $lte', '.find + $gt', '.find + $gte', '.find + $ne', '.find + $gt + $lt + $sort', '.find + $or nested + $sort', '.find + paginate', '.find + paginate + $limit + $skip', '.find + paginate + $limit 0', '.find + paginate + params', '.get + id + query id', '.remove + id + query id', '.update + id + query id', '.patch + id + query id' ]) describe('Feathers Memory Service', () => { it('loads the test suite', () => { assert.ok(typeof testSuite === 'function') }) it('exports as CommonJS', () => { assert.equal(typeof require('../lib'), 'function') }) }) ================================================ FILE: packages/adapter-tests/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/authentication/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) ### Bug Fixes - Revert to compatible UUID package ([#3630](https://github.com/feathersjs/feathers/issues/3630)) ([5c8c9e3](https://github.com/feathersjs/feathers/commit/5c8c9e36efbbf695eccd6d8822e36e1ea75c1516)) ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) ### Bug Fixes - Reduce usage of lodash ([#3455](https://github.com/feathersjs/feathers/issues/3455)) ([8ce807a](https://github.com/feathersjs/feathers/commit/8ce807a5ca53ff5b8d5107a0656c6329404e6e6c)) ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) ### Bug Fixes - **authentication:** Export JwtVerifyOptions ([#3214](https://github.com/feathersjs/feathers/issues/3214)) ([d59896e](https://github.com/feathersjs/feathers/commit/d59896eb0229f1490c712f19cf84eb2bcf123698)) ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/authentication ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Bug Fixes - **authentication:** Fix order of connection and login event handling ([#2909](https://github.com/feathersjs/feathers/issues/2909)) ([801a503](https://github.com/feathersjs/feathers/commit/801a503425062e27f2a32b91493b6ffae3822626)) - **core:** `context.type` for around hooks ([#2890](https://github.com/feathersjs/feathers/issues/2890)) ([d606ac6](https://github.com/feathersjs/feathers/commit/d606ac660fd5335c95206784fea36530dd2e851a)) ### Features - **schema:** Virtual property resolvers ([#2900](https://github.com/feathersjs/feathers/issues/2900)) ([7d03b57](https://github.com/feathersjs/feathers/commit/7d03b57ae2f633bdd4a368e0d5955011fbd6c329)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) ### Bug Fixes - **authentication:** Improve logout and disconnect connection handling ([#2813](https://github.com/feathersjs/feathers/issues/2813)) ([dd77379](https://github.com/feathersjs/feathers/commit/dd77379d8bdcd32d529bef912e672639e4899823)) # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) ### Features - **cli:** Generate full client test suite and improve typed client ([#2788](https://github.com/feathersjs/feathers/issues/2788)) ([57119b6](https://github.com/feathersjs/feathers/commit/57119b6bb2797f7297cf054268a248c093ecd538)) # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) - **schema:** Make schemas validation library independent and add TypeBox support ([#2772](https://github.com/feathersjs/feathers/issues/2772)) ([44172d9](https://github.com/feathersjs/feathers/commit/44172d99b566d11d9ceda04f1d0bf72b6d05ce76)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) ### Features - **authentication-oauth:** Koa and transport independent oAuth authentication ([#2737](https://github.com/feathersjs/feathers/issues/2737)) ([9231525](https://github.com/feathersjs/feathers/commit/9231525a24bb790ba9c5d940f2867a9c727691c9)) # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Bug Fixes - **authentication:** Add safe dispatch data for authentication requests ([#2662](https://github.com/feathersjs/feathers/issues/2662)) ([d8104a1](https://github.com/feathersjs/feathers/commit/d8104a19ee9181e6a5ea81014af29ff9a3c28a8a)) # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Features - **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5)) - **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28)) # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) ### Features - **authentication:** Add setup method for auth strategies ([#1611](https://github.com/feathersjs/feathers/issues/1611)) ([a3c3581](https://github.com/feathersjs/feathers/commit/a3c35814dccdbbf6de96f04f60b226ce206c6dbe)) - **configuration:** Allow app configuration to be validated against a schema ([#2590](https://github.com/feathersjs/feathers/issues/2590)) ([a268f86](https://github.com/feathersjs/feathers/commit/a268f86da92a8ada14ed11ab456aac0a4bba5bb0)) # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) ### Features - **express, koa:** make transports similar ([#2486](https://github.com/feathersjs/feathers/issues/2486)) ([26aa937](https://github.com/feathersjs/feathers/commit/26aa937c114fb8596dfefc599b1f53cead69c159)) # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Bug Fixes - **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110)) ### Features - **authentication-oauth:** Allow dynamic oAuth redirect ([#2469](https://github.com/feathersjs/feathers/issues/2469)) ([b7143d4](https://github.com/feathersjs/feathers/commit/b7143d4c0fbe961e714f79512be04449b9bbd7d9)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Bug Fixes - **hooks:** Migrate built-in hooks and allow backwards compatibility ([#2358](https://github.com/feathersjs/feathers/issues/2358)) ([759c5a1](https://github.com/feathersjs/feathers/commit/759c5a19327a731af965c3604119393b3d09a406)) - **koa:** Use extended query parser for compatibility ([#2397](https://github.com/feathersjs/feathers/issues/2397)) ([b2944ba](https://github.com/feathersjs/feathers/commit/b2944bac3ec6d5ecc80dc518cd4e58093692db74)) ### Features - **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) ### Features - **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) ### Features - Application service types default to any ([#1566](https://github.com/feathersjs/feathers/issues/1566)) ([d93ba9a](https://github.com/feathersjs/feathers/commit/d93ba9a17edd20d3397bb00f4f6e82e804e42ed6)) - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) **Note:** Version bump only for package @feathersjs/authentication # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) **Note:** Version bump only for package @feathersjs/authentication ## [4.5.10](https://github.com/feathersjs/feathers/compare/v4.5.9...v4.5.10) (2020-11-08) ### Bug Fixes - **authentication:** consistent response return between local and jwt strategy ([#2042](https://github.com/feathersjs/feathers/issues/2042)) ([8d25be1](https://github.com/feathersjs/feathers/commit/8d25be101a2593a9e789375c928a07780b9e28cf)) ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) **Note:** Version bump only for package @feathersjs/authentication ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) **Note:** Version bump only for package @feathersjs/authentication ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) ### Bug Fixes - **authentication:** Add JWT getEntityQuery ([#2013](https://github.com/feathersjs/feathers/issues/2013)) ([e0e7fb5](https://github.com/feathersjs/feathers/commit/e0e7fb5162940fe776731283b40026c61d9c8a33)) ## [4.5.6](https://github.com/feathersjs/feathers/compare/v4.5.5...v4.5.6) (2020-07-12) ### Bug Fixes - **authentication:** Omit query in JWT strategy ([#2011](https://github.com/feathersjs/feathers/issues/2011)) ([04ce7e9](https://github.com/feathersjs/feathers/commit/04ce7e98515fe9d495cd0e83e0da097e9bcd7382)) ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) ### Bug Fixes - **authentication:** Include query params when authenticating via authenticate hook [#2009](https://github.com/feathersjs/feathers/issues/2009) ([4cdb7bf](https://github.com/feathersjs/feathers/commit/4cdb7bf2898385ddac7a1692bc9ac2f6cf5ad446)) ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) ### Bug Fixes - **authentication:** Remove entity from connection information on logout ([#1889](https://github.com/feathersjs/feathers/issues/1889)) ([b062753](https://github.com/feathersjs/feathers/commit/b0627530d61babe15dd84369d3093ccae4b780ca)) ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) ### Bug Fixes - **authentication:** Improve JWT strategy configuration error message ([#1844](https://github.com/feathersjs/feathers/issues/1844)) ([2c771db](https://github.com/feathersjs/feathers/commit/2c771dbb22d53d4f7de3c3f514e57afa1a186322)) ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/authentication # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) ### Bug Fixes - Add `params.authentication` type, remove `hook.connection` type ([#1732](https://github.com/feathersjs/feathers/issues/1732)) ([d46b7b2](https://github.com/feathersjs/feathers/commit/d46b7b2abac8862c0e4dbfce20d71b8b8a96692f)) ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/authentication ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/authentication # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) **Note:** Version bump only for package @feathersjs/authentication ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) ### Bug Fixes - **authentication:** Retain object references in authenticate hook ([#1675](https://github.com/feathersjs/feathers/issues/1675)) ([e1939be](https://github.com/feathersjs/feathers/commit/e1939be19d4e79d3f5e2fe69ba894a11c627ae99)) ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/authentication ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) ### Bug Fixes - Add jsonwebtoken TypeScript type dependency ([317c80a](https://github.com/feathersjs/feathers/commit/317c80a9205e8853bb830a12c3aa1a19e95f9abc)) - Small type improvements ([#1624](https://github.com/feathersjs/feathers/issues/1624)) ([50162c6](https://github.com/feathersjs/feathers/commit/50162c6e562f0a47c6a280c4f01fff7c3afee293)) ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) **Note:** Version bump only for package @feathersjs/authentication ## [4.3.5](https://github.com/feathersjs/feathers/compare/v4.3.4...v4.3.5) (2019-10-07) ### Bug Fixes - Authentication type improvements and timeout fix ([#1605](https://github.com/feathersjs/feathers/issues/1605)) ([19854d3](https://github.com/feathersjs/feathers/commit/19854d3)) - Improve error message when authentication strategy is not allowed ([#1600](https://github.com/feathersjs/feathers/issues/1600)) ([317a312](https://github.com/feathersjs/feathers/commit/317a312)) ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) **Note:** Version bump only for package @feathersjs/authentication ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) ### Bug Fixes - check for undefined access token ([#1571](https://github.com/feathersjs/feathers/issues/1571)) ([976369d](https://github.com/feathersjs/feathers/commit/976369d)) - Small improvements in dependencies and code sturcture ([#1562](https://github.com/feathersjs/feathers/issues/1562)) ([42c13e2](https://github.com/feathersjs/feathers/commit/42c13e2)) ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) **Note:** Version bump only for package @feathersjs/authentication ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) ### Bug Fixes - Use long-timeout for JWT expiration timers ([#1552](https://github.com/feathersjs/feathers/issues/1552)) ([65637ec](https://github.com/feathersjs/feathers/commit/65637ec)) # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/authentication # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) ### Bug Fixes - Fix auth publisher mistake ([08bad61](https://github.com/feathersjs/feathers/commit/08bad61)) # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) ### Bug Fixes - Expire and remove authenticated real-time connections ([#1512](https://github.com/feathersjs/feathers/issues/1512)) ([2707c33](https://github.com/feathersjs/feathers/commit/2707c33)) - Update all dependencies ([7d53a00](https://github.com/feathersjs/feathers/commit/7d53a00)) ### Features - Let strategies handle the connection ([#1510](https://github.com/feathersjs/feathers/issues/1510)) ([4329feb](https://github.com/feathersjs/feathers/commit/4329feb)) # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) ### Bug Fixes - Add getEntityId to JWT strategy and fix legacy Socket authentication ([#1488](https://github.com/feathersjs/feathers/issues/1488)) ([9a3b324](https://github.com/feathersjs/feathers/commit/9a3b324)) - Add method to reliably get default authentication service ([#1470](https://github.com/feathersjs/feathers/issues/1470)) ([e542cb3](https://github.com/feathersjs/feathers/commit/e542cb3)) # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/authentication # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) **Note:** Version bump only for package @feathersjs/authentication # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) ### Bug Fixes - Updated typings for ServiceMethods ([#1409](https://github.com/feathersjs/feathers/issues/1409)) ([b5ee7e2](https://github.com/feathersjs/feathers/commit/b5ee7e2)) # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Make oAuth paths more consistent and improve authentication client ([#1377](https://github.com/feathersjs/feathers/issues/1377)) ([adb2543](https://github.com/feathersjs/feathers/commit/adb2543)) - Set authenticated: true after successful authentication ([#1367](https://github.com/feathersjs/feathers/issues/1367)) ([9918cff](https://github.com/feathersjs/feathers/commit/9918cff)) - Typings fix and improvements. ([#1364](https://github.com/feathersjs/feathers/issues/1364)) ([515b916](https://github.com/feathersjs/feathers/commit/515b916)) - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) ### Bug Fixes - Throw NotAuthenticated on token verification errors ([#1357](https://github.com/feathersjs/feathers/issues/1357)) ([e0120df](https://github.com/feathersjs/feathers/commit/e0120df)) # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) ### Bug Fixes - Always require strategy parameter in authentication ([#1327](https://github.com/feathersjs/feathers/issues/1327)) ([d4a8021](https://github.com/feathersjs/feathers/commit/d4a8021)) - Bring back params.authenticated ([#1317](https://github.com/feathersjs/feathers/issues/1317)) ([a0ffd5e](https://github.com/feathersjs/feathers/commit/a0ffd5e)) - Improve authentication parameter handling ([#1333](https://github.com/feathersjs/feathers/issues/1333)) ([6e77204](https://github.com/feathersjs/feathers/commit/6e77204)) - Merge httpStrategies and authStrategies option ([#1308](https://github.com/feathersjs/feathers/issues/1308)) ([afa4d55](https://github.com/feathersjs/feathers/commit/afa4d55)) - Rename jwtStrategies option to authStrategies ([#1305](https://github.com/feathersjs/feathers/issues/1305)) ([4aee151](https://github.com/feathersjs/feathers/commit/4aee151)) ### Features - Change and *JWT methods to *accessToken ([#1304](https://github.com/feathersjs/feathers/issues/1304)) ([5ac826b](https://github.com/feathersjs/feathers/commit/5ac826b)) # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Added path and method in to express request for passport ([#1112](https://github.com/feathersjs/feathers/issues/1112)) ([afa1cb4](https://github.com/feathersjs/feathers/commit/afa1cb4)) - Authentication core improvements ([#1260](https://github.com/feathersjs/feathers/issues/1260)) ([c5dc7a2](https://github.com/feathersjs/feathers/commit/c5dc7a2)) - Improve JWT authentication option handling ([#1261](https://github.com/feathersjs/feathers/issues/1261)) ([31b956b](https://github.com/feathersjs/feathers/commit/31b956b)) - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - Only merge authenticated property on update ([8a564f7](https://github.com/feathersjs/feathers/commit/8a564f7)) - reduce authentication connection hook complexity and remove unnecessary checks ([fa94b2f](https://github.com/feathersjs/feathers/commit/fa94b2f)) - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) - **authentication:** Fall back when req.app is not the application when emitting events ([#1185](https://github.com/feathersjs/feathers/issues/1185)) ([6a534f0](https://github.com/feathersjs/feathers/commit/6a534f0)) - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) - **docs/new-features:** syntax highlighting ([#347](https://github.com/feathersjs/feathers/issues/347)) ([4ab7c95](https://github.com/feathersjs/feathers/commit/4ab7c95)) - **package:** update @feathersjs/commons to version 2.0.0 ([#692](https://github.com/feathersjs/feathers/issues/692)) ([ca665ab](https://github.com/feathersjs/feathers/commit/ca665ab)) - **package:** update debug to version 3.0.0 ([#555](https://github.com/feathersjs/feathers/issues/555)) ([f788804](https://github.com/feathersjs/feathers/commit/f788804)) - **package:** update jsonwebtoken to version 8.0.0 ([#567](https://github.com/feathersjs/feathers/issues/567)) ([6811626](https://github.com/feathersjs/feathers/commit/6811626)) - **package:** update ms to version 2.0.0 ([#509](https://github.com/feathersjs/feathers/issues/509)) ([7e4b0b6](https://github.com/feathersjs/feathers/commit/7e4b0b6)) - **package:** update passport to version 0.4.0 ([#558](https://github.com/feathersjs/feathers/issues/558)) ([dcb14a5](https://github.com/feathersjs/feathers/commit/dcb14a5)) ### Features - @feathersjs/authentication-oauth ([#1299](https://github.com/feathersjs/feathers/issues/1299)) ([656bae7](https://github.com/feathersjs/feathers/commit/656bae7)) - Add AuthenticationBaseStrategy and make authentication option handling more explicit ([#1284](https://github.com/feathersjs/feathers/issues/1284)) ([2667d92](https://github.com/feathersjs/feathers/commit/2667d92)) - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - Authentication v3 core server implementation ([#1205](https://github.com/feathersjs/feathers/issues/1205)) ([1bd7591](https://github.com/feathersjs/feathers/commit/1bd7591)) - Authentication v3 local authentication ([#1211](https://github.com/feathersjs/feathers/issues/1211)) ([0fa5f7c](https://github.com/feathersjs/feathers/commit/0fa5f7c)) - Remove (hook, next) signature and SKIP support ([#1269](https://github.com/feathersjs/feathers/issues/1269)) ([211c0f8](https://github.com/feathersjs/feathers/commit/211c0f8)) - Support params symbol to skip authenticate hook ([#1296](https://github.com/feathersjs/feathers/issues/1296)) ([d16cf4d](https://github.com/feathersjs/feathers/commit/d16cf4d)) ### BREAKING CHANGES - Update authentication strategies for @feathersjs/authentication v3 ## [2.1.16](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication@2.1.15...@feathersjs/authentication@2.1.16) (2019-01-26) ### Bug Fixes - **authentication:** Fall back when req.app is not the application when emitting events ([#1185](https://github.com/feathersjs/feathers/issues/1185)) ([6a534f0](https://github.com/feathersjs/feathers/commit/6a534f0)) ## [2.1.15](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication@2.1.14...@feathersjs/authentication@2.1.15) (2019-01-02) ### Bug Fixes - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) ## [2.1.14](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication@2.1.13...@feathersjs/authentication@2.1.14) (2018-12-16) ### Bug Fixes - Added path and method in to express request for passport ([#1112](https://github.com/feathersjs/feathers/issues/1112)) ([afa1cb4](https://github.com/feathersjs/feathers/commit/afa1cb4)) ## [2.1.13](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication@2.1.12...@feathersjs/authentication@2.1.13) (2018-10-26) **Note:** Version bump only for package @feathersjs/authentication ## [2.1.12](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication@2.1.11...@feathersjs/authentication@2.1.12) (2018-10-25) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - Only merge authenticated property on update ([8a564f7](https://github.com/feathersjs/feathers/commit/8a564f7)) ## [2.1.11](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication@2.1.10...@feathersjs/authentication@2.1.11) (2018-09-21) **Note:** Version bump only for package @feathersjs/authentication ## [2.1.10](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication@2.1.9...@feathersjs/authentication@2.1.10) (2018-09-17) **Note:** Version bump only for package @feathersjs/authentication ## [2.1.9](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication@2.1.8...@feathersjs/authentication@2.1.9) (2018-09-02) **Note:** Version bump only for package @feathersjs/authentication ## 2.1.8 - Migrate to Monorepo ([feathers#462](https://github.com/feathersjs/feathers/issues/462)) ## [v2.1.7](https://github.com/feathersjs/authentication/tree/v2.1.7) (2018-06-29) [Full Changelog](https://github.com/feathersjs/authentication/compare/v2.1.6...v2.1.7) **Fixed bugs:** - XXXOrRestrict undermines provider \(security\) logic [\#395](https://github.com/feathersjs/authentication/issues/395) **Closed issues:** - Customize response of authentication service [\#679](https://github.com/feathersjs/authentication/issues/679) - hook.params.user is null using REST [\#678](https://github.com/feathersjs/authentication/issues/678) - Can't store JWT token to cookie on REST client [\#676](https://github.com/feathersjs/authentication/issues/676) - Is there a way to get req.user without using the authentication middleware? [\#675](https://github.com/feathersjs/authentication/issues/675) **Merged pull requests:** - Remove subject from the JWT verification options [\#686](https://github.com/feathersjs/authentication/pull/686) ([rasendubi](https://github.com/rasendubi)) - Replaced feathers.static with express.static [\#685](https://github.com/feathersjs/authentication/pull/685) ([georgehorrell](https://github.com/georgehorrell)) - Remove dependency on Express and Express middleware [\#683](https://github.com/feathersjs/authentication/pull/683) ([daffl](https://github.com/daffl)) - Update sinon to the latest version 🚀 [\#681](https://github.com/feathersjs/authentication/pull/681) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.1.6](https://github.com/feathersjs/authentication/tree/v2.1.6) (2018-06-01) [Full Changelog](https://github.com/feathersjs/authentication/compare/v2.1.5...v2.1.6) **Closed issues:** - Authentication local strategy not working with a Custom User service [\#672](https://github.com/feathersjs/authentication/issues/672) - CLI command bug: 'Feathers generate authentication' produces bad working 'users' service [\#670](https://github.com/feathersjs/authentication/issues/670) - config\default.json generated without callbackURL config needed to set redirect URL for Google Outh2 [\#669](https://github.com/feathersjs/authentication/issues/669) - HELP WANTED: Authentication strategy 'jwt' is not registered. [\#668](https://github.com/feathersjs/authentication/issues/668) - Authenticate shows error: No auth token [\#667](https://github.com/feathersjs/authentication/issues/667) - authentication - Method: remove [\#662](https://github.com/feathersjs/authentication/issues/662) - NotAuthenticated: jwt expired [\#633](https://github.com/feathersjs/authentication/issues/633) - Authentication via phone number [\#616](https://github.com/feathersjs/authentication/issues/616) - Persist auth tokens on db [\#569](https://github.com/feathersjs/authentication/issues/569) - Tighter integration with feathers-authentication-management [\#393](https://github.com/feathersjs/authentication/issues/393) **Merged pull requests:** - Fix tests to work with latest Sinon [\#674](https://github.com/feathersjs/authentication/pull/674) ([daffl](https://github.com/daffl)) - add option to allowUnauthenticated [\#599](https://github.com/feathersjs/authentication/pull/599) ([MichaelErmer](https://github.com/MichaelErmer)) ## [v2.1.5](https://github.com/feathersjs/authentication/tree/v2.1.5) (2018-04-16) [Full Changelog](https://github.com/feathersjs/authentication/compare/v2.1.4...v2.1.5) **Closed issues:** - feathersjs Invalid token: expired [\#661](https://github.com/feathersjs/authentication/issues/661) - Safari and iOS facebook login can't redirect back, but others can. [\#651](https://github.com/feathersjs/authentication/issues/651) **Merged pull requests:** - Remove payload and user entity on logout. [\#665](https://github.com/feathersjs/authentication/pull/665) ([bertho-zero](https://github.com/bertho-zero)) ## [v2.1.4](https://github.com/feathersjs/authentication/tree/v2.1.4) (2018-04-12) [Full Changelog](https://github.com/feathersjs/authentication/compare/v2.1.3...v2.1.4) **Closed issues:** - Column "createdAt" does not exist" in Autentication [\#660](https://github.com/feathersjs/authentication/issues/660) - How to make a user automatically logined on server side? [\#659](https://github.com/feathersjs/authentication/issues/659) - authentication-jwt functional example [\#657](https://github.com/feathersjs/authentication/issues/657) - "No auth token" with auth0 when following the guide [\#655](https://github.com/feathersjs/authentication/issues/655) - Service returns \[No Auth Token\] same by passing Authorization Token on HEADER [\#641](https://github.com/feathersjs/authentication/issues/641) **Merged pull requests:** - Throw an error for unavailable strategy [\#663](https://github.com/feathersjs/authentication/pull/663) ([daffl](https://github.com/daffl)) - Update sinon to the latest version 🚀 [\#656](https://github.com/feathersjs/authentication/pull/656) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.1.3](https://github.com/feathersjs/authentication/tree/v2.1.3) (2018-03-16) [Full Changelog](https://github.com/feathersjs/authentication/compare/v2.1.2...v2.1.3) **Closed issues:** - ts [\#647](https://github.com/feathersjs/authentication/issues/647) - Using /auth/facebook gives a 404 from vue-router [\#643](https://github.com/feathersjs/authentication/issues/643) - Crash after upgrade to feathersjs v3 [\#642](https://github.com/feathersjs/authentication/issues/642) - SameSite cookie option [\#640](https://github.com/feathersjs/authentication/issues/640) - context.params.user is empty object [\#635](https://github.com/feathersjs/authentication/issues/635) - Token is undefined for authenticated user [\#500](https://github.com/feathersjs/authentication/issues/500) - 1.x: logout timers need to be moved [\#467](https://github.com/feathersjs/authentication/issues/467) **Merged pull requests:** - Merge auk to master [\#653](https://github.com/feathersjs/authentication/pull/653) ([wnxhaja](https://github.com/wnxhaja)) - Update ws to the latest version 🚀 [\#645](https://github.com/feathersjs/authentication/pull/645) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update sinon-chai to the latest version 🚀 [\#644](https://github.com/feathersjs/authentication/pull/644) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.1.2](https://github.com/feathersjs/authentication/tree/v2.1.2) (2018-02-14) [Full Changelog](https://github.com/feathersjs/authentication/compare/v2.1.1...v2.1.2) **Fixed bugs:** - hook failed with auth & sync [\#540](https://github.com/feathersjs/authentication/issues/540) - JWT Cookie [\#389](https://github.com/feathersjs/authentication/issues/389) **Closed issues:** - forgot password [\#638](https://github.com/feathersjs/authentication/issues/638) - registered many authentication services [\#634](https://github.com/feathersjs/authentication/issues/634) - TypeError: Cannot read property '\_strategy' of undefined [\#632](https://github.com/feathersjs/authentication/issues/632) - How to change 5000ms timeout? [\#628](https://github.com/feathersjs/authentication/issues/628) - cookie reused from server in SSR app [\#619](https://github.com/feathersjs/authentication/issues/619) - Express middleware not setCookie [\#617](https://github.com/feathersjs/authentication/issues/617) - Server to Server Authentication Question [\#612](https://github.com/feathersjs/authentication/issues/612) - No way to share token between socket-rest-express [\#607](https://github.com/feathersjs/authentication/issues/607) - 404 when accessing route using customer authentication [\#579](https://github.com/feathersjs/authentication/issues/579) - \[question\] is it possible to protect by role a create method? [\#564](https://github.com/feathersjs/authentication/issues/564) - Authentication with server-side rendering [\#560](https://github.com/feathersjs/authentication/issues/560) - Problem authenticating using REST middleware [\#495](https://github.com/feathersjs/authentication/issues/495) - A supposed way to auth requests from SSR to Feathers API [\#469](https://github.com/feathersjs/authentication/issues/469) - rename `app.authenticate\(\)` to `app.\_authenticate\(\)` [\#468](https://github.com/feathersjs/authentication/issues/468) **Merged pull requests:** - Delete slack link [\#637](https://github.com/feathersjs/authentication/pull/637) ([vodniciarv](https://github.com/vodniciarv)) - Update @feathersjs/authentication-jwt to the latest version 🚀 [\#631](https://github.com/feathersjs/authentication/pull/631) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update mocha to the latest version 🚀 [\#629](https://github.com/feathersjs/authentication/pull/629) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update ws to the latest version 🚀 [\#625](https://github.com/feathersjs/authentication/pull/625) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Options merged [\#611](https://github.com/feathersjs/authentication/pull/611) ([Makingweb](https://github.com/Makingweb)) ## [v2.1.1](https://github.com/feathersjs/authentication/tree/v2.1.1) (2018-01-03) [Full Changelog](https://github.com/feathersjs/authentication/compare/v2.1.0...v2.1.1) **Closed issues:** - Deleted user successfully signs in using JWT [\#615](https://github.com/feathersjs/authentication/issues/615) - Feathers.authenticate gives window undefined \(server-rendered\) [\#573](https://github.com/feathersjs/authentication/issues/573) - Be careful with discard\('password'\) in user [\#434](https://github.com/feathersjs/authentication/issues/434) **Merged pull requests:** - Update readme to correspond with latest release [\#621](https://github.com/feathersjs/authentication/pull/621) ([daffl](https://github.com/daffl)) - Update semistandard to the latest version 🚀 [\#620](https://github.com/feathersjs/authentication/pull/620) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update mongodb to the latest version 🚀 [\#618](https://github.com/feathersjs/authentication/pull/618) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.1.0](https://github.com/feathersjs/authentication/tree/v2.1.0) (2017-12-06) [Full Changelog](https://github.com/feathersjs/authentication/compare/v2.0.1...v2.1.0) **Closed issues:** - Method "Remove" from Authentication Service gives Internal Server Error when using JWT Authentication with Cookies. [\#606](https://github.com/feathersjs/authentication/issues/606) - Anonymous Authentication fails over Socket.io [\#457](https://github.com/feathersjs/authentication/issues/457) **Merged pull requests:** - Always prevent publishing of authentication events [\#614](https://github.com/feathersjs/authentication/pull/614) ([daffl](https://github.com/daffl)) - Update feathers-memory to the latest version 🚀 [\#613](https://github.com/feathersjs/authentication/pull/613) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.0.1](https://github.com/feathersjs/authentication/tree/v2.0.1) (2017-11-16) [Full Changelog](https://github.com/feathersjs/authentication/compare/v2.0.0...v2.0.1) **Merged pull requests:** - Add default export for better ES module \(TypeScript\) compatibility [\#605](https://github.com/feathersjs/authentication/pull/605) ([daffl](https://github.com/daffl)) ## [v2.0.0](https://github.com/feathersjs/authentication/tree/v2.0.0) (2017-11-09) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.3.1...v2.0.0) **Closed issues:** - is there a way to detect if the token used is correct or not ? [\#601](https://github.com/feathersjs/authentication/issues/601) - option for non-JWT based session [\#597](https://github.com/feathersjs/authentication/issues/597) **Merged pull requests:** - Update nsp to the latest version 🚀 [\#603](https://github.com/feathersjs/authentication/pull/603) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.3.1](https://github.com/feathersjs/authentication/tree/v1.3.1) (2017-11-03) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.4.1...v1.3.1) **Merged pull requests:** - Only set the JWT UUID if it is not already set [\#600](https://github.com/feathersjs/authentication/pull/600) ([daffl](https://github.com/daffl)) ## [v1.4.1](https://github.com/feathersjs/authentication/tree/v1.4.1) (2017-11-01) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.4.0...v1.4.1) **Merged pull requests:** - Update dependencies for release [\#598](https://github.com/feathersjs/authentication/pull/598) ([daffl](https://github.com/daffl)) - Finalize v3 dependency updates [\#596](https://github.com/feathersjs/authentication/pull/596) ([daffl](https://github.com/daffl)) - Update Codeclimate coverage token [\#595](https://github.com/feathersjs/authentication/pull/595) ([daffl](https://github.com/daffl)) ## [v1.4.0](https://github.com/feathersjs/authentication/tree/v1.4.0) (2017-10-25) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.3.0...v1.4.0) **Closed issues:** - An in-range update of socket.io-client is breaking the build 🚨 [\#588](https://github.com/feathersjs/authentication/issues/588) - An in-range update of feathers-hooks is breaking the build 🚨 [\#587](https://github.com/feathersjs/authentication/issues/587) **Merged pull requests:** - Move to npm scope [\#594](https://github.com/feathersjs/authentication/pull/594) ([daffl](https://github.com/daffl)) - Update to Feathers v3 \(Buzzard\) [\#592](https://github.com/feathersjs/authentication/pull/592) ([daffl](https://github.com/daffl)) - Update to new plugin infrastructure [\#591](https://github.com/feathersjs/authentication/pull/591) ([daffl](https://github.com/daffl)) ## [v1.3.0](https://github.com/feathersjs/authentication/tree/v1.3.0) (2017-10-24) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.7.13...v1.3.0) **Merged pull requests:** - updating the codeclimate setup [\#589](https://github.com/feathersjs/authentication/pull/589) ([ekryski](https://github.com/ekryski)) ## [v0.7.13](https://github.com/feathersjs/authentication/tree/v0.7.13) (2017-10-23) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.2.7...v0.7.13) **Closed issues:** - Error authenticating! Error: Token provided to verifyJWT is missing or not a string ? [\#584](https://github.com/feathersjs/authentication/issues/584) - Visual Studio Code Debug no authentication [\#583](https://github.com/feathersjs/authentication/issues/583) - \[Feature Request\] Cloud DB's [\#581](https://github.com/feathersjs/authentication/issues/581) - Request doesn't contain any headers when user service requested [\#578](https://github.com/feathersjs/authentication/issues/578) - No way to pass Options to auth.express.authenticate. Needed for Google API refreshToken [\#576](https://github.com/feathersjs/authentication/issues/576) - /auth/google 404 Not Found [\#574](https://github.com/feathersjs/authentication/issues/574) - unique email not working while create [\#572](https://github.com/feathersjs/authentication/issues/572) - authentication service not return token jwt [\#571](https://github.com/feathersjs/authentication/issues/571) - typo in jwt default options [\#570](https://github.com/feathersjs/authentication/issues/570) - Generate new app, Google-only auth, throws error [\#568](https://github.com/feathersjs/authentication/issues/568) - An in-range update of feathers is breaking the build 🚨 [\#565](https://github.com/feathersjs/authentication/issues/565) - Documentation not understanding [\#563](https://github.com/feathersjs/authentication/issues/563) - Checking hook.params.headers.authorization [\#552](https://github.com/feathersjs/authentication/issues/552) - Ability to send token as part of URL [\#546](https://github.com/feathersjs/authentication/issues/546) - Anonymous Authentication [\#544](https://github.com/feathersjs/authentication/issues/544) - Quote Error [\#519](https://github.com/feathersjs/authentication/issues/519) - \[example\] CustomStrategy using passport-custom [\#516](https://github.com/feathersjs/authentication/issues/516) - \[Epic\] Auth 2.0.0 [\#513](https://github.com/feathersjs/authentication/issues/513) - ID set to null - Unable to delete with customer ID field. [\#422](https://github.com/feathersjs/authentication/issues/422) - Prefixing socket events [\#418](https://github.com/feathersjs/authentication/issues/418) - Passwordless auth [\#409](https://github.com/feathersjs/authentication/issues/409) - How to authenticate the application client? not only the users [\#405](https://github.com/feathersjs/authentication/issues/405) - Multi-factor Local Auth [\#5](https://github.com/feathersjs/authentication/issues/5) **Merged pull requests:** - Features/typescript fix [\#585](https://github.com/feathersjs/authentication/pull/585) ([TimMensch](https://github.com/TimMensch)) - Update mocha to the latest version 🚀 [\#582](https://github.com/feathersjs/authentication/pull/582) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update sinon to the latest version 🚀 [\#580](https://github.com/feathersjs/authentication/pull/580) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update jsonwebtoken to the latest version 🚀 [\#567](https://github.com/feathersjs/authentication/pull/567) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Include Babel Polyfill for Node 4 [\#566](https://github.com/feathersjs/authentication/pull/566) ([daffl](https://github.com/daffl)) - Update passport to the latest version 🚀 [\#558](https://github.com/feathersjs/authentication/pull/558) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Revert "Make feathers-authentication match security documents" [\#556](https://github.com/feathersjs/authentication/pull/556) ([ekryski](https://github.com/ekryski)) - Update debug to the latest version 🚀 [\#555](https://github.com/feathersjs/authentication/pull/555) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Make feathers-authentication match security documents [\#554](https://github.com/feathersjs/authentication/pull/554) ([micaksica2](https://github.com/micaksica2)) - Update sinon to the latest version 🚀 [\#551](https://github.com/feathersjs/authentication/pull/551) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update ws to the latest version 🚀 [\#549](https://github.com/feathersjs/authentication/pull/549) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update chai to the latest version 🚀 [\#543](https://github.com/feathersjs/authentication/pull/543) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - adding a default jwt uuid. Refs \#513 [\#539](https://github.com/feathersjs/authentication/pull/539) ([ekryski](https://github.com/ekryski)) - Refresh token must have a user ID [\#419](https://github.com/feathersjs/authentication/pull/419) ([francisco-sanchez-molina](https://github.com/francisco-sanchez-molina)) ## [v1.2.7](https://github.com/feathersjs/authentication/tree/v1.2.7) (2017-07-11) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.2.6...v1.2.7) **Closed issues:** - Connection without password [\#541](https://github.com/feathersjs/authentication/issues/541) - email in lower case ? [\#538](https://github.com/feathersjs/authentication/issues/538) - Im unable to ping feathers server from react native. [\#537](https://github.com/feathersjs/authentication/issues/537) - whats the official way to open cors in feather ? [\#536](https://github.com/feathersjs/authentication/issues/536) - Error options.service does not exist after initial auth setup [\#535](https://github.com/feathersjs/authentication/issues/535) - LogoutTimer not being cleared correctly [\#532](https://github.com/feathersjs/authentication/issues/532) - logoutTimer causing early logouts [\#404](https://github.com/feathersjs/authentication/issues/404) **Merged pull requests:** - fixed meta undefined error [\#542](https://github.com/feathersjs/authentication/pull/542) ([markacola](https://github.com/markacola)) ## [v1.2.6](https://github.com/feathersjs/authentication/tree/v1.2.6) (2017-06-22) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.2.5...v1.2.6) **Closed issues:** - OAuth 2 login for cordova [\#530](https://github.com/feathersjs/authentication/issues/530) **Merged pull requests:** - Change cleartimeout\(\) to lt.clearTimeout\(\) [\#534](https://github.com/feathersjs/authentication/pull/534) ([wnxhaja](https://github.com/wnxhaja)) - Update feathers-authentication-local to the latest version 🚀 [\#533](https://github.com/feathersjs/authentication/pull/533) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.2.5](https://github.com/feathersjs/authentication/tree/v1.2.5) (2017-06-21) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.2.4...v1.2.5) **Closed issues:** - Cannot read property 'user' of undefined - lib\socket\update-entity.js:26:104 [\#529](https://github.com/feathersjs/authentication/issues/529) - Provider is undefined when using restrictToRoles [\#525](https://github.com/feathersjs/authentication/issues/525) - How to make a request to an Endpoint that requires authentication from nodejs? [\#523](https://github.com/feathersjs/authentication/issues/523) **Merged pull requests:** - fixes several issues with update-entity w/ test cases [\#531](https://github.com/feathersjs/authentication/pull/531) ([jerfowler](https://github.com/jerfowler)) ## [v1.2.4](https://github.com/feathersjs/authentication/tree/v1.2.4) (2017-06-08) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.2.3...v1.2.4) **Fixed bugs:** - User \(Entity\) needs to be updated on the socket after authentication [\#293](https://github.com/feathersjs/authentication/issues/293) **Closed issues:** - Express Middleware local -\> jwt does not authorize on redirect [\#518](https://github.com/feathersjs/authentication/issues/518) - Issue with feathers-authentication [\#512](https://github.com/feathersjs/authentication/issues/512) - User Authentication Missing Credentials error \(and subsequent nav authorization\) [\#508](https://github.com/feathersjs/authentication/issues/508) - passport log failure [\#505](https://github.com/feathersjs/authentication/issues/505) - authenticate with a custom username field \(rather than email\) [\#502](https://github.com/feathersjs/authentication/issues/502) - app.get\('auth'\) vs app.get\('authentication'\) [\#497](https://github.com/feathersjs/authentication/issues/497) - Can't get success authorization with pure feathers server [\#491](https://github.com/feathersjs/authentication/issues/491) **Merged pull requests:** - Test and fix for authenticate event with invalid data [\#524](https://github.com/feathersjs/authentication/pull/524) ([daffl](https://github.com/daffl)) - Remove hook.data.payload [\#522](https://github.com/feathersjs/authentication/pull/522) ([marshallswain](https://github.com/marshallswain)) - Update socket entity [\#521](https://github.com/feathersjs/authentication/pull/521) ([marshallswain](https://github.com/marshallswain)) - Made each option, optional [\#515](https://github.com/feathersjs/authentication/pull/515) ([cranesandcaff](https://github.com/cranesandcaff)) - Add feathers-authentication-hooks in readme [\#510](https://github.com/feathersjs/authentication/pull/510) ([bertho-zero](https://github.com/bertho-zero)) - Update ms to the latest version 🚀 [\#509](https://github.com/feathersjs/authentication/pull/509) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Fix default authentication config keys [\#506](https://github.com/feathersjs/authentication/pull/506) ([ekryski](https://github.com/ekryski)) ## [v1.2.3](https://github.com/feathersjs/authentication/tree/v1.2.3) (2017-05-10) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.2.2...v1.2.3) **Closed issues:** - Validating custom express routes [\#498](https://github.com/feathersjs/authentication/issues/498) - Payload won't include userId when logging in with stored localStorage token [\#496](https://github.com/feathersjs/authentication/issues/496) - How to send oauth token authentication to another client server [\#493](https://github.com/feathersjs/authentication/issues/493) - Unhandled Promise Rejection error. [\#489](https://github.com/feathersjs/authentication/issues/489) - No Auth token on authentication resource [\#488](https://github.com/feathersjs/authentication/issues/488) - How to verify JWT in feathers issued by another feathers instance ? [\#484](https://github.com/feathersjs/authentication/issues/484) - hook.params.user [\#483](https://github.com/feathersjs/authentication/issues/483) - Overriding JWT's expiresIn with a value more than 20d prevents users from signing in [\#458](https://github.com/feathersjs/authentication/issues/458) **Merged pull requests:** - Update feathers-socketio to the latest version 🚀 [\#503](https://github.com/feathersjs/authentication/pull/503) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update socket.io-client to the latest version 🚀 [\#501](https://github.com/feathersjs/authentication/pull/501) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Fix issue with very large token timeout. [\#499](https://github.com/feathersjs/authentication/pull/499) ([asdacap](https://github.com/asdacap)) - Typo [\#492](https://github.com/feathersjs/authentication/pull/492) ([wdmtech](https://github.com/wdmtech)) - Update migrating.md [\#490](https://github.com/feathersjs/authentication/pull/490) ([MichaelErmer](https://github.com/MichaelErmer)) - Update semistandard to the latest version 🚀 [\#487](https://github.com/feathersjs/authentication/pull/487) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update feathers-hooks to the latest version 🚀 [\#485](https://github.com/feathersjs/authentication/pull/485) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update dependencies to enable Greenkeeper 🌴 [\#482](https://github.com/feathersjs/authentication/pull/482) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.2.2](https://github.com/feathersjs/authentication/tree/v1.2.2) (2017-04-12) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.2.1...v1.2.2) **Fixed bugs:** - accessToken not being used when provided by client over socketio [\#400](https://github.com/feathersjs/authentication/issues/400) **Closed issues:** - Incompatible old client dependency [\#479](https://github.com/feathersjs/authentication/issues/479) - Using feathers-authentication-client for an existing API? [\#478](https://github.com/feathersjs/authentication/issues/478) - app.authenticate error : UnhandledPromiseRejectionWarning: Unhandled promise rejection \(rejection id: 2\): \* Error \* [\#476](https://github.com/feathersjs/authentication/issues/476) - Make `socket.feathers` data available in authentication hooks [\#475](https://github.com/feathersjs/authentication/issues/475) - Allow the authenticate hook to be called with no parameters [\#473](https://github.com/feathersjs/authentication/issues/473) - Authenticate : How to return more infos ? [\#471](https://github.com/feathersjs/authentication/issues/471) **Merged pull requests:** - Use latest version of feathers-authentication-client [\#480](https://github.com/feathersjs/authentication/pull/480) ([daffl](https://github.com/daffl)) - Resolves \#475 - Socket params are made available to authentication hooks [\#477](https://github.com/feathersjs/authentication/pull/477) ([thomas-p-wilson](https://github.com/thomas-p-wilson)) ## [v1.2.1](https://github.com/feathersjs/authentication/tree/v1.2.1) (2017-04-07) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.2.0...v1.2.1) **Fixed bugs:** - failureRedirect is never used when using with oauth2 [\#387](https://github.com/feathersjs/authentication/issues/387) **Closed issues:** - OAuth guides [\#470](https://github.com/feathersjs/authentication/issues/470) - app.authenticate not working [\#466](https://github.com/feathersjs/authentication/issues/466) - how can I logout using local authentication? [\#465](https://github.com/feathersjs/authentication/issues/465) - How to do Socket.io Authentication [\#462](https://github.com/feathersjs/authentication/issues/462) - Add event filtering by default \(socket.io\) [\#460](https://github.com/feathersjs/authentication/issues/460) - Add ability to control if socket is marked as authenticated. [\#448](https://github.com/feathersjs/authentication/issues/448) - Auth redirect issue [\#425](https://github.com/feathersjs/authentication/issues/425) - E-mail verification step can be bypassed using Postman or Curl [\#391](https://github.com/feathersjs/authentication/issues/391) - Example app [\#386](https://github.com/feathersjs/authentication/issues/386) **Merged pull requests:** - Allow the cookie to be set if action is not `remove` [\#474](https://github.com/feathersjs/authentication/pull/474) ([marshallswain](https://github.com/marshallswain)) ## [v1.2.0](https://github.com/feathersjs/authentication/tree/v1.2.0) (2017-03-23) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.1.1...v1.2.0) **Fixed bugs:** - 1.0 authentication service hooks don't run when client uses feathers-socketio [\#455](https://github.com/feathersjs/authentication/issues/455) - `hook.params.provider` is not set when calling `client.authenticate\(\)` [\#432](https://github.com/feathersjs/authentication/issues/432) - remove method failed with JsonWebTokenError: invalid token [\#388](https://github.com/feathersjs/authentication/issues/388) **Closed issues:** - Token creation has side effect [\#454](https://github.com/feathersjs/authentication/issues/454) - Question: When is userId set? [\#453](https://github.com/feathersjs/authentication/issues/453) - How to authenticate SPA? More precisely how does the redirect works? [\#451](https://github.com/feathersjs/authentication/issues/451) - POST to auth/facebook for FacebookTokenStrategy 404? [\#447](https://github.com/feathersjs/authentication/issues/447) - feathers-authentication 1.1.1 `No auth token` [\#445](https://github.com/feathersjs/authentication/issues/445) - Another readme incorrect and maybe docs to [\#441](https://github.com/feathersjs/authentication/issues/441) - Readme incorrect and maybe docs to [\#440](https://github.com/feathersjs/authentication/issues/440) - npm version issue? [\#439](https://github.com/feathersjs/authentication/issues/439) - setCookie express middleware only works inside hooks [\#438](https://github.com/feathersjs/authentication/issues/438) - createJWT throws 'secret must provided' [\#437](https://github.com/feathersjs/authentication/issues/437) - Not useful error message on NotAuthenticated error [\#436](https://github.com/feathersjs/authentication/issues/436) - Passwordfeld in auth.local does not work as expected [\#435](https://github.com/feathersjs/authentication/issues/435) - Authentication via REST returns token without finding user on db [\#430](https://github.com/feathersjs/authentication/issues/430) **Merged pull requests:** - Filter out all events [\#461](https://github.com/feathersjs/authentication/pull/461) ([daffl](https://github.com/daffl)) - Fix socket auth [\#459](https://github.com/feathersjs/authentication/pull/459) ([marshallswain](https://github.com/marshallswain)) - Fix \#454 Token create has side effect [\#456](https://github.com/feathersjs/authentication/pull/456) ([whollacsek](https://github.com/whollacsek)) - Windows compatible version of the original compile comand with public folder support. [\#442](https://github.com/feathersjs/authentication/pull/442) ([appurist](https://github.com/appurist)) - Add client.js back for consistency [\#433](https://github.com/feathersjs/authentication/pull/433) ([daffl](https://github.com/daffl)) - add string to authenticate \(typescript\) [\#431](https://github.com/feathersjs/authentication/pull/431) ([superbarne](https://github.com/superbarne)) - Add support for Bearer scheme in remove method [\#403](https://github.com/feathersjs/authentication/pull/403) ([boybundit](https://github.com/boybundit)) ## [v1.1.1](https://github.com/feathersjs/authentication/tree/v1.1.1) (2017-03-02) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.1.0...v1.1.1) **Closed issues:** - Authentication over socket.io never answers [\#428](https://github.com/feathersjs/authentication/issues/428) **Merged pull requests:** - Remove lots of hardcoded values for config, and adds the `authenticate` hook [\#427](https://github.com/feathersjs/authentication/pull/427) ([myknbani](https://github.com/myknbani)) ## [v1.1.0](https://github.com/feathersjs/authentication/tree/v1.1.0) (2017-03-01) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.0.2...v1.1.0) **Fixed bugs:** - Mongo update error after logging into Facebook [\#244](https://github.com/feathersjs/authentication/issues/244) **Closed issues:** - Feature Request: Anonymous Authentication Strategy Support [\#423](https://github.com/feathersjs/authentication/issues/423) - Error is not thrown if token that is provided is invalid [\#421](https://github.com/feathersjs/authentication/issues/421) - Request body 'token' parameter disappears [\#420](https://github.com/feathersjs/authentication/issues/420) - Auth2 issue getting JWT token from server when different ports [\#416](https://github.com/feathersjs/authentication/issues/416) - Cookie-based authentication with XHR is not possible [\#413](https://github.com/feathersjs/authentication/issues/413) - JWT Authentication setup failing [\#411](https://github.com/feathersjs/authentication/issues/411) - how to disable service for external usage in version 1.0 [\#410](https://github.com/feathersjs/authentication/issues/410) - v1.0 is removed from npm? [\#408](https://github.com/feathersjs/authentication/issues/408) - Make JWT data more configurable [\#407](https://github.com/feathersjs/authentication/issues/407) - Possible typo [\#406](https://github.com/feathersjs/authentication/issues/406) - Authentication with an existing database with existing hashed \(md5\) passwords [\#398](https://github.com/feathersjs/authentication/issues/398) - can modify selected fields only [\#397](https://github.com/feathersjs/authentication/issues/397) - \[Discussion\] Migrating to 1.0 - hook changes [\#396](https://github.com/feathersjs/authentication/issues/396) - feathers-authentication 'local' strategy requires token? [\#394](https://github.com/feathersjs/authentication/issues/394) - JWT for local auth. [\#390](https://github.com/feathersjs/authentication/issues/390) - Feathers 'Twitter API' style [\#385](https://github.com/feathersjs/authentication/issues/385) - Missing code in example app [\#383](https://github.com/feathersjs/authentication/issues/383) - feathers-authentication errors with any view error, and redirects to /auth/failure [\#381](https://github.com/feathersjs/authentication/issues/381) - what does app.service\('authentication'\).remove\(...\) mean? [\#379](https://github.com/feathersjs/authentication/issues/379) - Rest Endpoints. [\#375](https://github.com/feathersjs/authentication/issues/375) - cordova google-plus signUp with id_token [\#373](https://github.com/feathersjs/authentication/issues/373) - How to reconnect socket with cookie after page refresh ? [\#372](https://github.com/feathersjs/authentication/issues/372) - Error: Could not find stored JWT and no authentication strategy was given [\#367](https://github.com/feathersjs/authentication/issues/367) - "No auth token" using authenticate strategy: 'jwt' \(v.1.0.0-beta-2\) [\#366](https://github.com/feathersjs/authentication/issues/366) - Navigating to /auth/\ twice redirects to /auth/failed [\#344](https://github.com/feathersjs/authentication/issues/344) - Meteor auth migration guide [\#334](https://github.com/feathersjs/authentication/issues/334) - Auth 1.0 [\#330](https://github.com/feathersjs/authentication/issues/330) - RSA token secret [\#309](https://github.com/feathersjs/authentication/issues/309) - Add option to use bcrypt [\#300](https://github.com/feathersjs/authentication/issues/300) - Better example of how to change hashing algorithm? \[Question\] [\#289](https://github.com/feathersjs/authentication/issues/289) - issuer doesn't work [\#284](https://github.com/feathersjs/authentication/issues/284) - passport auth question [\#274](https://github.com/feathersjs/authentication/issues/274) - Add support for authenticating active users only [\#259](https://github.com/feathersjs/authentication/issues/259) - 404 response from populateUser\(\) hook [\#258](https://github.com/feathersjs/authentication/issues/258) - Responses hang when token.secret is undefined for local authentication [\#249](https://github.com/feathersjs/authentication/issues/249) - Authentication without password [\#246](https://github.com/feathersjs/authentication/issues/246) - Fix successRedirect to not override cookie path [\#243](https://github.com/feathersjs/authentication/issues/243) - Deprecate verifyToken and populateUser hooks in favour of middleware [\#227](https://github.com/feathersjs/authentication/issues/227) - Authenticating and creating [\#100](https://github.com/feathersjs/authentication/issues/100) - Add a password service [\#83](https://github.com/feathersjs/authentication/issues/83) **Merged pull requests:** - Fix JWT options typo [\#415](https://github.com/feathersjs/authentication/pull/415) ([daffl](https://github.com/daffl)) - Prevent setCookie from mutating authOptions [\#414](https://github.com/feathersjs/authentication/pull/414) ([adrien-k](https://github.com/adrien-k)) - Typescript Definitions [\#412](https://github.com/feathersjs/authentication/pull/412) ([AbraaoAlves](https://github.com/AbraaoAlves)) - Docs for migrating to auth.hooks.authenticate hook [\#399](https://github.com/feathersjs/authentication/pull/399) ([petermikitsh](https://github.com/petermikitsh)) - Typo 'cookie.enable' should be 'cookie.enabled' [\#380](https://github.com/feathersjs/authentication/pull/380) ([whollacsek](https://github.com/whollacsek)) - Docs: Equalize usage of feathers-authenticate [\#378](https://github.com/feathersjs/authentication/pull/378) ([eikaramba](https://github.com/eikaramba)) ## [v1.0.2](https://github.com/feathersjs/authentication/tree/v1.0.2) (2016-12-14) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.0.1...v1.0.2) **Closed issues:** - successRedirect not redirecting [\#364](https://github.com/feathersjs/authentication/issues/364) ## [v1.0.1](https://github.com/feathersjs/authentication/tree/v1.0.1) (2016-12-14) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.0.0...v1.0.1) ## [v1.0.0](https://github.com/feathersjs/authentication/tree/v1.0.0) (2016-12-14) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.7.12...v1.0.0) **Fixed bugs:** - restrictToOwner does not support multi patch, update and remove [\#228](https://github.com/feathersjs/authentication/issues/228) **Closed issues:** - auth.express.authenticate got undefined [\#363](https://github.com/feathersjs/authentication/issues/363) - Non-standard header structure [\#361](https://github.com/feathersjs/authentication/issues/361) - localEndpoint without local strategy [\#359](https://github.com/feathersjs/authentication/issues/359) - Using custom passport strategies [\#356](https://github.com/feathersjs/authentication/issues/356) - Client-side app.on\('login'\) [\#355](https://github.com/feathersjs/authentication/issues/355) - Payload limiting on `app.get\('user'\)`? [\#354](https://github.com/feathersjs/authentication/issues/354) - Authentication token is missing [\#352](https://github.com/feathersjs/authentication/issues/352) - \[1.0\] The entity on the socket should pull from the strategy options. [\#348](https://github.com/feathersjs/authentication/issues/348) - \[1.0\] Only the first failure is returned on auth failure when chaining multiple strategies [\#346](https://github.com/feathersjs/authentication/issues/346) - Build 0.7.11 does not contain current code on NPMJS [\#342](https://github.com/feathersjs/authentication/issues/342) - feathers-authentication branch 0.8 did not work with payload \(tested on socket\) [\#264](https://github.com/feathersjs/authentication/issues/264) - Add method for updating JWT [\#260](https://github.com/feathersjs/authentication/issues/260) - 1.0 architecture considerations [\#226](https://github.com/feathersjs/authentication/issues/226) - Features/RFC [\#213](https://github.com/feathersjs/authentication/issues/213) - Support access_token based OAuth2 providers [\#169](https://github.com/feathersjs/authentication/issues/169) - Support openID [\#154](https://github.com/feathersjs/authentication/issues/154) - Disable cookie by default if not using OAuth [\#152](https://github.com/feathersjs/authentication/issues/152) - Add token service tests [\#144](https://github.com/feathersjs/authentication/issues/144) - Add local service tests [\#143](https://github.com/feathersjs/authentication/issues/143) - Add OAuth2 service tests [\#142](https://github.com/feathersjs/authentication/issues/142) - Add OAuth2 integration tests [\#141](https://github.com/feathersjs/authentication/issues/141) - Add integration tests for custom redirects [\#125](https://github.com/feathersjs/authentication/issues/125) - Support mobile authentication via OAuth1 [\#47](https://github.com/feathersjs/authentication/issues/47) - Support OAuth1 [\#42](https://github.com/feathersjs/authentication/issues/42) - Password-less Local Auth with Email / SMS [\#7](https://github.com/feathersjs/authentication/issues/7) **Merged pull requests:** - migrating to semistandard [\#371](https://github.com/feathersjs/authentication/pull/371) ([ekryski](https://github.com/ekryski)) - Logout should always give a response. [\#369](https://github.com/feathersjs/authentication/pull/369) ([marshallswain](https://github.com/marshallswain)) - Clarify that the authenticate hook is required. [\#368](https://github.com/feathersjs/authentication/pull/368) ([marshallswain](https://github.com/marshallswain)) - Fix README example [\#365](https://github.com/feathersjs/authentication/pull/365) ([saiberz](https://github.com/saiberz)) - Remove additional deprecation notice [\#362](https://github.com/feathersjs/authentication/pull/362) ([porsager](https://github.com/porsager)) - fix typo [\#360](https://github.com/feathersjs/authentication/pull/360) ([osenvosem](https://github.com/osenvosem)) - Update feathers-primus to version 2.0.0 🚀 [\#358](https://github.com/feathersjs/authentication/pull/358) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Create .codeclimate.yml [\#357](https://github.com/feathersjs/authentication/pull/357) ([larkinscott](https://github.com/larkinscott)) - fixing redirect middleware [\#353](https://github.com/feathersjs/authentication/pull/353) ([ekryski](https://github.com/ekryski)) - Remove useless quotes [\#351](https://github.com/feathersjs/authentication/pull/351) ([bertho-zero](https://github.com/bertho-zero)) - A bunch of bug fixes [\#349](https://github.com/feathersjs/authentication/pull/349) ([ekryski](https://github.com/ekryski)) - fix\(docs/new-features\): syntax highlighting [\#347](https://github.com/feathersjs/authentication/pull/347) ([justingreenberg](https://github.com/justingreenberg)) - Update superagent to version 3.0.0 🚀 [\#345](https://github.com/feathersjs/authentication/pull/345) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-memory to version 1.0.0 🚀 [\#343](https://github.com/feathersjs/authentication/pull/343) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - 1.0 Pre-release [\#336](https://github.com/feathersjs/authentication/pull/336) ([ekryski](https://github.com/ekryski)) ## [v0.7.12](https://github.com/feathersjs/authentication/tree/v0.7.12) (2016-11-11) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.7.11...v0.7.12) **Closed issues:** - App.authenticate uses wrong `this` reference [\#341](https://github.com/feathersjs/authentication/issues/341) - Getting more done in GitHub with ZenHub [\#331](https://github.com/feathersjs/authentication/issues/331) - Need help to use feathers authentication storage in vue vuex [\#329](https://github.com/feathersjs/authentication/issues/329) - How to get user id in hooks? [\#322](https://github.com/feathersjs/authentication/issues/322) - I checked out my new feathersjs app in another machine, created a new user but I can't log in! [\#320](https://github.com/feathersjs/authentication/issues/320) - restrict-to-owner throws error when user id is 0 [\#319](https://github.com/feathersjs/authentication/issues/319) - Not providing sufficient details for an auth provider should not be an error. [\#318](https://github.com/feathersjs/authentication/issues/318) - \[Question\] Is there a way to verify a user with password? [\#316](https://github.com/feathersjs/authentication/issues/316) - 0.8.0 beta 1 bug - this is not defined [\#315](https://github.com/feathersjs/authentication/issues/315) - Client: Document getJWT & verifyJWT [\#313](https://github.com/feathersjs/authentication/issues/313) - Socket client should automatically auth on reconnect [\#310](https://github.com/feathersjs/authentication/issues/310) - app.get\('token'\) doesn't work after a browser refresh. [\#303](https://github.com/feathersjs/authentication/issues/303) - Problem issuing multiple jwt's for the same user [\#302](https://github.com/feathersjs/authentication/issues/302) - restrict-to-owner does not allow Service.remove\(null\) from internal systems [\#301](https://github.com/feathersjs/authentication/issues/301) - How to migrate from restrictToOwner to checkPermissions [\#299](https://github.com/feathersjs/authentication/issues/299) - "username" cannot be used as local strategy usernameField [\#294](https://github.com/feathersjs/authentication/issues/294) - Bad Hook API Design: Hooks are inconsistent and impure functions [\#288](https://github.com/feathersjs/authentication/issues/288) - Mutliple 'user' models for authentication [\#282](https://github.com/feathersjs/authentication/issues/282) - Client should ensure socket.io upgrade is complete before authenticating [\#275](https://github.com/feathersjs/authentication/issues/275) - JWT is not sent after socket reconnection [\#272](https://github.com/feathersjs/authentication/issues/272) - 401 after service is moved/refactored [\#270](https://github.com/feathersjs/authentication/issues/270) - Client side auth should subscribe to user updates so that app.get\('user'\) is fresh [\#195](https://github.com/feathersjs/authentication/issues/195) - Make oauth2 more general [\#179](https://github.com/feathersjs/authentication/issues/179) - Add integration tests for custom service endpoints [\#145](https://github.com/feathersjs/authentication/issues/145) - Create a `requireAuth` wrapper for `verifyToken`, `populateUser`, `restrictToAuth` [\#118](https://github.com/feathersjs/authentication/issues/118) **Merged pull requests:** - babel-core@6.18.2 breaks build 🚨 [\#339](https://github.com/feathersjs/authentication/pull/339) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - 👻😱 Node.js 0.10 is unmaintained 😱👻 [\#337](https://github.com/feathersjs/authentication/pull/337) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - restrictToOwner -Fix check for methodNotAllowed [\#335](https://github.com/feathersjs/authentication/pull/335) ([daffl](https://github.com/daffl)) - Implement login and logout events for REST authentication [\#325](https://github.com/feathersjs/authentication/pull/325) ([daffl](https://github.com/daffl)) - Socket.io authentication tests and login logout event [\#324](https://github.com/feathersjs/authentication/pull/324) ([daffl](https://github.com/daffl)) - Reorganization [\#321](https://github.com/feathersjs/authentication/pull/321) ([ekryski](https://github.com/ekryski)) - client: use Authentication class, make `getJWT` and `verifyJWT` async [\#317](https://github.com/feathersjs/authentication/pull/317) ([marshallswain](https://github.com/marshallswain)) - 0.8 client decode jwt [\#314](https://github.com/feathersjs/authentication/pull/314) ([marshallswain](https://github.com/marshallswain)) - Store config at `app.config` [\#312](https://github.com/feathersjs/authentication/pull/312) ([marshallswain](https://github.com/marshallswain)) - Cookies will match jwt expiry by default. [\#308](https://github.com/feathersjs/authentication/pull/308) ([marshallswain](https://github.com/marshallswain)) - Remove permissions hooks and middleware [\#307](https://github.com/feathersjs/authentication/pull/307) ([daffl](https://github.com/daffl)) - First cut for authentication middleware [\#305](https://github.com/feathersjs/authentication/pull/305) ([daffl](https://github.com/daffl)) - 0.8 - OAuth fixes [\#304](https://github.com/feathersjs/authentication/pull/304) ([marshallswain](https://github.com/marshallswain)) ## [v0.7.11](https://github.com/feathersjs/authentication/tree/v0.7.11) (2016-09-28) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.7.10...v0.7.11) **Closed issues:** - Unable to authenticate with passport-google-oauth20 [\#295](https://github.com/feathersjs/authentication/issues/295) - "Unauthorized" Response with Hook Data [\#291](https://github.com/feathersjs/authentication/issues/291) - hashPassword in patch [\#286](https://github.com/feathersjs/authentication/issues/286) - Mobile App Facebook Login [\#276](https://github.com/feathersjs/authentication/issues/276) - Socket user should update automatically [\#266](https://github.com/feathersjs/authentication/issues/266) - Get user outside a service [\#261](https://github.com/feathersjs/authentication/issues/261) **Merged pull requests:** - hashPassword fall-through if there's no password [\#287](https://github.com/feathersjs/authentication/pull/287) ([marshallswain](https://github.com/marshallswain)) - Update feathers-memory to version 0.8.0 🚀 [\#285](https://github.com/feathersjs/authentication/pull/285) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Allow multiple username fields for local auth [\#283](https://github.com/feathersjs/authentication/pull/283) ([sdbondi](https://github.com/sdbondi)) ## [v0.7.10](https://github.com/feathersjs/authentication/tree/v0.7.10) (2016-08-31) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.7.9...v0.7.10) **Fixed bugs:** - restrictToOwner should not throw an error on mass deletions [\#175](https://github.com/feathersjs/authentication/issues/175) **Closed issues:** - Duplicate Email should be rejected by Default [\#281](https://github.com/feathersjs/authentication/issues/281) - Auth0 & featherjs authorization only [\#277](https://github.com/feathersjs/authentication/issues/277) - Cannot read property 'scope' of undefined [\#273](https://github.com/feathersjs/authentication/issues/273) - Socker.js | Custom successHandler [\#271](https://github.com/feathersjs/authentication/issues/271) - Use feathers-socketio? and rest&socket share session maybe? [\#269](https://github.com/feathersjs/authentication/issues/269) - Ability to invalidate old token/session when user login with another machine. [\#267](https://github.com/feathersjs/authentication/issues/267) - 0.8 authentication before hooks - only ever getting a 401 Unauthorised [\#263](https://github.com/feathersjs/authentication/issues/263) - REST Middleware breaks local auth [\#262](https://github.com/feathersjs/authentication/issues/262) - 0.8: Token Service errors on token auth using client [\#254](https://github.com/feathersjs/authentication/issues/254) - 0.8: Cookies, turning off feathers-session cookie also turns off feathers-jwt cookie. [\#253](https://github.com/feathersjs/authentication/issues/253) - Any example of how to do refresh token? [\#248](https://github.com/feathersjs/authentication/issues/248) - Custom Authentication Hooks [\#236](https://github.com/feathersjs/authentication/issues/236) - Is there an Authenticated Event [\#235](https://github.com/feathersjs/authentication/issues/235) - Error while using /auth/local [\#233](https://github.com/feathersjs/authentication/issues/233) - Providing token to feathers.authentication doesn't work [\#230](https://github.com/feathersjs/authentication/issues/230) - bundled hooks customize errors [\#215](https://github.com/feathersjs/authentication/issues/215) - Hooks should support a callback for conditionally running [\#210](https://github.com/feathersjs/authentication/issues/210) - restrictToRoles hook: More complex determination of "owner". [\#205](https://github.com/feathersjs/authentication/issues/205) - verifyToken hook option to error [\#200](https://github.com/feathersjs/authentication/issues/200) - Allow using restrictToOwner as an after hook [\#123](https://github.com/feathersjs/authentication/issues/123) **Merged pull requests:** - Manually supply an endpoint to the Client authenticate\(\) method [\#278](https://github.com/feathersjs/authentication/pull/278) ([mcnamee](https://github.com/mcnamee)) - Update mocha to version 3.0.0 🚀 [\#257](https://github.com/feathersjs/authentication/pull/257) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Don’t mix options when signing tokens [\#255](https://github.com/feathersjs/authentication/pull/255) ([marshallswain](https://github.com/marshallswain)) - Attempt to get token right away. [\#252](https://github.com/feathersjs/authentication/pull/252) ([marshallswain](https://github.com/marshallswain)) - Update async to version 2.0.0 🚀 [\#240](https://github.com/feathersjs/authentication/pull/240) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Creates better way or returning data in a familiar format [\#234](https://github.com/feathersjs/authentication/pull/234) ([codingfriend1](https://github.com/codingfriend1)) - Throws an error if restriction methods are used outside of a find or get hook [\#232](https://github.com/feathersjs/authentication/pull/232) ([codingfriend1](https://github.com/codingfriend1)) - RestrictToOwner now takes an array [\#231](https://github.com/feathersjs/authentication/pull/231) ([sscaff1](https://github.com/sscaff1)) - Adds ability to limit queries unless authenticated and authorized [\#229](https://github.com/feathersjs/authentication/pull/229) ([codingfriend1](https://github.com/codingfriend1)) ## [v0.7.9](https://github.com/feathersjs/authentication/tree/v0.7.9) (2016-06-20) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.7.8...v0.7.9) **Fixed bugs:** - Calling logout should revoke/blacklist a JWT [\#133](https://github.com/feathersjs/authentication/issues/133) **Closed issues:** - Query email rather than oauth provider id on /auth/\ [\#223](https://github.com/feathersjs/authentication/issues/223) - Cannot read property \'service\' of undefined [\#222](https://github.com/feathersjs/authentication/issues/222) **Merged pull requests:** - added support for hashing passwords when hook.data is an array [\#225](https://github.com/feathersjs/authentication/pull/225) ([eblin](https://github.com/eblin)) - jwt ssl warning [\#214](https://github.com/feathersjs/authentication/pull/214) ([aboutlo](https://github.com/aboutlo)) ## [v0.7.8](https://github.com/feathersjs/authentication/tree/v0.7.8) (2016-06-09) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.7.7...v0.7.8) **Closed issues:** - Feathers-authentication assumptions [\#220](https://github.com/feathersjs/authentication/issues/220) - Server-side header option does not accept capital letters [\#218](https://github.com/feathersjs/authentication/issues/218) - How to figure out why redirect to /auth/failure? [\#217](https://github.com/feathersjs/authentication/issues/217) - Getting token via REST is not documented [\#216](https://github.com/feathersjs/authentication/issues/216) - How to use Feathers Client to Authenticate Facebook/Instagram credentials [\#204](https://github.com/feathersjs/authentication/issues/204) - Remove token from localstorage [\#203](https://github.com/feathersjs/authentication/issues/203) - Check user password [\#193](https://github.com/feathersjs/authentication/issues/193) - app.authenticate\(\): Warning: a promise was rejected with a non-error: \[object Object\] [\#191](https://github.com/feathersjs/authentication/issues/191) - Authentication provider for Facebook Account Kit [\#189](https://github.com/feathersjs/authentication/issues/189) **Merged pull requests:** - Lowercase custom header [\#219](https://github.com/feathersjs/authentication/pull/219) ([mmwtsn](https://github.com/mmwtsn)) - mocha@2.5.0 breaks build 🚨 [\#212](https://github.com/feathersjs/authentication/pull/212) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Small refactoring to simplify structure and remove code duplication [\#209](https://github.com/feathersjs/authentication/pull/209) ([daffl](https://github.com/daffl)) - Use removeItem in the storage on logout [\#208](https://github.com/feathersjs/authentication/pull/208) ([daffl](https://github.com/daffl)) - Misspelled in a comment [\#201](https://github.com/feathersjs/authentication/pull/201) ([tryy3](https://github.com/tryy3)) - Update babel-plugin-add-module-exports to version 0.2.0 🚀 [\#199](https://github.com/feathersjs/authentication/pull/199) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v0.7.7](https://github.com/feathersjs/authentication/tree/v0.7.7) (2016-05-05) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.7.6...v0.7.7) **Fixed bugs:** - OAuth2 authentication callback failing due to missing property [\#196](https://github.com/feathersjs/authentication/issues/196) **Merged pull requests:** - properly handle optional `\_json` property [\#197](https://github.com/feathersjs/authentication/pull/197) ([nyaaao](https://github.com/nyaaao)) ## [v0.7.6](https://github.com/feathersjs/authentication/tree/v0.7.6) (2016-05-03) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.7.5...v0.7.6) **Fixed bugs:** - Facebook Authentication should do a patch not an update. [\#174](https://github.com/feathersjs/authentication/issues/174) **Closed issues:** - Authenticated user [\#192](https://github.com/feathersjs/authentication/issues/192) - REST token revoke [\#185](https://github.com/feathersjs/authentication/issues/185) - TypeError: Cannot read property 'service' of undefined [\#173](https://github.com/feathersjs/authentication/issues/173) - Optionally Include password in the params.query object passed to User.find\(\) [\#171](https://github.com/feathersjs/authentication/issues/171) - Pass more to local authentication params [\#165](https://github.com/feathersjs/authentication/issues/165) - Support custom authentication strategies [\#157](https://github.com/feathersjs/authentication/issues/157) **Merged pull requests:** - Allow manipulation of params before checking credentials [\#186](https://github.com/feathersjs/authentication/pull/186) ([saiichihashimoto](https://github.com/saiichihashimoto)) - Update feathers to version 2.0.1 🚀 [\#184](https://github.com/feathersjs/authentication/pull/184) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - fix\(oauth2\): Use patch to update user in oauthCallback [\#183](https://github.com/feathersjs/authentication/pull/183) ([beevelop](https://github.com/beevelop)) ## [v0.7.5](https://github.com/feathersjs/authentication/tree/v0.7.5) (2016-04-23) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.7.4...v0.7.5) **Fixed bugs:** - restrictToOwner and restrictToRoles have invalid type checking [\#172](https://github.com/feathersjs/authentication/issues/172) **Closed issues:** - user fails to signup with facebook if there is also local auth [\#168](https://github.com/feathersjs/authentication/issues/168) - Unable to authenticate requests when using vanilla Socket.IO [\#166](https://github.com/feathersjs/authentication/issues/166) ## [v0.7.4](https://github.com/feathersjs/authentication/tree/v0.7.4) (2016-04-18) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.7.3...v0.7.4) **Fixed bugs:** - restrictToOwner and restrictToRoles hooks don't work with nested models [\#163](https://github.com/feathersjs/authentication/issues/163) - Change restrictToOwner error when a request does not contain ID [\#160](https://github.com/feathersjs/authentication/issues/160) **Closed issues:** - authenticate\(\) can leak sensetive user data via token service [\#162](https://github.com/feathersjs/authentication/issues/162) - onBeforeLogin Hook [\#161](https://github.com/feathersjs/authentication/issues/161) **Merged pull requests:** - Hook fixes [\#164](https://github.com/feathersjs/authentication/pull/164) ([ekryski](https://github.com/ekryski)) ## [v0.7.3](https://github.com/feathersjs/authentication/tree/v0.7.3) (2016-04-16) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.7.2...v0.7.3) ## [v0.7.2](https://github.com/feathersjs/authentication/tree/v0.7.2) (2016-04-16) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.7.1...v0.7.2) **Closed issues:** - Auth doesn't work with non default local.userEndpoint [\#159](https://github.com/feathersjs/authentication/issues/159) - Automatically add the hashPassword hook to local.userEndpoint [\#158](https://github.com/feathersjs/authentication/issues/158) - Client authentication\(\) storage option not documented [\#155](https://github.com/feathersjs/authentication/issues/155) - restrictToRoles availability inconsistency [\#153](https://github.com/feathersjs/authentication/issues/153) - Does not populate user for other services [\#150](https://github.com/feathersjs/authentication/issues/150) **Merged pull requests:** - Steal Compatibility [\#156](https://github.com/feathersjs/authentication/pull/156) ([marshallswain](https://github.com/marshallswain)) ## [v0.7.1](https://github.com/feathersjs/authentication/tree/v0.7.1) (2016-04-08) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.7.0...v0.7.1) **Closed issues:** - Documentation discrepancies [\#148](https://github.com/feathersjs/authentication/issues/148) - bcrypt is hardcoded [\#146](https://github.com/feathersjs/authentication/issues/146) - Update Docs, Guides, Examples for v0.7 [\#129](https://github.com/feathersjs/authentication/issues/129) - populateUser: allow option to populate without db call. [\#92](https://github.com/feathersjs/authentication/issues/92) **Merged pull requests:** - Update feathers-memory to version 0.7.0 🚀 [\#149](https://github.com/feathersjs/authentication/pull/149) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - fix a typo [\#147](https://github.com/feathersjs/authentication/pull/147) ([chrjean](https://github.com/chrjean)) - Fix copy paste typo in queryWithCurrentUser hook. [\#140](https://github.com/feathersjs/authentication/pull/140) ([juodumas](https://github.com/juodumas)) ## [v0.7.0](https://github.com/feathersjs/authentication/tree/v0.7.0) (2016-03-30) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.6.0...v0.7.0) **Fixed bugs:** - logout should de-authenticate a socket [\#136](https://github.com/feathersjs/authentication/issues/136) - \[Security\] JsonWebToken Lifecycle Concerns; Set HttpOnly = true in JWT cookie [\#132](https://github.com/feathersjs/authentication/issues/132) - restrictToRoles hook needs to throw an error and not scope the query [\#128](https://github.com/feathersjs/authentication/issues/128) - restrictToOwner hook needs to throw an error and not scope the query [\#127](https://github.com/feathersjs/authentication/issues/127) - \[security\] Generated tokens are broadcast to all socket clients \(by default\) [\#126](https://github.com/feathersjs/authentication/issues/126) - \[oAuth\] User profile should be updated every time they are authenticated [\#124](https://github.com/feathersjs/authentication/issues/124) - Logout should clear the cookie [\#122](https://github.com/feathersjs/authentication/issues/122) - Want the default success/fail routes, not the sendFile [\#121](https://github.com/feathersjs/authentication/issues/121) **Closed issues:** - Make all hooks optional if used internally [\#138](https://github.com/feathersjs/authentication/issues/138) - Throw errors for deprecated hooks and update documentation [\#134](https://github.com/feathersjs/authentication/issues/134) - v6.0.0: How can I return the user object along with the token ? [\#131](https://github.com/feathersjs/authentication/issues/131) - user field not getting populated [\#119](https://github.com/feathersjs/authentication/issues/119) - Move to bcryptjs [\#112](https://github.com/feathersjs/authentication/issues/112) - Bundled hooks should pull from auth config to avoid having to pass duplicate props. [\#93](https://github.com/feathersjs/authentication/issues/93) - Customize the JWT payload [\#78](https://github.com/feathersjs/authentication/issues/78) - Needs a test for verifying that a custom tokenEndpoint works. [\#59](https://github.com/feathersjs/authentication/issues/59) - Finish test coverage for existing features. [\#9](https://github.com/feathersjs/authentication/issues/9) **Merged pull requests:** - 0.7 Release [\#139](https://github.com/feathersjs/authentication/pull/139) ([ekryski](https://github.com/ekryski)) ## [v0.6.0](https://github.com/feathersjs/authentication/tree/v0.6.0) (2016-03-24) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.5.1...v0.6.0) **Fixed bugs:** - Token encoding is not using the idField option. [\#107](https://github.com/feathersjs/authentication/issues/107) - Logging out breaks in React Native [\#105](https://github.com/feathersjs/authentication/issues/105) - Updating User Attached to Params in Client [\#102](https://github.com/feathersjs/authentication/issues/102) - local auth should not redirect by default [\#89](https://github.com/feathersjs/authentication/issues/89) **Closed issues:** - Id of user can't be 0 for auth [\#116](https://github.com/feathersjs/authentication/issues/116) - how to authenticate user in the socket.io? [\#111](https://github.com/feathersjs/authentication/issues/111) - Wrong Status Error [\#110](https://github.com/feathersjs/authentication/issues/110) - TypeError: Cannot read property 'service' of undefined \(continued\) [\#108](https://github.com/feathersjs/authentication/issues/108) - `idField` breaks from `tokenService.create\(\)` to `populateUser\(\)` after hook [\#103](https://github.com/feathersjs/authentication/issues/103) **Merged pull requests:** - Bcryptjs [\#137](https://github.com/feathersjs/authentication/pull/137) ([ekryski](https://github.com/ekryski)) - Allow user.id to be 0. Fixes \#116 [\#117](https://github.com/feathersjs/authentication/pull/117) ([marshallswain](https://github.com/marshallswain)) - client should return a 401 error code when no token is provided [\#115](https://github.com/feathersjs/authentication/pull/115) ([ccummings](https://github.com/ccummings)) - v0.6 - Bugs fixes, new hooks, and hook tests [\#109](https://github.com/feathersjs/authentication/pull/109) ([ekryski](https://github.com/ekryski)) - primus client connect event is 'open' [\#106](https://github.com/feathersjs/authentication/pull/106) ([ahdinosaur](https://github.com/ahdinosaur)) ## [v0.5.1](https://github.com/feathersjs/authentication/tree/v0.5.1) (2016-03-15) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.5.0...v0.5.1) ## [v0.5.0](https://github.com/feathersjs/authentication/tree/v0.5.0) (2016-03-14) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.4.1...v0.5.0) **Fixed bugs:** - Client should store token string and not the token object [\#95](https://github.com/feathersjs/authentication/issues/95) **Closed issues:** - using feathers-rest/client with feathers-authentication/client [\#94](https://github.com/feathersjs/authentication/issues/94) - populateUser can pull defaults from config, if available. [\#91](https://github.com/feathersjs/authentication/issues/91) - App level auth routes for multiple sub-routes [\#90](https://github.com/feathersjs/authentication/issues/90) - POST to /auth/local never gets response [\#88](https://github.com/feathersjs/authentication/issues/88) - populate-user.js do not get settings [\#86](https://github.com/feathersjs/authentication/issues/86) - Add rate limiting [\#81](https://github.com/feathersjs/authentication/issues/81) **Merged pull requests:** - Finalizing client side authentication module [\#101](https://github.com/feathersjs/authentication/pull/101) ([daffl](https://github.com/daffl)) - Ten hours is only 36 seconds [\#99](https://github.com/feathersjs/authentication/pull/99) ([mileswilson](https://github.com/mileswilson)) - Fix examples [\#98](https://github.com/feathersjs/authentication/pull/98) ([mastertinner](https://github.com/mastertinner)) - fix html in templates [\#97](https://github.com/feathersjs/authentication/pull/97) ([mastertinner](https://github.com/mastertinner)) - update populateUser\(\) hook [\#87](https://github.com/feathersjs/authentication/pull/87) ([kulakowka](https://github.com/kulakowka)) - Customize the JWT payload [\#80](https://github.com/feathersjs/authentication/pull/80) ([enten](https://github.com/enten)) ## [v0.4.1](https://github.com/feathersjs/authentication/tree/v0.4.1) (2016-02-28) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.4.0...v0.4.1) **Fixed bugs:** - app.logout\(\) fails [\#85](https://github.com/feathersjs/authentication/issues/85) **Closed issues:** - Username response ? [\#84](https://github.com/feathersjs/authentication/issues/84) - User doesn't get populated after authentication with databases that don't use \_id [\#71](https://github.com/feathersjs/authentication/issues/71) - Support client usage in NodeJS [\#52](https://github.com/feathersjs/authentication/issues/52) - Support async storage for React Native [\#51](https://github.com/feathersjs/authentication/issues/51) - RequireAdmin on userService [\#36](https://github.com/feathersjs/authentication/issues/36) - Create test for changing the `usernameField` [\#1](https://github.com/feathersjs/authentication/issues/1) ## [v0.4.0](https://github.com/feathersjs/authentication/tree/v0.4.0) (2016-02-27) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.3.5...v0.4.0) **Closed issues:** - Authentication not worked with hooks.remove\('password'\) [\#82](https://github.com/feathersjs/authentication/issues/82) **Merged pull requests:** - Refactoring for storage service [\#76](https://github.com/feathersjs/authentication/pull/76) ([ekryski](https://github.com/ekryski)) ## [v0.3.5](https://github.com/feathersjs/authentication/tree/v0.3.5) (2016-02-25) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.3.4...v0.3.5) **Merged pull requests:** - Adding support for OAuth2 token based auth strategies. Closes \#46. [\#77](https://github.com/feathersjs/authentication/pull/77) ([ekryski](https://github.com/ekryski)) ## [v0.3.4](https://github.com/feathersjs/authentication/tree/v0.3.4) (2016-02-25) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.3.3...v0.3.4) ## [v0.3.3](https://github.com/feathersjs/authentication/tree/v0.3.3) (2016-02-25) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.3.2...v0.3.3) ## [v0.3.2](https://github.com/feathersjs/authentication/tree/v0.3.2) (2016-02-24) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.3.1...v0.3.2) **Merged pull requests:** - bumping feathers-errors version [\#79](https://github.com/feathersjs/authentication/pull/79) ([ekryski](https://github.com/ekryski)) ## [v0.3.1](https://github.com/feathersjs/authentication/tree/v0.3.1) (2016-02-23) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.3.0...v0.3.1) **Closed issues:** - Fix toLowerCase hook [\#74](https://github.com/feathersjs/authentication/issues/74) - REST auth/local not working if socketio\(\) not set [\#72](https://github.com/feathersjs/authentication/issues/72) - Support mobile authentication via OAuth2 [\#46](https://github.com/feathersjs/authentication/issues/46) **Merged pull requests:** - Fix toLowerCase hook [\#75](https://github.com/feathersjs/authentication/pull/75) ([enten](https://github.com/enten)) ## [v0.3.0](https://github.com/feathersjs/authentication/tree/v0.3.0) (2016-02-19) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.2.4...v0.3.0) **Fixed bugs:** - Don't register successRedirect route if custom one is passed in [\#61](https://github.com/feathersjs/authentication/issues/61) **Closed issues:** - Specify the secret in one place instead of two [\#69](https://github.com/feathersjs/authentication/issues/69) - support a failRedirect [\#62](https://github.com/feathersjs/authentication/issues/62) - Document authentication updates [\#50](https://github.com/feathersjs/authentication/issues/50) **Merged pull requests:** - Config options [\#70](https://github.com/feathersjs/authentication/pull/70) ([ekryski](https://github.com/ekryski)) ## [v0.2.4](https://github.com/feathersjs/authentication/tree/v0.2.4) (2016-02-17) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.2.3...v0.2.4) **Closed issues:** - Find "query" is replaced by token [\#64](https://github.com/feathersjs/authentication/issues/64) **Merged pull requests:** - Add module exports Babel module and test CommonJS compatibility [\#68](https://github.com/feathersjs/authentication/pull/68) ([daffl](https://github.com/daffl)) ## [v0.2.3](https://github.com/feathersjs/authentication/tree/v0.2.3) (2016-02-15) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.2.2...v0.2.3) **Closed issues:** - How to forbid get and find on the userEndpoint? [\#66](https://github.com/feathersjs/authentication/issues/66) - userEndpoint problem in sub-app [\#63](https://github.com/feathersjs/authentication/issues/63) - How to modify successRedirect in local authentication? [\#60](https://github.com/feathersjs/authentication/issues/60) **Merged pull requests:** - Removing assigning token to params.query for sockets. [\#67](https://github.com/feathersjs/authentication/pull/67) ([ekryski](https://github.com/ekryski)) - Fixing client query [\#65](https://github.com/feathersjs/authentication/pull/65) ([fastlorenzo](https://github.com/fastlorenzo)) ## [v0.2.2](https://github.com/feathersjs/authentication/tree/v0.2.2) (2016-02-13) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.2.1...v0.2.2) **Closed issues:** - Custom tokenEndpoint failing [\#57](https://github.com/feathersjs/authentication/issues/57) - TypeError: Cannot read property 'service' of undefined [\#56](https://github.com/feathersjs/authentication/issues/56) - Login returns 500: Internal server error [\#54](https://github.com/feathersjs/authentication/issues/54) **Merged pull requests:** - Fixing token endpoint [\#58](https://github.com/feathersjs/authentication/pull/58) ([marshallswain](https://github.com/marshallswain)) ## [v0.2.1](https://github.com/feathersjs/authentication/tree/v0.2.1) (2016-02-12) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.2.0...v0.2.1) **Closed issues:** - Custom local options not being respected. [\#55](https://github.com/feathersjs/authentication/issues/55) - node can not require\("feathers-authentication"\).default [\#53](https://github.com/feathersjs/authentication/issues/53) ## [v0.2.0](https://github.com/feathersjs/authentication/tree/v0.2.0) (2016-02-12) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.1.2...v0.2.0) **Closed issues:** - Support graceful fallback to cookies [\#45](https://github.com/feathersjs/authentication/issues/45) - Add a client side component for authentication [\#44](https://github.com/feathersjs/authentication/issues/44) - Support OAuth2 [\#43](https://github.com/feathersjs/authentication/issues/43) - Support token based authentication [\#41](https://github.com/feathersjs/authentication/issues/41) - Support local authentication [\#40](https://github.com/feathersjs/authentication/issues/40) - Only sign the JWT with user id. Not the whole user object [\#38](https://github.com/feathersjs/authentication/issues/38) - Discussion: Securing token for socket.io auth [\#33](https://github.com/feathersjs/authentication/issues/33) - Handling expired tokens [\#25](https://github.com/feathersjs/authentication/issues/25) - Support multiple auth providers [\#6](https://github.com/feathersjs/authentication/issues/6) **Merged pull requests:** - Decoupling [\#49](https://github.com/feathersjs/authentication/pull/49) ([ekryski](https://github.com/ekryski)) - Adding an auth client [\#48](https://github.com/feathersjs/authentication/pull/48) ([ekryski](https://github.com/ekryski)) - Validate if provider [\#39](https://github.com/feathersjs/authentication/pull/39) ([mastertinner](https://github.com/mastertinner)) ## [v0.1.2](https://github.com/feathersjs/authentication/tree/v0.1.2) (2016-02-04) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.1.1...v0.1.2) **Closed issues:** - Hooks should support incoming data as arrays of objects. [\#34](https://github.com/feathersjs/authentication/issues/34) - Support authenticating with Username and Password via sockets [\#32](https://github.com/feathersjs/authentication/issues/32) **Merged pull requests:** - Check for params.provider in requireAuth hook [\#37](https://github.com/feathersjs/authentication/pull/37) ([marshallswain](https://github.com/marshallswain)) - safety check for data [\#35](https://github.com/feathersjs/authentication/pull/35) ([deanmcpherson](https://github.com/deanmcpherson)) ## [v0.1.1](https://github.com/feathersjs/authentication/tree/v0.1.1) (2016-01-30) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.1.0...v0.1.1) ## [v0.1.0](https://github.com/feathersjs/authentication/tree/v0.1.0) (2016-01-25) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.0.8...v0.1.0) **Closed issues:** - Get the Travis build to work. [\#27](https://github.com/feathersjs/authentication/issues/27) - Login not working [\#24](https://github.com/feathersjs/authentication/issues/24) - Hooks should be configurable \(they should be functions\) [\#11](https://github.com/feathersjs/authentication/issues/11) - Document the bundled hooks. [\#10](https://github.com/feathersjs/authentication/issues/10) **Merged pull requests:** - Migrate docs to book [\#31](https://github.com/feathersjs/authentication/pull/31) ([marshallswain](https://github.com/marshallswain)) - hashPassword: Async bcrypt usage needs a promise [\#30](https://github.com/feathersjs/authentication/pull/30) ([marshallswain](https://github.com/marshallswain)) - Removing extras from travis.yml [\#29](https://github.com/feathersjs/authentication/pull/29) ([marshallswain](https://github.com/marshallswain)) - Fixing build [\#28](https://github.com/feathersjs/authentication/pull/28) ([marshallswain](https://github.com/marshallswain)) - Adding nsp check [\#26](https://github.com/feathersjs/authentication/pull/26) ([marshallswain](https://github.com/marshallswain)) ## [v0.0.8](https://github.com/feathersjs/authentication/tree/v0.0.8) (2016-01-16) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.0.7...v0.0.8) **Merged pull requests:** - Support services that use pagination. [\#23](https://github.com/feathersjs/authentication/pull/23) ([marshallswain](https://github.com/marshallswain)) ## [v0.0.7](https://github.com/feathersjs/authentication/tree/v0.0.7) (2016-01-07) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.0.6...v0.0.7) **Closed issues:** - Password isn't removed from responses when using a mongoose service for users endpoint [\#19](https://github.com/feathersjs/authentication/issues/19) - next called twice using socket.io and using an unauthenticated service [\#17](https://github.com/feathersjs/authentication/issues/17) - Switch to a callback-based field configuration? [\#15](https://github.com/feathersjs/authentication/issues/15) - Cannot authenticate [\#14](https://github.com/feathersjs/authentication/issues/14) - Allow require without `.default` [\#13](https://github.com/feathersjs/authentication/issues/13) - Login validation [\#2](https://github.com/feathersjs/authentication/issues/2) **Merged pull requests:** - Adding separate route for refreshing a login token. [\#21](https://github.com/feathersjs/authentication/pull/21) ([corymsmith](https://github.com/corymsmith)) - Converting user model to object when using mongoose service [\#20](https://github.com/feathersjs/authentication/pull/20) ([corymsmith](https://github.com/corymsmith)) - Fixing issue where next is called twice when hitting an unauthenticated service via socket.io [\#18](https://github.com/feathersjs/authentication/pull/18) ([corymsmith](https://github.com/corymsmith)) - Fixing usage of mongoose service [\#16](https://github.com/feathersjs/authentication/pull/16) ([corymsmith](https://github.com/corymsmith)) ## [v0.0.6](https://github.com/feathersjs/authentication/tree/v0.0.6) (2015-11-22) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.0.5...v0.0.6) **Closed issues:** - Feathers Auth Configuration Error [\#12](https://github.com/feathersjs/authentication/issues/12) - Make sure we're returning proper error responses. [\#8](https://github.com/feathersjs/authentication/issues/8) ## [v0.0.5](https://github.com/feathersjs/authentication/tree/v0.0.5) (2015-11-19) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.0.4...v0.0.5) ## [v0.0.4](https://github.com/feathersjs/authentication/tree/v0.0.4) (2015-11-19) [Full Changelog](https://github.com/feathersjs/authentication/compare/v0.0.3...v0.0.4) ## [v0.0.3](https://github.com/feathersjs/authentication/tree/v0.0.3) (2015-11-18) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.0.6...v0.0.3) **Merged pull requests:** - allow runtime auth via socket.io [\#4](https://github.com/feathersjs/authentication/pull/4) ([randomnerd](https://github.com/randomnerd)) ## [v1.0.6](https://github.com/feathersjs/authentication/tree/v1.0.6) (2015-11-02) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.0.5...v1.0.6) ## [v1.0.5](https://github.com/feathersjs/authentication/tree/v1.0.5) (2015-11-02) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.0.4...v1.0.5) ## [v1.0.4](https://github.com/feathersjs/authentication/tree/v1.0.4) (2015-11-02) [Full Changelog](https://github.com/feathersjs/authentication/compare/v1.0.3...v1.0.4) ## [v1.0.3](https://github.com/feathersjs/authentication/tree/v1.0.3) (2015-10-12) \* _This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)_ ================================================ FILE: packages/authentication/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/authentication/README.md ================================================ # @feathersjs/authentication [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/authentication.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/authentication) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > Add Authentication to your FeathersJS app. ## Installation ``` npm install @feathersjs/authentication --save ``` ## Documentation Refer to the [Feathers authentication API documentation](https://feathersjs.com/api/authentication/) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/authentication/package.json ================================================ { "name": "@feathersjs/authentication", "description": "Add Authentication to your FeathersJS app.", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/authentication" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/commons": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/feathers": "^5.0.42", "@feathersjs/hooks": "^0.9.0", "@feathersjs/schema": "^5.0.42", "@feathersjs/transport-commons": "^5.0.42", "@types/jsonwebtoken": "^9.0.10", "jsonwebtoken": "^9.0.3", "lodash": "^4.17.23", "long-timeout": "^0.1.1", "uuid": "^11.1.0" }, "devDependencies": { "@feathersjs/memory": "^5.0.42", "@types/lodash": "^4.17.24", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "@types/uuid": "^10.0.0", "mocha": "^11.7.5", "shx": "^0.4.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/authentication/src/core.ts ================================================ import merge from 'lodash/merge' import jsonwebtoken, { SignOptions, Secret, VerifyOptions, Algorithm } from 'jsonwebtoken' import { v4 as uuidv4 } from 'uuid' import { NotAuthenticated } from '@feathersjs/errors' import { createDebug } from '@feathersjs/commons' import { Application, Params } from '@feathersjs/feathers' import { IncomingMessage, ServerResponse } from 'http' import { AuthenticationConfiguration, defaultOptions } from './options' const debug = createDebug('@feathersjs/authentication/base') export interface AuthenticationResult { [key: string]: any } export interface AuthenticationRequest { strategy?: string [key: string]: any } export interface AuthenticationParams extends Params { payload?: { [key: string]: any } jwtOptions?: SignOptions authStrategies?: string[] secret?: string [key: string]: any } export type ConnectionEvent = 'login' | 'logout' | 'disconnect' export interface AuthenticationStrategy { /** * Implement this method to get access to the AuthenticationService * * @param auth The AuthenticationService */ setAuthentication?(auth: AuthenticationBase): void /** * Implement this method to get access to the Feathers application * * @param app The Feathers application instance */ setApplication?(app: Application): void /** * Implement this method to get access to the strategy name * * @param name The name of the strategy */ setName?(name: string): void /** * Implement this method to verify the current configuration * and throw an error if it is invalid. */ verifyConfiguration?(): void /** * Implement this method to setup this strategy * @param auth The AuthenticationService * @param name The name of the strategy */ setup?(auth: AuthenticationBase, name: string): Promise /** * Authenticate an authentication request with this strategy. * Should throw an error if the strategy did not succeed. * * @param authentication The authentication request * @param params The service call parameters */ authenticate?( authentication: AuthenticationRequest, params: AuthenticationParams ): Promise /** * Update a real-time connection according to this strategy. * * @param connection The real-time connection * @param context The hook context */ handleConnection?(event: ConnectionEvent, connection: any, authResult?: AuthenticationResult): Promise /** * Parse a basic HTTP request and response for authentication request information. * * @param req The HTTP request * @param res The HTTP response */ parse?(req: IncomingMessage, res: ServerResponse): Promise } export interface JwtVerifyOptions extends VerifyOptions { algorithm?: string | string[] } /** * A base class for managing authentication strategies and creating and verifying JWTs */ export class AuthenticationBase { app: Application strategies: { [key: string]: AuthenticationStrategy } configKey: string isReady: boolean /** * Create a new authentication service. * * @param app The Feathers application instance * @param configKey The configuration key name in `app.get` (default: `authentication`) * @param options Optional initial options */ constructor(app: Application, configKey = 'authentication', options = {}) { if (!app || typeof app.use !== 'function') { throw new Error('An application instance has to be passed to the authentication service') } this.app = app this.strategies = {} this.configKey = configKey this.isReady = false app.set('defaultAuthentication', app.get('defaultAuthentication') || configKey) app.set(configKey, merge({}, app.get(configKey), options)) } /** * Return the current configuration from the application */ get configuration(): AuthenticationConfiguration { // Always returns a copy of the authentication configuration return Object.assign({}, defaultOptions, this.app.get(this.configKey)) } /** * A list of all registered strategy names */ get strategyNames() { return Object.keys(this.strategies) } /** * Register a new authentication strategy under a given name. * * @param name The name to register the strategy under * @param strategy The authentication strategy instance */ register(name: string, strategy: AuthenticationStrategy) { // Call the functions a strategy can implement if (typeof strategy.setName === 'function') { strategy.setName(name) } if (typeof strategy.setApplication === 'function') { strategy.setApplication(this.app) } if (typeof strategy.setAuthentication === 'function') { strategy.setAuthentication(this) } if (typeof strategy.verifyConfiguration === 'function') { strategy.verifyConfiguration() } // Register strategy as name this.strategies[name] = strategy if (this.isReady) { strategy.setup?.(this, name) } } /** * Get the registered authentication strategies for a list of names. * * @param names The list or strategy names */ getStrategies(...names: string[]) { return names.map((name) => this.strategies[name]).filter((current) => !!current) } /** * Returns a single strategy by name * * @param name The strategy name * @returns The authentication strategy or undefined */ getStrategy(name: string) { return this.strategies[name] } /** * Create a new access token with payload and options. * * @param payload The JWT payload * @param optsOverride The options to extend the defaults (`configuration.jwtOptions`) with * @param secretOverride Use a different secret instead */ async createAccessToken( payload: string | Buffer | object, optsOverride?: SignOptions, secretOverride?: Secret ) { const { secret, jwtOptions } = this.configuration // Use configuration by default but allow overriding the secret const jwtSecret = secretOverride || secret // Default jwt options merged with additional options const options = merge({}, jwtOptions, optsOverride) if (!options.jwtid) { // Generate a UUID as JWT ID by default options.jwtid = uuidv4() } return jsonwebtoken.sign(payload, jwtSecret, options) } /** * Verifies an access token. * * @param accessToken The token to verify * @param optsOverride The options to extend the defaults (`configuration.jwtOptions`) with * @param secretOverride Use a different secret instead */ async verifyAccessToken(accessToken: string, optsOverride?: JwtVerifyOptions, secretOverride?: Secret) { const { secret, jwtOptions } = this.configuration const jwtSecret = secretOverride || secret const options = merge({}, jwtOptions, optsOverride) const { algorithm } = options // Normalize the `algorithm` setting into the algorithms array if (algorithm && !options.algorithms) { options.algorithms = (Array.isArray(algorithm) ? algorithm : [algorithm]) as Algorithm[] delete options.algorithm } try { const verified = jsonwebtoken.verify(accessToken, jwtSecret, options) return verified as any } catch (error: any) { throw new NotAuthenticated(error.message, error) } } /** * Authenticate a given authentication request against a list of strategies. * * @param authentication The authentication request * @param params Service call parameters * @param allowed A list of allowed strategy names */ async authenticate( authentication: AuthenticationRequest, params: AuthenticationParams, ...allowed: string[] ) { const { strategy } = authentication || {} const [authStrategy] = this.getStrategies(strategy) const strategyAllowed = allowed.includes(strategy) debug('Running authenticate for strategy', strategy, allowed) if (!authentication || !authStrategy || !strategyAllowed) { const additionalInfo = (!strategy && ' (no `strategy` set)') || (!strategyAllowed && ' (strategy not allowed in authStrategies)') || '' // If there are no valid strategies or `authentication` is not an object throw new NotAuthenticated('Invalid authentication information' + additionalInfo) } return authStrategy.authenticate(authentication, { ...params, authenticated: true }) } async handleConnection(event: ConnectionEvent, connection: any, authResult?: AuthenticationResult) { const strategies = this.getStrategies(...Object.keys(this.strategies)).filter( (current) => typeof current.handleConnection === 'function' ) for (const strategy of strategies) { await strategy.handleConnection(event, connection, authResult) } } /** * Parse an HTTP request and response for authentication request information. * * @param req The HTTP request * @param res The HTTP response * @param names A list of strategies to use */ async parse(req: IncomingMessage, res: ServerResponse, ...names: string[]) { const strategies = this.getStrategies(...names).filter((current) => typeof current.parse === 'function') debug('Strategies parsing HTTP header for authentication information', names) for (const authStrategy of strategies) { const value = await authStrategy.parse(req, res) if (value !== null) { return value } } return null } async setup() { this.isReady = true for (const name of Object.keys(this.strategies)) { const strategy = this.strategies[name] await strategy.setup?.(this, name) } } } ================================================ FILE: packages/authentication/src/hooks/authenticate.ts ================================================ import { HookContext, NextFunction } from '@feathersjs/feathers' import { NotAuthenticated } from '@feathersjs/errors' import { createDebug } from '@feathersjs/commons' const debug = createDebug('@feathersjs/authentication/hooks/authenticate') export interface AuthenticateHookSettings { service?: string strategies?: string[] } export default (originalSettings: string | AuthenticateHookSettings, ...originalStrategies: string[]) => { const settings = typeof originalSettings === 'string' ? { strategies: [originalSettings, ...originalStrategies] } : originalSettings if (!originalSettings || settings.strategies.length === 0) { throw new Error('The authenticate hook needs at least one allowed strategy') } return async (context: HookContext, _next?: NextFunction) => { const next = typeof _next === 'function' ? _next : async () => context const { app, params, type, path, service } = context const { strategies } = settings const { provider, authentication } = params const authService = app.defaultAuthentication(settings.service) debug(`Running authenticate hook on '${path}'`) if (type && type !== 'before' && type !== 'around') { throw new NotAuthenticated('The authenticate hook must be used as a before hook') } if (!authService || typeof authService.authenticate !== 'function') { throw new NotAuthenticated('Could not find a valid authentication service') } if (service === authService) { throw new NotAuthenticated( 'The authenticate hook does not need to be used on the authentication service' ) } if (params.authenticated === true) { return next() } if (authentication) { const { provider, authentication, ...authParams } = params debug('Authenticating with', authentication, strategies) const authResult = await authService.authenticate(authentication, authParams, ...strategies) const { accessToken, ...authResultWithoutToken } = authResult context.params = { ...params, ...authResultWithoutToken, authenticated: true } } else if (provider) { throw new NotAuthenticated('Not authenticated') } return next() } } ================================================ FILE: packages/authentication/src/hooks/connection.ts ================================================ import { HookContext, NextFunction } from '@feathersjs/feathers' import { AuthenticationBase, ConnectionEvent } from '../core' export default (event: ConnectionEvent) => async (context: HookContext, next: NextFunction) => { await next() const { result, params: { connection } } = context if (connection) { const service = context.service as unknown as AuthenticationBase await service.handleConnection(event, connection, result) } } ================================================ FILE: packages/authentication/src/hooks/event.ts ================================================ import { HookContext, NextFunction } from '@feathersjs/feathers' import { createDebug } from '@feathersjs/commons' import { ConnectionEvent } from '../core' const debug = createDebug('@feathersjs/authentication/hooks/connection') export default (event: ConnectionEvent) => async (context: HookContext, next: NextFunction) => { await next() const { app, result, params } = context if (params.provider && result) { debug(`Sending authentication event '${event}'`) app.emit(event, result, params, context) } } ================================================ FILE: packages/authentication/src/hooks/index.ts ================================================ export { default as authenticate } from './authenticate' export { default as connection } from './connection' export { default as event } from './event' ================================================ FILE: packages/authentication/src/index.ts ================================================ export * as hooks from './hooks' export { authenticate } from './hooks' export { AuthenticationBase, AuthenticationRequest, AuthenticationResult, AuthenticationStrategy, AuthenticationParams, ConnectionEvent, JwtVerifyOptions } from './core' export { AuthenticationBaseStrategy } from './strategy' export { AuthenticationService } from './service' export { JWTStrategy } from './jwt' export { authenticationSettingsSchema, AuthenticationConfiguration } from './options' ================================================ FILE: packages/authentication/src/jwt.ts ================================================ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/ban-ts-comment */ import { IncomingMessage } from 'http' import { NotAuthenticated } from '@feathersjs/errors' import { Params } from '@feathersjs/feathers' import { createDebug } from '@feathersjs/commons' // @ts-ignore import lt from 'long-timeout' import { AuthenticationBaseStrategy } from './strategy' import { AuthenticationParams, AuthenticationRequest, AuthenticationResult, ConnectionEvent } from './core' const debug = createDebug('@feathersjs/authentication/jwt') const SPLIT_HEADER = /(\S+)\s+(\S+)/ export class JWTStrategy extends AuthenticationBaseStrategy { expirationTimers = new WeakMap() get configuration() { const authConfig = this.authentication.configuration const config = super.configuration return { service: authConfig.service, entity: authConfig.entity, entityId: authConfig.entityId, header: 'Authorization', schemes: ['Bearer', 'JWT'], ...config } } async handleConnection( event: ConnectionEvent, connection: any, authResult?: AuthenticationResult ): Promise { const isValidLogout = event === 'logout' && connection.authentication && authResult && connection.authentication.accessToken === authResult.accessToken const { accessToken } = authResult || {} const { entity } = this.configuration if (accessToken && event === 'login') { debug('Adding authentication information to connection') const { exp } = authResult?.authentication?.payload || (await this.authentication.verifyAccessToken(accessToken)) // The time (in ms) until the token expires const duration = exp * 1000 - Date.now() const timer = lt.setTimeout(() => this.app.emit('disconnect', connection), duration) debug(`Registering connection expiration timer for ${duration}ms`) lt.clearTimeout(this.expirationTimers.get(connection)) this.expirationTimers.set(connection, timer) debug('Adding authentication information to connection') connection.authentication = { strategy: this.name, accessToken } connection[entity] = authResult[entity] } else if (event === 'disconnect' || isValidLogout) { debug('Removing authentication information and expiration timer from connection') await new Promise((resolve) => process.nextTick(() => { delete connection[entity] delete connection.authentication resolve(connection) }) ) lt.clearTimeout(this.expirationTimers.get(connection)) this.expirationTimers.delete(connection) } } verifyConfiguration() { const allowedKeys = ['entity', 'entityId', 'service', 'header', 'schemes'] for (const key of Object.keys(this.configuration)) { if (!allowedKeys.includes(key)) { throw new Error( `Invalid JwtStrategy option 'authentication.${this.name}.${key}'. Did you mean to set it in 'authentication.jwtOptions'?` ) } } if (typeof this.configuration.header !== 'string') { throw new Error(`The 'header' option for the ${this.name} strategy must be a string`) } } async getEntityQuery(_params: Params) { return {} } /** * Return the entity for a given id * * @param id The id to use * @param params Service call parameters */ async getEntity(id: string, params: Params) { const entityService = this.entityService const { entity } = this.configuration debug('Getting entity', id) if (entityService === null) { throw new NotAuthenticated('Could not find entity service') } const query = await this.getEntityQuery(params) const { provider, ...paramsWithoutProvider } = params const result = await entityService.get(id, { ...paramsWithoutProvider, query }) if (!params.provider) { return result } return entityService.get(id, { ...params, [entity]: result }) } async getEntityId(authResult: AuthenticationResult, _params: Params) { return authResult.authentication.payload.sub } async authenticate(authentication: AuthenticationRequest, params: AuthenticationParams) { const { accessToken } = authentication const { entity } = this.configuration if (!accessToken) { throw new NotAuthenticated('No access token') } const payload = await this.authentication.verifyAccessToken(accessToken, params.jwt) const result = { accessToken, authentication: { strategy: 'jwt', accessToken, payload } } if (entity === null) { return result } const entityId = await this.getEntityId(result, params) const value = await this.getEntity(entityId, params) return { ...result, [entity]: value } } async parse(req: IncomingMessage): Promise<{ strategy: string accessToken: string } | null> { const { header, schemes }: { header: string; schemes: string[] } = this.configuration const headerValue = req.headers && req.headers[header.toLowerCase()] if (!headerValue || typeof headerValue !== 'string') { return null } debug('Found parsed header value') const [, scheme, schemeValue] = headerValue.match(SPLIT_HEADER) || [] const hasScheme = scheme && schemes.some((current) => new RegExp(current, 'i').test(scheme)) if (scheme && !hasScheme) { return null } return { strategy: this.name, accessToken: hasScheme ? schemeValue : headerValue } } } ================================================ FILE: packages/authentication/src/options.ts ================================================ import { FromSchema, authenticationSettingsSchema } from '@feathersjs/schema' export const defaultOptions = { authStrategies: [] as string[], jwtOptions: { header: { typ: 'access' }, // by default is an access token but can be any type audience: 'https://yourdomain.com', // The resource server where the token is processed issuer: 'feathers', // The issuing server, application or resource algorithm: 'HS256', expiresIn: '1d' } } export { authenticationSettingsSchema } export type AuthenticationConfiguration = FromSchema ================================================ FILE: packages/authentication/src/service.ts ================================================ import merge from 'lodash/merge' import { NotAuthenticated } from '@feathersjs/errors' import '@feathersjs/transport-commons' import { createDebug } from '@feathersjs/commons' import { ServiceMethods } from '@feathersjs/feathers' import { resolveDispatch } from '@feathersjs/schema' import jsonwebtoken from 'jsonwebtoken' import { hooks } from '@feathersjs/hooks' import { AuthenticationBase, AuthenticationResult, AuthenticationRequest, AuthenticationParams } from './core' import { connection, event } from './hooks' import { RealTimeConnection } from '@feathersjs/feathers' const debug = createDebug('@feathersjs/authentication/service') declare module '@feathersjs/feathers/lib/declarations' { // eslint-disable-next-line @typescript-eslint/no-unused-vars interface FeathersApplication { // eslint-disable-line /** * Returns the default authentication service or the * authentication service for a given path. * * @param location The service path to use (optional) */ defaultAuthentication?(location?: string): AuthenticationService } interface Params { authenticated?: boolean authentication?: AuthenticationRequest } } export class AuthenticationService extends AuthenticationBase implements Partial> { constructor(app: any, configKey = 'authentication', options = {}) { super(app, configKey, options) hooks(this, { create: [resolveDispatch(), event('login'), connection('login')], remove: [resolveDispatch(), event('logout'), connection('logout')] }) this.app.on('disconnect', async (connection: RealTimeConnection) => { await this.handleConnection('disconnect', connection) }) if (typeof app.defaultAuthentication !== 'function') { app.defaultAuthentication = function (location?: string) { const configKey = app.get('defaultAuthentication') const path = location || Object.keys(this.services).find((current) => this.service(current).configKey === configKey) return path ? this.service(path) : null } } } /** * Return the payload for a JWT based on the authentication result. * Called internally by the `create` method. * * @param _authResult The current authentication result * @param params The service call parameters */ async getPayload(_authResult: AuthenticationResult, params: AuthenticationParams) { // Uses `params.payload` or returns an empty payload const { payload = {} } = params return payload } /** * Returns the JWT options based on an authentication result. * By default sets the JWT subject to the entity id. * * @param authResult The authentication result * @param params Service call parameters */ async getTokenOptions(authResult: AuthenticationResult, params: AuthenticationParams) { const { service, entity, entityId } = this.configuration const jwtOptions = merge({}, params.jwtOptions, params.jwt) const value = service && entity && authResult[entity] // Set the subject to the entity id if it is available if (value && !jwtOptions.subject) { const idProperty = entityId || this.app.service(service).id const subject = value[idProperty] if (subject === undefined) { throw new NotAuthenticated(`Can not set subject from ${entity}.${idProperty}`) } jwtOptions.subject = `${subject}` } return jwtOptions } /** * Create and return a new JWT for a given authentication request. * Will trigger the `login` event. * * @param data The authentication request (should include `strategy` key) * @param params Service call parameters */ async create(data: AuthenticationRequest, params?: AuthenticationParams) { const authStrategies = params.authStrategies || this.configuration.authStrategies if (!authStrategies.length) { throw new NotAuthenticated('No authentication strategies allowed for creating a JWT (`authStrategies`)') } const authResult = await this.authenticate(data, params, ...authStrategies) debug('Got authentication result', authResult) if (authResult.accessToken) { return authResult } const [payload, jwtOptions] = await Promise.all([ this.getPayload(authResult, params), this.getTokenOptions(authResult, params) ]) debug('Creating JWT with', payload, jwtOptions) const accessToken = await this.createAccessToken(payload, jwtOptions, params.secret) return { accessToken, ...authResult, authentication: { ...authResult.authentication, payload: jsonwebtoken.decode(accessToken) } } } /** * Mark a JWT as removed. By default only verifies the JWT and returns the result. * Triggers the `logout` event. * * @param id The JWT to remove or null * @param params Service call parameters */ async remove(id: string | null, params?: AuthenticationParams) { const { authentication } = params const { authStrategies } = this.configuration // When an id is passed it is expected to be the authentication `accessToken` if (id !== null && id !== authentication.accessToken) { throw new NotAuthenticated('Invalid access token') } debug('Verifying authentication strategy in remove') return this.authenticate(authentication, params, ...authStrategies) } /** * Validates the service configuration. */ async setup() { await super.setup() // The setup method checks for valid settings and registers the // connection and event (login, logout) hooks const { secret, service, entity, entityId } = this.configuration if (typeof secret !== 'string') { throw new Error("A 'secret' must be provided in your authentication configuration") } if (entity !== null) { if (service === undefined) { throw new Error("The 'service' option is not set in the authentication configuration") } if (this.app.service(service) === undefined) { throw new Error( `The '${service}' entity service does not exist (set to 'null' if it is not required)` ) } if (this.app.service(service).id === undefined && entityId === undefined) { throw new Error( `The '${service}' service does not have an 'id' property and no 'entityId' option is set.` ) } } const publishable = this as any if (typeof publishable.publish === 'function') { publishable.publish((): any => null) } } } ================================================ FILE: packages/authentication/src/strategy.ts ================================================ import { AuthenticationStrategy, AuthenticationBase } from './core' import { Application, Service } from '@feathersjs/feathers' export class AuthenticationBaseStrategy implements AuthenticationStrategy { authentication?: AuthenticationBase app?: Application name?: string setAuthentication(auth: AuthenticationBase) { this.authentication = auth } setApplication(app: Application) { this.app = app } setName(name: string) { this.name = name } get configuration(): any { return this.authentication.configuration[this.name] } get entityService(): Service { const { service } = this.configuration if (!service) { return null } return this.app.service(service) || null } } ================================================ FILE: packages/authentication/test/core.test.ts ================================================ /* eslint-disable @typescript-eslint/ban-ts-comment */ import assert from 'assert' import { feathers, Application } from '@feathersjs/feathers' import jwt from 'jsonwebtoken' import { Infer, schema } from '@feathersjs/schema' import { AuthenticationBase, AuthenticationRequest } from '../src/core' import { authenticationSettingsSchema } from '../src/options' import { Strategy1, Strategy2, MockRequest } from './fixtures' import { ServerResponse } from 'http' const UUID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/ describe('authentication/core', () => { let app: Application let auth: AuthenticationBase beforeEach(() => { app = feathers() auth = new AuthenticationBase(app, 'authentication', { entity: 'user', service: 'users', secret: 'supersecret', first: { hello: 'test' } }) auth.register('first', new Strategy1()) auth.register('second', new Strategy2()) auth.register('dummy', { async authenticate(data: AuthenticationRequest) { return data } }) }) describe('configuration', () => { it('infers configuration from settings schema', async () => { const settingsSchema = schema({ $id: 'AuthSettingsSchema', ...authenticationSettingsSchema } as const) type Settings = Infer const config: Settings = { entity: 'user', secret: 'supersecret', authStrategies: ['some', 'thing'] } await settingsSchema.validate(config) }) it('throws an error when app is not provided', () => { try { // @ts-ignore const otherAuth = new AuthenticationBase() assert.fail('Should never get here') assert.ok(otherAuth) } catch (error: any) { assert.strictEqual( error.message, 'An application instance has to be passed to the authentication service' ) } }) it('sets defaults', () => { // Getting configuration twice returns a copy assert.notStrictEqual(auth.configuration, auth.configuration) assert.strictEqual(auth.configuration.entity, 'user') }) it('allows to override jwtOptions, does not merge', () => { const { jwtOptions } = auth.configuration const auth2options = { jwtOptions: { expiresIn: '1w' } } app.set('auth2', auth2options) const auth2 = new AuthenticationBase(app, 'auth2') assert.ok(jwtOptions) assert.strictEqual(jwtOptions.expiresIn, '1d') assert.strictEqual(jwtOptions.issuer, 'feathers') assert.deepStrictEqual(auth2.configuration.jwtOptions, auth2options.jwtOptions) }) it('sets configKey and defaultAuthentication', () => { assert.strictEqual(app.get('defaultAuthentication'), 'authentication') }) it('uses default configKey', () => { const otherApp = feathers() const otherAuth = new AuthenticationBase(otherApp) assert.ok(otherAuth) assert.strictEqual(otherApp.get('defaultAuthentication'), 'authentication') assert.deepStrictEqual(otherApp.get('authentication'), {}) }) }) describe('strategies', () => { it('strategyNames', () => { assert.deepStrictEqual(auth.strategyNames, ['first', 'second', 'dummy']) }) it('getStrategies', () => { const first = auth.getStrategies('first') const invalid = auth.getStrategies('first', 'invalid', 'second') assert.strictEqual(first.length, 1) assert.strictEqual(invalid.length, 2, 'Filtered out invalid strategies') }) it('getStrategy', () => { const first = auth.getStrategy('first') assert.ok(first) }) it('calls setName, setApplication and setAuthentication if available', () => { const [first] = auth.getStrategies('first') as [Strategy1] assert.strictEqual(first.name, 'first') assert.strictEqual(first.app, app) assert.strictEqual(first.authentication, auth) }) it('strategy configuration getter', () => { const [first] = auth.getStrategies('first') as [Strategy1] assert.deepStrictEqual(first.configuration, { hello: 'test' }) }) it('strategy configuration getter', () => { const [first] = auth.getStrategies('first') as [Strategy1] const oldService = auth.configuration.service delete auth.configuration.service assert.strictEqual(first.entityService, null) auth.configuration.service = oldService }) }) describe('authenticate', () => { describe('with strategy set in params', () => { it('returns first success', async () => { const result = await auth.authenticate( { strategy: 'first', username: 'David' }, {}, 'first', 'second' ) assert.deepStrictEqual(result, Strategy1.result) }) it('returns error when failed', async () => { try { await auth.authenticate( { strategy: 'first', username: 'Steve' }, {}, 'first', 'second' ) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'Invalid Dave') } }) it('returns second success', async () => { const authentication = { strategy: 'second', v2: true, password: 'supersecret' } const result = await auth.authenticate(authentication, {}, 'first', 'second') assert.deepStrictEqual( result, Object.assign({}, Strategy2.result, { authentication, params: { authenticated: true } }) ) }) it('passes params', async () => { const params = { some: 'thing' } const authentication = { strategy: 'second', v2: true, password: 'supersecret' } const result = await auth.authenticate(authentication, params, 'first', 'second') assert.deepStrictEqual( result, Object.assign( { params: Object.assign(params, { authenticated: true }), authentication }, Strategy2.result ) ) }) it('throws error when allowed and passed strategy does not match', async () => { try { await auth.authenticate( { strategy: 'first', username: 'Dummy' }, {}, 'second' ) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual( error.message, 'Invalid authentication information (strategy not allowed in authStrategies)' ) } }) it('throws error when strategy is not set', async () => { try { await auth.authenticate( { username: 'Dummy' }, {}, 'second' ) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'Invalid authentication information (no `strategy` set)') } }) }) }) describe('parse', () => { const res = {} as ServerResponse it('returns null when no names are given', async () => { const req = {} as MockRequest assert.strictEqual(await auth.parse(req, res), null) }) it('successfully parses a request (first)', async () => { const req = { isDave: true } as MockRequest const result = await auth.parse(req, res, 'first', 'second') assert.deepStrictEqual(result, Strategy1.result) }) it('successfully parses a request (second)', async () => { const req = { isV2: true } as MockRequest const result = await auth.parse(req, res, 'first', 'second') assert.deepStrictEqual(result, Strategy2.result) }) it('null when no success', async () => { const req = {} as MockRequest const result = await auth.parse(req, res, 'first', 'second') assert.strictEqual(result, null) }) }) describe('jwt', () => { const message = 'Some payload' describe('createAccessToken', () => { // it('errors with no payload', () => { // try { // // @ts-ignore // await auth.createAccessToken(); // assert.fail('Should never get here'); // } catch (error: any) { // assert.strictEqual(error.message, 'payload is required'); // } // }); it('with default options', async () => { const msg = 'Some payload' const accessToken = await auth.createAccessToken({ message: msg }) const decoded = jwt.decode(accessToken) const settings = auth.configuration.jwtOptions if (decoded === null || typeof decoded === 'string') { throw new Error('Not encoded properly') } assert.ok(typeof accessToken === 'string') assert.strictEqual(decoded.message, msg, 'Set payload') assert.ok(UUID.test(decoded.jti), 'Set `jti` to default UUID') assert.strictEqual(decoded.aud, settings.audience) assert.strictEqual(decoded.iss, settings.issuer) }) it('with default and overriden options', async () => { const overrides = { issuer: 'someoneelse', audience: 'people', jwtid: 'something' } const accessToken = await auth.createAccessToken({ message }, overrides) assert.ok(typeof accessToken === 'string') const decoded = jwt.decode(accessToken) if (decoded === null || typeof decoded === 'string') { throw new Error('Not encoded properly') } assert.strictEqual(decoded.message, message, 'Set payload') assert.strictEqual(decoded.jti, 'something') assert.strictEqual(decoded.aud, overrides.audience) assert.strictEqual(decoded.iss, overrides.issuer) }) it('errors with invalid options', async () => { const overrides = { algorithm: 'fdjsklfsndkl' } try { // @ts-ignore await auth.createAccessToken({}, overrides) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, '"algorithm" must be a valid string enum value') } }) }) describe('verifyAccessToken', () => { let validToken: string let expiredToken: string beforeEach(async () => { validToken = await auth.createAccessToken({ message }) expiredToken = await auth.createAccessToken( {}, { expiresIn: '1ms' } ) }) it('returns payload when token is valid', async () => { const payload = await auth.verifyAccessToken(validToken) assert.strictEqual(payload.message, message) }) it('errors when custom algorithm property does not match', async () => { try { await auth.verifyAccessToken(validToken, { algorithm: ['HS512'] }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'invalid algorithm') } }) it('errors when algorithms property does not match', async () => { try { await auth.verifyAccessToken(validToken, { algorithms: ['HS512'] }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'invalid algorithm') } }) it('errors when secret is different', async () => { try { await auth.verifyAccessToken(validToken, {}, 'fdjskl') assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'invalid signature') } }) it('errors when other custom options do not match', async () => { try { await auth.verifyAccessToken(validToken, { issuer: 'someonelse' }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.ok(/jwt issuer invalid/.test(error.message)) } }) it('errors when token is expired', async () => { try { await auth.verifyAccessToken(expiredToken) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'jwt expired') assert.strictEqual(error.data.name, 'TokenExpiredError') assert.ok(error.data.expiredAt) } }) }) }) }) ================================================ FILE: packages/authentication/test/fixtures.ts ================================================ import { NotAuthenticated } from '@feathersjs/errors' import { Params } from '@feathersjs/feathers' import { AuthenticationRequest } from '../src/core' import { IncomingMessage } from 'http' import { AuthenticationBaseStrategy } from '../src/strategy' export interface MockRequest extends IncomingMessage { isDave?: boolean isV2?: boolean } export class Strategy1 extends AuthenticationBaseStrategy { static result = { user: { id: 123, name: 'Dave' }, authenticated: true } async authenticate(authentication: AuthenticationRequest) { if (authentication.username === 'David' || authentication.both) { return { ...Strategy1.result } } throw new NotAuthenticated('Invalid Dave') } async parse(req: MockRequest) { if (req.isDave) { return { ...Strategy1.result } } return null } } export class Strategy2 extends AuthenticationBaseStrategy { static result = { user: { name: 'V2', version: 2 }, authenticated: true } authenticate(authentication: AuthenticationRequest, params: Params) { const isV2 = authentication.v2 === true && authentication.password === 'supersecret' if (isV2 || authentication.both) { return Promise.resolve(Object.assign({ params, authentication }, Strategy2.result)) } return Promise.reject(new NotAuthenticated('Invalid v2 user')) } async parse(req: MockRequest) { if (req.isV2) { return Strategy2.result } return null } } ================================================ FILE: packages/authentication/test/hooks/authenticate.test.ts ================================================ /* eslint-disable @typescript-eslint/ban-ts-comment */ import assert from 'assert' import { feathers, Application, Params, ServiceMethods } from '@feathersjs/feathers' import { Strategy1, Strategy2 } from '../fixtures' import { AuthenticationService, hooks } from '../../src' const { authenticate } = hooks describe('authentication/hooks/authenticate', () => { let app: Application<{ authentication: AuthenticationService 'auth-v2': AuthenticationService users: Partial & { id: string } }> beforeEach(() => { app = feathers() app.use( 'authentication', new AuthenticationService(app, 'authentication', { entity: 'user', service: 'users', secret: 'supersecret', authStrategies: ['first'] }) ) app.use( 'auth-v2', new AuthenticationService(app, 'auth-v2', { entity: 'user', service: 'users', secret: 'supersecret', authStrategies: ['test'] }) ) app.use('users', { id: 'id', async find() { return [] }, async get(_id: string | number, params: Params) { return params } }) const service = app.service('authentication') service.register('first', new Strategy1()) service.register('second', new Strategy2()) app.service('auth-v2').register('test', new Strategy1()) app.service('users').hooks({ get: [authenticate('first', 'second')] }) app.service('users').id = 'name' app.setup() }) it('throws an error when no strategies are passed', () => { try { // @ts-ignore authenticate() assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'The authenticate hook needs at least one allowed strategy') } }) it('throws an error when not a before hook', async () => { const users = app.service('users') users.hooks({ after: { all: [authenticate('first')] } }) try { await users.find() assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'The authenticate hook must be used as a before hook') } }) it('throws an error if authentication service is gone', async () => { delete app.services.authentication try { await app.service('users').get(1, { authentication: { some: 'thing' } }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'Could not find a valid authentication service') } }) it('authenticates with first strategy, merges params', async () => { const params = { authentication: { strategy: 'first', username: 'David' } } const result = await app.service('users').get(1, params) assert.deepStrictEqual(result, Object.assign({}, params, Strategy1.result)) }) it('authenticates with first strategy, keeps references alive (#1629)', async () => { const connection = {} const params = { connection, authentication: { strategy: 'first', username: 'David' } } app.service('users').hooks({ after: { get: (context) => { context.result.params = context.params } } }) const result = await app.service('users').get(1, params) assert.ok(result.params.connection === connection) }) it('authenticates with different authentication service', async () => { const params = { authentication: { strategy: 'test', username: 'David' } } app.service('users').hooks({ before: { find: [ authenticate({ service: 'auth-v2', strategies: ['test'] }) ] } }) const result = await app.service('users').find(params) assert.deepStrictEqual(result, []) }) it('authenticates with second strategy', async () => { const params = { authentication: { strategy: 'second', v2: true, password: 'supersecret' } } const result = await app.service('users').get(1, params) assert.deepStrictEqual( result, Object.assign( { authentication: params.authentication, params: { authenticated: true } }, Strategy2.result ) ) }) it('passes for internal calls without authentication', async () => { const result = await app.service('users').get(1) assert.deepStrictEqual(result, {}) }) it('fails for invalid params.authentication', async () => { try { await app.service('users').get(1, { authentication: { strategy: 'first', some: 'thing' } }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'Invalid Dave') } }) it('fails for external calls without authentication', async () => { try { await app.service('users').get(1, { provider: 'rest' }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'Not authenticated') } }) it('passes with authenticated: true but external call', async () => { const params = { provider: 'rest', authenticated: true } const result = await app.service('users').get(1, params) assert.deepStrictEqual(result, params) }) it('errors when used on the authentication service', async () => { const auth = app.service('authentication') auth.hooks({ before: { create: authenticate('first') } }) try { await auth.create({ strategy: 'first', username: 'David' }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual( error.message, 'The authenticate hook does not need to be used on the authentication service' ) } }) }) ================================================ FILE: packages/authentication/test/hooks/event.test.ts ================================================ import assert from 'assert' import { feathers, HookContext } from '@feathersjs/feathers' import hook from '../../src/hooks/event' import { AuthenticationParams, AuthenticationRequest, AuthenticationResult } from '../../src/core' describe('authentication/hooks/events', () => { const app = feathers().use('authentication', { async create(data: AuthenticationRequest) { return data }, async remove(id: string) { return { id } } }) const service = app.service('authentication') service.hooks({ create: [hook('login')], remove: [hook('logout')] }) it('login', (done) => { const data = { message: 'test' } app.once('login', (result: AuthenticationResult, params: AuthenticationParams, context: HookContext) => { try { assert.deepStrictEqual(result, data) assert.ok(params.testParam) assert.ok(context.method, 'create') done() } catch (error: any) { done(error) } }) service.create(data, { testParam: true, provider: 'test' } as any) }) it('logout', (done) => { app.once('logout', (result: AuthenticationResult, params: AuthenticationParams, context: HookContext) => { try { assert.deepStrictEqual(result, { id: 'test' }) assert.ok(params.testParam) assert.ok(context.method, 'remove') done() } catch (error: any) { done(error) } }) service.remove('test', { testParam: true, provider: 'test' } as any) }) it('does nothing when provider is not set', (done) => { const handler = () => { done(new Error('Should never get here')) } app.on('logout', handler) service.once('removed', (result: AuthenticationResult) => { app.removeListener('logout', handler) assert.deepStrictEqual(result, { id: 'test' }) done() }) service.remove('test') }) }) ================================================ FILE: packages/authentication/test/jwt.test.ts ================================================ import assert from 'assert' import merge from 'lodash/merge' import { feathers, Application, Service } from '@feathersjs/feathers' import { memory } from '@feathersjs/memory' import { getDispatch, resolve, resolveDispatch } from '@feathersjs/schema' import { AuthenticationService, JWTStrategy, hooks } from '../src' import { ServerResponse } from 'http' import { MockRequest } from './fixtures' const { authenticate } = hooks describe('authentication/jwt', () => { let app: Application<{ authentication: AuthenticationService users: Partial protected: Partial }> let user: any let accessToken: string let payload: any const userDispatchResolver = resolve({ converter: async () => { return { dispatch: true, message: 'Hello world' } }, properties: {} }) beforeEach(async () => { app = feathers() const authService = new AuthenticationService(app, 'authentication', { entity: 'user', service: 'users', secret: 'supersecret', authStrategies: ['jwt'] }) authService.register('jwt', new JWTStrategy()) app.use('users', memory()) app.use('protected', { async get(id, params) { return { id, params } } }) app.use('authentication', authService) const service = app.service('authentication') app.service('protected').hooks({ before: { all: [authenticate('jwt')] } }) app.service('users').hooks({ around: { all: [resolveDispatch(userDispatchResolver)] }, after: { get: [ (context) => { if (context.params.provider) { context.result.isExternal = true } return context } ] } }) user = await app.service('users').create({ name: 'David' }) accessToken = await service.createAccessToken( {}, { subject: `${user.id}` } ) payload = await service.verifyAccessToken(accessToken) app.setup() }) it('getEntity', async () => { const [strategy] = app.service('authentication').getStrategies('jwt') as JWTStrategy[] let entity = await strategy.getEntity(user.id, { query: { name: 'Dave' } }) assert.deepStrictEqual(entity, user) entity = await strategy.getEntity(user.id, { provider: 'rest' }) assert.deepStrictEqual(entity, { ...user, isExternal: true }) }) describe('handleConnection', () => { it('adds entity and authentication information on create', async () => { const connection: any = {} await app.service('authentication').create( { strategy: 'jwt', accessToken }, { connection } ) assert.deepStrictEqual(connection.user, user) assert.deepStrictEqual(connection.authentication, { strategy: 'jwt', accessToken }) }) it('login event connection has authentication information (#2908)', async () => { const connection: any = {} const onLogin = new Promise((resolve, reject) => app.once('login', (data, { connection }) => { try { assert.deepStrictEqual(connection.user, { ...user, isExternal: true }) resolve(data) } catch (error) { reject(error) } }) ) await app.service('authentication').create( { strategy: 'jwt', accessToken }, { connection, provider: 'test' } ) await onLogin }) it('resolves safe dispatch data in authentication result', async () => { const authResult = await app.service('authentication').create({ strategy: 'jwt', accessToken }) const dispatch = getDispatch(authResult) assert.deepStrictEqual(dispatch.user, { dispatch: true, message: 'Hello world' }) }) it('sends disconnect event when connection token expires and removes all connection information', async () => { const connection: any = {} const token: string = await app.service('authentication').createAccessToken( {}, { subject: `${user.id}`, expiresIn: '1s' } ) const result = await app.service('authentication').create( { strategy: 'jwt', accessToken: token }, { connection } ) assert.ok(connection.authentication) assert.strictEqual(result.accessToken, token) const disconnection = await new Promise((resolve) => app.once('disconnect', resolve)) assert.strictEqual(disconnection, connection) assert.ok(!connection.authentication) assert.ok(!connection.user) assert.strictEqual(Object.keys(connection).length, 0) }) it('deletes authentication information on remove', async () => { const connection: any = {} await app.service('authentication').create( { strategy: 'jwt', accessToken }, { connection } ) assert.ok(connection.authentication) await app.service('authentication').remove(null, { authentication: connection.authentication, connection }) assert.ok(!connection.authentication) assert.ok(!connection.user) }) it('deletes authentication information on disconnect but maintains it in event handler', async () => { const connection: any = {} await app.service('authentication').create( { strategy: 'jwt', accessToken }, { connection } ) assert.ok(connection.authentication) assert.ok(connection.user) const disconnectPromise = new Promise((resolve, reject) => app.once('disconnect', (connection) => { try { assert.ok(connection.authentication) assert.ok(connection.user) resolve(connection) } catch (error) { reject(error) } }) ) app.emit('disconnect', connection) await disconnectPromise await new Promise((resolve) => process.nextTick(resolve)) assert.ok(!connection.authentication) assert.ok(!connection.user) }) it('does not remove if accessToken does not match', async () => { const connection: any = {} await app.service('authentication').create( { strategy: 'jwt', accessToken }, { connection } ) assert.ok(connection.authentication) await app.service('authentication').remove(null, { authentication: { strategy: 'jwt', accessToken: await app.service('authentication').createAccessToken( {}, { subject: `${user.id}` } ) }, connection }) assert.ok(connection.authentication) }) }) describe('with authenticate hook', () => { it('fails for protected service and external call when not set', async () => { try { await app.service('protected').get('test', { provider: 'rest' }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'Not authenticated') } }) it('fails for protected service and external call when not strategy', async () => { try { await app.service('protected').get('test', { provider: 'rest', authentication: { username: 'Dave' } }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'Invalid authentication information (no `strategy` set)') } }) it('fails when entity service was not found', async () => { delete app.services.users await assert.rejects( () => app.service('protected').get('test', { provider: 'rest', authentication: { strategy: 'jwt', accessToken } }), { message: "Can not find service 'users'" } ) }) it('fails when accessToken is not set', async () => { try { await app.service('protected').get('test', { provider: 'rest', authentication: { strategy: 'jwt' } }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'No access token') } }) it('passes when authentication is set and merges params', async () => { const params = { provider: 'rest', authentication: { strategy: 'jwt', accessToken } } const result = await app.service('protected').get('test', params) assert.strictEqual(Object.keys(result.params).length, 4) assert.ok(!result.params.accessToken, 'Did not merge accessToken') assert.deepStrictEqual(result, { id: 'test', params: merge({}, params, { user, authentication: { payload }, authenticated: true }) }) }) it('works with entity set to null', async () => { const params = { provider: 'rest', authentication: { strategy: 'jwt', accessToken } } app.get('authentication').entity = null const result = await app.service('protected').get('test', params) assert.strictEqual(Object.keys(result.params).length, 3) assert.ok(!result.params.accessToken, 'Did not merge accessToken') assert.deepStrictEqual(result, { id: 'test', params: merge({}, params, { authentication: { payload }, authenticated: true }) }) }) }) describe('on authentication service', () => { it('authenticates but does not return a new accessToken', async () => { const authResult = await app.service('authentication').create({ strategy: 'jwt', accessToken }) assert.strictEqual(authResult.accessToken, accessToken) assert.deepStrictEqual(authResult.user, user) assert.deepStrictEqual(authResult.authentication.payload, payload) }) it('errors when trying to set invalid option', () => { app.get('authentication').otherJwt = { expiresIn: 'something' } try { app.service('authentication').register('otherJwt', new JWTStrategy()) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual( error.message, "Invalid JwtStrategy option 'authentication.otherJwt.expiresIn'. Did you mean to set it in 'authentication.jwtOptions'?" ) } }) it('errors when `header` option is an object`', () => { app.get('authentication').otherJwt = { header: { message: 'This is wrong' } } assert.throws(() => app.service('authentication').register('otherJwt', new JWTStrategy()), { message: "The 'header' option for the otherJwt strategy must be a string" }) }) }) describe('parse', () => { const res = {} as ServerResponse it('returns null when header not set', async () => { const req = {} as MockRequest const result = await app.service('authentication').parse(req, res, 'jwt') assert.strictEqual(result, null) }) it('parses plain Authorization header', async () => { const req = { headers: { authorization: accessToken } } as MockRequest const result = await app.service('authentication').parse(req, res, 'jwt') assert.deepStrictEqual(result, { strategy: 'jwt', accessToken }) }) it('parses Authorization header with Bearer scheme', async () => { const req = { headers: { authorization: ` Bearer ${accessToken} ` } } as MockRequest const result = await app.service('authentication').parse(req, res, 'jwt') assert.deepStrictEqual(result, { strategy: 'jwt', accessToken }) }) it('return null when scheme does not match', async () => { const req = { headers: { authorization: ' Basic something' } } as MockRequest const result = await app.service('authentication').parse(req, res, 'jwt') assert.strictEqual(result, null) }) }) }) ================================================ FILE: packages/authentication/test/service.test.ts ================================================ /* eslint-disable @typescript-eslint/ban-ts-comment */ import assert from 'assert' import omit from 'lodash/omit' import jwt from 'jsonwebtoken' import { feathers, Application } from '@feathersjs/feathers' import { memory, MemoryService } from '@feathersjs/memory' import { defaultOptions } from '../src/options' import { AuthenticationService } from '../src' import { Strategy1 } from './fixtures' const UUID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/ describe('authentication/service', () => { const message = 'Some payload' let app: Application<{ authentication: AuthenticationService users: MemoryService }> beforeEach(() => { app = feathers() app.use( 'authentication', new AuthenticationService(app, 'authentication', { entity: 'user', service: 'users', secret: 'supersecret', authStrategies: ['first'] }) ) app.use('users', memory()) app.service('authentication').register('first', new Strategy1()) }) it('settings returns authentication options', () => { assert.deepStrictEqual( app.service('authentication').configuration, Object.assign({}, defaultOptions, app.get('authentication')) ) }) it('app.defaultAuthentication()', () => { assert.strictEqual(app.defaultAuthentication(), app.service('authentication')) assert.throws(() => app.defaultAuthentication('dummy'), { message: "Can not find service 'dummy'" }) }) describe('create', () => { it('creates a valid accessToken and includes strategy result', async () => { const service = app.service('authentication') const result = await service.create({ strategy: 'first', username: 'David' }) const settings = service.configuration.jwtOptions const decoded = jwt.decode(result.accessToken) if (typeof decoded === 'string') { throw new Error('Unexpected decoded JWT type') } assert.ok(result.accessToken) assert.deepStrictEqual(omit(result, 'accessToken', 'authentication'), Strategy1.result) assert.deepStrictEqual(result.authentication.payload, decoded) assert.ok(UUID.test(decoded.jti), 'Set `jti` to default UUID') assert.strictEqual(decoded.aud, settings.audience) assert.strictEqual(decoded.iss, settings.issuer) }) it('fails when strategy fails', async () => { try { await app.service('authentication').create({ strategy: 'first', username: 'Dave' }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'Invalid Dave') } }) it('creates a valid accessToken with strategy and params.payload', async () => { const result = await app.service('authentication').create( { strategy: 'first', username: 'David' }, { payload: { message } } ) const decoded = jwt.decode(result.accessToken) if (typeof decoded === 'string') { throw new Error('Unexpected decoded JWT type') } assert.strictEqual(decoded.message, message) }) it('sets the subject authResult[entity][entityService.id]', async () => { const { accessToken } = await app.service('authentication').create({ strategy: 'first', username: 'David' }) const decoded = jwt.decode(accessToken) assert.strictEqual(decoded.sub, Strategy1.result.user.id.toString()) }) it('sets the subject authResult[entity][entityId]', async () => { app.get('authentication').entityId = 'name' const { accessToken } = await app.service('authentication').create({ strategy: 'first', username: 'David' }) const decoded = jwt.decode(accessToken) assert.strictEqual(decoded.sub, Strategy1.result.user.name.toString()) }) it('does not override the subject if already set', async () => { const subject = 'Davester' const { accessToken } = await app.service('authentication').create( { strategy: 'first', username: 'David' }, { jwt: { subject } } ) const decoded = jwt.decode(accessToken) assert.strictEqual(decoded.sub, subject) }) it('errors when subject can not be found', async () => { // @ts-ignore app.service('users').options.id = 'somethingElse' try { await app.service('authentication').create({ strategy: 'first', username: 'David' }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'Can not set subject from user.somethingElse') } }) it('errors when no allowed strategies are set', async () => { const service = app.service('authentication') const configuration = service.configuration delete configuration.authStrategies app.set('authentication', configuration) try { await service.create({ strategy: 'first', username: 'Dave' }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual( error.message, 'No authentication strategies allowed for creating a JWT (`authStrategies`)' ) } }) }) describe('remove', () => { it('can remove with authentication strategy set', async () => { const authResult = await app.service('authentication').remove(null, { authentication: { strategy: 'first', username: 'David' } }) assert.deepStrictEqual(authResult, Strategy1.result) }) it('passes when id is set and matches accessToken', async () => { const authResult = await app.service('authentication').remove('test', { authentication: { strategy: 'first', username: 'David', accessToken: 'test' } }) assert.deepStrictEqual(authResult, Strategy1.result) }) it('fails when id is set and does not match accessToken', async () => { await assert.rejects( () => app.service('authentication').remove('test', { authentication: { strategy: 'first', username: 'David', accessToken: 'testing' } }), { name: 'NotAuthenticated', message: 'Invalid access token' } ) }) it('errors when trying to remove with nothing', async () => { try { await app.service('authentication').remove(null) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'Invalid authentication information (no `strategy` set)') } }) }) describe('setup', () => { it('errors when there is no secret', async () => { delete app.get('authentication').secret await assert.rejects(() => app.setup(), { message: "A 'secret' must be provided in your authentication configuration" }) }) it('throws an error if service name is not set', async () => { const otherApp = feathers() otherApp.use( '/authentication', new AuthenticationService(otherApp, 'authentication', { secret: 'supersecret', authStrategies: ['first'] }) ) await assert.rejects(() => otherApp.setup(), { message: "The 'service' option is not set in the authentication configuration" }) }) it('throws an error if entity service does not exist', async () => { const otherApp = feathers() otherApp.use( '/authentication', new AuthenticationService(otherApp, 'authentication', { entity: 'user', service: 'users', secret: 'supersecret', authStrategies: ['first'] }) ) await assert.rejects(() => otherApp.setup(), { message: "Can not find service 'users'" }) }) it('throws an error if entity service exists but has no `id`', async () => { const otherApp = feathers() otherApp.use( '/authentication', new AuthenticationService(otherApp, 'authentication', { entity: 'user', service: 'users', secret: 'supersecret', strategies: ['first'] }) ) otherApp.use('/users', { async get() { return {} } }) await assert.rejects(() => otherApp.setup(), { message: "The 'users' service does not have an 'id' property and no 'entityId' option is set." }) }) it('passes when entity service exists and `entityId` property is set', () => { app.get('authentication').entityId = 'id' app.use('users', memory()) app.setup() }) it('does nothing when `entity` is explicitly `null`', () => { app.get('authentication').entity = null app.setup() }) }) }) ================================================ FILE: packages/authentication/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/authentication-client/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) ### Bug Fixes - **authentication-client:** Allow to abort fetch ([#3310](https://github.com/feathersjs/feathers/issues/3310)) ([ff3e104](https://github.com/feathersjs/feathers/commit/ff3e104b62d02d45261a293aff4e9491241f486f)) ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) ### Bug Fixes - **authentication-client:** Do not trigger storage methods if storage not defined ([#3210](https://github.com/feathersjs/feathers/issues/3210)) ([261acbc](https://github.com/feathersjs/feathers/commit/261acbcde387db731e434cb106a27b49dcb64a9a)) - **authentication-client:** removeAccessToken throws error if storage not defined ([#3195](https://github.com/feathersjs/feathers/issues/3195)) ([b8e2769](https://github.com/feathersjs/feathers/commit/b8e27698f7958a91fe9a4ee64ec5591d23194c44)) ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.2](https://github.com/feathersjs/feathers/compare/v5.0.1...v5.0.2) (2023-03-23) **Note:** Version bump only for package @feathersjs/authentication-client ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Bug Fixes - **authentication-client:** Do not cache authentication errors ([#2892](https://github.com/feathersjs/feathers/issues/2892)) ([cc4e767](https://github.com/feathersjs/feathers/commit/cc4e76726fce1ac73252cfd92e22570d4bdeca20)) - **authentication-client:** Improve socket reauthentication handling ([#2895](https://github.com/feathersjs/feathers/issues/2895)) ([9db5e7a](https://github.com/feathersjs/feathers/commit/9db5e7adb0f6aea43d607f530d8258ade98b7362)) - **authentication-client:** Remove access token for fatal 400 errors ([#2894](https://github.com/feathersjs/feathers/issues/2894)) ([cfc6c7a](https://github.com/feathersjs/feathers/commit/cfc6c7a6b9dbc7fb60816e2b7f15897c38deb98d)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) ### Features - **cli:** Add authentication client to generated client ([#2801](https://github.com/feathersjs/feathers/issues/2801)) ([bd59f91](https://github.com/feathersjs/feathers/commit/bd59f91b45a01c2eea0c4386e567f4de5aa6ad99)) # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **authentication-client:** Properly handle missing token error ([#2700](https://github.com/feathersjs/feathers/issues/2700)) ([160746e](https://github.com/feathersjs/feathers/commit/160746e2bceb465fd1b6a003415f8ab38daba521)) - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) ### Bug Fixes - **authentication-client:** Ensure reAuthenticate works in parallel with other requests ([#2690](https://github.com/feathersjs/feathers/issues/2690)) ([41b3761](https://github.com/feathersjs/feathers/commit/41b376106b47e2f40a8914db7a5ed2935e070c08)) # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Bug Fixes - **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Bug Fixes - **hooks:** Migrate built-in hooks and allow backwards compatibility ([#2358](https://github.com/feathersjs/feathers/issues/2358)) ([759c5a1](https://github.com/feathersjs/feathers/commit/759c5a19327a731af965c3604119393b3d09a406)) - **koa:** Use extended query parser for compatibility ([#2397](https://github.com/feathersjs/feathers/issues/2397)) ([b2944ba](https://github.com/feathersjs/feathers/commit/b2944bac3ec6d5ecc80dc518cd4e58093692db74)) ### Features - **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) ### Features - **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) **Note:** Version bump only for package @feathersjs/authentication-client # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) ### Features - Application service types default to any ([#1566](https://github.com/feathersjs/feathers/issues/1566)) ([d93ba9a](https://github.com/feathersjs/feathers/commit/d93ba9a17edd20d3397bb00f4f6e82e804e42ed6)) - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) - **authentication-client:** Throw separate OauthError in authentication client ([#2189](https://github.com/feathersjs/feathers/issues/2189)) ([fa45ec5](https://github.com/feathersjs/feathers/commit/fa45ec520b21834e103e6fe4200b06dced56c0e6)) # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### chore - **package:** Remove @feathersjs/primus packages from core ([#1919](https://github.com/feathersjs/feathers/issues/1919)) ([d20b7d5](https://github.com/feathersjs/feathers/commit/d20b7d5a70f4d3306e294696156e8aa0337c35e9)), closes [#1899](https://github.com/feathersjs/feathers/issues/1899) ### BREAKING CHANGES - **package:** Remove primus packages to be moved into the ecosystem. # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### chore - **package:** Remove @feathersjs/primus packages from core ([#1919](https://github.com/feathersjs/feathers/issues/1919)) ([d20b7d5](https://github.com/feathersjs/feathers/commit/d20b7d5a70f4d3306e294696156e8aa0337c35e9)), closes [#1899](https://github.com/feathersjs/feathers/issues/1899) ### BREAKING CHANGES - **package:** Remove primus packages to be moved into the ecosystem. ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) ### Bug Fixes - **authentication-client:** Allow reAuthentication using specific strategy ([#2140](https://github.com/feathersjs/feathers/issues/2140)) ([2a2bbf7](https://github.com/feathersjs/feathers/commit/2a2bbf7f8ee6d32b9fac8afab3421286b06e6443)) - **socketio-client:** Throw an error and show a warning if someone tries to use socket.io-client v3 ([#2135](https://github.com/feathersjs/feathers/issues/2135)) ([cc3521c](https://github.com/feathersjs/feathers/commit/cc3521c935a1cbd690e29b7057998e3898f282db)) ## [4.5.10](https://github.com/feathersjs/feathers/compare/v4.5.9...v4.5.10) (2020-11-08) **Note:** Version bump only for package @feathersjs/authentication-client ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) **Note:** Version bump only for package @feathersjs/authentication-client ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) ### Bug Fixes - **authentication-client:** Fix storage type so it works with all supported interfaces ([#2041](https://github.com/feathersjs/feathers/issues/2041)) ([6ee0e78](https://github.com/feathersjs/feathers/commit/6ee0e78d55cf1214f61458f386b94c350eec32af)) ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) **Note:** Version bump only for package @feathersjs/authentication-client ## [4.5.6](https://github.com/feathersjs/feathers/compare/v4.5.5...v4.5.6) (2020-07-12) **Note:** Version bump only for package @feathersjs/authentication-client ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) **Note:** Version bump only for package @feathersjs/authentication-client ## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-04-29) **Note:** Version bump only for package @feathersjs/authentication-client ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) **Note:** Version bump only for package @feathersjs/authentication-client ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) **Note:** Version bump only for package @feathersjs/authentication-client ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/authentication-client # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) **Note:** Version bump only for package @feathersjs/authentication-client ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/authentication-client ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/authentication-client # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) ### Bug Fixes - **authentication-client:** Reset authentication promise on socket disconnect ([#1696](https://github.com/feathersjs/feathers/issues/1696)) ([3951626](https://github.com/feathersjs/feathers/commit/395162633ff22e95833a3c2900cb9464bb5b056f)) ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) **Note:** Version bump only for package @feathersjs/authentication-client ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/authentication-client ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) **Note:** Version bump only for package @feathersjs/authentication-client ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) ### Bug Fixes - Improve authentication client default storage initialization ([#1613](https://github.com/feathersjs/feathers/issues/1613)) ([d7f5107](https://github.com/feathersjs/feathers/commit/d7f5107ef76297b4ca6db580afc5e2b372f5ee4d)) ## [4.3.5](https://github.com/feathersjs/feathers/compare/v4.3.4...v4.3.5) (2019-10-07) ### Bug Fixes - Authentication type improvements and timeout fix ([#1605](https://github.com/feathersjs/feathers/issues/1605)) ([19854d3](https://github.com/feathersjs/feathers/commit/19854d3)) ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) ### Bug Fixes - Typing improvements ([#1580](https://github.com/feathersjs/feathers/issues/1580)) ([7818aec](https://github.com/feathersjs/feathers/commit/7818aec)) ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) ### Bug Fixes - Small improvements in dependencies and code sturcture ([#1562](https://github.com/feathersjs/feathers/issues/1562)) ([42c13e2](https://github.com/feathersjs/feathers/commit/42c13e2)) ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) **Note:** Version bump only for package @feathersjs/authentication-client ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) **Note:** Version bump only for package @feathersjs/authentication-client # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) ### Bug Fixes - Only remove token on NotAuthenticated error in authentication client and handle error better ([#1525](https://github.com/feathersjs/feathers/issues/1525)) ([13a8758](https://github.com/feathersjs/feathers/commit/13a8758)) # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/authentication-client # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) ### Bug Fixes - Update all dependencies ([7d53a00](https://github.com/feathersjs/feathers/commit/7d53a00)) ### Features - Let strategies handle the connection ([#1510](https://github.com/feathersjs/feathers/issues/1510)) ([4329feb](https://github.com/feathersjs/feathers/commit/4329feb)) # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) ### Bug Fixes - Do not error in authentication client on logout ([#1473](https://github.com/feathersjs/feathers/issues/1473)) ([8211b98](https://github.com/feathersjs/feathers/commit/8211b98)) # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/authentication-client # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) **Note:** Version bump only for package @feathersjs/authentication-client # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) **Note:** Version bump only for package @feathersjs/authentication-client # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Make oAuth paths more consistent and improve authentication client ([#1377](https://github.com/feathersjs/feathers/issues/1377)) ([adb2543](https://github.com/feathersjs/feathers/commit/adb2543)) - Typings fix and improvements. ([#1364](https://github.com/feathersjs/feathers/issues/1364)) ([515b916](https://github.com/feathersjs/feathers/commit/515b916)) - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) **Note:** Version bump only for package @feathersjs/authentication-client # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) ### Bug Fixes - Guard against null in client side logout function ([#1319](https://github.com/feathersjs/feathers/issues/1319)) ([fa7f057](https://github.com/feathersjs/feathers/commit/fa7f057)) - Handle error oAuth redirect in authentication client ([#1307](https://github.com/feathersjs/feathers/issues/1307)) ([12d48ee](https://github.com/feathersjs/feathers/commit/12d48ee)) - Merge httpStrategies and authStrategies option ([#1308](https://github.com/feathersjs/feathers/issues/1308)) ([afa4d55](https://github.com/feathersjs/feathers/commit/afa4d55)) - Rename jwtStrategies option to authStrategies ([#1305](https://github.com/feathersjs/feathers/issues/1305)) ([4aee151](https://github.com/feathersjs/feathers/commit/4aee151)) - Update version number check ([53575c5](https://github.com/feathersjs/feathers/commit/53575c5)) # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Authentication core improvements ([#1260](https://github.com/feathersjs/feathers/issues/1260)) ([c5dc7a2](https://github.com/feathersjs/feathers/commit/c5dc7a2)) - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) - **package:** update debug to version 3.0.0 ([#61](https://github.com/feathersjs/feathers/issues/61)) ([6f5009c](https://github.com/feathersjs/feathers/commit/6f5009c)) ### Features - @feathersjs/authentication-oauth ([#1299](https://github.com/feathersjs/feathers/issues/1299)) ([656bae7](https://github.com/feathersjs/feathers/commit/656bae7)) - Add authentication through oAuth redirect to authentication client ([#1301](https://github.com/feathersjs/feathers/issues/1301)) ([35d8043](https://github.com/feathersjs/feathers/commit/35d8043)) - Add AuthenticationBaseStrategy and make authentication option handling more explicit ([#1284](https://github.com/feathersjs/feathers/issues/1284)) ([2667d92](https://github.com/feathersjs/feathers/commit/2667d92)) - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - Authentication v3 client ([#1240](https://github.com/feathersjs/feathers/issues/1240)) ([65b43bd](https://github.com/feathersjs/feathers/commit/65b43bd)) - Authentication v3 core server implementation ([#1205](https://github.com/feathersjs/feathers/issues/1205)) ([1bd7591](https://github.com/feathersjs/feathers/commit/1bd7591)) ### BREAKING CHANGES - Rewrite for authentication v3 ## [1.0.11](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-client@1.0.10...@feathersjs/authentication-client@1.0.11) (2019-01-26) **Note:** Version bump only for package @feathersjs/authentication-client ## [1.0.10](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-client@1.0.9...@feathersjs/authentication-client@1.0.10) (2019-01-02) ### Bug Fixes - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) ## [1.0.9](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-client@1.0.8...@feathersjs/authentication-client@1.0.9) (2018-12-16) **Note:** Version bump only for package @feathersjs/authentication-client ## [1.0.8](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-client@1.0.7...@feathersjs/authentication-client@1.0.8) (2018-10-26) **Note:** Version bump only for package @feathersjs/authentication-client ## [1.0.7](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-client@1.0.6...@feathersjs/authentication-client@1.0.7) (2018-10-25) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) ## [1.0.6](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-client@1.0.5...@feathersjs/authentication-client@1.0.6) (2018-09-21) **Note:** Version bump only for package @feathersjs/authentication-client ## [1.0.5](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-client@1.0.4...@feathersjs/authentication-client@1.0.5) (2018-09-17) **Note:** Version bump only for package @feathersjs/authentication-client ## [1.0.4](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-client@1.0.3...@feathersjs/authentication-client@1.0.4) (2018-09-02) **Note:** Version bump only for package @feathersjs/authentication-client ## 1.0.3 - Migrate to Monorepo ([feathers#462](https://github.com/feathersjs/feathers/issues/462)) ## [v1.0.2](https://github.com/feathersjs/authentication-client/tree/v1.0.2) (2018-01-03) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v1.0.1...v1.0.2) **Closed issues:** - No Auth header added when sending 1st request [\#80](https://github.com/feathersjs/authentication-client/issues/80) **Merged pull requests:** - Update to correspond with latest release [\#84](https://github.com/feathersjs/authentication-client/pull/84) ([daffl](https://github.com/daffl)) - Update semistandard to the latest version 🚀 [\#83](https://github.com/feathersjs/authentication-client/pull/83) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update feathers-memory to the latest version 🚀 [\#82](https://github.com/feathersjs/authentication-client/pull/82) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.1](https://github.com/feathersjs/authentication-client/tree/v1.0.1) (2017-11-16) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v1.0.0...v1.0.1) **Merged pull requests:** - Add default export for better ES module \(TypeScript\) compatibility [\#81](https://github.com/feathersjs/authentication-client/pull/81) ([daffl](https://github.com/daffl)) - Update @feathersjs/authentication to the latest version 🚀 [\#79](https://github.com/feathersjs/authentication-client/pull/79) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.0](https://github.com/feathersjs/authentication-client/tree/v1.0.0) (2017-11-01) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v1.0.0-pre.1...v1.0.0) **Merged pull requests:** - Update dependencies for release [\#78](https://github.com/feathersjs/authentication-client/pull/78) ([daffl](https://github.com/daffl)) ## [v1.0.0-pre.1](https://github.com/feathersjs/authentication-client/tree/v1.0.0-pre.1) (2017-10-25) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.3.3...v1.0.0-pre.1) **Closed issues:** - Error authenticating! Error: Token provided to verifyJWT is missing or not a string ? [\#73](https://github.com/feathersjs/authentication-client/issues/73) - Authorization Header not sent!! [\#69](https://github.com/feathersjs/authentication-client/issues/69) - users.get\(id\) failed \(Not authenticated\) after successful login. [\#66](https://github.com/feathersjs/authentication-client/issues/66) **Merged pull requests:** - Updates for Feathers v3 [\#77](https://github.com/feathersjs/authentication-client/pull/77) ([daffl](https://github.com/daffl)) - Update Codeclimate token and badges [\#76](https://github.com/feathersjs/authentication-client/pull/76) ([daffl](https://github.com/daffl)) - Rename repository and use npm scope [\#75](https://github.com/feathersjs/authentication-client/pull/75) ([daffl](https://github.com/daffl)) - Update to new plugin infrastructure [\#74](https://github.com/feathersjs/authentication-client/pull/74) ([daffl](https://github.com/daffl)) - Update mocha to the latest version 🚀 [\#72](https://github.com/feathersjs/authentication-client/pull/72) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Add babel-polyfill and package-lock.json [\#68](https://github.com/feathersjs/authentication-client/pull/68) ([daffl](https://github.com/daffl)) - Passport.verifyJWT should return Promise\, not Promise\ [\#65](https://github.com/feathersjs/authentication-client/pull/65) ([zxh19890103](https://github.com/zxh19890103)) - Update debug to the latest version 🚀 [\#61](https://github.com/feathersjs/authentication-client/pull/61) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update ws to the latest version 🚀 [\#60](https://github.com/feathersjs/authentication-client/pull/60) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v0.3.3](https://github.com/feathersjs/authentication-client/tree/v0.3.3) (2017-07-18) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.3.2...v0.3.3) **Closed issues:** - An in-range update of feathers is breaking the build 🚨 [\#59](https://github.com/feathersjs/authentication-client/issues/59) - An in-range update of feathers is breaking the build 🚨 [\#58](https://github.com/feathersjs/authentication-client/issues/58) **Merged pull requests:** - typings: add auth methods to feathers.Application interface [\#57](https://github.com/feathersjs/authentication-client/pull/57) ([j2L4e](https://github.com/j2L4e)) - Update feathers-authentication-local to the latest version 🚀 [\#55](https://github.com/feathersjs/authentication-client/pull/55) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update chai to the latest version 🚀 [\#54](https://github.com/feathersjs/authentication-client/pull/54) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update feathers-socketio to the latest version 🚀 [\#50](https://github.com/feathersjs/authentication-client/pull/50) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update socket.io-client to the latest version 🚀 [\#49](https://github.com/feathersjs/authentication-client/pull/49) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update README.md [\#47](https://github.com/feathersjs/authentication-client/pull/47) ([bertho-zero](https://github.com/bertho-zero)) ## [v0.3.2](https://github.com/feathersjs/authentication-client/tree/v0.3.2) (2017-04-30) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.3.1...v0.3.2) **Closed issues:** - An in-range update of feathers-errors is breaking the build 🚨 [\#45](https://github.com/feathersjs/authentication-client/issues/45) - Proper way to save jwt in cookies [\#41](https://github.com/feathersjs/authentication-client/issues/41) - Allow customizing the `tokenField` [\#38](https://github.com/feathersjs/authentication-client/issues/38) - Show blank page in safari@iOS 8.3 [\#37](https://github.com/feathersjs/authentication-client/issues/37) **Merged pull requests:** - Catch getJWT promise errors [\#46](https://github.com/feathersjs/authentication-client/pull/46) ([NikitaVlaznev](https://github.com/NikitaVlaznev)) - Update semistandard to the latest version 🚀 [\#43](https://github.com/feathersjs/authentication-client/pull/43) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update feathers-hooks to the latest version 🚀 [\#42](https://github.com/feathersjs/authentication-client/pull/42) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update dependencies to enable Greenkeeper 🌴 [\#40](https://github.com/feathersjs/authentication-client/pull/40) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Note that auth must be configured after rest/socket clients [\#36](https://github.com/feathersjs/authentication-client/pull/36) ([hubgit](https://github.com/hubgit)) ## [v0.3.1](https://github.com/feathersjs/authentication-client/tree/v0.3.1) (2017-03-10) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.3.0...v0.3.1) **Closed issues:** - The latest tag on NPM is wrong [\#35](https://github.com/feathersjs/authentication-client/issues/35) - exp claim should be optional [\#33](https://github.com/feathersjs/authentication-client/issues/33) **Merged pull requests:** - Fix \#33 exp claim should be optional [\#34](https://github.com/feathersjs/authentication-client/pull/34) ([whollacsek](https://github.com/whollacsek)) ## [v0.3.0](https://github.com/feathersjs/authentication-client/tree/v0.3.0) (2017-03-08) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.2.0...v0.3.0) ## [v0.2.0](https://github.com/feathersjs/authentication-client/tree/v0.2.0) (2017-03-07) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.1.10...v0.2.0) **Closed issues:** - Support `authenticated` and `logout` client side events [\#29](https://github.com/feathersjs/authentication-client/issues/29) - The default header mismatches the default feathers-authentication header [\#23](https://github.com/feathersjs/authentication-client/issues/23) - Re-authenticating fails when passing options [\#22](https://github.com/feathersjs/authentication-client/issues/22) - Socket.io timeout does nothing when there is JWT token available [\#19](https://github.com/feathersjs/authentication-client/issues/19) **Merged pull requests:** - Fix header casing [\#32](https://github.com/feathersjs/authentication-client/pull/32) ([daffl](https://github.com/daffl)) - Add client side `authenticated` and `logout` events [\#31](https://github.com/feathersjs/authentication-client/pull/31) ([daffl](https://github.com/daffl)) - Add support for socket timeouts and some refactoring [\#30](https://github.com/feathersjs/authentication-client/pull/30) ([daffl](https://github.com/daffl)) ## [v0.1.10](https://github.com/feathersjs/authentication-client/tree/v0.1.10) (2017-03-03) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.1.9...v0.1.10) **Merged pull requests:** - Remove hardcoded values for Config and Credentials typings [\#28](https://github.com/feathersjs/authentication-client/pull/28) ([myknbani](https://github.com/myknbani)) ## [v0.1.9](https://github.com/feathersjs/authentication-client/tree/v0.1.9) (2017-03-01) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.1.8...v0.1.9) **Merged pull requests:** - Typescript Definitions [\#25](https://github.com/feathersjs/authentication-client/pull/25) ([AbraaoAlves](https://github.com/AbraaoAlves)) ## [v0.1.8](https://github.com/feathersjs/authentication-client/tree/v0.1.8) (2017-02-05) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.1.7...v0.1.8) **Closed issues:** - Uncaught TypeError: Cannot read property 'options' of undefined [\#26](https://github.com/feathersjs/authentication-client/issues/26) - Browser Version [\#24](https://github.com/feathersjs/authentication-client/issues/24) **Merged pull requests:** - Hoist upgrade handler into current scope by using an arrow function [\#27](https://github.com/feathersjs/authentication-client/pull/27) ([daffl](https://github.com/daffl)) ## [v0.1.7](https://github.com/feathersjs/authentication-client/tree/v0.1.7) (2017-01-29) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.1.6...v0.1.7) **Closed issues:** - \[Webpack\] TypeError: \_this4.storage.getItem is not a function [\#18](https://github.com/feathersjs/authentication-client/issues/18) - \[Feature request\] Signup via socket [\#17](https://github.com/feathersjs/authentication-client/issues/17) - Missing auth token when used with feathers-rest in comparison to feathers-socketio [\#16](https://github.com/feathersjs/authentication-client/issues/16) - Cannot read property 'on' of undefined - feathers-authentication-client [\#12](https://github.com/feathersjs/authentication-client/issues/12) **Merged pull requests:** - Update passport.js [\#20](https://github.com/feathersjs/authentication-client/pull/20) ([bertho-zero](https://github.com/bertho-zero)) ## [v0.1.6](https://github.com/feathersjs/authentication-client/tree/v0.1.6) (2016-12-14) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.1.5...v0.1.6) **Closed issues:** - `logout\(\)` doesn't resolve [\#10](https://github.com/feathersjs/authentication-client/issues/10) **Merged pull requests:** - Fix linting [\#13](https://github.com/feathersjs/authentication-client/pull/13) ([marshallswain](https://github.com/marshallswain)) ## [v0.1.5](https://github.com/feathersjs/authentication-client/tree/v0.1.5) (2016-12-13) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.1.4...v0.1.5) ## [v0.1.4](https://github.com/feathersjs/authentication-client/tree/v0.1.4) (2016-12-13) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.1.3...v0.1.4) **Closed issues:** - populateAccessToken tries to access non-existent property [\#11](https://github.com/feathersjs/authentication-client/issues/11) - Socket client should automatically auth on reconnect [\#2](https://github.com/feathersjs/authentication-client/issues/2) **Merged pull requests:** - More specific imports for StealJS [\#14](https://github.com/feathersjs/authentication-client/pull/14) ([marshallswain](https://github.com/marshallswain)) ## [v0.1.3](https://github.com/feathersjs/authentication-client/tree/v0.1.3) (2016-11-23) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.1.2...v0.1.3) **Closed issues:** - Client should ensure socket.io upgrade is complete before authenticating [\#4](https://github.com/feathersjs/authentication-client/issues/4) **Merged pull requests:** - Socket reconnect [\#9](https://github.com/feathersjs/authentication-client/pull/9) ([ekryski](https://github.com/ekryski)) ## [v0.1.2](https://github.com/feathersjs/authentication-client/tree/v0.1.2) (2016-11-22) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.1.1...v0.1.2) **Merged pull requests:** - Custom jwt strategy names [\#8](https://github.com/feathersjs/authentication-client/pull/8) ([ekryski](https://github.com/ekryski)) ## [v0.1.1](https://github.com/feathersjs/authentication-client/tree/v0.1.1) (2016-11-21) [Full Changelog](https://github.com/feathersjs/authentication-client/compare/v0.1.0...v0.1.1) **Merged pull requests:** - Socket reconnect upgrade auth [\#3](https://github.com/feathersjs/authentication-client/pull/3) ([marshallswain](https://github.com/marshallswain)) ## [v0.1.0](https://github.com/feathersjs/authentication-client/tree/v0.1.0) (2016-11-18) **Closed issues:** - Relation with feathers-authentication [\#6](https://github.com/feathersjs/authentication-client/issues/6) - Client: Docs for getJWT & verifyJWT [\#1](https://github.com/feathersjs/authentication-client/issues/1) **Merged pull requests:** - Feathers authentication 1.0 compatible client [\#7](https://github.com/feathersjs/authentication-client/pull/7) ([ekryski](https://github.com/ekryski)) \* _This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)_ ================================================ FILE: packages/authentication-client/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/authentication-client/README.md ================================================ # @feathersjs/authentication-client [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/authentication-client.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/authentication-client) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > Feathers authentication client ## Installation ``` npm install @feathersjs/authentication-client --save ``` ## Documentation Refer to the [Feathers authentication client API documentation](https://feathersjs.com/api/authentication/client.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/authentication-client/package.json ================================================ { "name": "@feathersjs/authentication-client", "description": "The authentication plugin for feathers-client", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/authentication-client" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/authentication": "^5.0.42", "@feathersjs/commons": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/feathers": "^5.0.42" }, "devDependencies": { "@feathersjs/authentication-local": "^5.0.42", "@feathersjs/express": "^5.0.42", "@feathersjs/memory": "^5.0.42", "@feathersjs/rest-client": "^5.0.42", "@feathersjs/socketio": "^5.0.42", "@feathersjs/socketio-client": "^5.0.42", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "axios": "^1.13.6", "mocha": "^11.7.5", "shx": "^0.4.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/authentication-client/src/core.ts ================================================ import { NotAuthenticated, FeathersError } from '@feathersjs/errors' import { Application, Params } from '@feathersjs/feathers' import { AuthenticationRequest, AuthenticationResult } from '@feathersjs/authentication' import { Storage, StorageWrapper } from './storage' class OauthError extends FeathersError { constructor(message: string, data?: any) { super(message, 'OauthError', 401, 'oauth-error', data) } } const getMatch = (location: Location, key: string): [string, RegExp] => { const regex = new RegExp(`(?:\&?)${key}=([^&]*)`) const match = location.hash ? location.hash.match(regex) : null if (match !== null) { const [, value] = match return [value, regex] } return [null, regex] } export type ClientConstructor = new ( app: Application, options: AuthenticationClientOptions ) => AuthenticationClient export interface AuthenticationClientOptions { storage: Storage header: string scheme: string storageKey: string locationKey: string locationErrorKey: string jwtStrategy: string path: string Authentication: ClientConstructor } export class AuthenticationClient { app: Application authenticated: boolean options: AuthenticationClientOptions constructor(app: Application, options: AuthenticationClientOptions) { const socket = app.io const storage = new StorageWrapper(app.get('storage') || options.storage) this.app = app this.options = options this.authenticated = false this.app.set('storage', storage) if (socket) { this.handleSocket(socket) } } get service() { return this.app.service(this.options.path) } get storage() { return this.app.get('storage') as Storage } handleSocket(socket: any) { // When the socket disconnects and we are still authenticated, try to reauthenticate right away // the websocket connection will handle timeouts and retries socket.on('disconnect', () => { if (this.authenticated) { this.reAuthenticate(true) } }) } /** * Parse the access token or authentication error from the window location hash. Will remove it from the hash * if found. * * @param location The window location * @returns The access token if available, will throw an error if found, otherwise null */ getFromLocation(location: Location) { const [accessToken, tokenRegex] = getMatch(location, this.options.locationKey) if (accessToken !== null) { location.hash = location.hash.replace(tokenRegex, '') return Promise.resolve(accessToken) } const [message, errorRegex] = getMatch(location, this.options.locationErrorKey) if (message !== null) { location.hash = location.hash.replace(errorRegex, '') return Promise.reject(new OauthError(decodeURIComponent(message))) } return Promise.resolve(null) } /** * Set the access token in storage. * * @param accessToken The access token to set * @returns */ setAccessToken(accessToken: string) { return this.storage.setItem(this.options.storageKey, accessToken) } /** * Returns the access token from storage or the window location hash. * * @returns The access token from storage or location hash */ getAccessToken(): Promise { return this.storage.getItem(this.options.storageKey).then((accessToken: string) => { if (!accessToken && typeof window !== 'undefined' && window.location) { return this.getFromLocation(window.location) } return accessToken || null }) } /** * Remove the access token from storage * @returns The removed access token */ removeAccessToken() { return this.storage.removeItem(this.options.storageKey) } /** * Reset the internal authentication state. Usually not necessary to call directly. * * @returns null */ reset() { this.app.set('authentication', null) this.authenticated = false return Promise.resolve(null) } handleError(error: FeathersError, type: 'authenticate' | 'logout') { // For NotAuthenticated, PaymentError, Forbidden, NotFound, MethodNotAllowed, NotAcceptable // errors, remove the access token if (error.code > 400 && error.code < 408) { const promise = this.removeAccessToken().then(() => this.reset()) return type === 'logout' ? promise : promise.then(() => Promise.reject(error)) } return this.reset().then(() => Promise.reject(error)) } /** * Try to reauthenticate using the token from storage. Will do nothing if already authenticated unless * `force` is true. * * @param force force reauthentication with the server * @param strategy The name of the strategy to use. Defaults to `options.jwtStrategy` * @param authParams Additional authentication parameters * @returns The reauthentication result */ reAuthenticate(force = false, strategy?: string, authParams?: Params): Promise { // Either returns the authentication state or // tries to re-authenticate with the stored JWT and strategy let authPromise = this.app.get('authentication') if (!authPromise || force === true) { authPromise = this.getAccessToken().then((accessToken) => { if (!accessToken) { return this.handleError(new NotAuthenticated('No accessToken found in storage'), 'authenticate') } return this.authenticate( { strategy: strategy || this.options.jwtStrategy, accessToken }, authParams ) }) this.app.set('authentication', authPromise) } return authPromise } /** * Authenticate using a specific strategy and data. * * @param authentication The authentication data * @param params Additional parameters * @returns The authentication result */ authenticate(authentication?: AuthenticationRequest, params?: Params): Promise { if (!authentication) { return this.reAuthenticate() } const promise = this.service .create(authentication, params) .then((authResult: AuthenticationResult) => { const { accessToken } = authResult this.authenticated = true this.app.emit('login', authResult) this.app.emit('authenticated', authResult) return this.setAccessToken(accessToken).then(() => authResult) }) .catch((error: FeathersError) => this.handleError(error, 'authenticate')) this.app.set('authentication', promise) return promise } /** * Log out the current user and remove their token. Will do nothing * if not authenticated. * * @returns The log out result. */ logout(): Promise { return Promise.resolve(this.app.get('authentication')) .then(() => this.service.remove(null).then((authResult: AuthenticationResult) => this.removeAccessToken() .then(() => this.reset()) .then(() => { this.app.emit('logout', authResult) return authResult }) ) ) .catch((error: FeathersError) => this.handleError(error, 'logout')) } } ================================================ FILE: packages/authentication-client/src/hooks/authentication.ts ================================================ import { HookContext, NextFunction } from '@feathersjs/feathers' import { stripSlashes } from '@feathersjs/commons' export const authentication = () => { return (context: HookContext, next: NextFunction) => { const { app, params, path, method, app: { authentication: service } } = context if (stripSlashes(service.options.path) === path && method === 'create') { return next() } return Promise.resolve(app.get('authentication')) .then((authResult) => { if (authResult) { context.params = Object.assign({}, authResult, params) } }) .then(next) } } ================================================ FILE: packages/authentication-client/src/hooks/index.ts ================================================ export { authentication } from './authentication' export { populateHeader } from './populate-header' ================================================ FILE: packages/authentication-client/src/hooks/populate-header.ts ================================================ import { HookContext, NextFunction } from '@feathersjs/feathers' export const populateHeader = () => { return (context: HookContext, next: NextFunction) => { const { app, params: { accessToken } } = context const authentication = app.authentication // Set REST header if necessary if (app.rest && accessToken) { const { scheme, header } = authentication.options const authHeader = `${scheme} ${accessToken}` context.params.headers = Object.assign( {}, { [header]: authHeader }, context.params.headers ) } return next() } } ================================================ FILE: packages/authentication-client/src/index.ts ================================================ import { AuthenticationClient, AuthenticationClientOptions } from './core' import * as hooks from './hooks' import { Application } from '@feathersjs/feathers' import { Storage, MemoryStorage, StorageWrapper } from './storage' declare module '@feathersjs/feathers/lib/declarations' { // eslint-disable-next-line @typescript-eslint/no-unused-vars interface Application { // eslint-disable-line io: any rest?: any authentication: AuthenticationClient authenticate: AuthenticationClient['authenticate'] reAuthenticate: AuthenticationClient['reAuthenticate'] logout: AuthenticationClient['logout'] } } export const getDefaultStorage = () => { try { return new StorageWrapper(window.localStorage) } catch (error: any) {} return new MemoryStorage() } export { AuthenticationClient, AuthenticationClientOptions, Storage, MemoryStorage, hooks } export type ClientConstructor = new ( app: Application, options: AuthenticationClientOptions ) => AuthenticationClient export const defaultStorage: Storage = getDefaultStorage() export const defaults: AuthenticationClientOptions = { header: 'Authorization', scheme: 'Bearer', storageKey: 'feathers-jwt', locationKey: 'access_token', locationErrorKey: 'error', jwtStrategy: 'jwt', path: '/authentication', Authentication: AuthenticationClient, storage: defaultStorage } const init = (_options: Partial = {}) => { const options: AuthenticationClientOptions = Object.assign({}, defaults, _options) const { Authentication } = options return (app: Application) => { const authentication = new Authentication(app, options) app.authentication = authentication app.authenticate = authentication.authenticate.bind(authentication) app.reAuthenticate = authentication.reAuthenticate.bind(authentication) app.logout = authentication.logout.bind(authentication) app.hooks([hooks.authentication(), hooks.populateHeader()]) } } export default init if (typeof module !== 'undefined') { module.exports = Object.assign(init, module.exports) } ================================================ FILE: packages/authentication-client/src/storage.ts ================================================ export interface Storage { getItem(key: string): any setItem?(key: string, value: any): any removeItem?(key: string): any } export class MemoryStorage implements Storage { store: { [key: string]: any } constructor() { this.store = {} } getItem(key: string) { return Promise.resolve(this.store[key]) } setItem(key: string, value: any) { return Promise.resolve((this.store[key] = value)) } removeItem(key: string) { const value = this.store[key] delete this.store[key] return Promise.resolve(value) } } export class StorageWrapper implements Storage { storage: any constructor(storage: any) { this.storage = storage } getItem(key: string) { return Promise.resolve(this.storage?.getItem(key)) } setItem(key: string, value: any) { return Promise.resolve(this.storage?.setItem(key, value)) } removeItem(key: string) { return Promise.resolve(this.storage?.removeItem(key)) } } ================================================ FILE: packages/authentication-client/test/index.test.ts ================================================ import assert from 'assert' import { feathers, Application } from '@feathersjs/feathers' import client from '../src' import { AuthenticationClient } from '../src' import { NotAuthenticated } from '@feathersjs/errors' describe('@feathersjs/authentication-client', () => { const accessToken = 'testing' const user = { name: 'Test User' } let app: Application beforeEach(() => { app = feathers() app.configure(client()) app.use('/authentication', { async create(data: any) { if (data.error) { throw new Error('Did not work') } return { accessToken, data, user } }, async remove(id) { if (!app.get('authentication')) { throw new NotAuthenticated('Not logged in') } return { id } } }) app.use('dummy', { async find(params) { return params } }) }) it('initializes', () => { assert.ok(app.authentication instanceof AuthenticationClient) assert.strictEqual(app.get('storage'), app.authentication.storage) assert.strictEqual(typeof app.authenticate, 'function') assert.strictEqual(typeof app.logout, 'function') }) it('setAccessToken, getAccessToken, removeAccessToken', async () => { const auth = app.authentication const token = 'hi' await auth.setAccessToken(token) const res = await auth.getAccessToken() assert.strictEqual(res, token) await auth.removeAccessToken() assert.strictEqual(await auth.getAccessToken(), null) }) it('getFromLocation', async () => { const auth = app.authentication let dummyLocation = { hash: 'access_token=testing' } as Location let token = await auth.getFromLocation(dummyLocation) assert.strictEqual(token, 'testing') assert.strictEqual(dummyLocation.hash, '') dummyLocation.hash = 'a=b&access_token=otherTest&c=d' token = await auth.getFromLocation(dummyLocation) assert.strictEqual(token, 'otherTest') assert.strictEqual(dummyLocation.hash, 'a=b&c=d') dummyLocation = { search: 'access_token=testing' } as Location token = await auth.getFromLocation(dummyLocation) assert.strictEqual(await auth.getFromLocation({} as Location), null) try { await auth.getFromLocation({ hash: 'error=Error Happened&x=y' } as Location) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'OauthError') assert.strictEqual(error.message, 'Error Happened') } }) it('authenticate, authentication hook, login event', async () => { const data = { strategy: 'testing' } const promise = new Promise((resolve) => { app.once('login', resolve) }) app.authenticate(data) const result = await promise assert.deepStrictEqual(result, { accessToken, data, user }) let at = await app.authentication.getAccessToken() assert.strictEqual(at, accessToken, 'Set accessToken in storage') at = await Promise.resolve(app.get('storage').getItem('feathers-jwt')) assert.strictEqual(at, accessToken, 'Set accessToken in storage') const found = await app.service('dummy').find() assert.deepStrictEqual(found.accessToken, accessToken) assert.deepStrictEqual(found.user, user) }) it('logout event', async () => { const promise = new Promise((resolve) => app.once('logout', resolve)) app.authenticate({ strategy: 'testing' }).then(() => app.logout()) const result = await promise assert.deepStrictEqual(result, { id: null }) }) it('does not remove AccessToken on other errors', async () => { await app.authenticate({ strategy: 'testing' }) await app.authenticate({ strategy: 'testing' }) const at = await app.authentication.getAccessToken() assert.strictEqual(at, accessToken) }) it('resets after any error (#1947)', async () => { await assert.rejects(() => app.authenticate({ strategy: 'testing', error: true }), { message: 'Did not work' }) const found = await app.service('dummy').find() assert.deepStrictEqual(found, {}) }) it('logout when not logged in without error', async () => { const result = await app.logout() assert.strictEqual(result, null) }) describe('reauthenticate', () => { it('fails when no token in storage and resets authentication state', async () => { await assert.rejects(() => app.authentication.reAuthenticate(), { message: 'No accessToken found in storage' }) assert.ok(!app.get('authentication'), 'Reset authentication') }) it('reauthenticates when token is in storage', async () => { const data = { strategy: 'testing' } const result = await app.authenticate(data) assert.deepStrictEqual(result, { accessToken, data, user }) await app.authentication.reAuthenticate() await app.authentication.reset() let at = await Promise.resolve(app.get('storage').getItem('feathers-jwt')) assert.strictEqual(at, accessToken, 'Set accessToken in storage') at = await app.authentication.reAuthenticate() assert.deepStrictEqual(at, { accessToken, data: { strategy: 'jwt', accessToken: 'testing' }, user }) await app.logout() at = await Promise.resolve(app.get('storage').getItem('feathers-jwt')) assert.ok(!at) assert.ok(!app.get('authentication')) }) it('reAuthenticate works with parallel requests', async () => { const data = { strategy: 'testing' } await app.authenticate(data) await app.reAuthenticate() await app.authentication.reset() app.reAuthenticate() const found = await app.service('dummy').find() assert.deepStrictEqual(found.accessToken, accessToken) assert.deepStrictEqual(found.user, user) }) it('reauthenticates using different strategy', async () => { app.configure(client({ jwtStrategy: 'any' })) const data = { strategy: 'testing' } let result = await app.authenticate(data) assert.deepStrictEqual(result, { accessToken, data, user }) result = await app.authentication.reAuthenticate(false, 'jwt') assert.deepStrictEqual(result, { accessToken, data, user }) }) }) }) ================================================ FILE: packages/authentication-client/test/integration/commons.ts ================================================ import assert from 'assert' import { Application } from '@feathersjs/feathers' import '../../src' export default ( getApp: () => Application, getClient: () => Application, { provider, email, password }: { provider: string; email: string; password: string } ) => { describe('common tests', () => { let client: Application let user: any before( async () => (user = await getApp().service('users').create({ email, password })) ) beforeEach(() => { client = getClient() }) after(async () => { await getApp().service('users').remove(user.id) }) it('authenticates with local strategy', async () => { const result = await client.authenticate({ strategy: 'local', email, password }) assert.ok(result.accessToken) assert.strictEqual(result.authentication.strategy, 'local') assert.strictEqual(result.user.email, email) }) it('authentication with wrong credentials fails, does not maintain state', async () => { await assert.rejects( () => client.authenticate({ strategy: 'local', email, password: 'blabla' }), { name: 'NotAuthenticated', message: 'Invalid login' } ) assert.ok(!client.get('authentication'), 'Reset client state') }) it('errors when not authenticated', async () => { await assert.rejects(() => client.service('dummy').find(), { name: 'NotAuthenticated', code: 401, message: 'Not authenticated' }) }) it('authenticates and allows access', async () => { await client.authenticate({ strategy: 'local', email, password }) const result = await client.service('dummy').find() assert.strictEqual(result.provider, provider) assert.ok(result.authentication) assert.ok(result.authentication.payload) assert.strictEqual(result.user.email, user.email) assert.strictEqual(result.user.id, user.id) }) it('re-authenticates', async () => { await client.authenticate({ strategy: 'local', email, password }) client.authentication.reset() client.authenticate() const result = await client.service('dummy').find() assert.strictEqual(result.provider, provider) assert.ok(result.authentication) assert.ok(result.authentication.payload) assert.strictEqual(result.user.email, user.email) assert.strictEqual(result.user.id, user.id) }) it('after logout does not allow subsequent access', async () => { await client.authenticate({ strategy: 'local', email, password }) const result = await client.logout() assert.ok(result!.accessToken) assert.ok(result!.user) assert.rejects(() => client.service('dummy').find(), { name: 'NotAuthenticated', code: 401, message: 'Not authenticated' }) }) }) } ================================================ FILE: packages/authentication-client/test/integration/express.test.ts ================================================ import axios from 'axios' import { Server } from 'http' import { feathers, Application as FeathersApplication } from '@feathersjs/feathers' import * as express from '@feathersjs/express' import rest from '@feathersjs/rest-client' import authClient from '../../src' import getApp from './fixture' import commonTests from './commons' describe('@feathersjs/authentication-client Express integration', () => { let app: express.Application let server: Server before(async () => { const restApp = express .default(feathers()) .use(express.json()) .configure(express.rest()) .use(express.parseAuthentication()) app = getApp(restApp as unknown as FeathersApplication) as express.Application app.use(express.errorHandler()) server = await app.listen(9776) }) after((done) => server.close(() => done())) commonTests( () => app, () => { return feathers().configure(rest('http://localhost:9776').axios(axios)).configure(authClient()) }, { email: 'expressauth@feathersjs.com', password: 'secret', provider: 'rest' } ) }) ================================================ FILE: packages/authentication-client/test/integration/fixture.ts ================================================ import { authenticate } from '@feathersjs/authentication' import { HookContext, Application } from '@feathersjs/feathers' import { memory } from '@feathersjs/memory' import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication' import { LocalStrategy, hooks } from '@feathersjs/authentication-local' const { hashPassword, protect } = hooks export default (app: Application) => { const authentication = new AuthenticationService(app) app.set('authentication', { entity: 'user', service: 'users', secret: 'supersecret', authStrategies: ['local', 'jwt'], local: { usernameField: 'email', passwordField: 'password' } }) authentication.register('jwt', new JWTStrategy()) authentication.register('local', new LocalStrategy()) app.use('/authentication', authentication) app.use( '/users', memory({ paginate: { default: 10, max: 20 } }) ) app.service('users').hooks({ before: { create: hashPassword('password') }, after: protect('password') }) app.use('/dummy', { find(params) { return Promise.resolve(params) } }) app.service('dummy').hooks({ before: authenticate('jwt') }) app.service('users').hooks({ before(context: HookContext) { if (context.id !== undefined && context.id !== null) { context.id = parseInt(context.id as string, 10) } return context } }) return app } ================================================ FILE: packages/authentication-client/test/integration/socketio.test.ts ================================================ import { io } from 'socket.io-client' import assert from 'assert' import { feathers, Application } from '@feathersjs/feathers' import socketio from '@feathersjs/socketio' import socketioClient from '@feathersjs/socketio-client' import authClient from '../../src' import getApp from './fixture' import commonTests from './commons' import { AuthenticationResult } from '@feathersjs/authentication/lib' describe('@feathersjs/authentication-client Socket.io integration', () => { let app: Application before(async () => { app = getApp(feathers().configure(socketio())) await app.listen(9777) }) after((done) => { app.io.close(() => done()) }) it('allows to authenticate with handshake headers and sends login event', async () => { const user = { email: 'authtest@example.com', password: 'alsosecret' } await app.service('users').create(user) const { accessToken } = await app.service('authentication').create({ strategy: 'local', ...user }) const socket = io('http://localhost:9777', { transports: ['websocket'], transportOptions: { websocket: { extraHeaders: { Authorization: `Bearer ${accessToken}` } } } }) const authResult: any = await new Promise((resolve) => app.once('login', (res) => resolve(res))) assert.strictEqual(authResult.accessToken, accessToken) const dummy: any = await new Promise((resolve, reject) => { socket.emit('find', 'dummy', {}, (error: Error, page: any) => (error ? reject(error) : resolve(page))) }) assert.strictEqual(dummy.user.email, user.email) assert.strictEqual(dummy.authentication.accessToken, accessToken) assert.strictEqual(dummy.headers.authorization, `Bearer ${accessToken}`) }) it('reconnects after socket disconnection', async () => { const user = { email: 'disconnecttest@example.com', password: 'alsosecret' } const socket = io('http://localhost:9777', { timeout: 500, reconnection: true, reconnectionDelay: 100 }) const client = feathers().configure(socketioClient(socket)).configure(authClient()) await app.service('users').create(user) await client.authenticate({ strategy: 'local', ...user }) const onLogin = new Promise((resolve) => app.once('login', (data) => resolve(data))) socket.once('disconnect', () => socket.connect()) socket.disconnect() const { authentication: { strategy } } = await onLogin const dummy = await client.service('dummy').find() assert.strictEqual(strategy, 'jwt') assert.strictEqual(dummy.user.email, user.email) }) commonTests( () => app, () => { return feathers() .configure(socketioClient(io('http://localhost:9777'))) .configure(authClient()) }, { email: 'socketioauth@feathersjs.com', password: 'secretive', provider: 'socketio' } ) }) ================================================ FILE: packages/authentication-client/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/authentication-local/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) ### Bug Fixes - Reduce usage of lodash ([#3455](https://github.com/feathersjs/feathers/issues/3455)) ([8ce807a](https://github.com/feathersjs/feathers/commit/8ce807a5ca53ff5b8d5107a0656c6329404e6e6c)) ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) ### Bug Fixes - **authentication-local:** Local Auth - Nested username & Password fields ([#3091](https://github.com/feathersjs/feathers/issues/3091)) ([d135526](https://github.com/feathersjs/feathers/commit/d135526da18ecf2dc620b82820e1d09d8af5c0b5)) ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/authentication-local ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) ### Features - **authentication-oauth:** Koa and transport independent oAuth authentication ([#2737](https://github.com/feathersjs/feathers/issues/2737)) ([9231525](https://github.com/feathersjs/feathers/commit/9231525a24bb790ba9c5d940f2867a9c727691c9)) # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Features - **authentication-local:** Add passwordHash property resolver ([#2660](https://github.com/feathersjs/feathers/issues/2660)) ([b41279b](https://github.com/feathersjs/feathers/commit/b41279b55eea3771a6fa4983a37be2413287bbc6)) # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Features - **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5)) # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) ### Bug Fixes - **hooks:** Allow all built-in hooks to be used the async and regular way ([#2559](https://github.com/feathersjs/feathers/issues/2559)) ([8f9f631](https://github.com/feathersjs/feathers/commit/8f9f631e0ce89de349207db72def84e7ab496a4a)) # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Bug Fixes - **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) ### Bug Fixes - **authentication-local:** adds error handling for undefined/null password field ([#2444](https://github.com/feathersjs/feathers/issues/2444)) ([4323f98](https://github.com/feathersjs/feathers/commit/4323f9859a66a7fe3f7f15d81476bd81b735c226)) # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Bug Fixes - **hooks:** Migrate built-in hooks and allow backwards compatibility ([#2358](https://github.com/feathersjs/feathers/issues/2358)) ([759c5a1](https://github.com/feathersjs/feathers/commit/759c5a19327a731af965c3604119393b3d09a406)) - **koa:** Use extended query parser for compatibility ([#2397](https://github.com/feathersjs/feathers/issues/2397)) ([b2944ba](https://github.com/feathersjs/feathers/commit/b2944bac3ec6d5ecc80dc518cd4e58093692db74)) ### Features - **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) ### Features - **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) ### Features - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) **Note:** Version bump only for package @feathersjs/authentication-local # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) **Note:** Version bump only for package @feathersjs/authentication-local ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) **Note:** Version bump only for package @feathersjs/authentication-local ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) ### Bug Fixes - **authentication:** Add JWT getEntityQuery ([#2013](https://github.com/feathersjs/feathers/issues/2013)) ([e0e7fb5](https://github.com/feathersjs/feathers/commit/e0e7fb5162940fe776731283b40026c61d9c8a33)) ## [4.5.6](https://github.com/feathersjs/feathers/compare/v4.5.5...v4.5.6) (2020-07-12) **Note:** Version bump only for package @feathersjs/authentication-local ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) **Note:** Version bump only for package @feathersjs/authentication-local ## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-04-29) ### Bug Fixes - **authentication-local:** Allow to hash passwords in array data ([#1936](https://github.com/feathersjs/feathers/issues/1936)) ([64705f5](https://github.com/feathersjs/feathers/commit/64705f5d9d4dc27f799da3a074efaf74379a3398)) ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) **Note:** Version bump only for package @feathersjs/authentication-local ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) ### Bug Fixes - **test:** typo in password ([#1797](https://github.com/feathersjs/feathers/issues/1797)) ([dfba6ec](https://github.com/feathersjs/feathers/commit/dfba6ec2f21adf3aa739218cf870eaaaa5df6e9c)) ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/authentication-local # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) **Note:** Version bump only for package @feathersjs/authentication-local ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/authentication-local ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/authentication-local # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) ### Features - **authentication:** Add parseStrategies to allow separate strategies for creating JWTs and parsing headers ([#1708](https://github.com/feathersjs/feathers/issues/1708)) ([5e65629](https://github.com/feathersjs/feathers/commit/5e65629b924724c3e81d7c81df047e123d1c8bd7)) ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) **Note:** Version bump only for package @feathersjs/authentication-local ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/authentication-local ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) **Note:** Version bump only for package @feathersjs/authentication-local ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) **Note:** Version bump only for package @feathersjs/authentication-local ## [4.3.5](https://github.com/feathersjs/feathers/compare/v4.3.4...v4.3.5) (2019-10-07) **Note:** Version bump only for package @feathersjs/authentication-local ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) **Note:** Version bump only for package @feathersjs/authentication-local ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) ### Bug Fixes - Small improvements in dependencies and code sturcture ([#1562](https://github.com/feathersjs/feathers/issues/1562)) ([42c13e2](https://github.com/feathersjs/feathers/commit/42c13e2)) ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) ### Bug Fixes - LocalStrategy authenticates without username ([#1560](https://github.com/feathersjs/feathers/issues/1560)) ([2b258fd](https://github.com/feathersjs/feathers/commit/2b258fd)), closes [#1559](https://github.com/feathersjs/feathers/issues/1559) ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) **Note:** Version bump only for package @feathersjs/authentication-local # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/authentication-local # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/authentication-local # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) ### Bug Fixes - Update all dependencies ([7d53a00](https://github.com/feathersjs/feathers/commit/7d53a00)) # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) ### Bug Fixes - Add method to reliably get default authentication service ([#1470](https://github.com/feathersjs/feathers/issues/1470)) ([e542cb3](https://github.com/feathersjs/feathers/commit/e542cb3)) # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/authentication-local # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) **Note:** Version bump only for package @feathersjs/authentication-local # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) **Note:** Version bump only for package @feathersjs/authentication-local # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) **Note:** Version bump only for package @feathersjs/authentication-local # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) ### Bug Fixes - Always require strategy parameter in authentication ([#1327](https://github.com/feathersjs/feathers/issues/1327)) ([d4a8021](https://github.com/feathersjs/feathers/commit/d4a8021)) - Improve authentication parameter handling ([#1333](https://github.com/feathersjs/feathers/issues/1333)) ([6e77204](https://github.com/feathersjs/feathers/commit/6e77204)) - Merge httpStrategies and authStrategies option ([#1308](https://github.com/feathersjs/feathers/issues/1308)) ([afa4d55](https://github.com/feathersjs/feathers/commit/afa4d55)) - Rename jwtStrategies option to authStrategies ([#1305](https://github.com/feathersjs/feathers/issues/1305)) ([4aee151](https://github.com/feathersjs/feathers/commit/4aee151)) ### Features - Change and *JWT methods to *accessToken ([#1304](https://github.com/feathersjs/feathers/issues/1304)) ([5ac826b](https://github.com/feathersjs/feathers/commit/5ac826b)) # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Authentication core improvements ([#1260](https://github.com/feathersjs/feathers/issues/1260)) ([c5dc7a2](https://github.com/feathersjs/feathers/commit/c5dc7a2)) - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) - **package:** update debug to version 3.0.0 ([#31](https://github.com/feathersjs/feathers/issues/31)) ([f23d617](https://github.com/feathersjs/feathers/commit/f23d617)) ### Features - @feathersjs/authentication-oauth ([#1299](https://github.com/feathersjs/feathers/issues/1299)) ([656bae7](https://github.com/feathersjs/feathers/commit/656bae7)) - Add AuthenticationBaseStrategy and make authentication option handling more explicit ([#1284](https://github.com/feathersjs/feathers/issues/1284)) ([2667d92](https://github.com/feathersjs/feathers/commit/2667d92)) - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - Authentication v3 core server implementation ([#1205](https://github.com/feathersjs/feathers/issues/1205)) ([1bd7591](https://github.com/feathersjs/feathers/commit/1bd7591)) - Authentication v3 local authentication ([#1211](https://github.com/feathersjs/feathers/issues/1211)) ([0fa5f7c](https://github.com/feathersjs/feathers/commit/0fa5f7c)) ### BREAKING CHANGES - Update authentication strategies for @feathersjs/authentication v3 ## [1.2.9](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-local@1.2.8...@feathersjs/authentication-local@1.2.9) (2019-01-02) ### Bug Fixes - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) ## [1.2.8](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-local@1.2.7...@feathersjs/authentication-local@1.2.8) (2018-12-16) **Note:** Version bump only for package @feathersjs/authentication-local ## [1.2.7](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-local@1.2.6...@feathersjs/authentication-local@1.2.7) (2018-10-26) **Note:** Version bump only for package @feathersjs/authentication-local ## [1.2.6](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-local@1.2.5...@feathersjs/authentication-local@1.2.6) (2018-10-25) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) ## [1.2.5](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-local@1.2.4...@feathersjs/authentication-local@1.2.5) (2018-09-21) **Note:** Version bump only for package @feathersjs/authentication-local ## [1.2.4](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-local@1.2.3...@feathersjs/authentication-local@1.2.4) (2018-09-17) **Note:** Version bump only for package @feathersjs/authentication-local ## [1.2.3](https://github.com/feathersjs/feathers/compare/@feathersjs/authentication-local@1.2.2...@feathersjs/authentication-local@1.2.3) (2018-09-02) **Note:** Version bump only for package @feathersjs/authentication-local ## 1.2.2 - Migrate to Monorepo ([feathers#462](https://github.com/feathersjs/feathers/issues/462)) ## [v1.2.1](https://github.com/feathersjs/authentication-local/tree/v1.2.1) (2018-05-02) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v1.2.0...v1.2.1) **Merged pull requests:** - Make sure the original object is not modified [\#65](https://github.com/feathersjs/authentication-local/pull/65) ([daffl](https://github.com/daffl)) ## [v1.2.0](https://github.com/feathersjs/authentication-local/tree/v1.2.0) (2018-05-02) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v1.1.3...v1.2.0) **Merged pull requests:** - added support for nested password fields option in hash password hook [\#64](https://github.com/feathersjs/authentication-local/pull/64) ([ThePesta](https://github.com/ThePesta)) ## [v1.1.3](https://github.com/feathersjs/authentication-local/tree/v1.1.3) (2018-04-20) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v1.1.2...v1.1.3) **Merged pull requests:** - Adding tests and calling to hasOwnProperty on Object.prototype instead of assuming valid prototype [\#63](https://github.com/feathersjs/authentication-local/pull/63) ([pmabres](https://github.com/pmabres)) ## [v1.1.2](https://github.com/feathersjs/authentication-local/tree/v1.1.2) (2018-04-15) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v1.1.1...v1.1.2) **Closed issues:** - Protect hooks does not support dot notation [\#61](https://github.com/feathersjs/authentication-local/issues/61) **Merged pull requests:** - Use latest version of Lodash [\#62](https://github.com/feathersjs/authentication-local/pull/62) ([daffl](https://github.com/daffl)) ## [v1.1.1](https://github.com/feathersjs/authentication-local/tree/v1.1.1) (2018-03-25) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v1.1.0...v1.1.1) **Closed issues:** - hash-password hook will skip users if they are missing password [\#58](https://github.com/feathersjs/authentication-local/issues/58) - User service create method gets called upon each validation [\#56](https://github.com/feathersjs/authentication-local/issues/56) **Merged pull requests:** - Do not skip users that have no password [\#60](https://github.com/feathersjs/authentication-local/pull/60) ([daffl](https://github.com/daffl)) - Update sinon to the latest version 🚀 [\#59](https://github.com/feathersjs/authentication-local/pull/59) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update sinon-chai to the latest version 🚀 [\#57](https://github.com/feathersjs/authentication-local/pull/57) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.1.0](https://github.com/feathersjs/authentication-local/tree/v1.1.0) (2018-01-23) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v1.0.4...v1.1.0) **Closed issues:** - protect hook attempts to map through 'result.data' on all service methods. [\#53](https://github.com/feathersjs/authentication-local/issues/53) - Protect hook should check for toJSON [\#48](https://github.com/feathersjs/authentication-local/issues/48) **Merged pull requests:** - Use .toJSON if available [\#55](https://github.com/feathersjs/authentication-local/pull/55) ([daffl](https://github.com/daffl)) - Only map data for find method [\#54](https://github.com/feathersjs/authentication-local/pull/54) ([daffl](https://github.com/daffl)) - Update @feathersjs/authentication-jwt to the latest version 🚀 [\#52](https://github.com/feathersjs/authentication-local/pull/52) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update mocha to the latest version 🚀 [\#51](https://github.com/feathersjs/authentication-local/pull/51) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.4](https://github.com/feathersjs/authentication-local/tree/v1.0.4) (2018-01-03) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v1.0.3...v1.0.4) ## [v1.0.3](https://github.com/feathersjs/authentication-local/tree/v1.0.3) (2018-01-03) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v1.0.2...v1.0.3) **Closed issues:** - local authentication bug with users as sequelize service [\#47](https://github.com/feathersjs/authentication-local/issues/47) **Merged pull requests:** - Update documentation to correspond with latest release [\#50](https://github.com/feathersjs/authentication-local/pull/50) ([daffl](https://github.com/daffl)) - Update semistandard to the latest version 🚀 [\#49](https://github.com/feathersjs/authentication-local/pull/49) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.2](https://github.com/feathersjs/authentication-local/tree/v1.0.2) (2017-12-06) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v1.0.1...v1.0.2) **Closed issues:** - why is the password send as plain text instead of encrypting it on client side? [\#44](https://github.com/feathersjs/authentication-local/issues/44) **Merged pull requests:** - Update hook.result if an external provider is set [\#46](https://github.com/feathersjs/authentication-local/pull/46) ([daffl](https://github.com/daffl)) - Update feathers-memory to the latest version 🚀 [\#45](https://github.com/feathersjs/authentication-local/pull/45) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.1](https://github.com/feathersjs/authentication-local/tree/v1.0.1) (2017-11-16) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v1.0.0...v1.0.1) **Merged pull requests:** - Add default export for better ES module \(TypeScript\) compatibility [\#43](https://github.com/feathersjs/authentication-local/pull/43) ([daffl](https://github.com/daffl)) - Update @feathersjs/authentication to the latest version 🚀 [\#42](https://github.com/feathersjs/authentication-local/pull/42) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.0](https://github.com/feathersjs/authentication-local/tree/v1.0.0) (2017-11-01) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v1.0.0-pre.2...v1.0.0) **Merged pull requests:** - Update dependencies for release [\#41](https://github.com/feathersjs/authentication-local/pull/41) ([daffl](https://github.com/daffl)) ## [v1.0.0-pre.2](https://github.com/feathersjs/authentication-local/tree/v1.0.0-pre.2) (2017-10-27) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v1.0.0-pre.1...v1.0.0-pre.2) **Merged pull requests:** - Safely dispatch without password [\#40](https://github.com/feathersjs/authentication-local/pull/40) ([daffl](https://github.com/daffl)) ## [v1.0.0-pre.1](https://github.com/feathersjs/authentication-local/tree/v1.0.0-pre.1) (2017-10-25) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v0.4.4...v1.0.0-pre.1) **Closed issues:** - How configure local strategy to feathers-authentication? [\#36](https://github.com/feathersjs/authentication-local/issues/36) - An in-range update of feathers is breaking the build 🚨 [\#32](https://github.com/feathersjs/authentication-local/issues/32) **Merged pull requests:** - Update to Feathers v3 [\#39](https://github.com/feathersjs/authentication-local/pull/39) ([daffl](https://github.com/daffl)) - Rename repository and use npm scope [\#38](https://github.com/feathersjs/authentication-local/pull/38) ([daffl](https://github.com/daffl)) - Update to new plugin infrastructure [\#37](https://github.com/feathersjs/authentication-local/pull/37) ([daffl](https://github.com/daffl)) - Update mocha to the latest version 🚀 [\#35](https://github.com/feathersjs/authentication-local/pull/35) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update sinon to the latest version 🚀 [\#34](https://github.com/feathersjs/authentication-local/pull/34) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Add babel-polyfill and package-lock.json [\#33](https://github.com/feathersjs/authentication-local/pull/33) ([daffl](https://github.com/daffl)) - Update sinon to the latest version 🚀 [\#29](https://github.com/feathersjs/authentication-local/pull/29) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v0.4.4](https://github.com/feathersjs/authentication-local/tree/v0.4.4) (2017-08-11) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v0.4.3...v0.4.4) **Closed issues:** - i18n support [\#28](https://github.com/feathersjs/authentication-local/issues/28) - Couldn't store jwt token in cookies [\#17](https://github.com/feathersjs/authentication-local/issues/17) - Strategy for subapp [\#9](https://github.com/feathersjs/authentication-local/issues/9) **Merged pull requests:** - Update debug to the latest version 🚀 [\#31](https://github.com/feathersjs/authentication-local/pull/31) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Increase bcrypt cost factor, add future cost factor auto-optimization [\#30](https://github.com/feathersjs/authentication-local/pull/30) ([micaksica2](https://github.com/micaksica2)) ## [v0.4.3](https://github.com/feathersjs/authentication-local/tree/v0.4.3) (2017-06-22) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v0.4.2...v0.4.3) **Closed issues:** - Log a warning if service.id is undefined or null [\#19](https://github.com/feathersjs/authentication-local/issues/19) **Merged pull requests:** - throw error if service.id is missing [\#27](https://github.com/feathersjs/authentication-local/pull/27) ([marshallswain](https://github.com/marshallswain)) ## [v0.4.2](https://github.com/feathersjs/authentication-local/tree/v0.4.2) (2017-06-22) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v0.4.1...v0.4.2) ## [v0.4.1](https://github.com/feathersjs/authentication-local/tree/v0.4.1) (2017-06-22) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v0.4.0...v0.4.1) **Merged pull requests:** - Resolves \#14 - Passes Feathers params to service hooks [\#15](https://github.com/feathersjs/authentication-local/pull/15) ([thomas-p-wilson](https://github.com/thomas-p-wilson)) ## [v0.4.0](https://github.com/feathersjs/authentication-local/tree/v0.4.0) (2017-06-22) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v0.3.4...v0.4.0) **Closed issues:** - Module is using the wrong default config key [\#21](https://github.com/feathersjs/authentication-local/issues/21) - Feathers params not available to user service hooks [\#14](https://github.com/feathersjs/authentication-local/issues/14) - Bad error message is returned for invalid credentials [\#10](https://github.com/feathersjs/authentication-local/issues/10) **Merged pull requests:** - Greenkeeper/chai 4.0.2 [\#26](https://github.com/feathersjs/authentication-local/pull/26) ([daffl](https://github.com/daffl)) - Return Invalid login message when user doesn’t exist [\#25](https://github.com/feathersjs/authentication-local/pull/25) ([marshallswain](https://github.com/marshallswain)) - Adding separate entity username and password fields [\#23](https://github.com/feathersjs/authentication-local/pull/23) ([adamvr](https://github.com/adamvr)) - use the correct default config key. Closes \#21 [\#22](https://github.com/feathersjs/authentication-local/pull/22) ([ekryski](https://github.com/ekryski)) - Update feathers-socketio to the latest version 🚀 [\#20](https://github.com/feathersjs/authentication-local/pull/20) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update semistandard to the latest version 🚀 [\#18](https://github.com/feathersjs/authentication-local/pull/18) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update feathers-hooks to the latest version 🚀 [\#16](https://github.com/feathersjs/authentication-local/pull/16) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update dependencies to enable Greenkeeper 🌴 [\#13](https://github.com/feathersjs/authentication-local/pull/13) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v0.3.4](https://github.com/feathersjs/authentication-local/tree/v0.3.4) (2017-03-28) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v0.3.3...v0.3.4) **Closed issues:** - Shouldn't it be `authentication` instead of the old `auth` there? [\#11](https://github.com/feathersjs/authentication-local/issues/11) **Merged pull requests:** - Fix default authentication config name [\#12](https://github.com/feathersjs/authentication-local/pull/12) ([marshallswain](https://github.com/marshallswain)) ## [v0.3.3](https://github.com/feathersjs/authentication-local/tree/v0.3.3) (2017-01-27) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v0.3.2...v0.3.3) **Closed issues:** - Support dot notation [\#7](https://github.com/feathersjs/authentication-local/issues/7) - Automatically register the authenticate hook with 'local' [\#4](https://github.com/feathersjs/authentication-local/issues/4) **Merged pull requests:** - Add support for dot notation, fix some whitespace [\#8](https://github.com/feathersjs/authentication-local/pull/8) ([elfey](https://github.com/elfey)) ## [v0.3.2](https://github.com/feathersjs/authentication-local/tree/v0.3.2) (2016-12-14) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v0.3.1...v0.3.2) ## [v0.3.1](https://github.com/feathersjs/authentication-local/tree/v0.3.1) (2016-12-14) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v0.3.0...v0.3.1) **Closed issues:** - Add docs section on expected request params. [\#5](https://github.com/feathersjs/authentication-local/issues/5) **Merged pull requests:** - Document expected request data [\#6](https://github.com/feathersjs/authentication-local/pull/6) ([marshallswain](https://github.com/marshallswain)) ## [v0.3.0](https://github.com/feathersjs/authentication-local/tree/v0.3.0) (2016-11-23) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v0.2.0...v0.3.0) **Closed issues:** - Doesn't pull configuration from `auth.local` by default [\#2](https://github.com/feathersjs/authentication-local/issues/2) - Does not pull from global auth config when strategy has a custom name [\#1](https://github.com/feathersjs/authentication-local/issues/1) **Merged pull requests:** - Payload support [\#3](https://github.com/feathersjs/authentication-local/pull/3) ([ekryski](https://github.com/ekryski)) ## [v0.2.0](https://github.com/feathersjs/authentication-local/tree/v0.2.0) (2016-11-16) [Full Changelog](https://github.com/feathersjs/authentication-local/compare/v0.1.0...v0.2.0) ## [v0.1.0](https://github.com/feathersjs/authentication-local/tree/v0.1.0) (2016-11-09) \* _This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)_ ================================================ FILE: packages/authentication-local/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/authentication-local/README.md ================================================ # @feathersjs/authentication-local [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/authentication-local.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/authentication-local) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > Local username and password authentication strategy for Feathers authentication ## Installation ``` npm install @feathersjs/authentication-local --save ``` ## Documentation Refer to the [Feathers local authentication API documentation](https://feathersjs.com/api/authentication/local.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/authentication-local/package.json ================================================ { "name": "@feathersjs/authentication-local", "description": "Local authentication strategy for @feathers/authentication", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/authentication-local" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/authentication": "^5.0.42", "@feathersjs/commons": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/feathers": "^5.0.42", "bcryptjs": "^3.0.3", "lodash": "^4.17.23" }, "devDependencies": { "@feathersjs/memory": "^5.0.42", "@feathersjs/schema": "^5.0.42", "@types/bcryptjs": "^2.4.6", "@types/lodash": "^4.17.24", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "mocha": "^11.7.5", "shx": "^0.4.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/authentication-local/src/hooks/hash-password.ts ================================================ import get from 'lodash/get' import set from 'lodash/set' import cloneDeep from 'lodash/cloneDeep' import { BadRequest } from '@feathersjs/errors' import { createDebug } from '@feathersjs/commons' import { HookContext, NextFunction } from '@feathersjs/feathers' import { LocalStrategy } from '../strategy' const debug = createDebug('@feathersjs/authentication-local/hooks/hash-password') export interface HashPasswordOptions { authentication?: string strategy?: string } /** * @deprecated Use Feathers schema resolvers and the `passwordHash` resolver instead * @param field * @param options * @returns * @see https://dove.feathersjs.com/api/authentication/local.html#passwordhash */ export default function hashPassword(field: string, options: HashPasswordOptions = {}) { if (!field) { throw new Error('The hashPassword hook requires a field name option') } return async (context: HookContext, next?: NextFunction) => { const { app, data, params } = context if (data !== undefined) { const authService = app.defaultAuthentication(options.authentication) const { strategy = 'local' } = options if (!authService || typeof authService.getStrategies !== 'function') { throw new BadRequest('Could not find an authentication service to hash password') } const [localStrategy] = authService.getStrategies(strategy) as LocalStrategy[] if (!localStrategy || typeof localStrategy.hashPassword !== 'function') { throw new BadRequest(`Could not find '${strategy}' strategy to hash password`) } const addHashedPassword = async (data: any) => { const password = get(data, field) if (password === undefined) { debug(`hook.data.${field} is undefined, not hashing password`) return data } const hashedPassword: string = await localStrategy.hashPassword(password, params) return set(cloneDeep(data), field, hashedPassword) } context.data = Array.isArray(data) ? await Promise.all(data.map(addHashedPassword)) : await addHashedPassword(data) } if (typeof next === 'function') { return next() } } } ================================================ FILE: packages/authentication-local/src/hooks/protect.ts ================================================ import omit from 'lodash/omit' import { HookContext, NextFunction } from '@feathersjs/feathers' /** * @deprecated For reliable safe data representations use Feathers schema dispatch resolvers. * @see https://dove.feathersjs.comapi/authentication/local.html#protecting-fields */ export default (...fields: string[]) => { const o = (current: any) => { if (typeof current === 'object' && !Array.isArray(current)) { const data = typeof current.toJSON === 'function' ? current.toJSON() : current return omit(data, fields) } return current } return async (context: HookContext, next?: NextFunction) => { if (typeof next === 'function') { await next() } const result = context.dispatch || context.result if (result) { if (Array.isArray(result)) { context.dispatch = result.map(o) } else if (result.data && context.method === 'find') { context.dispatch = Object.assign({}, result, { data: result.data.map(o) }) } else { context.dispatch = o(result) } if (context.params && context.params.provider) { context.result = context.dispatch } } } } ================================================ FILE: packages/authentication-local/src/index.ts ================================================ import { HookContext } from '@feathersjs/feathers' import hashPassword from './hooks/hash-password' import protect from './hooks/protect' import { LocalStrategy } from './strategy' export const hooks = { hashPassword, protect } export { LocalStrategy } /** * Returns as property resolver that hashes a given plain text password using a Local * authentication strategy. * * @param options The authentication `service` and `strategy` name * @returns */ export const passwordHash = (options: { service?: string; strategy: string }) => async >(value: string | undefined, _data: any, context: H) => { if (value === undefined) { return value } const { app, params } = context const authService = app.defaultAuthentication(options.service) const localStrategy = authService.getStrategy(options.strategy) as LocalStrategy return localStrategy.hashPassword(value, params) } ================================================ FILE: packages/authentication-local/src/strategy.ts ================================================ /* eslint-disable @typescript-eslint/no-unused-vars */ import bcrypt from 'bcryptjs' import get from 'lodash/get' import { NotAuthenticated } from '@feathersjs/errors' import { Query, Params } from '@feathersjs/feathers' import { AuthenticationRequest, AuthenticationBaseStrategy } from '@feathersjs/authentication' import { createDebug } from '@feathersjs/commons' const debug = createDebug('@feathersjs/authentication-local/strategy') export class LocalStrategy extends AuthenticationBaseStrategy { verifyConfiguration() { const config = this.configuration ;['usernameField', 'passwordField'].forEach((prop) => { if (typeof config[prop] !== 'string') { throw new Error(`'${this.name}' authentication strategy requires a '${prop}' setting`) } }) } get configuration() { const authConfig = this.authentication.configuration const config = super.configuration || {} return { hashSize: 10, service: authConfig.service, entity: authConfig.entity, entityId: authConfig.entityId, errorMessage: 'Invalid login', entityPasswordField: config.passwordField, entityUsernameField: config.usernameField, ...config } } async getEntityQuery(query: Query, _params: Params) { return { $limit: 1, ...query } } async findEntity(username: string, params: Params) { const { entityUsernameField, errorMessage } = this.configuration if (!username) { // don't query for users without any condition set. throw new NotAuthenticated(errorMessage) } const query = await this.getEntityQuery( { [entityUsernameField]: username }, params ) const findParams = Object.assign({}, params, { query }) const entityService = this.entityService debug('Finding entity with query', params.query) const result = await entityService.find(findParams) const list = Array.isArray(result) ? result : result.data if (!Array.isArray(list) || list.length === 0) { debug('No entity found') throw new NotAuthenticated(errorMessage) } const [entity] = list return entity } async getEntity(result: any, params: Params) { const entityService = this.entityService const { entityId = (entityService as any).id, entity } = this.configuration if (!entityId || result[entityId] === undefined) { throw new NotAuthenticated('Could not get local entity') } if (!params.provider) { return result } return entityService.get(result[entityId], { ...params, [entity]: result }) } async comparePassword(entity: any, password: string) { const { entityPasswordField, errorMessage } = this.configuration // find password in entity, this allows for dot notation const hash = get(entity, entityPasswordField) if (!hash) { debug(`Record is missing the '${entityPasswordField}' password field`) throw new NotAuthenticated(errorMessage) } debug('Verifying password') const result = await bcrypt.compare(password, hash) if (result) { return entity } throw new NotAuthenticated(errorMessage) } async hashPassword(password: string, _params: Params) { return bcrypt.hash(password, this.configuration.hashSize) } async authenticate(data: AuthenticationRequest, params: Params) { const { passwordField, usernameField, entity, errorMessage } = this.configuration const username = get(data, usernameField) const password = get(data, passwordField) if (!password) { // exit early if there is no password throw new NotAuthenticated(errorMessage) } const { provider, ...paramsWithoutProvider } = params const result = await this.findEntity(username, paramsWithoutProvider) await this.comparePassword(result, password) return { authentication: { strategy: this.name }, [entity]: await this.getEntity(result, params) } } } ================================================ FILE: packages/authentication-local/test/fixture.ts ================================================ import { feathers } from '@feathersjs/feathers' import { memory, MemoryService } from '@feathersjs/memory' import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication' import { LocalStrategy, hooks } from '../src' const { hashPassword, protect } = hooks export type ServiceTypes = { authentication: AuthenticationService users: MemoryService } export function createApplication( app = feathers(), authOptionOverrides: Record = {} ) { const authentication = new AuthenticationService(app) const authConfig = { entity: 'user', service: 'users', secret: 'supersecret', authStrategies: ['local', 'jwt'], parseStrategies: ['jwt'], local: { usernameField: 'email', passwordField: 'password' }, ...authOptionOverrides } app.set('authentication', authConfig) authentication.register('jwt', new JWTStrategy()) authentication.register('local', new LocalStrategy()) app.use('authentication', authentication) app.use( 'users', memory({ multi: ['create'], paginate: { default: 10, max: 20 } }) ) app.service('users').hooks([protect(authConfig.local.passwordField)]) app.service('users').hooks({ create: [hashPassword(authConfig.local.passwordField)], get: [ async (context, next) => { await next() if (context.params.provider) { context.result.fromGet = true } } ] }) return app } ================================================ FILE: packages/authentication-local/test/hooks/hash-password.test.ts ================================================ /* eslint-disable @typescript-eslint/ban-ts-comment */ import assert from 'assert' import { Application } from '@feathersjs/feathers' import { hooks } from '../../src' import { createApplication, ServiceTypes } from '../fixture' const { hashPassword } = hooks describe('@feathersjs/authentication-local/hooks/hash-password', () => { let app: Application beforeEach(() => { app = createApplication() }) it('throws error when no field provided', () => { try { // @ts-ignore hashPassword() assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'The hashPassword hook requires a field name option') } }) it('errors when authentication service does not exist', async () => { delete app.services.authentication try { await app.service('users').create({ email: 'dave@hashpassword.com', password: 'supersecret' }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'Could not find an authentication service to hash password') } }) it('errors when authentication strategy does not exist', async () => { delete app.services.authentication.strategies.local try { await app.service('users').create({ email: 'dave@hashpassword.com', password: 'supersecret' }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, "Could not find 'local' strategy to hash password") } }) it('hashes password on field', async () => { const password = 'supersecret' const user = await app.service('users').create({ email: 'dave@hashpassword.com', password }) assert.notStrictEqual(user.password, password) }) it('hashes password on array data', async () => { const password = 'supersecret' const users = await app.service('users').create([ { email: 'dave@hashpassword.com', password }, { email: 'dave2@hashpassword.com', password: 'secret2' } ]) assert.notStrictEqual(users[0].password, password) assert.notStrictEqual(users[1].password, 'secret2') }) it('does nothing when field is not present', async () => { const user = await app.service('users').create({ email: 'dave@hashpassword.com' }) assert.strictEqual(user.password, undefined) }) }) ================================================ FILE: packages/authentication-local/test/hooks/protect.test.ts ================================================ import assert from 'assert' import { HookContext } from '@feathersjs/feathers' import { hooks } from '../../src' const { protect } = hooks function testOmit(title: string, property: string) { describe(title, () => { const fn = protect('password') it('omits from object', async () => { const data = { email: 'test@user.com', password: 'supersecret' } const context = { [property]: data } as unknown as HookContext await fn(context) assert.deepStrictEqual(context, { [property]: data, dispatch: { email: 'test@user.com' } }) }) it('omits from nested object', async () => { const hook = protect('user.password') const data = { user: { email: 'test@user.com', password: 'supersecret' } } const context = { [property]: data } as unknown as HookContext await hook(context) assert.deepStrictEqual(context, { [property]: data, dispatch: { user: { email: 'test@user.com' } } }) }) it('handles `data` property only for find', async () => { const data = { email: 'test@user.com', password: 'supersecret', data: 'yes' } const context = { [property]: data } as unknown as HookContext await fn(context) assert.deepStrictEqual(context, { [property]: data, dispatch: { email: 'test@user.com', data: 'yes' } }) }) it('uses .toJSON (#48)', async () => { class MyUser { toJSON() { return { email: 'test@user.com', password: 'supersecret' } } } const data = new MyUser() const context = { [property]: data } as unknown as HookContext await fn(context) assert.deepStrictEqual(context, { [property]: data, dispatch: { email: 'test@user.com' } }) }) it('omits from array but only objects (#2053)', async () => { const data = [ { email: 'test1@user.com', password: 'supersecret' }, { email: 'test2@user.com', password: 'othersecret' }, ['one', 'two', 'three'], 'test' ] const context = { [property]: data } as unknown as HookContext await fn(context) assert.deepStrictEqual(context, { [property]: data, dispatch: [{ email: 'test1@user.com' }, { email: 'test2@user.com' }, ['one', 'two', 'three'], 'test'] }) }) it('omits from pagination object', async () => { const data = { total: 2, data: [ { email: 'test1@user.com', password: 'supersecret' }, { email: 'test2@user.com', password: 'othersecret' } ] } const context = { method: 'find', [property]: data } as unknown as HookContext await fn(context) assert.deepStrictEqual(context, { method: 'find', [property]: data, dispatch: { total: 2, data: [{ email: 'test1@user.com' }, { email: 'test2@user.com' }] } }) }) it('updates result if params.provider is set', async () => { const data = [ { email: 'test1@user.com', password: 'supersecret' }, { email: 'test2@user.com', password: 'othersecret' } ] const params = { provider: 'test' } const context = { [property]: data, params } as unknown as HookContext await fn(context) assert.deepStrictEqual(context, { [property]: data, params, result: [{ email: 'test1@user.com' }, { email: 'test2@user.com' }], dispatch: [{ email: 'test1@user.com' }, { email: 'test2@user.com' }] }) }) }) } describe('@feathersjs/authentication-local/hooks/protect', () => { it('does nothing when called with no result', async () => { const fn = protect() assert.deepStrictEqual(await fn({} as any), undefined) }) testOmit('with hook.result', 'result') testOmit('with hook.dispatch already set', 'dispatch') }) ================================================ FILE: packages/authentication-local/test/strategy.test.ts ================================================ import assert from 'assert' import omit from 'lodash/omit' import { Application, HookContext } from '@feathersjs/feathers' import { resolve } from '@feathersjs/schema' import { LocalStrategy, passwordHash } from '../src' import { createApplication, ServiceTypes } from './fixture' describe('@feathersjs/authentication-local/strategy', () => { const password = 'localsecret' const email = 'localtester@feathersjs.com' let app: Application let user: any beforeEach(async () => { app = createApplication() user = await app.service('users').create({ email, password }) }) it('throw error when configuration is not set', () => { const auth = app.service('authentication') try { auth.register('something', new LocalStrategy()) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual( error.message, "'something' authentication strategy requires a 'usernameField' setting" ) } }) it('fails when entity not found', async () => { const authService = app.service('authentication') try { await authService.create({ strategy: 'local', email: 'not in database', password }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'Invalid login') } }) it('getEntity', async () => { const [strategy] = app.service('authentication').getStrategies('local') as [LocalStrategy] let entity = await strategy.getEntity(user, {}) assert.deepStrictEqual(entity, user) entity = await strategy.getEntity(user, { provider: 'testing' }) assert.deepStrictEqual(entity, { ...omit(user, 'password'), fromGet: true }) try { await strategy.getEntity({}, {}) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'Could not get local entity') } }) it('strategy fails when strategy is different', async () => { const [local] = app.service('authentication').getStrategies('local') await assert.rejects( () => local.authenticate( { strategy: 'not-me', password: 'dummy', email }, {} ), { name: 'NotAuthenticated', message: 'Invalid login' } ) }) it('fails when password is wrong', async () => { const authService = app.service('authentication') try { await authService.create({ strategy: 'local', email, password: 'dummy' }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'Invalid login') } }) it('fails when password is not provided', async () => { const authService = app.service('authentication') try { await authService.create({ strategy: 'local', email }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'Invalid login') } }) it('fails when password field is not available', async () => { const userEmail = 'someuser@localtest.com' const authService = app.service('authentication') try { await app.service('users').create({ email: userEmail }) await authService.create({ strategy: 'local', password: 'dummy', email: userEmail }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotAuthenticated') assert.strictEqual(error.message, 'Invalid login') } }) it('authenticates an existing user', async () => { const authService = app.service('authentication') const authResult = await authService.create({ strategy: 'local', email, password }) const { accessToken } = authResult assert.ok(accessToken) assert.strictEqual(authResult.user.email, email) const decoded = await authService.verifyAccessToken(accessToken) assert.strictEqual(decoded.sub, `${user.id}`) }) it('returns safe result when params.provider is set, works without pagination', async () => { const authService = app.service('authentication') const authResult = await authService.create( { strategy: 'local', email, password }, { provider: 'rest', paginate: false } ) const { accessToken } = authResult assert.ok(accessToken) assert.strictEqual(authResult.user.email, email) assert.strictEqual(authResult.user.password, undefined) assert.ok(authResult.user.fromGet) const decoded = await authService.verifyAccessToken(accessToken) assert.strictEqual(decoded.sub, `${user.id}`) }) it('passwordHash property resolver', async () => { const userResolver = resolve<{ password: string }, HookContext>({ properties: { password: passwordHash({ strategy: 'local' }) } }) const resolvedData = await userResolver.resolve({ password: 'supersecret' }, { app } as HookContext) assert.notStrictEqual(resolvedData.password, 'supersecret') }) it('should allow for nested values in the usernameField', async () => { const appWithNestedFieldOverride = createApplication(undefined, { local: { usernameField: 'auth.email', passwordField: 'auth.password' } }) const nestedUser = await appWithNestedFieldOverride.service('users').create({ auth: { email, password } }) const authService = appWithNestedFieldOverride.service('authentication') const authResult = await authService.create({ strategy: 'local', auth: { email, password } }) const { accessToken } = authResult assert.ok(accessToken) assert.strictEqual(authResult.user.auth.email, email) const decoded = await authService.verifyAccessToken(accessToken) assert.strictEqual(decoded.sub, `${nestedUser.id}`) // }) }) ================================================ FILE: packages/authentication-local/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/authentication-oauth/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - **authentication-oauth:** Fix OAuth Callback Account Takeover ([#3663](https://github.com/feathersjs/feathers/issues/3663)) ([d6b0b5c](https://github.com/feathersjs/feathers/commit/d6b0b5cfbaf6f86a63662027c25616c28e54ede1)) - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) ### Bug Fixes - **oauth:** Patch open redirect and origin validation ([#3653](https://github.com/feathersjs/feathers/issues/3653)) ([ee19a0a](https://github.com/feathersjs/feathers/commit/ee19a0ae9bc2ebf23b1fe598a1f7361981b65401)) ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) ### Bug Fixes - **authentication-oauth:** Allow POST oauth callbacks ([#3497](https://github.com/feathersjs/feathers/issues/3497)) ([ffcc90b](https://github.com/feathersjs/feathers/commit/ffcc90bb95329cbb4b8f310e37024d417c216d8c)) ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) ### Bug Fixes - **oauth:** Export OAuthService type ([#3479](https://github.com/feathersjs/feathers/issues/3479)) ([e7185cd](https://github.com/feathersjs/feathers/commit/e7185cde63990a0d24a7180c63b61dbc8ef6cd5b)) - Reduce usage of lodash ([#3455](https://github.com/feathersjs/feathers/issues/3455)) ([8ce807a](https://github.com/feathersjs/feathers/commit/8ce807a5ca53ff5b8d5107a0656c6329404e6e6c)) ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) ### Bug Fixes - **authentication-oauth:** Move Grant error handling to the correct spot ([#3297](https://github.com/feathersjs/feathers/issues/3297)) ([e9c0828](https://github.com/feathersjs/feathers/commit/e9c0828937453c3f0a1bd16010089b825185eab6)) ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) ### Bug Fixes - **authentication-oauth:** Properly handle all oAuth errors ([#3284](https://github.com/feathersjs/feathers/issues/3284)) ([148a9a3](https://github.com/feathersjs/feathers/commit/148a9a319b8e29138fda82d6c03bb489a7b4a6e1)) ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) ### Bug Fixes - **authentication-oauth:** Update OAuth redirect to handle user requested redirect paths ([#3186](https://github.com/feathersjs/feathers/issues/3186)) ([3742028](https://github.com/feathersjs/feathers/commit/37420283c17bb8129c6ffdde841ce2034109cc6b)) ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - **authentication-oauth:** Use original headers in oauth flow ([#3025](https://github.com/feathersjs/feathers/issues/3025)) ([fb3d8cc](https://github.com/feathersjs/feathers/commit/fb3d8cca123d68a77b096bc92e49baa55424afe0)) - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Bug Fixes - **core:** Improve service option usage and method option typings ([#2902](https://github.com/feathersjs/feathers/issues/2902)) ([164d75c](https://github.com/feathersjs/feathers/commit/164d75c0f11139a316baa91f1762de8f8eb7da2d)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Bug Fixes - **authentication-oauth:** Fix regression with prefix handling in OAuth ([#2773](https://github.com/feathersjs/feathers/issues/2773)) ([b1844b1](https://github.com/feathersjs/feathers/commit/b1844b1f27feeb7e66920ec9e318872857711834)) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) ### Bug Fixes - **authentication-oauth:** Fix oAuth origin and error handling ([#2752](https://github.com/feathersjs/feathers/issues/2752)) ([f7e1c33](https://github.com/feathersjs/feathers/commit/f7e1c33de1b7af0672a302d2ba6e15d997f0aa83)) ### Features - Add CORS support to oAuth, Express, Koa and generated application ([#2744](https://github.com/feathersjs/feathers/issues/2744)) ([fd218f2](https://github.com/feathersjs/feathers/commit/fd218f289f8ca4c101e9938e8683e2efef6e8131)) - **authentication-oauth:** Koa and transport independent oAuth authentication ([#2737](https://github.com/feathersjs/feathers/issues/2737)) ([9231525](https://github.com/feathersjs/feathers/commit/9231525a24bb790ba9c5d940f2867a9c727691c9)) # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Bug Fixes - **authentication-oauth:** Fix bug and properly set Grant defaults ([#2659](https://github.com/feathersjs/feathers/issues/2659)) ([cb93bb9](https://github.com/feathersjs/feathers/commit/cb93bb911fd92282424da2db805cd685b7e4a45b)) ### Features - **cli:** Add typed client to a generated app ([#2669](https://github.com/feathersjs/feathers/issues/2669)) ([5b801b5](https://github.com/feathersjs/feathers/commit/5b801b5017ddc3eaa95622b539f51d605916bc86)) # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) ### Bug Fixes - **authentication-oauth:** Fix regression using incorrect callback and redirect_uri ([#2631](https://github.com/feathersjs/feathers/issues/2631)) ([43d8a08](https://github.com/feathersjs/feathers/commit/43d8a082d7e1807f8a431c44a1dbd9b04c3af0d2)) # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **authentication-oauth:** Don't send origins in Grant's config, as it will be considered another provider ([#2617](https://github.com/feathersjs/feathers/issues/2617)) ([ae3dddd](https://github.com/feathersjs/feathers/commit/ae3dddd8a654924465512d56b4651413912c6932)) - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Bug Fixes - **authentication-oauth:** Fix issue with overriding the default Grant configuration ([#2615](https://github.com/feathersjs/feathers/issues/2615)) ([b345857](https://github.com/feathersjs/feathers/commit/b3458578532f9750de2940aeb8afdc75cb0b46f2)) - **authentication-oauth:** Make oAuth authentication work with cookie-session ([#2614](https://github.com/feathersjs/feathers/issues/2614)) ([9f10bfc](https://github.com/feathersjs/feathers/commit/9f10bfc75083d5bcabea77cfb385aa3965cdf6d6)) ### Features - **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28)) # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) ### Bug Fixes - **authentication-oauth:** OAuth redirect lost sometimes due to session store race ([#2514](https://github.com/feathersjs/feathers/issues/2514)) ([#2515](https://github.com/feathersjs/feathers/issues/2515)) ([6109c44](https://github.com/feathersjs/feathers/commit/6109c44428c6b8f6bb4e089be760ea1a4ef3d01e)) # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Features - **authentication-oauth:** Allow dynamic oAuth redirect ([#2469](https://github.com/feathersjs/feathers/issues/2469)) ([b7143d4](https://github.com/feathersjs/feathers/commit/b7143d4c0fbe961e714f79512be04449b9bbd7d9)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Bug Fixes - **authentication-oauth:** Omit query from internal calls ([#2398](https://github.com/feathersjs/feathers/issues/2398)) ([04c7c83](https://github.com/feathersjs/feathers/commit/04c7c83eeaa6a7466c84b958071b468ed42f0b0f)) - **koa:** Use extended query parser for compatibility ([#2397](https://github.com/feathersjs/feathers/issues/2397)) ([b2944ba](https://github.com/feathersjs/feathers/commit/b2944bac3ec6d5ecc80dc518cd4e58093692db74)) ### Features - **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) ### Features - **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) ### Features - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) **Note:** Version bump only for package @feathersjs/authentication-oauth # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) ### Bug Fixes - **authentication-oauth:** Always end session after oAuth flows are finished ([#2087](https://github.com/feathersjs/feathers/issues/2087)) ([d219d0d](https://github.com/feathersjs/feathers/commit/d219d0d89c5e45aa289dd67cb0c8bdc05044c846)) ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) ### Bug Fixes - **typescript:** Revert add overload types for `find` service methods ([#1972](https://github.com/feathersjs/feathers/issues/1972))" ([#2025](https://github.com/feathersjs/feathers/issues/2025)) ([a9501ac](https://github.com/feathersjs/feathers/commit/a9501acb4d3ef58dfb87d62c57a9bf76569da281)) ## [4.5.6](https://github.com/feathersjs/feathers/compare/v4.5.5...v4.5.6) (2020-07-12) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) ### Bug Fixes - **authentication-oauth:** Updated typings for projects with strictNullChecks ([#1941](https://github.com/feathersjs/feathers/issues/1941)) ([be91206](https://github.com/feathersjs/feathers/commit/be91206e3dba1e65a81412b7aa636bece3ab4aa2)) - **typescript:** add overload types for `find` service methods ([#1972](https://github.com/feathersjs/feathers/issues/1972)) ([ef55af0](https://github.com/feathersjs/feathers/commit/ef55af088d05d9d36aba9d9f8d6c2c908a4f20dd)) ## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-04-29) ### Bug Fixes - **authentication-oauth:** Add getEntity method to oAuth authentication and remove provider field for other calls ([#1935](https://github.com/feathersjs/feathers/issues/1935)) ([d925c1b](https://github.com/feathersjs/feathers/commit/d925c1bd193b5c19cb23a246f04fc46d0429fc75)) ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) ### Bug Fixes - **authentication-oauth:** Allow req.feathers to be used in oAuth authentication requests ([#1886](https://github.com/feathersjs/feathers/issues/1886)) ([854c9ca](https://github.com/feathersjs/feathers/commit/854c9cac9a9a5f8f89054a90feb24ab5c4766f5f)) ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) ### Bug Fixes - **package:** update grant-profile to version 0.0.11 ([#1841](https://github.com/feathersjs/feathers/issues/1841)) ([5dcd2aa](https://github.com/feathersjs/feathers/commit/5dcd2aa3483059cc7a2546b145dd72b4705fe2fe)) ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/authentication-oauth # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) ### Features - **authentication-oauth:** Set oAuth redirect URL dynamically and pass query the service ([#1737](https://github.com/feathersjs/feathers/issues/1737)) ([0b05f0b](https://github.com/feathersjs/feathers/commit/0b05f0b58a257820fa61d695a36f36455209f6a1)) ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/authentication-oauth # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) ### Features - **authentication-oauth:** Set oAuth redirect URL dynamically ([#1608](https://github.com/feathersjs/feathers/issues/1608)) ([1293e08](https://github.com/feathersjs/feathers/commit/1293e088abbb3d23f4a44680836645a8049ceaae)) ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) ### Bug Fixes - **authentication-oauth:** Allow hash based redirects ([#1676](https://github.com/feathersjs/feathers/issues/1676)) ([ffe7cf3](https://github.com/feathersjs/feathers/commit/ffe7cf3fbb4e62d7689065cf7b61f25f602ce8cf)) ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) ### Bug Fixes - Only initialize default Express session if oAuth is actually used ([#1648](https://github.com/feathersjs/feathers/issues/1648)) ([9b9b43f](https://github.com/feathersjs/feathers/commit/9b9b43ff09af1080e4aaa537064bac37b881c9a2)) ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [4.3.5](https://github.com/feathersjs/feathers/compare/v4.3.4...v4.3.5) (2019-10-07) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) ### Bug Fixes - Small improvements in dependencies and code sturcture ([#1562](https://github.com/feathersjs/feathers/issues/1562)) ([42c13e2](https://github.com/feathersjs/feathers/commit/42c13e2)) ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) **Note:** Version bump only for package @feathersjs/authentication-oauth ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) ### Bug Fixes - Omit standard protocol ports from the default hostname ([#1543](https://github.com/feathersjs/feathers/issues/1543)) ([ef16d29](https://github.com/feathersjs/feathers/commit/ef16d29)) # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/authentication-oauth # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/authentication-oauth # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) ### Bug Fixes - Update all dependencies ([7d53a00](https://github.com/feathersjs/feathers/commit/7d53a00)) - Use WeakMap to connect socket to connection ([#1509](https://github.com/feathersjs/feathers/issues/1509)) ([64807e3](https://github.com/feathersjs/feathers/commit/64807e3)) # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) ### Bug Fixes - Add method to reliably get default authentication service ([#1470](https://github.com/feathersjs/feathers/issues/1470)) ([e542cb3](https://github.com/feathersjs/feathers/commit/e542cb3)) # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/authentication-oauth # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) **Note:** Version bump only for package @feathersjs/authentication-oauth # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) **Note:** Version bump only for package @feathersjs/authentication-oauth # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Make oAuth paths more consistent and improve authentication client ([#1377](https://github.com/feathersjs/feathers/issues/1377)) ([adb2543](https://github.com/feathersjs/feathers/commit/adb2543)) - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) ### Bug Fixes - Correctly read the oauth strategy config ([#1349](https://github.com/feathersjs/feathers/issues/1349)) ([9abf314](https://github.com/feathersjs/feathers/commit/9abf314)) ### Features - Add global disconnect event ([#1355](https://github.com/feathersjs/feathers/issues/1355)) ([85afcca](https://github.com/feathersjs/feathers/commit/85afcca)) # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) ### Bug Fixes - Always require strategy parameter in authentication ([#1327](https://github.com/feathersjs/feathers/issues/1327)) ([d4a8021](https://github.com/feathersjs/feathers/commit/d4a8021)) - Improve authentication parameter handling ([#1333](https://github.com/feathersjs/feathers/issues/1333)) ([6e77204](https://github.com/feathersjs/feathers/commit/6e77204)) - Improve oAuth option handling and usability ([#1335](https://github.com/feathersjs/feathers/issues/1335)) ([adb137d](https://github.com/feathersjs/feathers/commit/adb137d)) - Merge httpStrategies and authStrategies option ([#1308](https://github.com/feathersjs/feathers/issues/1308)) ([afa4d55](https://github.com/feathersjs/feathers/commit/afa4d55)) - Rename jwtStrategies option to authStrategies ([#1305](https://github.com/feathersjs/feathers/issues/1305)) ([4aee151](https://github.com/feathersjs/feathers/commit/4aee151)) ### Features - Change and *JWT methods to *accessToken ([#1304](https://github.com/feathersjs/feathers/issues/1304)) ([5ac826b](https://github.com/feathersjs/feathers/commit/5ac826b)) # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Features - @feathersjs/authentication-oauth ([#1299](https://github.com/feathersjs/feathers/issues/1299)) ([656bae7](https://github.com/feathersjs/feathers/commit/656bae7)) ================================================ FILE: packages/authentication-oauth/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/authentication-oauth/README.md ================================================ # @feathersjs/authentication-oauth [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/authentication-oauth.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/authentication-oauth) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > OAuth 1 and 2 authentication for Feathers. Powered by Grant. ## Installation ``` npm install @feathersjs/authentication-oauth --save ``` ## Documentation Refer to the [Feathers oAuth authentication API documentation](https://feathersjs.com/api/authentication/oauth.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/authentication-oauth/package.json ================================================ { "name": "@feathersjs/authentication-oauth", "description": "oAuth 1 and 2 authentication for Feathers. Powered by Grant.", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/authentication-oauth" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "scripts": { "start": "ts-node test/app", "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/authentication": "^5.0.42", "@feathersjs/commons": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/express": "^5.0.42", "@feathersjs/feathers": "^5.0.42", "@feathersjs/koa": "^5.0.42", "@feathersjs/schema": "^5.0.42", "cookie-session": "^2.1.1", "grant": "^5.4.24", "koa-session": "^7.0.2", "qs": "^6.15.0" }, "devDependencies": { "@feathersjs/memory": "^5.0.42", "@types/cookie-session": "^2.0.49", "@types/express": "^4.17.21", "@types/koa-session": "^6.4.5", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "@types/tough-cookie": "^4.0.5", "axios": "^1.13.6", "mocha": "^11.7.5", "shx": "^0.4.0", "tough-cookie": "^6.0.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/authentication-oauth/src/index.ts ================================================ import { Application } from '@feathersjs/feathers' import { createDebug } from '@feathersjs/commons' import { resolveDispatch } from '@feathersjs/schema' import { OAuthStrategy, OAuthProfile } from './strategy' import { redirectHook, OAuthService, OAuthCallbackService } from './service' import { getGrantConfig, authenticationServiceOptions, OauthSetupSettings } from './utils' const debug = createDebug('@feathersjs/authentication-oauth') export { OauthSetupSettings, OAuthStrategy, OAuthProfile, OAuthService } export const oauth = (settings: Partial = {}) => (app: Application) => { const authService = app.defaultAuthentication ? app.defaultAuthentication(settings.authService) : null if (!authService) { throw new Error( 'An authentication service must exist before registering @feathersjs/authentication-oauth' ) } if (!authService.configuration.oauth) { debug('No oauth configuration found in authentication configuration. Skipping oAuth setup.') return } const oauthOptions = { linkStrategy: 'jwt', ...settings } const grantConfig = getGrantConfig(authService) const serviceOptions = authenticationServiceOptions(authService, oauthOptions) const servicePath = `${grantConfig.defaults.prefix || 'oauth'}/:provider` const callbackServicePath = `${servicePath}/callback` const oauthService = new OAuthService(authService, oauthOptions) app.use(servicePath, oauthService, serviceOptions) app.use(callbackServicePath, new OAuthCallbackService(oauthService), serviceOptions) app.service(servicePath).hooks({ around: { all: [resolveDispatch(), redirectHook()] } }) app.service(callbackServicePath).hooks({ around: { all: [resolveDispatch(), redirectHook()] } }) if (typeof app.service(servicePath).publish === 'function') { app.service(servicePath).publish(() => null) } if (typeof app.service(callbackServicePath).publish === 'function') { app.service(callbackServicePath).publish(() => null) } } ================================================ FILE: packages/authentication-oauth/src/service.ts ================================================ import { createDebug } from '@feathersjs/commons' import { HookContext, NextFunction, Params } from '@feathersjs/feathers' import { FeathersError, GeneralError, NotAuthenticated } from '@feathersjs/errors' // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore import Grant from 'grant/lib/grant' import { AuthenticationService } from '@feathersjs/authentication' import { OAuthStrategy } from './strategy' import { getGrantConfig, OauthSetupSettings } from './utils' const debug = createDebug('@feathersjs/authentication-oauth/services') export type GrantResponse = { location: string session: any state: any } export type OAuthParams = Omit & { session: any state: Record route: { provider: string } } export class OAuthError extends FeathersError { constructor( message: string, data: any, public location: string ) { super(message, 'NotAuthenticated', 401, 'not-authenticated', data) } } export const redirectHook = () => async (context: HookContext, next: NextFunction) => { try { await next() const { location } = context.result debug(`oAuth redirect to ${location}`) if (location) { context.http = { ...context.http, location } } } catch (error: any) { if (error.location) { context.http = { ...context.http, location: error.location } context.result = typeof error.toJSON === 'function' ? error.toJSON() : error } else { throw error } } } export class OAuthService { grant: any constructor( public service: AuthenticationService, public settings: OauthSetupSettings ) { const config = getGrantConfig(service) this.grant = Grant({ config }) } async handler(method: string, params: OAuthParams, body?: any, override?: string): Promise { const { session, state, query, route: { provider } } = params const result: GrantResponse = await this.grant({ params: { provider, override }, state: state.grant, session: session.grant, query, method, body }) session.grant = result.session state.grant = result.state return result } async authenticate(params: OAuthParams, result: GrantResponse) { const name = params.route.provider const { linkStrategy, authService } = this.settings const { accessToken, grant, headers, query = {}, redirect } = params.session const strategy = this.service.getStrategy(name) as OAuthStrategy const authParams = { ...params, headers, authStrategies: [name], authentication: accessToken ? { strategy: linkStrategy, accessToken } : null, query, redirect } const payload = grant?.response || result?.session?.response || result?.state?.response if (!payload) { throw new NotAuthenticated( 'No valid oAuth response. You must initiate the oAuth flow from the authorize endpoint.' ) } const authentication = { strategy: name, ...payload } try { if (payload.error) { throw new GeneralError(payload.error_description || payload.error, payload) } debug(`Calling ${authService}.create authentication with strategy ${name}`) const authResult = await this.service.create(authentication, authParams) debug('Successful oAuth authentication, sending response') const location = await strategy.getRedirect(authResult, authParams) if (typeof params.session.destroy === 'function') { await params.session.destroy() } return { ...authResult, location } } catch (error: any) { const location = await strategy.getRedirect(error, authParams) const e = new OAuthError(error.message, error.data, location) if (typeof params.session.destroy === 'function') { await params.session.destroy() } e.stack = error.stack throw e } } async find(params: OAuthParams) { const { session, query, headers } = params const { feathers_token, redirect, ...restQuery } = query const handlerParams = { ...params, query: restQuery } if (feathers_token) { debug('Got feathers_token query parameter to link accounts', feathers_token) session.accessToken = feathers_token } session.redirect = redirect session.query = restQuery // Only store the referer header needed for origin validation session.headers = { referer: headers?.referer } return this.handler('GET', handlerParams, {}) } async get(override: string, params: OAuthParams) { const result = await this.handler('GET', params, {}, override) return result } async create(data: any, params: OAuthParams) { return this.handler('POST', params, data) } } export class OAuthCallbackService { constructor(public service: OAuthService) {} async find(params: OAuthParams) { const result = await this.service.handler('GET', params, {}, 'callback') return this.service.authenticate(params, result) } async create(data: any, params: OAuthParams) { const result = await this.service.handler('POST', params, data, 'callback') return this.service.authenticate(params, result) } } ================================================ FILE: packages/authentication-oauth/src/strategy.ts ================================================ import { AuthenticationRequest, AuthenticationBaseStrategy, AuthenticationResult, AuthenticationParams } from '@feathersjs/authentication' import { Params } from '@feathersjs/feathers' import { NotAuthenticated } from '@feathersjs/errors' import { createDebug, _ } from '@feathersjs/commons' import qs from 'qs' const debug = createDebug('@feathersjs/authentication-oauth/strategy') export interface OAuthProfile { id?: string | number [key: string]: any } export class OAuthStrategy extends AuthenticationBaseStrategy { get configuration() { const { entity, service, entityId, oauth } = this.authentication.configuration const config = oauth[this.name] as any return { entity, service, entityId, ...config } } get entityId(): string { const { entityService } = this return this.configuration.entityId || (entityService && (entityService as any).id) } async getEntityQuery(profile: OAuthProfile, _params: Params) { return { [`${this.name}Id`]: profile.sub || profile.id } } async getEntityData(profile: OAuthProfile, _existingEntity: any, _params: Params) { return { [`${this.name}Id`]: profile.sub || profile.id } } async getProfile(data: AuthenticationRequest, _params: Params) { return data.profile } async getCurrentEntity(params: Params) { const { authentication } = params const { entity } = this.configuration if (authentication && authentication.strategy) { debug('getCurrentEntity with authentication', authentication) const { strategy } = authentication const authResult = await this.authentication.authenticate(authentication, params, strategy) return authResult[entity] } return null } async getAllowedOrigin(params?: Params) { const { redirect, origins = this.app.get('origins') } = this.authentication.configuration.oauth if (Array.isArray(origins)) { const referer = params?.headers?.referer || origins[0] // Parse the referer to get its origin for proper comparison let refererOrigin: string try { refererOrigin = new URL(referer).origin } catch { throw new NotAuthenticated(`Invalid referer "${referer}".`) } // Compare full origins const allowedOrigin = origins.find((current) => refererOrigin.toLowerCase() === current.toLowerCase()) if (!allowedOrigin) { throw new NotAuthenticated(`Referer "${referer}" is not allowed.`) } return allowedOrigin } return redirect } async getRedirect( data: AuthenticationResult | Error, params?: AuthenticationParams ): Promise { const queryRedirect = (params && params.redirect) || '' const redirect = await this.getAllowedOrigin(params) if (!redirect) { return null } // Validate redirect parameter to prevent open redirect via URL authority injection // Only allow relative paths starting with / to prevent: // - @attacker.com -> https://target.com@attacker.com (authority injection) // - .attacker.com -> https://target.com.attacker.com (domain suffix attack) // - -attacker.com -> https://target.com-attacker.com (domain suffix attack) // - //attacker.com -> protocol-relative redirect // - \attacker.com -> backslash redirect if (queryRedirect && (!/^\//.test(queryRedirect) || /[@\\]|\/\//.test(queryRedirect))) { throw new NotAuthenticated('Invalid redirect path.') } const redirectUrl = `${redirect}${queryRedirect}` const separator = redirectUrl.endsWith('?') ? '' : redirect.indexOf('#') !== -1 ? '?' : '#' const authResult: AuthenticationResult = data const query = authResult.accessToken ? { access_token: authResult.accessToken } : { error: data.message || 'OAuth Authentication not successful' } return `${redirectUrl}${separator}${qs.stringify(query)}` } async findEntity(profile: OAuthProfile, params: Params) { const query = await this.getEntityQuery(profile, params) debug('findEntity with query', query) const result = await this.entityService.find({ ...params, query }) const [entity = null] = result.data ? result.data : result debug('findEntity returning', entity) return entity } async createEntity(profile: OAuthProfile, params: Params) { const data = await this.getEntityData(profile, null, params) debug('createEntity with data', data) return this.entityService.create(data, _.omit(params, 'query')) } async updateEntity(entity: any, profile: OAuthProfile, params: Params) { const id = entity[this.entityId] const data = await this.getEntityData(profile, entity, params) debug(`updateEntity with id ${id} and data`, data) return this.entityService.patch(id, data, _.omit(params, 'query')) } async getEntity(result: any, params: Params) { const { entityService } = this const { entityId = (entityService as any).id, entity } = this.configuration if (!entityId || result[entityId] === undefined) { throw new NotAuthenticated('Could not get oAuth entity') } if (!params.provider) { return result } return entityService.get(result[entityId], { ..._.omit(params, 'query'), [entity]: result }) } async authenticate(authentication: AuthenticationRequest, originalParams: AuthenticationParams) { const entity: string = this.configuration.entity const { provider, ...params } = originalParams const profile = await this.getProfile(authentication, params) const existingEntity = (await this.findEntity(profile, params)) || (await this.getCurrentEntity(params)) debug('authenticate with (existing) entity', existingEntity) const authEntity = !existingEntity ? await this.createEntity(profile, params) : await this.updateEntity(existingEntity, profile, params) return { authentication: { strategy: this.name }, [entity]: await this.getEntity(authEntity, originalParams) } } } ================================================ FILE: packages/authentication-oauth/src/utils.ts ================================================ import type { RequestHandler } from 'express' import type { Middleware, Application as KoaApplication } from '@feathersjs/koa' import type { ServiceOptions } from '@feathersjs/feathers' import '@feathersjs/koa' import '@feathersjs/express' import expressCookieSession from 'cookie-session' import koaCookieSession from 'koa-session' import { AuthenticationService } from '@feathersjs/authentication' import { GrantConfig } from 'grant' export interface OauthSetupSettings { linkStrategy: string authService?: string expressSession?: RequestHandler koaSession?: Middleware } export const getGrantConfig = (service: AuthenticationService): GrantConfig => { const { app, configuration: { oauth } } = service // Set up all the defaults const port = app.get('port') let host = app.get('host') let protocol = 'https' // Development environments commonly run on HTTP with an extended port if (process.env.NODE_ENV !== 'production') { protocol = 'http' if (String(port) !== '80') { host += `:${port}` } } // omit 'redirect' and 'origins' from oauth const { redirect, origins, ...oauthConfig } = oauth const grant: GrantConfig = { ...oauthConfig, defaults: { prefix: '/oauth', origin: `${protocol}://${host}`, transport: 'state', response: ['tokens', 'raw', 'profile'], ...oauthConfig.defaults } } const getUrl = (url: string) => { const { defaults } = grant return `${defaults.origin}${defaults.prefix}/${url}` } // iterate over grant object with key and value for (const [name, value] of Object.entries(grant)) { if (name !== 'defaults') { value.redirect_uri = value.redirect_uri || getUrl(`${name}/callback`) } } return grant } export const setExpressParams: RequestHandler = (req, res, next) => { req.session.destroy ||= () => { req.session = null } req.feathers = { ...req.feathers, session: req.session, state: res.locals } next() } export const setKoaParams: Middleware = async (ctx, next) => { ctx.session.destroy ||= () => { ctx.session = null } ctx.feathers = { ...ctx.feathers, session: ctx.session, state: ctx.state } as any await next() } export const authenticationServiceOptions = ( service: AuthenticationService, settings: OauthSetupSettings ): ServiceOptions => { const { secret } = service.configuration const koaApp = service.app as KoaApplication if (koaApp.context) { koaApp.keys = [secret] const { koaSession = koaCookieSession({ key: 'feathers.oauth' }, koaApp as any) } = settings return { koa: { before: [koaSession, setKoaParams] } } } const { expressSession = expressCookieSession({ name: 'feathers.oauth', keys: [secret] }) } = settings return { express: { before: [expressSession, setExpressParams] } } } ================================================ FILE: packages/authentication-oauth/test/index.test.ts ================================================ import { strict as assert } from 'assert' import { feathers } from '@feathersjs/feathers' import { oauth, OauthSetupSettings } from '../src' import { AuthenticationService } from '@feathersjs/authentication' describe('@feathersjs/authentication-oauth', () => { describe('setup', () => { it('errors when service does not exist', () => { const app = feathers() assert.throws( () => { app.configure(oauth({ authService: 'something' } as OauthSetupSettings)) }, { message: 'An authentication service must exist before registering @feathersjs/authentication-oauth' } ) }) it('does not error when service is configured', () => { const app = feathers() app.use('/authentication', new AuthenticationService(app)) app.configure(oauth()) }) }) }) ================================================ FILE: packages/authentication-oauth/test/service.test.ts ================================================ import { strict as assert } from 'assert' import axios, { AxiosResponse } from 'axios' import { CookieJar } from 'tough-cookie' import { expressFixture } from './utils/fixture' describe('@feathersjs/authentication-oauth service security', () => { const port = 9780 const req = axios.create({ withCredentials: true, maxRedirects: 0 }) let app: Awaited> const fetchErrorResponse = async ( url: string, headers?: Record ): Promise => { try { await req.get(url, { headers }) } catch (error: any) { return error.response } assert.fail('Should never get here') } before(async () => { app = await expressFixture(port, 5117) }) after(async () => { await app.teardown() }) describe('internal headers exposure via session cookie', () => { it('should not store sensitive internal headers in session cookie', async () => { const host = `http://localhost:${port}` const location = `${host}/oauth/github` // Make request with internal/sensitive headers that might be added by proxies const oauthResponse = await fetchErrorResponse(location, { 'x-forwarded-for': '10.0.0.1', 'x-internal-api-key': 'sk_live_secret123', 'x-real-ip': '192.168.1.1' }) assert.equal(oauthResponse.status, 303) // Get the session cookie const cookies = oauthResponse.headers['set-cookie'] assert.ok(cookies, 'Should have set-cookie header') // Find the oauth session cookie (express cookie-session uses 'feathers.oauth') const oauthCookie = cookies.find((c: string) => c.startsWith('feathers.oauth=')) assert.ok(oauthCookie, 'Should have feathers.oauth session cookie') // Extract the cookie value and decode it const match = oauthCookie.match(/feathers\.oauth=([^;]+)/) assert.ok(match, 'Should be able to extract cookie value') const cookieValue = decodeURIComponent(match[1]) // Cookie session uses base64 encoding const decoded = Buffer.from(cookieValue, 'base64').toString('utf-8') const sessionData = JSON.parse(decoded) // The vulnerability: all headers are stored in session.headers // This test should FAIL if headers object contains sensitive internal headers assert.ok(sessionData.headers, 'Session should have headers stored') // These assertions verify the FIX is in place - they should FAIL currently // because the vulnerable code stores ALL headers const storedHeaderKeys = Object.keys(sessionData.headers).map((k) => k.toLowerCase()) // Only 'referer' should be stored (if needed for origin validation) // Any other headers being stored is a security issue const sensitiveHeaders = [ 'x-forwarded-for', 'x-internal-api-key', 'x-real-ip', 'authorization', 'cookie' ] const exposedSensitiveHeaders = sensitiveHeaders.filter((h) => storedHeaderKeys.includes(h)) assert.deepEqual( exposedSensitiveHeaders, [], `Sensitive headers should not be stored in session cookie, but found: ${exposedSensitiveHeaders.join(', ')}` ) }) }) }) describe('Account Takeover via OAuth Callback Query Parameter Forgery', () => { const port = 9781 const req = axios.create({ withCredentials: true, maxRedirects: 0 }) let app: Awaited> const fetchResponse = async (url: string, headers?: Record): Promise => { try { return await req.get(url, { headers }) } catch (error: any) { return error.response } } before(async () => { app = await expressFixture(port, 5118) // Create an existing user to demonstrate account takeover await app.service('users').create({ email: 'admin@example.com' }) }) after(async () => { await app.teardown() }) it('should not authenticate when calling callback directly with forged query parameters', async () => { const host = `http://localhost:${port}` // Attack: directly hit the callback endpoint with a forged profile in query params // Without a valid OAuth session, Grant returns no response, so the payload // falls back to params.query which the attacker controls const attackUrl = `${host}/oauth/github/callback?profile[foo]=bar&code=fake&state=fake` const response = await fetchResponse(attackUrl) // The forged request must NOT return a valid access token. // Currently the vulnerable code falls back to params.query as the auth payload, // allowing the attacker to forge authentication and receive a JWT. const hasAccessToken = response.data?.accessToken || (response.headers.location && response.headers.location.includes('access_token')) assert.ok(!hasAccessToken, `Forged callback request should not return an access token but got one`) }) it('should not authenticate when callback is called with a targeted profile id', async () => { const host = `http://localhost:${port}` // Attack: forge a specific profile ID to target a known user const attackUrl = `${host}/oauth/github/callback?profile[id]=12345&code=fake&state=fake` const response = await fetchResponse(attackUrl) const hasAccessToken = response.data?.accessToken || (response.headers.location && response.headers.location.includes('access_token')) assert.ok( !hasAccessToken, `Forged callback request with targeted profile ID should not return an access token` ) }) }) describe('@feathersjs/authentication-oauth service', () => { const port = 9778 const req = axios.create({ withCredentials: true, maxRedirects: 0 }) const cookie = new CookieJar() let app: Awaited> const fetchErrorResponse = async (url: string): Promise => { try { await req.get(url) } catch (error: any) { return error.response } assert.fail('Should never get here') } before(async () => { app = await expressFixture(port, 5115) }) after(async () => { await app.teardown() }) it('runs through the oAuth flow', async () => { const host = `http://localhost:${port}` let location = `${host}/oauth/github` const oauthResponse = await fetchErrorResponse(location) assert.equal(oauthResponse.status, 303) oauthResponse.headers['set-cookie']?.forEach((value) => cookie.setCookie(value, host)) location = oauthResponse.data.location const providerResponse = await fetchErrorResponse(location) assert.equal(providerResponse.status, 302) location = providerResponse.headers.location const { data } = await req.get(location, { headers: { cookie: await cookie.getCookieString(host) } }) assert.ok(data.accessToken) assert.equal(data.authentication.strategy, 'github') }) }) ================================================ FILE: packages/authentication-oauth/test/strategy.test.ts ================================================ import { strict as assert } from 'assert' import { expressFixture, TestOAuthStrategy } from './utils/fixture' import { AuthenticationService } from '@feathersjs/authentication' describe('@feathersjs/authentication-oauth/strategy security', () => { let app: Awaited> let authService: AuthenticationService let strategy: TestOAuthStrategy before(async () => { app = await expressFixture(9779, 5116) authService = app.service('authentication') strategy = authService.getStrategy('github') as TestOAuthStrategy }) after(async () => { await app.teardown() }) describe('open redirect via URL authority injection', () => { beforeEach(() => { app.get('authentication').oauth.origins = ['https://target.com'] }) afterEach(() => { delete app.get('authentication').oauth.origins }) it('should reject redirect parameter containing @ character', async () => { // Attack: ?redirect=@attacker.com would result in https://target.com@attacker.com // which browsers parse as username "target.com" and host "attacker.com" await assert.rejects( () => strategy.getRedirect( { accessToken: 'testing' }, { redirect: '@attacker.com', headers: { referer: 'https://target.com/login' } } ), { name: 'NotAuthenticated' } ) }) it('should reject redirect parameter containing // for protocol-relative URLs', async () => { // Attack: ?redirect=//attacker.com would result in https://target.com//attacker.com // which some parsers might interpret as protocol-relative URL await assert.rejects( () => strategy.getRedirect( { accessToken: 'testing' }, { redirect: '//attacker.com', headers: { referer: 'https://target.com/login' } } ), { name: 'NotAuthenticated' } ) }) it('should reject redirect with backslash characters', async () => { // Some browsers treat backslash as forward slash await assert.rejects( () => strategy.getRedirect( { accessToken: 'testing' }, { redirect: '\\\\attacker.com', headers: { referer: 'https://target.com/login' } } ), { name: 'NotAuthenticated' } ) }) }) describe('open redirect via domain suffix attack', () => { beforeEach(() => { app.get('authentication').oauth.origins = ['https://target.com'] }) afterEach(() => { delete app.get('authentication').oauth.origins }) it('should reject redirect starting with dot (domain suffix attack)', async () => { // Attack: ?redirect=.attacker.com -> https://target.com.attacker.com await assert.rejects( () => strategy.getRedirect( { accessToken: 'testing' }, { redirect: '.attacker.com', headers: { referer: 'https://target.com/login' } } ), { name: 'NotAuthenticated' } ) }) it('should reject redirect starting with hyphen (domain suffix attack)', async () => { // Attack: ?redirect=-attacker.com -> https://target.com-attacker.com await assert.rejects( () => strategy.getRedirect( { accessToken: 'testing' }, { redirect: '-attacker.com', headers: { referer: 'https://target.com/login' } } ), { name: 'NotAuthenticated' } ) }) it('should reject redirect with bare domain', async () => { // Attack: ?redirect=attacker.com -> https://target.comattacker.com await assert.rejects( () => strategy.getRedirect( { accessToken: 'testing' }, { redirect: 'attacker.com', headers: { referer: 'https://target.com/login' } } ), { name: 'NotAuthenticated' } ) }) it('should allow valid relative path redirect', async () => { const redirect = await strategy.getRedirect( { accessToken: 'testing' }, { redirect: '/dashboard', headers: { referer: 'https://target.com/login' } } ) assert.equal(redirect, 'https://target.com/dashboard#access_token=testing') }) it('should allow relative path with query string', async () => { const redirect = await strategy.getRedirect( { accessToken: 'testing' }, { redirect: '/callback?state=abc', headers: { referer: 'https://target.com/login' } } ) assert.ok(redirect!.startsWith('https://target.com/callback?state=abc')) }) }) describe('origin validation bypass via startsWith', () => { beforeEach(() => { app.get('authentication').oauth.origins = ['https://target.com'] }) afterEach(() => { delete app.get('authentication').oauth.origins }) it('should reject referer from domain that shares prefix with allowed origin', async () => { // Attack: attacker registers target.com.attacker.com // startsWith('https://target.com') would incorrectly return true await assert.rejects( () => strategy.getRedirect( { accessToken: 'testing' }, { headers: { referer: 'https://target.com.attacker.com/login' } } ), { message: 'Referer "https://target.com.attacker.com/login" is not allowed.' } ) }) it('should reject referer with extra subdomain-like prefix', async () => { // Another variant: target.com-evil.attacker.com await assert.rejects( () => strategy.getRedirect( { accessToken: 'testing' }, { headers: { referer: 'https://target.com-evil.attacker.com/login' } } ), { message: 'Referer "https://target.com-evil.attacker.com/login" is not allowed.' } ) }) it('should accept exact origin match with path', async () => { // Legitimate use case should still work const redirect = await strategy.getRedirect( { accessToken: 'testing' }, { headers: { referer: 'https://target.com/some/path' } } ) assert.equal(redirect, 'https://target.com#access_token=testing') }) }) }) describe('@feathersjs/authentication-oauth/strategy', () => { let app: Awaited> let authService: AuthenticationService let strategy: TestOAuthStrategy before(async () => { app = await expressFixture(9778, 5115) authService = app.service('authentication') strategy = authService.getStrategy('github') as TestOAuthStrategy }) after(async () => { await app.teardown() }) it('initializes, has .entityId and configuration', () => { assert.ok(strategy) assert.strictEqual(strategy.entityId, 'id') assert.ok(strategy.configuration.entity) }) it('reads configuration from the oauth key', () => { const testConfigValue = Math.random() app.get('authentication').oauth.github.hello = testConfigValue assert.strictEqual(strategy.configuration.hello, testConfigValue) }) it('getRedirect', async () => { app.get('authentication').oauth.redirect = '/home' let redirect = await strategy.getRedirect({ accessToken: 'testing' }) assert.equal(redirect, '/home#access_token=testing') redirect = await strategy.getRedirect( { accessToken: 'testing' }, { redirect: '/hi-there' } ) assert.strictEqual('/home/hi-there#access_token=testing', redirect) redirect = await strategy.getRedirect( { accessToken: 'testing' }, { redirect: '/hi-there?' } ) assert.equal(redirect, '/home/hi-there?access_token=testing') redirect = await strategy.getRedirect(new Error('something went wrong')) assert.equal(redirect, '/home#error=something%20went%20wrong') redirect = await strategy.getRedirect(new Error()) assert.equal(redirect, '/home#error=OAuth%20Authentication%20not%20successful') app.get('authentication').oauth.redirect = '/home?' redirect = await strategy.getRedirect({ accessToken: 'testing' }) assert.equal(redirect, '/home?access_token=testing') delete app.get('authentication').oauth.redirect redirect = await strategy.getRedirect({ accessToken: 'testing' }) assert.equal(redirect, null) app.get('authentication').oauth.redirect = '/#dashboard' redirect = await strategy.getRedirect({ accessToken: 'testing' }) assert.equal(redirect, '/#dashboard?access_token=testing') }) it('getRedirect with referrer and allowed origins (#2430)', async () => { app.get('authentication').oauth.origins = ['https://feathersjs.com', 'https://feathers.cloud'] let redirect = await strategy.getRedirect( { accessToken: 'testing' }, { headers: { referer: 'https://feathersjs.com/somewhere' } } ) assert.equal(redirect, 'https://feathersjs.com#access_token=testing') redirect = await strategy.getRedirect({ accessToken: 'testing' }, {}) assert.equal(redirect, 'https://feathersjs.com#access_token=testing') redirect = await strategy.getRedirect( { accessToken: 'testing' }, { headers: { referer: 'HTTPS://feathers.CLOUD' } } ) assert.equal(redirect, 'https://feathers.cloud#access_token=testing') redirect = await strategy.getRedirect( { accessToken: 'testing' }, { redirect: '/home', headers: { referer: 'https://feathersjs.com/somewhere' } } ) assert.equal(redirect, 'https://feathersjs.com/home#access_token=testing') await assert.rejects( () => strategy.getRedirect( { accessToken: 'testing' }, { headers: { referer: 'https://example.com' } } ), { message: 'Referer "https://example.com" is not allowed.' } ) }) describe('authenticate', () => { it('with new user', async () => { const authResult = await strategy.authenticate( { strategy: 'test', profile: { id: 'newEntity' } }, {} ) assert.deepEqual(authResult, { authentication: { strategy: 'github' }, user: { githubId: 'newEntity', id: authResult.user.id } }) }) it('with existing user and already linked strategy', async () => { const existingUser = await app.service('users').create({ githubId: 'existingEntity', name: 'David' }) const authResult = await strategy.authenticate( { strategy: 'test', profile: { id: 'existingEntity' } }, {} ) assert.deepEqual(authResult, { authentication: { strategy: 'github' }, user: existingUser }) }) it('links user with existing authentication', async () => { const user = await app.service('users').create({ name: 'David' }) const jwt = await authService.createAccessToken( {}, { subject: `${user.id}` } ) const authResult = await strategy.authenticate( { strategy: 'test', profile: { id: 'linkedEntity' } }, { authentication: { strategy: 'jwt', accessToken: jwt } } ) assert.deepEqual(authResult, { authentication: { strategy: 'github' }, user: { id: user.id, name: user.name, githubId: 'linkedEntity' } }) }) }) }) ================================================ FILE: packages/authentication-oauth/test/utils/fixture.ts ================================================ import { Application, feathers, NextFunction } from '@feathersjs/feathers' import express, { rest, errorHandler } from '@feathersjs/express' import { memory, MemoryService } from '@feathersjs/memory' import { AuthenticationService, JWTStrategy, AuthenticationRequest, AuthenticationParams } from '@feathersjs/authentication' import { provider } from './provider' import { oauth, OAuthStrategy } from '../../src' export interface ServiceTypes { authentication: AuthenticationService users: MemoryService } export class TestOAuthStrategy extends OAuthStrategy { async authenticate(data: AuthenticationRequest, params: AuthenticationParams) { const { fromMiddleware } = params const authResult = await super.authenticate(data, params) if (fromMiddleware) { authResult.fromMiddleware = fromMiddleware } return authResult } } export const fixtureConfig = (port: number, providerInstance: Awaited>) => (app: Application) => { app.set('host', '127.0.0.1') app.set('port', port) app.set('authentication', { secret: 'supersecret', entity: 'user', service: 'users', authStrategies: ['jwt'], oauth: { github: { key: 'some-key', secret: 'a secret secret', authorize_url: providerInstance.url(`/github/authorize_url`), access_url: providerInstance.url(`/github/access_url`), dynamic: true } } }) return app } export const expressFixture = async (serverPort: number, providerPort: number) => { const providerInstance = await provider({ flow: 'oauth2', port: providerPort }) const app = express(feathers()) const auth = new AuthenticationService(app) auth.register('jwt', new JWTStrategy()) auth.register('github', new TestOAuthStrategy()) app.configure(rest()) app.configure(fixtureConfig(serverPort, providerInstance)) app.use((req, _res, next) => { req.feathers = { fromMiddleware: 'testing' } next() }) app.use('authentication', auth) app.use('users', memory()) app.configure(oauth()) app.use(errorHandler({ logger: false })) app.hooks({ teardown: [ async (_context: any, next: NextFunction) => { await providerInstance.close() await next() } ] }) app.hooks({ error: { all: [ async (context) => { console.error(context.error) } ] } }) await app.listen(serverPort) return app } ================================================ FILE: packages/authentication-oauth/test/utils/provider.ts ================================================ /* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-empty-function */ // Ported from https://github.com/simov/grant/blob/master/test/util/provider.js import http from 'http' import _url from 'url' import qs from 'qs' const buffer = (req: http.IncomingMessage, done: any) => { let data = '' req.on('data', (chunk: any) => (data += chunk)) req.on('end', () => done(/^{.*}$/.test(data) ? JSON.parse(data) : qs.parse(data))) } const _query = (req: http.IncomingMessage) => { const parsed = _url.parse(req.url as string, false) const query = qs.parse(parsed.query as any) return query } const _oauth = (req: http.IncomingMessage) => qs.parse((req.headers.authorization || '').replace('OAuth ', '').replace(/"/g, '').replace(/,/g, '&')) const sign = (...args: any[]) => args .map((arg, index) => index < 2 ? Buffer.from(JSON.stringify(arg)) .toString('base64') .replace(/=/g, '') .replace(/\+/g, '-') .replace(/\//g, '_') : arg ) .join('.') export const provider = async ({ flow, port = 5000 }: { flow: 'oauth2' | 'oauth1'; port: number }) => { const server = await (flow === 'oauth2' ? oauth2(port) : oauth1(port)) return { oauth1, oauth2, on, server, url: (path: string) => `http://localhost:${port}${path}`, close: () => new Promise((resolve) => server.close(resolve)) } } const oauth1 = (port: number) => new Promise((resolve) => { let callback: any const server = http.createServer() server.on('request', (req, res) => { const method = req.method const url = req.url as string const headers = req.headers const oauth = _oauth(req) const query = _query(req) const provider = /^\/(.*)\/.*/.exec(url) && /^\/(.*)\/.*/.exec(url)![1] if (/request_url/.test(url)) { callback = oauth.oauth_callback buffer(req, (form: any) => { if (provider === 'getpocket') { callback = form.redirect_uri } on.request({ url, headers, query, form, oauth }) provider === 'sellsy' ? res.writeHead(200, { 'content-type': 'application/json' }) : res.writeHead(200, { 'content-type': 'application/x-www-form-urlencoded' }) provider === 'getpocket' ? res.end(qs.stringify({ code: 'code' })) : provider === 'sellsy' ? res.end( 'authentification_url=https://apifeed.sellsy.com/0/login.php&oauth_token=token&oauth_token_secret=secret&oauth_callback_confirmed=true' ) : res.end(qs.stringify({ oauth_token: 'token', oauth_token_secret: 'secret' })) }) } else if (/authorize_url/.test(url)) { const location = callback + '?' + qs.stringify({ oauth_token: 'token', oauth_verifier: 'verifier' }) on.authorize({ url, headers, query }) res.writeHead(302, { location }) res.end() } else if (/access_url/.test(url)) { buffer(req, (form: any) => { on.access({ url, headers, query, form, oauth }) res.writeHead(200, { 'content-type': 'application/json' }) provider === 'getpocket' ? res.end(JSON.stringify({ access_token: 'token' })) : res.end( JSON.stringify({ oauth_token: 'token', oauth_token_secret: 'secret', user_id: provider === 'twitter' ? 'id' : undefined }) ) }) } else if (/request_error_message/.test(url)) { callback = oauth.oauth_callback buffer(req, (form: any) => { on.request({ url, headers, query, form, oauth }) res.writeHead(200, { 'content-type': 'application/x-www-form-urlencoded' }) res.end(qs.stringify({ error: { message: 'invalid' } })) }) } else if (/request_error_token/.test(url)) { callback = oauth.oauth_callback buffer(req, (form: any) => { on.request({ url, headers, query, form, oauth }) res.writeHead(200, { 'content-type': 'application/x-www-form-urlencoded' }) res.end() }) } else if (/request_error_status/.test(url)) { callback = oauth.oauth_callback buffer(req, (form: any) => { on.request({ url, headers, query, form, oauth }) res.writeHead(500, { 'content-type': 'application/x-www-form-urlencoded' }) res.end(qs.stringify({ invalid: 'request_url' })) }) } else if (/authorize_error_message/.test(url)) { const location = callback + '?' + qs.stringify({ error: { message: 'invalid' } }) on.authorize({ url, headers, query }) res.writeHead(302, { location }) res.end() } else if (/authorize_error_token/.test(url)) { const location = callback as string on.authorize({ url, headers, query }) res.writeHead(302, { location }) res.end() } else if (/access_error_status/.test(url)) { buffer(req, (form: any) => { on.access({ url, headers, query, form, oauth }) res.writeHead(500, { 'content-type': 'application/json' }) res.end(JSON.stringify({ invalid: 'access_url' })) }) } else if (/profile_url/.test(url)) { on.profile({ method, url, query, headers }) res.writeHead(200, { 'content-type': 'application/json' }) provider === 'flickr' ? res.end('callback({"user": "simov"})') : res.end(JSON.stringify({ user: 'simov' })) } }) server.listen(port, () => resolve(server)) }) const oauth2 = (port: number) => new Promise((resolve) => { const server = http.createServer() let openid: any server.on('request', (req, res) => { const method = req.method const url = req.url as string const headers = req.headers const query = _query(req) as any const provider = /^\/(.*)\/.*/.exec(url) && /^\/(.*)\/.*/.exec(url)![1] if (/authorize_url/.test(url)) { openid = (query.scope || []).includes('openid') on.authorize({ provider, method, url, headers, query }) if (query.response_mode === 'form_post') { provider === 'apple' ? res.end( qs.stringify({ code: 'code', user: { name: { firstName: 'jon', lastName: 'doe' }, email: 'jon@doe.com' } }) ) : res.end('code') return } const location = query.redirect_uri + '?' + (provider === 'intuit' ? qs.stringify({ code: 'code', realmId: '123' }) : qs.stringify({ code: 'code' })) res.writeHead(302, { location }) res.end() } else if (/access_url/.test(url)) { buffer(req, (form: any) => { on.access({ provider, method, url, headers, query, form }) res.writeHead(200, { 'content-type': 'application/json' }) provider === 'concur' ? res.end(' token refresh ') : provider === 'withings' ? res.end( JSON.stringify({ body: { access_token: 'token', refresh_token: 'refresh', expires_in: 3600 } }) ) : res.end( JSON.stringify({ access_token: 'token', refresh_token: 'refresh', expires_in: 3600, id_token: openid ? sign({ typ: 'JWT' }, { nonce: 'whatever' }, 'signature') : undefined, open_id: provider === 'tiktok' ? 'id' : undefined, uid: provider === 'weibo' ? 'id' : undefined, openid: provider === 'wechat' ? 'openid' : undefined }) ) }) } else if (/authorize_error_message/.test(url)) { on.authorize({ url, query, headers }) const location = query.redirect_uri + '?' + qs.stringify({ error: { message: 'invalid' } }) res.writeHead(302, { location }) res.end() } else if (/authorize_error_code/.test(url)) { on.authorize({ url, query, headers }) const location = query.redirect_uri as string res.writeHead(302, { location }) res.end() } else if (/authorize_error_state_mismatch/.test(url)) { on.authorize({ url, query, headers }) const location = query.redirect_uri + '?' + qs.stringify({ code: 'code', state: 'whatever' }) res.writeHead(302, { location }) res.end() } else if (/authorize_error_state_missing/.test(url)) { on.authorize({ url, query, headers }) const location = query.redirect_uri + '?' + qs.stringify({ code: 'code' }) res.writeHead(302, { location }) res.end() } else if (/access_error_nonce_mismatch/.test(url)) { buffer(req, (form: any) => { on.access({ method, url, query, headers, form }) res.writeHead(200, { 'content-type': 'application/json' }) res.end( JSON.stringify({ id_token: sign({ typ: 'JWT' }, { nonce: 'whatever' }, 'signature') }) ) }) } else if (/access_error_nonce_missing/.test(url)) { buffer(req, (form: any) => { on.access({ method, url, query, headers, form }) res.writeHead(200, { 'content-type': 'application/json' }) res.end( JSON.stringify({ id_token: sign({ typ: 'JWT' }, {}, 'signature') }) ) }) } else if (/access_error_message/.test(url)) { buffer(req, (form: any) => { on.access({ method, url, query, headers, form }) res.writeHead(200, { 'content-type': 'application/json' }) res.end(JSON.stringify({ error: { message: 'invalid' } })) }) } else if (/access_error_status/.test(url)) { buffer(req, (form: any) => { on.access({ method, url, query, headers, form }) res.writeHead(500, { 'content-type': 'application/json' }) res.end(JSON.stringify({ invalid: 'access_url' })) }) } else if (/profile_url/.test(url)) { if (method === 'POST') { buffer(req, (form: any) => { on.profile({ method, url, query, headers, form }) res.writeHead(200, { 'content-type': 'application/json' }) res.end(JSON.stringify({ id: 'test', user: 'simov' })) }) } else { on.profile({ method, url, query, headers }) res.writeHead(200, { 'content-type': 'application/json' }) res.end(JSON.stringify({ id: 'test', user: 'simov' })) } } else if (/profile_error/.test(url)) { on.profile({ method, url, query, headers }) res.writeHead(400, { 'content-type': 'application/json' }) res.end(JSON.stringify({ error: { message: 'Not Found' } })) } }) server.listen(port, () => resolve(server)) }) const on = { request: (_opts: any) => {}, authorize: (_opts: any) => {}, access: (_opts: any) => {}, profile: (_opts: any) => {} } ================================================ FILE: packages/authentication-oauth/test/utils.test.ts ================================================ import { AuthenticationService } from '@feathersjs/authentication/lib' import { feathers } from '@feathersjs/feathers/lib' import { strict as assert } from 'assert' import { getGrantConfig } from '../src/utils' describe('@feathersjs/authentication-oauth/utils', () => { it('getGrantConfig initialises Grant defaults', () => { const app = feathers<{ authentication: AuthenticationService }>() const auth = new AuthenticationService(app) app.set('host', '127.0.0.1') app.set('port', '8877') app.set('authentication', { secret: 'supersecret', entity: 'user', service: 'users', authStrategies: ['jwt'], oauth: { github: { key: 'some-key', secret: 'a secret secret', authorize_url: '/github/authorize_url', access_url: '/github/access_url', dynamic: true } } }) const { defaults } = getGrantConfig(auth) assert.deepStrictEqual(defaults, { prefix: '/oauth', origin: 'http://127.0.0.1:8877', transport: 'state', response: ['tokens', 'raw', 'profile'] }) }) it('getGrantConfig uses Grant defaults when set', () => { const app = feathers<{ authentication: AuthenticationService }>() const auth = new AuthenticationService(app) app.set('host', '127.0.0.1') app.set('port', '8877') app.set('authentication', { secret: 'supersecret', entity: 'user', service: 'users', authStrategies: ['jwt'], oauth: { defaults: { prefix: '/auth', origin: 'https://localhost:3344' }, github: { key: 'some-key', secret: 'a secret secret', authorize_url: '/github/authorize_url', access_url: '/github/access_url', dynamic: true } } }) const { defaults, github } = getGrantConfig(auth) assert.deepStrictEqual(defaults, { prefix: '/auth', origin: 'https://localhost:3344', transport: 'state', response: ['tokens', 'raw', 'profile'] }) assert.strictEqual(github?.redirect_uri, 'https://localhost:3344/auth/github/callback') }) }) ================================================ FILE: packages/authentication-oauth/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/cli/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/cli ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/cli ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/cli ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/cli ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/cli ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/cli ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/cli ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/cli ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/cli ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/cli ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/cli ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/cli ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/cli ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/cli ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/cli ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/cli ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) ### Bug Fixes - **cli:** Add JS extension to binaries ([#3398](https://github.com/feathersjs/feathers/issues/3398)) ([aaf181d](https://github.com/feathersjs/feathers/commit/aaf181d924d0cb67c7792a54197082c59109264d)) ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/cli ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) ### Bug Fixes - **cli:** Fix another ES module issue ([#3395](https://github.com/feathersjs/feathers/issues/3395)) ([8e39884](https://github.com/feathersjs/feathers/commit/8e39884a23d0e7868546dce4f7a3ee6e954c2b31)) ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/cli ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) ### Bug Fixes - **generators:** Move generators and CLI to featherscloud/pinion ([#3386](https://github.com/feathersjs/feathers/issues/3386)) ([eb87c99](https://github.com/feathersjs/feathers/commit/eb87c9922db56c5610e5b808f3ffe033c830e2b2)) ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/cli ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/cli ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/cli ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/cli ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/cli ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/cli ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/cli ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/cli ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/cli ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.2](https://github.com/feathersjs/feathers/compare/v5.0.1...v5.0.2) (2023-03-23) **Note:** Version bump only for package @feathersjs/cli ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package @feathersjs/cli # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/cli # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) ### Features - **generators:** Final tweaks to the generators ([#3060](https://github.com/feathersjs/feathers/issues/3060)) ([1bf1544](https://github.com/feathersjs/feathers/commit/1bf1544fa8deeaa44ba354fb539dc3f1fd187767)) # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/cli # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Bug Fixes - **cli:** Add unhandledRejection handler to generated index file ([#2932](https://github.com/feathersjs/feathers/issues/2932)) ([e3cedc8](https://github.com/feathersjs/feathers/commit/e3cedc8e00f52d892f21fd6a3eb4ca4fe40a903c)) - **cli:** Minor generated app improvements ([#2936](https://github.com/feathersjs/feathers/issues/2936)) ([ba1a550](https://github.com/feathersjs/feathers/commit/ba1a5500a8a5ea4ab44da44ac509e48c723d7efd)) - **cli:** Properly log validation errors in log-error hook ([54c883c](https://github.com/feathersjs/feathers/commit/54c883c2bb5c35c02b1a2081b2f17554550aa1d4)) - **cli:** Use correct package manager when installing an app ([#2973](https://github.com/feathersjs/feathers/issues/2973)) ([99c2a70](https://github.com/feathersjs/feathers/commit/99c2a70b77f0b68698a66180b69a56cb20c2ca0d)) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Bug Fixes - **cli:** mongodb connection string for node 17+ ([#2875](https://github.com/feathersjs/feathers/issues/2875)) ([7fa2012](https://github.com/feathersjs/feathers/commit/7fa2012897d8429b522fbca72211fc9be1c25f7e)) ### Features - **adapter:** Add patch data type to adapters and refactor AdapterBase usage ([#2906](https://github.com/feathersjs/feathers/issues/2906)) ([9ddc2e6](https://github.com/feathersjs/feathers/commit/9ddc2e6b028f026f939d6af68125847e5c6734b4)) - **cli:** Use separate patch schema and types ([#2916](https://github.com/feathersjs/feathers/issues/2916)) ([7088af6](https://github.com/feathersjs/feathers/commit/7088af64a539dc7f1a016d832b77b98aaaf92603)) - **docs:** CLI and application structure guide ([#2818](https://github.com/feathersjs/feathers/issues/2818)) ([142914f](https://github.com/feathersjs/feathers/commit/142914fc001a8420056dd56db992c1c4f1bd312c)) - **schema:** Split resolver options and property resolvers ([#2889](https://github.com/feathersjs/feathers/issues/2889)) ([4822c94](https://github.com/feathersjs/feathers/commit/4822c949812e5a1dceff3c62b2f9de4781b4d601)) - **schema:** Virtual property resolvers ([#2900](https://github.com/feathersjs/feathers/issues/2900)) ([7d03b57](https://github.com/feathersjs/feathers/commit/7d03b57ae2f633bdd4a368e0d5955011fbd6c329)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) ### Bug Fixes - **cli:** Fix MongoDB connection database name parsing ([#2845](https://github.com/feathersjs/feathers/issues/2845)) ([50e7463](https://github.com/feathersjs/feathers/commit/50e7463971ef95cb98358b70a721e67554d92eb5)) - **cli:** Use proper MSSQL client ([#2853](https://github.com/feathersjs/feathers/issues/2853)) ([bae5176](https://github.com/feathersjs/feathers/commit/bae5176488b46fc377e53719d20e0036e087aa16)) - **docs:** Add JavaScript web app frontend guide ([#2834](https://github.com/feathersjs/feathers/issues/2834)) ([68cf03f](https://github.com/feathersjs/feathers/commit/68cf03f092da38ccbec5e9fd42b95d00f5a0a9f2)) ### Features - **mongodb:** Add ObjectId resolvers and MongoDB option in the guide ([#2847](https://github.com/feathersjs/feathers/issues/2847)) ([c5c1fba](https://github.com/feathersjs/feathers/commit/c5c1fba5718a63412075cd3838b86b889eb0bd48)) # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) ### Bug Fixes - **cli:** Ensure code injection points are not code style dependent ([#2832](https://github.com/feathersjs/feathers/issues/2832)) ([0776e26](https://github.com/feathersjs/feathers/commit/0776e26bfe4c1df9d2786499941bd3faba1715c0)) - **cli:** Only generate authentication setup when selected ([#2823](https://github.com/feathersjs/feathers/issues/2823)) ([7d219d9](https://github.com/feathersjs/feathers/commit/7d219d9c5269267b50f3ce99a5653d645f9927c1)) - **docs:** Review transport API docs and update Express middleware setup ([#2811](https://github.com/feathersjs/feathers/issues/2811)) ([1b97f14](https://github.com/feathersjs/feathers/commit/1b97f14d474f5613482f259eeaa585c24fcfab43)) - **transports:** Add remaining middleware for generated apps to Koa and Express ([#2796](https://github.com/feathersjs/feathers/issues/2796)) ([0d5781a](https://github.com/feathersjs/feathers/commit/0d5781a5c72a0cbb2ec8211bfa099f0aefe115a2)) ### Features - **cli:** Add authentication client to generated client ([#2801](https://github.com/feathersjs/feathers/issues/2801)) ([bd59f91](https://github.com/feathersjs/feathers/commit/bd59f91b45a01c2eea0c4386e567f4de5aa6ad99)) # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) ### Features - **cli:** Generate full client test suite and improve typed client ([#2788](https://github.com/feathersjs/feathers/issues/2788)) ([57119b6](https://github.com/feathersjs/feathers/commit/57119b6bb2797f7297cf054268a248c093ecd538)) - **cli:** Improve generated schema definitions ([#2783](https://github.com/feathersjs/feathers/issues/2783)) ([474a9fd](https://github.com/feathersjs/feathers/commit/474a9fda2107e9bcf357746320a8e00cda8182b6)) # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Bug Fixes - **core:** Ensure setup and teardown can be overriden and maintain hook functionality ([#2779](https://github.com/feathersjs/feathers/issues/2779)) ([ab580cb](https://github.com/feathersjs/feathers/commit/ab580cbcaa68d19144d86798c13bf564f9d424a6)) ### Features - **cli:** Add ability to `npm init feathers` ([#2755](https://github.com/feathersjs/feathers/issues/2755)) ([d734931](https://github.com/feathersjs/feathers/commit/d734931ffd4f983a05d9e771ce0e43b696c2bc0e)) - **cli:** Improve CLI interface ([#2753](https://github.com/feathersjs/feathers/issues/2753)) ([c7e1b7e](https://github.com/feathersjs/feathers/commit/c7e1b7e80aacb84441908c3d73512d9cf7557f7e)) - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) - **schema:** Make schemas validation library independent and add TypeBox support ([#2772](https://github.com/feathersjs/feathers/issues/2772)) ([44172d9](https://github.com/feathersjs/feathers/commit/44172d99b566d11d9ceda04f1d0bf72b6d05ce76)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) ### Features - Add CORS support to oAuth, Express, Koa and generated application ([#2744](https://github.com/feathersjs/feathers/issues/2744)) ([fd218f2](https://github.com/feathersjs/feathers/commit/fd218f289f8ca4c101e9938e8683e2efef6e8131)) - **authentication-oauth:** Koa and transport independent oAuth authentication ([#2737](https://github.com/feathersjs/feathers/issues/2737)) ([9231525](https://github.com/feathersjs/feathers/commit/9231525a24bb790ba9c5d940f2867a9c727691c9)) - **cli:** Add custom environment variable support to generated application ([#2751](https://github.com/feathersjs/feathers/issues/2751)) ([c7bf80d](https://github.com/feathersjs/feathers/commit/c7bf80d82c28c190e3f0136d51af5b7de1bc4868)) - **cli:** Adding ClientService to CLI ([#2750](https://github.com/feathersjs/feathers/issues/2750)) ([1d45427](https://github.com/feathersjs/feathers/commit/1d45427988521ac028755cbe128685fcdf34f636)) # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) ### Bug Fixes - **cli:** Fix flaky authentication migration and SQL id schema types ([#2676](https://github.com/feathersjs/feathers/issues/2676)) ([04ce9a5](https://github.com/feathersjs/feathers/commit/04ce9a53f4226cd6283f9dc241876e90ddf48618)) ### Features - **cli:** Add support for Prettier ([#2684](https://github.com/feathersjs/feathers/issues/2684)) ([83aa8f9](https://github.com/feathersjs/feathers/commit/83aa8f9f212cb122d831dca8858852b0ac9b4da8)) - **cli:** Improve generated application folder structure ([#2678](https://github.com/feathersjs/feathers/issues/2678)) ([d114557](https://github.com/feathersjs/feathers/commit/d114557721e73d6302aa88c11e3726dbcbd5c92b)) # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) ### Bug Fixes - **cli:** Fix compilation folders that got mixed up ([fc4cb74](https://github.com/feathersjs/feathers/commit/fc4cb742f7f9164096d9319b13dfaaa5f54686a6)) # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) ### Bug Fixes - **cli:** Generator fixes to work with the new guide ([#2674](https://github.com/feathersjs/feathers/issues/2674)) ([b773fa5](https://github.com/feathersjs/feathers/commit/b773fa5dbd7ff450cfb2f7b93e64882592262712)) # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Features - **cli:** Add generators for new Knex SQL database adapter ([#2673](https://github.com/feathersjs/feathers/issues/2673)) ([0fb2c0f](https://github.com/feathersjs/feathers/commit/0fb2c0f629116f71184b8698c383af8cfd149688)) - **cli:** Add hook generator ([#2667](https://github.com/feathersjs/feathers/issues/2667)) ([24e4bc0](https://github.com/feathersjs/feathers/commit/24e4bc04a67fadee0e6a96a8389d788faba5c305)) - **cli:** Add support for JavaScript to the new CLI ([#2668](https://github.com/feathersjs/feathers/issues/2668)) ([ebac587](https://github.com/feathersjs/feathers/commit/ebac587f7d00dc7607c3f546352d79f79b89a5d4)) - **cli:** Add typed client to a generated app ([#2669](https://github.com/feathersjs/feathers/issues/2669)) ([5b801b5](https://github.com/feathersjs/feathers/commit/5b801b5017ddc3eaa95622b539f51d605916bc86)) - **cli:** Initial Feathers v5 CLI and Pinion generator ([#2578](https://github.com/feathersjs/feathers/issues/2578)) ([7f59ae7](https://github.com/feathersjs/feathers/commit/7f59ae7f1471895ba8a82aa4702f1a23f71b7682)) ================================================ FILE: packages/cli/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/cli/README.md ================================================ # @feathersjs/cli [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/cli.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/cli) > The command line interface for creating Feathers applications ## Installation ``` npm install @feathersjs/cli --save-dev ``` ## Usage ``` $ npx feathers help ``` ## Documentation Refer to the [Feathers CLI guide](https://feathersjs.com/guides/cli/) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/cli/bin/feathers.js ================================================ #!/usr/bin/env node 'use strict' import { program } from '../lib/index.js' program.parse() ================================================ FILE: packages/cli/package.json ================================================ { "name": "@feathersjs/cli", "description": "The command line interface for creating Feathers applications", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/index.js", "type": "module", "bin": { "feathers": "./bin/feathers.js" }, "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 14" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "lib/**", "lib/app/static/.gitignore", "bin/**", "*.d.ts", "*.js" ], "scripts": { "prepublish": "npm run compile", "compile": "shx rm -rf lib/ && tsc", "mocha": "mocha --timeout 60000 --config ../../.mocharc.json --require tsx --recursive test/**.test.ts test/**/*.test.ts", "test": "npm run compile && npm run mocha && bin/feathers.js --help" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/generators": "^5.0.42", "chalk": "^5.6.2", "commander": "^13.1.0" }, "devDependencies": { "@feathersjs/adapter-commons": "^5.0.42", "@feathersjs/authentication": "^5.0.42", "@feathersjs/authentication-client": "^5.0.42", "@feathersjs/authentication-local": "^5.0.42", "@feathersjs/authentication-oauth": "^5.0.42", "@feathersjs/configuration": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/express": "^5.0.42", "@feathersjs/feathers": "^5.0.42", "@feathersjs/knex": "^5.0.42", "@feathersjs/koa": "^5.0.42", "@feathersjs/mongodb": "^5.0.42", "@feathersjs/rest-client": "^5.0.42", "@feathersjs/schema": "^5.0.42", "@feathersjs/socketio": "^5.0.42", "@feathersjs/transport-commons": "^5.0.42", "@feathersjs/typebox": "^5.0.42", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "@types/prettier": "^2.7.3", "axios": "^1.13.6", "mocha": "^11.7.5", "shx": "^0.4.0", "ts-node": "^10.9.2", "type-fest": "^5.4.4", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/cli/src/index.ts ================================================ import chalk from 'chalk' import { Command } from 'commander' import { dirname } from 'path' import { runGenerator, getContext, FeathersBaseContext, version } from '@feathersjs/generators' import { createRequire } from 'node:module' export * from 'commander' export { chalk } const require = createRequire(import.meta.url) export const commandRunner = (name: string) => async (options: any) => { const folder = dirname(require.resolve('@feathersjs/generators')) const ctx = getContext({ ...options }) await Promise.resolve(ctx) .then(runGenerator(folder, name, 'index.js')) .catch((error) => { const { logger } = ctx.pinion logger.error(`Error: ${chalk.white(error.message)}`) }) } export const program = new Command() program .name('feathers') .description('The Feathers command line interface 🕊️') .version(version) .showHelpAfterError() const generate = program.command('generate').alias('g') generate .command('app') .description('Generate a new application') .option('--name ', 'The name of the application') .action(commandRunner('app')) generate .command('service') .description('Generate a new service') .option('--name ', 'The service name') .option('--path ', 'The path to register the service on') .option('--type ', 'The service type (knex, mongodb, custom)') .action(commandRunner('service')) generate .command('hook') .description('Generate a hook') .option('--name ', 'The name of the hook') .option('--type ', 'The hook type (around or regular)') .action(commandRunner('hook')) generate .command('connection') .description('Add a new database connection') .action(commandRunner('connection')) generate .command('authentication') .description('Add authentication to the application') .action(commandRunner('authentication')) generate.description( `Run a generator. Currently available: \n ${generate.commands .map((cmd) => `${chalk.blue(cmd.name())}: ${cmd.description()} `) .join('\n ')}` ) ================================================ FILE: packages/cli/test/cli.test.ts ================================================ import { strict } from 'assert' import { program } from '../src' describe('cli tests', () => { it('exports the program', async () => { strict.ok(program) }) }) ================================================ FILE: packages/cli/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib", "module": "ESNext", "moduleResolution": "Node" } } ================================================ FILE: packages/client/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/client ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/client ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/client ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/client ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/client ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/client ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/client ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/client ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/client ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/client ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/client ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/client ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/client ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/client ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/client ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/client ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/client ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/client ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/client ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/client ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/client ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/client ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/client ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/client ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/client ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/client ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/client ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/client ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/client ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/client ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) **Note:** Version bump only for package @feathersjs/client ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.2](https://github.com/feathersjs/feathers/compare/v5.0.1...v5.0.2) (2023-03-23) **Note:** Version bump only for package @feathersjs/client ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package @feathersjs/client # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Bug Fixes - **client:** Fix @feathersjs/client types field ([#2596](https://github.com/feathersjs/feathers/issues/2596)) ([d719f54](https://github.com/feathersjs/feathers/commit/d719f54daee63daf9ed5cc762626ca15131086de)) ### Features - **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5)) # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) ### Features - **express, koa:** make transports similar ([#2486](https://github.com/feathersjs/feathers/issues/2486)) ([26aa937](https://github.com/feathersjs/feathers/commit/26aa937c114fb8596dfefc599b1f53cead69c159)) # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/client # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Features - **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) ### Features - **koa:** KoaJS transport adapter ([#2315](https://github.com/feathersjs/feathers/issues/2315)) ([2554b57](https://github.com/feathersjs/feathers/commit/2554b57cf05731df58feeba9c12faab18e442107)) # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/client # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) ### Bug Fixes - **dependencies:** Fix transport-commons dependency and update other dependencies ([#2284](https://github.com/feathersjs/feathers/issues/2284)) ([05b03b2](https://github.com/feathersjs/feathers/commit/05b03b27b40604d956047e3021d8053c3a137616)) # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) ### Features - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### chore - **package:** Remove @feathersjs/primus packages from core ([#1919](https://github.com/feathersjs/feathers/issues/1919)) ([d20b7d5](https://github.com/feathersjs/feathers/commit/d20b7d5a70f4d3306e294696156e8aa0337c35e9)), closes [#1899](https://github.com/feathersjs/feathers/issues/1899) ### Features - **core:** use @feathers/hooks and add async type ([#1929](https://github.com/feathersjs/feathers/issues/1929)) ([a5c4756](https://github.com/feathersjs/feathers/commit/a5c47562eae8410c82fe2f6308f26f8e78b6a3e8)) ### BREAKING CHANGES - **package:** Remove primus packages to be moved into the ecosystem. # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### chore - **package:** Remove @feathersjs/primus packages from core ([#1919](https://github.com/feathersjs/feathers/issues/1919)) ([d20b7d5](https://github.com/feathersjs/feathers/commit/d20b7d5a70f4d3306e294696156e8aa0337c35e9)), closes [#1899](https://github.com/feathersjs/feathers/issues/1899) ### Features - **core:** use @feathers/hooks and add async type ([#1929](https://github.com/feathersjs/feathers/issues/1929)) ([a5c4756](https://github.com/feathersjs/feathers/commit/a5c47562eae8410c82fe2f6308f26f8e78b6a3e8)) ### BREAKING CHANGES - **package:** Remove primus packages to be moved into the ecosystem. ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) **Note:** Version bump only for package @feathersjs/client ## [4.5.10](https://github.com/feathersjs/feathers/compare/v4.5.9...v4.5.10) (2020-11-08) ### Bug Fixes - **package:** Fix clean script in non Unix environments ([#2110](https://github.com/feathersjs/feathers/issues/2110)) ([09b62c0](https://github.com/feathersjs/feathers/commit/09b62c0c7e636caf620904ba87d61f168a020f05)) ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) **Note:** Version bump only for package @feathersjs/client ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) **Note:** Version bump only for package @feathersjs/client ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) **Note:** Version bump only for package @feathersjs/client ## [4.5.6](https://github.com/feathersjs/feathers/compare/v4.5.5...v4.5.6) (2020-07-12) **Note:** Version bump only for package @feathersjs/client ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) **Note:** Version bump only for package @feathersjs/client ## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-04-29) **Note:** Version bump only for package @feathersjs/client ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) **Note:** Version bump only for package @feathersjs/client ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) **Note:** Version bump only for package @feathersjs/client ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/client # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) **Note:** Version bump only for package @feathersjs/client ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/client ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/client # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) **Note:** Version bump only for package @feathersjs/client ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) **Note:** Version bump only for package @feathersjs/client ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/client ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) **Note:** Version bump only for package @feathersjs/client ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) **Note:** Version bump only for package @feathersjs/client ## [4.3.5](https://github.com/feathersjs/feathers/compare/v4.3.4...v4.3.5) (2019-10-07) **Note:** Version bump only for package @feathersjs/client ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) **Note:** Version bump only for package @feathersjs/client ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) **Note:** Version bump only for package @feathersjs/client ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) **Note:** Version bump only for package @feathersjs/client ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) **Note:** Version bump only for package @feathersjs/client # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/client # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/client # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) **Note:** Version bump only for package @feathersjs/client # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) **Note:** Version bump only for package @feathersjs/client # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/client # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) ### Bug Fixes - Fix feathers-memory dependency that did not get updated ([9422b13](https://github.com/feathersjs/feathers/commit/9422b13)) # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) **Note:** Version bump only for package @feathersjs/client # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) ### Bug Fixes - Use `export =` in TypeScript definitions ([#1285](https://github.com/feathersjs/feathers/issues/1285)) ([12d0f4b](https://github.com/feathersjs/feathers/commit/12d0f4b)) # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) ### Bug Fixes - Improve authentication parameter handling ([#1333](https://github.com/feathersjs/feathers/issues/1333)) ([6e77204](https://github.com/feathersjs/feathers/commit/6e77204)) # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) - **chore:** Properly configure and run code linter ([#1092](https://github.com/feathersjs/feathers/issues/1092)) ([fd3fc34](https://github.com/feathersjs/feathers/commit/fd3fc34)) ### Features - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - Authentication v3 core server implementation ([#1205](https://github.com/feathersjs/feathers/issues/1205)) ([1bd7591](https://github.com/feathersjs/feathers/commit/1bd7591)) ## [3.7.8](https://github.com/feathersjs/feathers/compare/@feathersjs/client@3.7.7...@feathersjs/client@3.7.8) (2019-01-26) **Note:** Version bump only for package @feathersjs/client ## [3.7.7](https://github.com/feathersjs/feathers/compare/@feathersjs/client@3.7.6...@feathersjs/client@3.7.7) (2019-01-02) ### Bug Fixes - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) ## [3.7.6](https://github.com/feathersjs/feathers/compare/@feathersjs/client@3.7.5...@feathersjs/client@3.7.6) (2018-12-16) ### Bug Fixes - **chore:** Properly configure and run code linter ([#1092](https://github.com/feathersjs/feathers/issues/1092)) ([fd3fc34](https://github.com/feathersjs/feathers/commit/fd3fc34)) ## [3.7.5](https://github.com/feathersjs/feathers/compare/@feathersjs/client@3.7.4...@feathersjs/client@3.7.5) (2018-10-26) **Note:** Version bump only for package @feathersjs/client ## [3.7.4](https://github.com/feathersjs/feathers/compare/@feathersjs/client@3.7.3...@feathersjs/client@3.7.4) (2018-10-25) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) ## [3.7.3](https://github.com/feathersjs/feathers/compare/@feathersjs/client@3.7.2...@feathersjs/client@3.7.3) (2018-09-24) **Note:** Version bump only for package @feathersjs/client ## 3.7.2 (2018-09-21) **Note:** Version bump only for package @feathersjs/client # Change Log ## [v3.7.1](https://github.com/feathersjs/client/tree/v3.7.1) (2018-09-21) [Full Changelog](https://github.com/feathersjs/client/compare/v3.7.0...v3.7.1) ## [v3.7.0](https://github.com/feathersjs/client/tree/v3.7.0) (2018-09-18) [Full Changelog](https://github.com/feathersjs/client/compare/v3.6.0...v3.7.0) **Closed issues:** - Cannot patch multiple items [\#267](https://github.com/feathersjs/client/issues/267) **Merged pull requests:** - Update all dependencies and build to Babel 8 [\#294](https://github.com/feathersjs/client/pull/294) ([daffl](https://github.com/daffl)) - Update uglifyjs-webpack-plugin to the latest version 🚀 [\#287](https://github.com/feathersjs/client/pull/287) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.6.0](https://github.com/feathersjs/client/tree/v3.6.0) (2018-09-03) [Full Changelog](https://github.com/feathersjs/client/compare/v3.5.6...v3.6.0) **Merged pull requests:** - Update all dependencies [\#285](https://github.com/feathersjs/client/pull/285) ([daffl](https://github.com/daffl)) - Update all dependencies [\#278](https://github.com/feathersjs/client/pull/278) ([daffl](https://github.com/daffl)) - Update @feathersjs/errors to the latest version 🚀 [\#272](https://github.com/feathersjs/client/pull/272) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.5.6](https://github.com/feathersjs/client/tree/v3.5.6) (2018-08-13) [Full Changelog](https://github.com/feathersjs/client/compare/v3.5.5...v3.5.6) ## [v3.5.5](https://github.com/feathersjs/client/tree/v3.5.5) (2018-08-02) [Full Changelog](https://github.com/feathersjs/client/compare/v3.5.4...v3.5.5) **Closed issues:** - IE11: TypeError: Object doesn't support property or method 'from' [\#270](https://github.com/feathersjs/client/issues/270) **Merged pull requests:** - Update ws to the latest version 🚀 [\#269](https://github.com/feathersjs/client/pull/269) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.5.4](https://github.com/feathersjs/client/tree/v3.5.4) (2018-07-19) [Full Changelog](https://github.com/feathersjs/client/compare/v3.5.3...v3.5.4) **Merged pull requests:** - Update all dependencies to latest [\#268](https://github.com/feathersjs/client/pull/268) ([daffl](https://github.com/daffl)) ## [v3.5.3](https://github.com/feathersjs/client/tree/v3.5.3) (2018-06-28) [Full Changelog](https://github.com/feathersjs/client/compare/v3.5.2...v3.5.3) **Merged pull requests:** - Update @feathersjs/rest-client to the latest version 🚀 [\#266](https://github.com/feathersjs/client/pull/266) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.5.2](https://github.com/feathersjs/client/tree/v3.5.2) (2018-06-16) [Full Changelog](https://github.com/feathersjs/client/compare/v3.5.1...v3.5.2) **Closed issues:** - service times out when sending any request to the server, not on localhost [\#264](https://github.com/feathersjs/client/issues/264) **Merged pull requests:** - Update @feathersjs/feathers to the latest version 🚀 [\#265](https://github.com/feathersjs/client/pull/265) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update shx to the latest version 🚀 [\#263](https://github.com/feathersjs/client/pull/263) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.5.1](https://github.com/feathersjs/client/tree/v3.5.1) (2018-06-03) [Full Changelog](https://github.com/feathersjs/client/compare/v3.5.0...v3.5.1) **Closed issues:** - 'exports' is undefined [\#261](https://github.com/feathersjs/client/issues/261) - I got error from NuxtJS when I use FeathersJS client V3 [\#260](https://github.com/feathersjs/client/issues/260) **Merged pull requests:** - Update @feathersjs/feathers to the latest version 🚀 [\#262](https://github.com/feathersjs/client/pull/262) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.5.0](https://github.com/feathersjs/client/tree/v3.5.0) (2018-05-17) [Full Changelog](https://github.com/feathersjs/client/compare/v3.4.5...v3.5.0) **Merged pull requests:** - Update @feathersjs/rest-client to the latest version 🚀 [\#259](https://github.com/feathersjs/client/pull/259) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.4.5](https://github.com/feathersjs/client/tree/v3.4.5) (2018-05-04) [Full Changelog](https://github.com/feathersjs/client/compare/v3.4.4...v3.4.5) **Merged pull requests:** - Update @feathersjs/feathers to the latest version 🚀 [\#258](https://github.com/feathersjs/client/pull/258) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.4.4](https://github.com/feathersjs/client/tree/v3.4.4) (2018-03-27) [Full Changelog](https://github.com/feathersjs/client/compare/v3.4.3...v3.4.4) **Merged pull requests:** - Update @feathersjs/feathers to the latest version 🚀 [\#257](https://github.com/feathersjs/client/pull/257) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update @feathersjs/rest-client to the latest version 🚀 [\#256](https://github.com/feathersjs/client/pull/256) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.4.3](https://github.com/feathersjs/client/tree/v3.4.3) (2018-03-07) [Full Changelog](https://github.com/feathersjs/client/compare/v3.4.2...v3.4.3) **Closed issues:** - Can't capture event on client side [\#253](https://github.com/feathersjs/client/issues/253) **Merged pull requests:** - Update ws to the latest version 🚀 [\#255](https://github.com/feathersjs/client/pull/255) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update webpack to the latest version 🚀 [\#254](https://github.com/feathersjs/client/pull/254) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.4.2](https://github.com/feathersjs/client/tree/v3.4.2) (2018-02-16) [Full Changelog](https://github.com/feathersjs/client/compare/v3.4.1...v3.4.2) **Closed issues:** - Feathers client now working with HTTPS self signed certs [\#250](https://github.com/feathersjs/client/issues/250) **Merged pull requests:** - Update @feathersjs/feathers to the latest version 🚀 [\#252](https://github.com/feathersjs/client/pull/252) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update @feathersjs/errors to the latest version 🚀 [\#251](https://github.com/feathersjs/client/pull/251) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.4.1](https://github.com/feathersjs/client/tree/v3.4.1) (2018-02-10) [Full Changelog](https://github.com/feathersjs/client/compare/v3.4.0...v3.4.1) **Merged pull requests:** - Update @feathersjs/feathers to the latest version 🚀 [\#249](https://github.com/feathersjs/client/pull/249) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.4.0](https://github.com/feathersjs/client/tree/v3.4.0) (2018-02-09) [Full Changelog](https://github.com/feathersjs/client/compare/v3.3.2...v3.4.0) **Merged pull requests:** - Update @feathersjs/primus-client to the latest version 🚀 [\#248](https://github.com/feathersjs/client/pull/248) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update @feathersjs/socketio-client to the latest version 🚀 [\#247](https://github.com/feathersjs/client/pull/247) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.3.2](https://github.com/feathersjs/client/tree/v3.3.2) (2018-02-09) [Full Changelog](https://github.com/feathersjs/client/compare/v3.3.1...v3.3.2) **Merged pull requests:** - Update @feathersjs/feathers to the latest version 🚀 [\#246](https://github.com/feathersjs/client/pull/246) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - delete slack link [\#245](https://github.com/feathersjs/client/pull/245) ([vodniciarv](https://github.com/vodniciarv)) ## [v3.3.1](https://github.com/feathersjs/client/tree/v3.3.1) (2018-02-05) [Full Changelog](https://github.com/feathersjs/client/compare/v3.3.0...v3.3.1) **Merged pull requests:** - Update @feathersjs/socketio-client to the latest version 🚀 [\#244](https://github.com/feathersjs/client/pull/244) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update @feathersjs/primus-client to the latest version 🚀 [\#243](https://github.com/feathersjs/client/pull/243) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update node-fetch to the latest version 🚀 [\#242](https://github.com/feathersjs/client/pull/242) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.3.0](https://github.com/feathersjs/client/tree/v3.3.0) (2018-01-26) [Full Changelog](https://github.com/feathersjs/client/compare/v3.2.0...v3.3.0) **Merged pull requests:** - Update @feathersjs/feathers to the latest version 🚀 [\#241](https://github.com/feathersjs/client/pull/241) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.2.0](https://github.com/feathersjs/client/tree/v3.2.0) (2018-01-24) [Full Changelog](https://github.com/feathersjs/client/compare/v3.1.2...v3.2.0) **Closed issues:** - Index.d.ts has a lack of return-type annotation [\#238](https://github.com/feathersjs/client/issues/238) - feathers rest client call get but server execute find [\#237](https://github.com/feathersjs/client/issues/237) - EventEmitter memory leak detected [\#236](https://github.com/feathersjs/client/issues/236) **Merged pull requests:** - Update @feathersjs/errors to the latest version 🚀 [\#240](https://github.com/feathersjs/client/pull/240) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update mocha to the latest version 🚀 [\#239](https://github.com/feathersjs/client/pull/239) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update ws to the latest version 🚀 [\#235](https://github.com/feathersjs/client/pull/235) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update @feathersjs/feathers to the latest version 🚀 [\#234](https://github.com/feathersjs/client/pull/234) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update @feathersjs/rest-client to the latest version 🚀 [\#233](https://github.com/feathersjs/client/pull/233) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update @feathersjs/feathers to the latest version 🚀 [\#232](https://github.com/feathersjs/client/pull/232) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update @feathersjs/authentication-client to the latest version 🚀 [\#231](https://github.com/feathersjs/client/pull/231) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update @feathersjs/socketio-client to the latest version 🚀 [\#230](https://github.com/feathersjs/client/pull/230) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update @feathersjs/primus-client to the latest version 🚀 [\#229](https://github.com/feathersjs/client/pull/229) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update @feathersjs/errors to the latest version 🚀 [\#228](https://github.com/feathersjs/client/pull/228) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.1.2](https://github.com/feathersjs/client/tree/v3.1.2) (2018-01-02) [Full Changelog](https://github.com/feathersjs/client/compare/v3.1.1...v3.1.2) **Closed issues:** - Socket.io on iOS and Firefox don't work [\#225](https://github.com/feathersjs/client/issues/225) **Merged pull requests:** - Update @feathersjs/feathers to the latest version 🚀 [\#227](https://github.com/feathersjs/client/pull/227) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update semistandard to the latest version 🚀 [\#226](https://github.com/feathersjs/client/pull/226) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.1.1](https://github.com/feathersjs/client/tree/v3.1.1) (2017-12-05) [Full Changelog](https://github.com/feathersjs/client/compare/v3.1.0...v3.1.1) **Merged pull requests:** - Update @feathersjs/feathers to the latest version 🚀 [\#224](https://github.com/feathersjs/client/pull/224) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-memory to the latest version 🚀 [\#223](https://github.com/feathersjs/client/pull/223) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update @feathersjs/errors to the latest version 🚀 [\#222](https://github.com/feathersjs/client/pull/222) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update @feathersjs/errors to the latest version 🚀 [\#221](https://github.com/feathersjs/client/pull/221) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v3.1.0](https://github.com/feathersjs/client/tree/v3.1.0) (2017-11-16) [Full Changelog](https://github.com/feathersjs/client/compare/v3.0.0...v3.1.0) **Merged pull requests:** - Link client packages directly to builds and update all dependencies [\#219](https://github.com/feathersjs/client/pull/219) ([daffl](https://github.com/daffl)) - Update @feathersjs/feathers to the latest version 🚀 [\#217](https://github.com/feathersjs/client/pull/217) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update package.json [\#215](https://github.com/feathersjs/client/pull/215) ([frank-dspeed](https://github.com/frank-dspeed)) ## [v3.0.0](https://github.com/feathersjs/client/tree/v3.0.0) (2017-11-01) [Full Changelog](https://github.com/feathersjs/client/compare/v3.0.0-pre.1...v3.0.0) **Merged pull requests:** - Update dependencies for release [\#214](https://github.com/feathersjs/client/pull/214) ([daffl](https://github.com/daffl)) ## [v3.0.0-pre.1](https://github.com/feathersjs/client/tree/v3.0.0-pre.1) (2017-10-30) [Full Changelog](https://github.com/feathersjs/client/compare/v2.4.0...v3.0.0-pre.1) **Closed issues:** - help data - angularjs [\#210](https://github.com/feathersjs/client/issues/210) - npm packages are installed even if they already exist when creating a new sequelize mysql service [\#209](https://github.com/feathersjs/client/issues/209) - Do you need feathers setup on the server to use feathers on the client? [\#196](https://github.com/feathersjs/client/issues/196) - Reorganization of client-side repositories [\#137](https://github.com/feathersjs/client/issues/137) **Merged pull requests:** - Upgrade to Feathers v3 \(Buzzard\) and new builds [\#213](https://github.com/feathersjs/client/pull/213) ([daffl](https://github.com/daffl)) - Update dependencies to enable Greenkeeper 🌴 [\#212](https://github.com/feathersjs/client/pull/212) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-hooks to the latest version 🚀 [\#208](https://github.com/feathersjs/client/pull/208) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers to the latest version 🚀 [\#207](https://github.com/feathersjs/client/pull/207) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update mocha to the latest version 🚀 [\#206](https://github.com/feathersjs/client/pull/206) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - update script src deps example [\#205](https://github.com/feathersjs/client/pull/205) ([crobinson42](https://github.com/crobinson42)) - Update feathers to the latest version 🚀 [\#204](https://github.com/feathersjs/client/pull/204) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-hooks to the latest version 🚀 [\#203](https://github.com/feathersjs/client/pull/203) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-hooks to the latest version 🚀 [\#202](https://github.com/feathersjs/client/pull/202) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers to the latest version 🚀 [\#201](https://github.com/feathersjs/client/pull/201) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-hooks to the latest version 🚀 [\#200](https://github.com/feathersjs/client/pull/200) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update TypeScript definition for service.patch [\#199](https://github.com/feathersjs/client/pull/199) ([kfatehi](https://github.com/kfatehi)) - Update feathers-errors to the latest version 🚀 [\#197](https://github.com/feathersjs/client/pull/197) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v2.4.0](https://github.com/feathersjs/client/tree/v2.4.0) (2017-09-02) [Full Changelog](https://github.com/feathersjs/client/compare/v2.3.0...v2.4.0) **Closed issues:** - Feathers Authentication returning NotFound: Page not found [\#188](https://github.com/feathersjs/client/issues/188) - Typescript import build error [\#179](https://github.com/feathersjs/client/issues/179) **Merged pull requests:** - Update feathers to the latest version 🚀 [\#195](https://github.com/feathersjs/client/pull/195) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Add default export to TypeScript definition [\#194](https://github.com/feathersjs/client/pull/194) ([jonlambert](https://github.com/jonlambert)) - Update ws to the latest version 🚀 [\#193](https://github.com/feathersjs/client/pull/193) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-errors to the latest version 🚀 [\#192](https://github.com/feathersjs/client/pull/192) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-errors to the latest version 🚀 [\#191](https://github.com/feathersjs/client/pull/191) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - fix\(package\): update feathers to version 2.1.7 [\#190](https://github.com/feathersjs/client/pull/190) ([daffl](https://github.com/daffl)) - Update feathers-hooks to the latest version 🚀 [\#187](https://github.com/feathersjs/client/pull/187) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-errors to the latest version 🚀 [\#186](https://github.com/feathersjs/client/pull/186) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v2.3.0](https://github.com/feathersjs/client/tree/v2.3.0) (2017-07-04) [Full Changelog](https://github.com/feathersjs/client/compare/v2.2.0...v2.3.0) **Closed issues:** - An in-range update of socket.io-client is breaking the build 🚨 [\#181](https://github.com/feathersjs/client/issues/181) - Drop socket.io [\#177](https://github.com/feathersjs/client/issues/177) - Providing client connection metadata for service event filtering purpose [\#172](https://github.com/feathersjs/client/issues/172) - Support offline mode [\#29](https://github.com/feathersjs/client/issues/29) **Merged pull requests:** - Update feathers-rest to the latest version 🚀 [\#185](https://github.com/feathersjs/client/pull/185) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-rest to the latest version 🚀 [\#184](https://github.com/feathersjs/client/pull/184) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Remove IE edge again since it does not seem to be running on Saucelabs [\#183](https://github.com/feathersjs/client/pull/183) ([daffl](https://github.com/daffl)) - Update feathers to the latest version 🚀 [\#182](https://github.com/feathersjs/client/pull/182) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-rest to the latest version 🚀 [\#180](https://github.com/feathersjs/client/pull/180) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-errors to the latest version 🚀 [\#178](https://github.com/feathersjs/client/pull/178) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers to the latest version 🚀 [\#176](https://github.com/feathersjs/client/pull/176) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-primus to the latest version 🚀 [\#175](https://github.com/feathersjs/client/pull/175) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-socketio to the latest version 🚀 [\#173](https://github.com/feathersjs/client/pull/173) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers to the latest version 🚀 [\#171](https://github.com/feathersjs/client/pull/171) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update socket.io-client to the latest version 🚀 [\#170](https://github.com/feathersjs/client/pull/170) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-errors to the latest version 🚀 [\#169](https://github.com/feathersjs/client/pull/169) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-errors to the latest version 🚀 [\#168](https://github.com/feathersjs/client/pull/168) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update feathers-hooks to the latest version 🚀 [\#167](https://github.com/feathersjs/client/pull/167) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Add IE Edge instead of IE 9 [\#166](https://github.com/feathersjs/client/pull/166) ([daffl](https://github.com/daffl)) ## [v2.2.0](https://github.com/feathersjs/client/tree/v2.2.0) (2017-04-25) [Full Changelog](https://github.com/feathersjs/client/compare/v2.1.0...v2.2.0) **Merged pull requests:** - Update feathers-errors to the latest version 🚀 [\#165](https://github.com/feathersjs/client/pull/165) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Add feathers-errors test [\#164](https://github.com/feathersjs/client/pull/164) ([christopherjbaker](https://github.com/christopherjbaker)) - Update semistandard to the latest version 🚀 [\#163](https://github.com/feathersjs/client/pull/163) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) ## [v2.1.0](https://github.com/feathersjs/client/tree/v2.1.0) (2017-04-18) [Full Changelog](https://github.com/feathersjs/client/compare/v2.0.0...v2.1.0) **Closed issues:** - implementation of feathers client in angular-2 [\#135](https://github.com/feathersjs/client/issues/135) **Merged pull requests:** - Update feathers-hooks to the latest version 🚀 [\#162](https://github.com/feathersjs/client/pull/162) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Update dependencies to enable Greenkeeper 🌴 [\#161](https://github.com/feathersjs/client/pull/161) ([greenkeeper[bot]](https://github.com/marketplace/greenkeeper)) - Added generics to typescript definition. [\#158](https://github.com/feathersjs/client/pull/158) ([noah79](https://github.com/noah79)) ## [v2.0.0](https://github.com/feathersjs/client/tree/v2.0.0) (2017-04-11) [Full Changelog](https://github.com/feathersjs/client/compare/v2.0.0-pre.2...v2.0.0) **Closed issues:** - Bundled feathers.js - Socket Authentication with Local Strategy Always Times Out [\#155](https://github.com/feathersjs/client/issues/155) **Merged pull requests:** - Update feathers-rest to version 1.7.2 🚀 [\#160](https://github.com/feathersjs/client/pull/160) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v2.0.0-pre.2](https://github.com/feathersjs/client/tree/v2.0.0-pre.2) (2017-03-08) [Full Changelog](https://github.com/feathersjs/client/compare/v2.0.0-pre.1...v2.0.0-pre.2) **Closed issues:** - Authentication should be removed [\#136](https://github.com/feathersjs/client/issues/136) **Merged pull requests:** - Lock package.json versions [\#153](https://github.com/feathersjs/client/pull/153) ([daffl](https://github.com/daffl)) - Add feathers-errors to the client export [\#152](https://github.com/feathersjs/client/pull/152) ([daffl](https://github.com/daffl)) - Update feathers to version 2.1.1 🚀 [\#151](https://github.com/feathersjs/client/pull/151) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-socketio to version 1.5.2 🚀 [\#150](https://github.com/feathersjs/client/pull/150) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-hooks to version 1.8.1 🚀 [\#149](https://github.com/feathersjs/client/pull/149) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-rest to version 1.7.1 🚀 [\#148](https://github.com/feathersjs/client/pull/148) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-socketio to version 1.5.1 🚀 [\#147](https://github.com/feathersjs/client/pull/147) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-socketio to version 1.5.0 🚀 [\#146](https://github.com/feathersjs/client/pull/146) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-rest to version 1.7.0 🚀 [\#145](https://github.com/feathersjs/client/pull/145) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-primus to version 2.1.0 🚀 [\#144](https://github.com/feathersjs/client/pull/144) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-hooks to version 1.8.0 🚀 [\#143](https://github.com/feathersjs/client/pull/143) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers to version 2.1.0 🚀 [\#142](https://github.com/feathersjs/client/pull/142) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-socketio to version 1.4.3 🚀 [\#141](https://github.com/feathersjs/client/pull/141) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update browserify to version 14.1.0 🚀 [\#140](https://github.com/feathersjs/client/pull/140) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update ws to version 2.0.0 🚀 [\#139](https://github.com/feathersjs/client/pull/139) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v2.0.0-pre.1](https://github.com/feathersjs/client/tree/v2.0.0-pre.1) (2017-01-11) [Full Changelog](https://github.com/feathersjs/client/compare/v1.9.0...v2.0.0-pre.1) **Closed issues:** - Socket.io timeout does nothing when there is JWT token available [\#129](https://github.com/feathersjs/client/issues/129) **Merged pull requests:** - Feathers Auth Update [\#131](https://github.com/feathersjs/client/pull/131) ([flyboarder](https://github.com/flyboarder)) ## [v1.9.0](https://github.com/feathersjs/client/tree/v1.9.0) (2016-12-31) [Full Changelog](https://github.com/feathersjs/client/compare/v1.8.0...v1.9.0) **Closed issues:** - Typings don't include configure method [\#130](https://github.com/feathersjs/client/issues/130) **Merged pull requests:** - Add .configure method to TypeScript definitions [\#134](https://github.com/feathersjs/client/pull/134) ([daffl](https://github.com/daffl)) - Update feathers-rest to version 1.6.0 🚀 [\#133](https://github.com/feathersjs/client/pull/133) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-rest to version 1.5.3 🚀 [\#132](https://github.com/feathersjs/client/pull/132) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-hooks to version 1.7.1 🚀 [\#128](https://github.com/feathersjs/client/pull/128) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - socket.io-client@1.7.2 breaks build 🚨 [\#126](https://github.com/feathersjs/client/pull/126) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers to version 2.0.3 🚀 [\#125](https://github.com/feathersjs/client/pull/125) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Typings changes. [\#124](https://github.com/feathersjs/client/pull/124) ([ninachaubal](https://github.com/ninachaubal)) - Update feathers-primus to version 2.0.0 🚀 [\#123](https://github.com/feathersjs/client/pull/123) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - feathers-commons@0.8.7 breaks build 🚨 [\#122](https://github.com/feathersjs/client/pull/122) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - superagent@3.1.0 breaks build 🚨 [\#121](https://github.com/feathersjs/client/pull/121) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.8.0](https://github.com/feathersjs/client/tree/v1.8.0) (2016-11-26) [Full Changelog](https://github.com/feathersjs/client/compare/v1.7.2...v1.8.0) **Closed issues:** - How to get `hooks` `socketio` etc from `feathers` object [\#118](https://github.com/feathersjs/client/issues/118) - send back to server additional fields in 'params' besides 'query' [\#115](https://github.com/feathersjs/client/issues/115) **Merged pull requests:** - Update feathers-hooks to version 1.7.0 🚀 [\#120](https://github.com/feathersjs/client/pull/120) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Remove reference to typings/index.d.ts [\#119](https://github.com/feathersjs/client/pull/119) ([ninachaubal](https://github.com/ninachaubal)) - Update superagent to version 3.0.0 🚀 [\#116](https://github.com/feathersjs/client/pull/116) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Add TypeScript type definitions. [\#114](https://github.com/feathersjs/client/pull/114) ([ninachaubal](https://github.com/ninachaubal)) - Update feathers-memory to version 1.0.0 🚀 [\#113](https://github.com/feathersjs/client/pull/113) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-authentication to version 0.7.12 🚀 [\#112](https://github.com/feathersjs/client/pull/112) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-commons to version 0.8.0 🚀 [\#111](https://github.com/feathersjs/client/pull/111) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.7.2](https://github.com/feathersjs/client/tree/v1.7.2) (2016-11-08) [Full Changelog](https://github.com/feathersjs/client/compare/v1.7.1...v1.7.2) **Merged pull requests:** - Update feathers-rest to version 1.5.2 🚀 [\#110](https://github.com/feathersjs/client/pull/110) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-socketio to version 1.4.2 🚀 [\#109](https://github.com/feathersjs/client/pull/109) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.7.1](https://github.com/feathersjs/client/tree/v1.7.1) (2016-11-02) [Full Changelog](https://github.com/feathersjs/client/compare/v1.7.0...v1.7.1) **Closed issues:** - Bower: Version mismatch [\#104](https://github.com/feathersjs/client/issues/104) **Merged pull requests:** - Update feathers-hooks to version 1.6.1 🚀 [\#108](https://github.com/feathersjs/client/pull/108) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Make sure Bower and NPM version are in sync [\#107](https://github.com/feathersjs/client/pull/107) ([daffl](https://github.com/daffl)) ## [v1.7.0](https://github.com/feathersjs/client/tree/v1.7.0) (2016-11-02) [Full Changelog](https://github.com/feathersjs/client/compare/v1.6.2...v1.7.0) **Closed issues:** - How to access feathers-client [\#102](https://github.com/feathersjs/client/issues/102) - Set up Saucelabs [\#97](https://github.com/feathersjs/client/issues/97) **Merged pull requests:** - 👻😱 Node.js 0.10 is unmaintained 😱👻 [\#106](https://github.com/feathersjs/client/pull/106) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-hooks to version 1.6.0 🚀 [\#105](https://github.com/feathersjs/client/pull/105) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Change variable naming from "app" to "feathersClient" [\#103](https://github.com/feathersjs/client/pull/103) ([nicoknoll](https://github.com/nicoknoll)) - jshint —\> semistandard [\#101](https://github.com/feathersjs/client/pull/101) ([corymsmith](https://github.com/corymsmith)) - Cross browser testing in Saucelabs [\#100](https://github.com/feathersjs/client/pull/100) ([daffl](https://github.com/daffl)) ## [v1.6.2](https://github.com/feathersjs/client/tree/v1.6.2) (2016-10-22) [Full Changelog](https://github.com/feathersjs/client/compare/v1.6.1...v1.6.2) **Closed issues:** - Browser Support [\#96](https://github.com/feathersjs/client/issues/96) - How to destroy feathers and socketio client? [\#95](https://github.com/feathersjs/client/issues/95) - Use tests from feathers-commons [\#26](https://github.com/feathersjs/client/issues/26) **Merged pull requests:** - Update feathers-rest to version 1.5.1 🚀 [\#99](https://github.com/feathersjs/client/pull/99) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Use tests from feathers-commons [\#98](https://github.com/feathersjs/client/pull/98) ([daffl](https://github.com/daffl)) - Update feathers-authentication to version 0.7.11 🚀 [\#92](https://github.com/feathersjs/client/pull/92) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-hooks to version 1.5.8 🚀 [\#91](https://github.com/feathersjs/client/pull/91) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.6.1](https://github.com/feathersjs/client/tree/v1.6.1) (2016-09-15) [Full Changelog](https://github.com/feathersjs/client/compare/v1.6.0...v1.6.1) **Closed issues:** - documentation on how to build client [\#87](https://github.com/feathersjs/client/issues/87) **Merged pull requests:** - Update feathers to version 2.0.2 🚀 [\#90](https://github.com/feathersjs/client/pull/90) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.6.0](https://github.com/feathersjs/client/tree/v1.6.0) (2016-09-09) [Full Changelog](https://github.com/feathersjs/client/compare/v1.5.3...v1.6.0) **Closed issues:** - How to declare the app in a static way? [\#86](https://github.com/feathersjs/client/issues/86) - feathers client and requireJS [\#85](https://github.com/feathersjs/client/issues/85) - SocketIO timeout based on service [\#84](https://github.com/feathersjs/client/issues/84) **Merged pull requests:** - Update feathers-rest to version 1.5.0 🚀 [\#89](https://github.com/feathersjs/client/pull/89) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-memory to version 0.8.0 🚀 [\#88](https://github.com/feathersjs/client/pull/88) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.5.3](https://github.com/feathersjs/client/tree/v1.5.3) (2016-08-31) [Full Changelog](https://github.com/feathersjs/client/compare/v1.5.2...v1.5.3) **Closed issues:** - Use of feathers-client with es6 \(JSPM\) [\#78](https://github.com/feathersjs/client/issues/78) **Merged pull requests:** - Update feathers-authentication to version 0.7.10 🚀 [\#82](https://github.com/feathersjs/client/pull/82) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-hooks to version 1.5.7 🚀 [\#77](https://github.com/feathersjs/client/pull/77) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-rest to version 1.4.4 🚀 [\#76](https://github.com/feathersjs/client/pull/76) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-hooks to version 1.5.6 🚀 [\#75](https://github.com/feathersjs/client/pull/75) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.5.2](https://github.com/feathersjs/client/tree/v1.5.2) (2016-08-12) [Full Changelog](https://github.com/feathersjs/client/compare/v1.5.1...v1.5.2) **Closed issues:** - \[Question\] Large client-side bundle filesize when requiring feathers client [\#71](https://github.com/feathersjs/client/issues/71) **Merged pull requests:** - Update feathers-hooks to version 1.5.5 🚀 [\#73](https://github.com/feathersjs/client/pull/73) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update mocha to version 3.0.0 🚀 [\#72](https://github.com/feathersjs/client/pull/72) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.5.1](https://github.com/feathersjs/client/tree/v1.5.1) (2016-07-14) [Full Changelog](https://github.com/feathersjs/client/compare/v1.5.0...v1.5.1) **Merged pull requests:** - Update feathers-rest to version 1.4.3 🚀 [\#70](https://github.com/feathersjs/client/pull/70) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.5.0](https://github.com/feathersjs/client/tree/v1.5.0) (2016-07-05) [Full Changelog](https://github.com/feathersjs/client/compare/v1.4.1...v1.5.0) **Closed issues:** - Refresh browser [\#68](https://github.com/feathersjs/client/issues/68) ## [v1.4.1](https://github.com/feathersjs/client/tree/v1.4.1) (2016-06-27) [Full Changelog](https://github.com/feathersjs/client/compare/v1.4.0...v1.4.1) ## [v1.4.0](https://github.com/feathersjs/client/tree/v1.4.0) (2016-06-24) [Full Changelog](https://github.com/feathersjs/client/compare/v1.3.2...v1.4.0) **Closed issues:** - feathers.min.js? [\#64](https://github.com/feathersjs/client/issues/64) - Facebook login [\#62](https://github.com/feathersjs/client/issues/62) **Merged pull requests:** - Add dist/feathers.min.js [\#65](https://github.com/feathersjs/client/pull/65) ([daffl](https://github.com/daffl)) - Update feathers-authentication to version 0.7.9 🚀 [\#63](https://github.com/feathersjs/client/pull/63) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.3.2](https://github.com/feathersjs/client/tree/v1.3.2) (2016-06-09) [Full Changelog](https://github.com/feathersjs/client/compare/v1.3.1...v1.3.2) **Merged pull requests:** - Update feathers-authentication to version 0.7.8 🚀 [\#61](https://github.com/feathersjs/client/pull/61) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.3.1](https://github.com/feathersjs/client/tree/v1.3.1) (2016-06-04) [Full Changelog](https://github.com/feathersjs/client/compare/v1.3.0...v1.3.1) **Merged pull requests:** - Update feathers-rest to version 1.4.2 🚀 [\#60](https://github.com/feathersjs/client/pull/60) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.3.0](https://github.com/feathersjs/client/tree/v1.3.0) (2016-05-30) [Full Changelog](https://github.com/feathersjs/client/compare/v1.2.1...v1.3.0) **Merged pull requests:** - Update feathers-rest to version 1.4.1 🚀 [\#59](https://github.com/feathersjs/client/pull/59) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-hooks to version 1.5.4 🚀 [\#57](https://github.com/feathersjs/client/pull/57) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update superagent to version 2.0.0 🚀 [\#56](https://github.com/feathersjs/client/pull/56) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-socketio to version 1.4.1 🚀 [\#53](https://github.com/feathersjs/client/pull/53) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-primus to version 1.4.1 🚀 [\#52](https://github.com/feathersjs/client/pull/52) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.2.1](https://github.com/feathersjs/client/tree/v1.2.1) (2016-05-19) [Full Changelog](https://github.com/feathersjs/client/compare/v1.2.0...v1.2.1) **Closed issues:** - Feathers-client not return correct error object. [\#44](https://github.com/feathersjs/client/issues/44) **Merged pull requests:** - Lock versions for Greenkeeper to make a PR for every release [\#50](https://github.com/feathersjs/client/pull/50) ([daffl](https://github.com/daffl)) - Update babel-plugin-add-module-exports to version 0.2.0 🚀 [\#46](https://github.com/feathersjs/client/pull/46) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.2.0](https://github.com/feathersjs/client/tree/v1.2.0) (2016-04-29) [Full Changelog](https://github.com/feathersjs/client/compare/v1.1.0...v1.2.0) **Closed issues:** - Socket.io timeouts? [\#42](https://github.com/feathersjs/client/issues/42) - Add batch support [\#4](https://github.com/feathersjs/client/issues/4) **Merged pull requests:** - nsp@2.3.2 breaks build 🚨 [\#41](https://github.com/feathersjs/client/pull/41) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Fixing url for link in readme to feathers-authentication [\#39](https://github.com/feathersjs/client/pull/39) ([xiplias](https://github.com/xiplias)) - feathers-primus@1.3.3 breaks build 🚨 [\#38](https://github.com/feathersjs/client/pull/38) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - ws@1.1.0 breaks build 🚨 [\#36](https://github.com/feathersjs/client/pull/36) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-memory to version 0.7.0 🚀 [\#33](https://github.com/feathersjs/client/pull/33) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.1.0](https://github.com/feathersjs/client/tree/v1.1.0) (2016-04-03) [Full Changelog](https://github.com/feathersjs/client/compare/v1.0.0...v1.1.0) **Merged pull requests:** - Update all dependencies 🌴 [\#31](https://github.com/feathersjs/client/pull/31) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.0.0](https://github.com/feathersjs/client/tree/v1.0.0) (2016-03-14) [Full Changelog](https://github.com/feathersjs/client/compare/v1.0.0-pre.3...v1.0.0) **Merged pull requests:** - Use a gcc version that can build bcrypt [\#30](https://github.com/feathersjs/client/pull/30) ([daffl](https://github.com/daffl)) ## [v1.0.0-pre.3](https://github.com/feathersjs/client/tree/v1.0.0-pre.3) (2016-03-14) [Full Changelog](https://github.com/feathersjs/client/compare/v1.0.0-pre.2...v1.0.0-pre.3) ## [v1.0.0-pre.2](https://github.com/feathersjs/client/tree/v1.0.0-pre.2) (2016-03-04) [Full Changelog](https://github.com/feathersjs/client/compare/v0.5.3...v1.0.0-pre.2) **Closed issues:** - Can't get $regex to work in find function with feathers-nedb in the background [\#28](https://github.com/feathersjs/client/issues/28) - feathers.fetch is undefined [\#27](https://github.com/feathersjs/client/issues/27) - Add documentation for using in React Native [\#10](https://github.com/feathersjs/client/issues/10) ## [v0.5.3](https://github.com/feathersjs/client/tree/v0.5.3) (2016-02-12) [Full Changelog](https://github.com/feathersjs/client/compare/v1.0.0-pre.1...v0.5.3) ## [v1.0.0-pre.1](https://github.com/feathersjs/client/tree/v1.0.0-pre.1) (2016-02-11) [Full Changelog](https://github.com/feathersjs/client/compare/v0.5.2...v1.0.0-pre.1) ## [v0.5.2](https://github.com/feathersjs/client/tree/v0.5.2) (2016-02-09) [Full Changelog](https://github.com/feathersjs/client/compare/v0.5.1...v0.5.2) **Merged pull requests:** - Universal feathers [\#25](https://github.com/feathersjs/client/pull/25) ([daffl](https://github.com/daffl)) - Adding nsp check [\#24](https://github.com/feathersjs/client/pull/24) ([marshallswain](https://github.com/marshallswain)) ## [v0.5.1](https://github.com/feathersjs/client/tree/v0.5.1) (2016-01-15) [Full Changelog](https://github.com/feathersjs/client/compare/v0.5.0...v0.5.1) **Closed issues:** - REST base.js missing ${options.base} leads to broken relative url [\#21](https://github.com/feathersjs/client/issues/21) - Add hook support [\#20](https://github.com/feathersjs/client/issues/20) - $sort does not work for find\(\) [\#19](https://github.com/feathersjs/client/issues/19) **Merged pull requests:** - fix issue \#21 [\#22](https://github.com/feathersjs/client/pull/22) ([wuyuanyi135](https://github.com/wuyuanyi135)) ## [v0.5.0](https://github.com/feathersjs/client/tree/v0.5.0) (2016-01-05) [Full Changelog](https://github.com/feathersjs/client/compare/v0.4.0...v0.5.0) **Closed issues:** - how to use in typescript [\#17](https://github.com/feathersjs/client/issues/17) **Merged pull requests:** - Added fetch support [\#18](https://github.com/feathersjs/client/pull/18) ([corymsmith](https://github.com/corymsmith)) - Adding events and querystring dependencies. [\#16](https://github.com/feathersjs/client/pull/16) ([marshallswain](https://github.com/marshallswain)) ## [v0.4.0](https://github.com/feathersjs/client/tree/v0.4.0) (2015-12-11) [Full Changelog](https://github.com/feathersjs/client/compare/v0.3.3...v0.4.0) **Fixed bugs:** - Importing in ES6 is broken [\#14](https://github.com/feathersjs/client/issues/14) **Closed issues:** - .babelrc messes with react-native [\#15](https://github.com/feathersjs/client/issues/15) ## [v0.3.3](https://github.com/feathersjs/client/tree/v0.3.3) (2015-11-27) [Full Changelog](https://github.com/feathersjs/client/compare/v0.3.2...v0.3.3) **Closed issues:** - npm package is broken. [\#12](https://github.com/feathersjs/client/issues/12) **Merged pull requests:** - Fix es6 build and add Steal compatibility. [\#13](https://github.com/feathersjs/client/pull/13) ([marshallswain](https://github.com/marshallswain)) ## [v0.3.2](https://github.com/feathersjs/client/tree/v0.3.2) (2015-11-26) [Full Changelog](https://github.com/feathersjs/client/compare/v0.3.1...v0.3.2) **Closed issues:** - Update lodash [\#11](https://github.com/feathersjs/client/issues/11) ## [v0.3.1](https://github.com/feathersjs/client/tree/v0.3.1) (2015-11-26) [Full Changelog](https://github.com/feathersjs/client/compare/v0.3.0...v0.3.1) **Closed issues:** - Working with can-connect [\#8](https://github.com/feathersjs/client/issues/8) ## [v0.3.0](https://github.com/feathersjs/client/tree/v0.3.0) (2015-11-15) [Full Changelog](https://github.com/feathersjs/client/compare/v0.2.1...v0.3.0) **Closed issues:** - Use Promises [\#7](https://github.com/feathersjs/client/issues/7) **Merged pull requests:** - Migration to ES6 and using Promises [\#9](https://github.com/feathersjs/client/pull/9) ([daffl](https://github.com/daffl)) ## [v0.2.1](https://github.com/feathersjs/client/tree/v0.2.1) (2015-10-06) [Full Changelog](https://github.com/feathersjs/client/compare/v0.2.0...v0.2.1) **Merged pull requests:** - Make client depend on feathers-commons, remove arguments.js [\#6](https://github.com/feathersjs/client/pull/6) ([daffl](https://github.com/daffl)) ## [v0.2.0](https://github.com/feathersjs/client/tree/v0.2.0) (2015-07-18) [Full Changelog](https://github.com/feathersjs/client/compare/v0.1.3...v0.2.0) ## [v0.1.3](https://github.com/feathersjs/client/tree/v0.1.3) (2015-07-06) [Full Changelog](https://github.com/feathersjs/client/compare/v0.1.2...v0.1.3) **Merged pull requests:** - Fixing requires and missing deps. [\#5](https://github.com/feathersjs/client/pull/5) ([marshallswain](https://github.com/marshallswain)) ## [v0.1.2](https://github.com/feathersjs/client/tree/v0.1.2) (2015-06-22) [Full Changelog](https://github.com/feathersjs/client/compare/v0.1.1...v0.1.2) **Closed issues:** - Publish to NPM and Bower [\#1](https://github.com/feathersjs/client/issues/1) ## [v0.1.1](https://github.com/feathersjs/client/tree/v0.1.1) (2015-06-21) [Full Changelog](https://github.com/feathersjs/client/compare/v0.0.1...v0.1.1) ## [v0.0.1](https://github.com/feathersjs/client/tree/v0.0.1) (2015-06-21) [Full Changelog](https://github.com/feathersjs/client/compare/v0.1.0...v0.0.1) ## [v0.1.0](https://github.com/feathersjs/client/tree/v0.1.0) (2015-06-06) \* _This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)_ ================================================ FILE: packages/client/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2015 Feathers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/client/README.md ================================================ # @feathersjs/client [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/client.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/client) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > A client build for FeathersJS ## Installation ``` npm install @feathersjs/client --save ``` ## Documentation Refer to the [Feathers client API documentation](https://docs.feathersjs.com/api/client.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/client/core.js ================================================ module.exports = require('./dist/core'); ================================================ FILE: packages/client/package.json ================================================ { "name": "@feathersjs/client", "description": "A module that consolidates Feathers client modules for REST (jQuery, Request, Superagent) and Websocket (Socket.io, Primus) connections", "version": "5.0.42", "repository": { "type": "git", "url": "https://github.com/feathersjs/feathers.git", "directory": "packages/client" }, "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "homepage": "https://github.com/feathersjs/client", "keywords": [ "feathers", "feathers-plugin" ], "author": "Feathers contributors", "engines": { "node": ">= 12" }, "main": "dist/feathers", "types": "dist/feathers", "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "dist/**", "*.d.ts", "*.js" ], "scripts": { "compile": "tsc", "version": "npm run build", "clean": "shx rm -rf dist/ && shx mkdir -p dist", "build": "npm run clean && npm run compile && npm run webpack", "mocha": "mocha --config ../../.mocharc.json --recursive test/**/*.test.ts", "test": "npm run build && npm run mocha", "webpack": "webpack --config webpack/feathers.js && webpack --config webpack/feathers.min.js && webpack --config webpack/core.js && webpack --config webpack/core.min.js" }, "browserslist": [ "last 2 versions", "IE 11" ], "dependencies": { "@feathersjs/authentication-client": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/feathers": "^5.0.42", "@feathersjs/rest-client": "^5.0.42", "@feathersjs/socketio-client": "^5.0.42" }, "devDependencies": { "@babel/core": "^7.29.0", "@babel/preset-env": "^7.29.0", "@feathersjs/express": "^5.0.42", "@feathersjs/memory": "^5.0.42", "@feathersjs/socketio": "^5.0.42", "@feathersjs/tests": "^5.0.42", "babel-loader": "^10.0.0", "mocha": "^11.7.5", "node-fetch": "^2.6.1", "shx": "^0.4.0", "socket.io-client": "^4.8.3", "superagent": "^10.3.0", "ts-loader": "^9.5.4", "typescript": "^5.9.3", "webpack": "^5.105.4", "webpack-cli": "^6.0.1", "webpack-merge": "^6.0.1" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/client/src/core.ts ================================================ export * from '@feathersjs/feathers' ================================================ FILE: packages/client/src/feathers.ts ================================================ import { feathers } from '@feathersjs/feathers' import authentication from '@feathersjs/authentication-client' import rest from '@feathersjs/rest-client' import socketio from '@feathersjs/socketio-client' export * from '@feathersjs/feathers' export * as errors from '@feathersjs/errors' export { authentication, rest, socketio } export default feathers if (typeof module !== 'undefined') { module.exports = Object.assign(feathers, module.exports) } ================================================ FILE: packages/client/test/fetch.test.ts ================================================ /* eslint-disable @typescript-eslint/ban-ts-comment */ // @ts-ignore import fetch from 'node-fetch' import { Server } from 'http' import { clientTests } from '@feathersjs/tests' import * as feathers from '../dist/feathers' import app from './fixture' describe('fetch REST connector', function () { let server: Server const rest = feathers.rest('http://localhost:8889') const client = feathers.default().configure(rest.fetch(fetch)) before(async () => { server = await app().listen(8889) }) after(function (done) { server.close(done) }) clientTests(client, 'todos') }) ================================================ FILE: packages/client/test/fixture.ts ================================================ import { feathers, Application, HookContext, Id, Params } from '@feathersjs/feathers' import * as express from '@feathersjs/express' import { MemoryService } from '@feathersjs/memory' // eslint-disable-next-line no-extend-native Object.defineProperty(Error.prototype, 'toJSON', { value() { const alt: any = {} Object.getOwnPropertyNames(this).forEach((key: string) => { alt[key] = this[key] }) return alt }, configurable: true }) // Create an in-memory CRUD service for our Todos class TodoService extends MemoryService { async get(id: Id, params: Params) { if (params.query.error) { throw new Error('Something went wrong') } return super.get(id).then((data) => Object.assign({ query: params.query }, data)) } } export default (configurer?: (app: Application) => void) => { const app = express .default(feathers()) // Parse HTTP bodies .use(express.json()) .use(express.urlencoded({ extended: true })) // Host the current directory (for index.html) .use(express.static(process.cwd())) .configure(express.rest()) if (typeof configurer === 'function') { configurer.call(app, app) } app // Host our Todos service on the /todos path .use( '/todos', new TodoService({ multi: true }) ) .use(express.errorHandler()) const testTodo = { text: 'some todo', complete: false } const service: any = app.service('todos') service.create(testTodo) service.hooks({ after: { remove(hook: HookContext) { if (hook.id === null) { service._uId = 0 return service.create(testTodo).then(() => hook) } } } }) app.on('connection', (connection) => (app as any).channel('general').join(connection)) if (service.publish) { service.publish(() => app.channel('general')) } return app } ================================================ FILE: packages/client/test/socketio.test.ts ================================================ import { io } from 'socket.io-client' import socketio from '@feathersjs/socketio' import { Server } from 'http' import { clientTests } from '@feathersjs/tests' import * as feathers from '../dist/feathers' import app from './fixture' describe('Socket.io connector', function () { let server: Server const socket = io('http://localhost:9988') const client = feathers.default().configure(feathers.socketio(socket)) before(async () => { server = await app((app) => app.configure(socketio())).listen(9988) }) after(function (done) { socket.once('disconnect', () => { server.close() done() }) socket.disconnect() }) clientTests(client, 'todos') }) ================================================ FILE: packages/client/test/superagent.test.ts ================================================ import superagent from 'superagent' import { clientTests } from '@feathersjs/tests' import { Server } from 'http' import * as feathers from '../dist/feathers' import app from './fixture' describe('Superagent REST connector', function () { let server: Server const rest = feathers.rest('http://localhost:8889') const client = feathers.default().configure(rest.superagent(superagent)) before(async () => { server = await app().listen(8889) }) after(function (done) { server.close(done) }) clientTests(client, 'todos') }) ================================================ FILE: packages/client/tsconfig.json ================================================ { "extends": "../../tsconfig", "sourceMap": false, "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "dist/" } } ================================================ FILE: packages/client/webpack/core.js ================================================ const createConfig = require('./create-config'); module.exports = createConfig('core'); ================================================ FILE: packages/client/webpack/create-config.js ================================================ const path = require('path'); const webpack = require('webpack'); const { merge } = require('webpack-merge'); module.exports = function createConfig (output, isProduction = false) { const commons = { entry: [ `./src/${output}.ts` ], output: { library: 'feathers', libraryTarget: 'umd', globalObject: 'this', path: path.resolve(__dirname, '..', 'dist'), filename: `${output}.js` }, resolve: { extensions: [ '.tsx', '.ts', '.js' ] }, module: { rules: [{ test: /\.tsx?$/, use: 'ts-loader', exclude: /node_modules/ }, { test: /\.js/, exclude: /node_modules\/(?!(@feathersjs|debug))/, loader: 'babel-loader', options: { presets: ['@babel/preset-env'] // plugins: ['@babel/plugin-transform-classes'] } }] } }; const dev = { mode: 'development', devtool: 'source-map' }; const production = { mode: 'production', output: { filename: `${output}.min.js` }, plugins: [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }) ] }; return merge(commons, isProduction ? production : dev); } ================================================ FILE: packages/client/webpack/feathers.js ================================================ const createConfig = require('./create-config'); module.exports = createConfig('feathers'); ================================================ FILE: packages/commons/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/commons ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/commons ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/commons ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/commons ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/commons ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/commons ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/commons ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/commons ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/commons ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/commons ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/commons ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/commons ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/commons ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/commons ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/commons ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/commons ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/commons ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/commons ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/commons ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/commons ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/commons ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/commons ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/commons ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/commons ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/commons ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/commons ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/commons ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/commons ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/commons ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/commons ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) ### Bug Fixes - **core:** Use Symbol.for to instantiate shared symbols ([#3087](https://github.com/feathersjs/feathers/issues/3087)) ([7f3fc21](https://github.com/feathersjs/feathers/commit/7f3fc2167576f228f8183568eb52b077160e8d65)) # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) ### Features - **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) **Note:** Version bump only for package @feathersjs/commons # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### Features - **core:** Migrate @feathersjs/feathers to TypeScript ([#1963](https://github.com/feathersjs/feathers/issues/1963)) ([7812529](https://github.com/feathersjs/feathers/commit/7812529ff0f1008e21211f1d01efbc49795dbe55)) - **core:** use @feathers/hooks and add async type ([#1929](https://github.com/feathersjs/feathers/issues/1929)) ([a5c4756](https://github.com/feathersjs/feathers/commit/a5c47562eae8410c82fe2f6308f26f8e78b6a3e8)) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### Features - **core:** Migrate @feathersjs/feathers to TypeScript ([#1963](https://github.com/feathersjs/feathers/issues/1963)) ([7812529](https://github.com/feathersjs/feathers/commit/7812529ff0f1008e21211f1d01efbc49795dbe55)) - **core:** use @feathers/hooks and add async type ([#1929](https://github.com/feathersjs/feathers/issues/1929)) ([a5c4756](https://github.com/feathersjs/feathers/commit/a5c47562eae8410c82fe2f6308f26f8e78b6a3e8)) ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) **Note:** Version bump only for package @feathersjs/commons ## [4.5.10](https://github.com/feathersjs/feathers/compare/v4.5.9...v4.5.10) (2020-11-08) **Note:** Version bump only for package @feathersjs/commons ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) **Note:** Version bump only for package @feathersjs/commons ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) **Note:** Version bump only for package @feathersjs/commons ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) **Note:** Version bump only for package @feathersjs/commons ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) **Note:** Version bump only for package @feathersjs/commons ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) **Note:** Version bump only for package @feathersjs/commons ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) **Note:** Version bump only for package @feathersjs/commons ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/commons # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) **Note:** Version bump only for package @feathersjs/commons ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/commons ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/commons ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) ### Bug Fixes - make \_\_hooks writable and configurable ([#1520](https://github.com/feathersjs/feathers/issues/1520)) ([1c6c374](https://github.com/feathersjs/feathers/commit/1c6c3742ecf1cb813be56074da89e6736d03ffe8)) # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/commons # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/commons # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) ### Bug Fixes - Update all dependencies ([7d53a00](https://github.com/feathersjs/feathers/commit/7d53a00)) # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) **Note:** Version bump only for package @feathersjs/commons # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/commons # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) **Note:** Version bump only for package @feathersjs/commons # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) **Note:** Version bump only for package @feathersjs/commons # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) - use minimal RegExp matching for better performance ([#977](https://github.com/feathersjs/feathers/issues/977)) ([3ca7e97](https://github.com/feathersjs/feathers/commit/3ca7e97)) ### Features - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - Common database adapter utilities and test suite ([#1130](https://github.com/feathersjs/feathers/issues/1130)) ([17b3dc8](https://github.com/feathersjs/feathers/commit/17b3dc8)) - Remove (hook, next) signature and SKIP support ([#1269](https://github.com/feathersjs/feathers/issues/1269)) ([211c0f8](https://github.com/feathersjs/feathers/commit/211c0f8)) ### BREAKING CHANGES - Move database adapter utilities from @feathersjs/commons into its own module # [4.0.0](https://github.com/feathersjs/feathers/compare/@feathersjs/commons@3.0.1...@feathersjs/commons@4.0.0) (2018-12-16) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) ### Features - Common database adapter utilities and test suite ([#1130](https://github.com/feathersjs/feathers/issues/1130)) ([17b3dc8](https://github.com/feathersjs/feathers/commit/17b3dc8)) ### BREAKING CHANGES - Move database adapter utilities from @feathersjs/commons into its own module ## [3.0.1](https://github.com/feathersjs/feathers/compare/@feathersjs/commons@3.0.0...@feathersjs/commons@3.0.1) (2018-09-17) ### Bug Fixes - use minimal RegExp matching for better performance ([#977](https://github.com/feathersjs/feathers/issues/977)) ([3ca7e97](https://github.com/feathersjs/feathers/commit/3ca7e97)) # Change Log ## [v3.0.0-pre.1](https://github.com/feathersjs/commons/tree/v3.0.0-pre.1) (2018-08-13) [Full Changelog](https://github.com/feathersjs/commons/compare/v2.0.0...v3.0.0-pre.1) **Merged pull requests:** - Remove argument verification and add further utilities [\#81](https://github.com/feathersjs/commons/pull/81) ([daffl](https://github.com/daffl)) ## [v2.0.0](https://github.com/feathersjs/commons/tree/v2.0.0) (2018-08-03) [Full Changelog](https://github.com/feathersjs/commons/compare/v1.4.4...v2.0.0) **Merged pull requests:** - Merge major with latest changes [\#80](https://github.com/feathersjs/commons/pull/80) ([daffl](https://github.com/daffl)) - Ability to specify custom filters in filterQuery [\#73](https://github.com/feathersjs/commons/pull/73) ([vonagam](https://github.com/vonagam)) ## [v1.4.4](https://github.com/feathersjs/commons/tree/v1.4.4) (2018-08-01) [Full Changelog](https://github.com/feathersjs/commons/compare/v1.4.3...v1.4.4) ## [v1.4.3](https://github.com/feathersjs/commons/tree/v1.4.3) (2018-07-25) [Full Changelog](https://github.com/feathersjs/commons/compare/v1.4.2...v1.4.3) **Merged pull requests:** - Revert breaking change from 78d780de91ae8333f3843be153beb5deea55c792 [\#78](https://github.com/feathersjs/commons/pull/78) ([daffl](https://github.com/daffl)) ## [v1.4.2](https://github.com/feathersjs/commons/tree/v1.4.2) (2018-07-25) [Full Changelog](https://github.com/feathersjs/commons/compare/v1.4.1...v1.4.2) **Closed issues:** - Sort error on multiple fields [\#74](https://github.com/feathersjs/commons/issues/74) - Cannot build with create-react-app \(again\) [\#71](https://github.com/feathersjs/commons/issues/71) **Merged pull requests:** - Update all dependencies [\#77](https://github.com/feathersjs/commons/pull/77) ([daffl](https://github.com/daffl)) - Use sorting algorithm from NeDB [\#76](https://github.com/feathersjs/commons/pull/76) ([daffl](https://github.com/daffl)) - Open hook workflow to custom methods [\#72](https://github.com/feathersjs/commons/pull/72) ([bertho-zero](https://github.com/bertho-zero)) ## [v1.4.1](https://github.com/feathersjs/commons/tree/v1.4.1) (2018-04-12) [Full Changelog](https://github.com/feathersjs/commons/compare/v1.4.0...v1.4.1) **Closed issues:** - Uncaught ReferenceError: convertGetOrRemove is not defined [\#69](https://github.com/feathersjs/commons/issues/69) - Cannot build with create-react-app [\#68](https://github.com/feathersjs/commons/issues/68) **Merged pull requests:** - Make conversion functions more concise [\#70](https://github.com/feathersjs/commons/pull/70) ([daffl](https://github.com/daffl)) - Update mocha to the latest version 🚀 [\#67](https://github.com/feathersjs/commons/pull/67) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.4.0](https://github.com/feathersjs/commons/tree/v1.4.0) (2018-01-17) [Full Changelog](https://github.com/feathersjs/commons/compare/v1.3.1...v1.4.0) **Merged pull requests:** - Add ability to skip all following hooks [\#65](https://github.com/feathersjs/commons/pull/65) ([sylvainlap](https://github.com/sylvainlap)) ## [v1.3.1](https://github.com/feathersjs/commons/tree/v1.3.1) (2018-01-12) [Full Changelog](https://github.com/feathersjs/commons/compare/v1.3.0...v1.3.1) **Merged pull requests:** - Allow array for sorting [\#66](https://github.com/feathersjs/commons/pull/66) ([daffl](https://github.com/daffl)) - Update semistandard to the latest version 🚀 [\#64](https://github.com/feathersjs/commons/pull/64) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.3.0](https://github.com/feathersjs/commons/tree/v1.3.0) (2017-11-20) [Full Changelog](https://github.com/feathersjs/commons/compare/v1.2.0...v1.3.0) **Merged pull requests:** - Add a toJSON method to the hook context [\#63](https://github.com/feathersjs/commons/pull/63) ([daffl](https://github.com/daffl)) - updating contributing guide and issue template [\#61](https://github.com/feathersjs/commons/pull/61) ([ekryski](https://github.com/ekryski)) ## [v1.2.0](https://github.com/feathersjs/commons/tree/v1.2.0) (2017-10-25) [Full Changelog](https://github.com/feathersjs/commons/compare/v1.1.0...v1.2.0) **Merged pull requests:** - Bring back makeUrl [\#62](https://github.com/feathersjs/commons/pull/62) ([daffl](https://github.com/daffl)) - adding codeclimate config [\#60](https://github.com/feathersjs/commons/pull/60) ([ekryski](https://github.com/ekryski)) ## [v1.1.0](https://github.com/feathersjs/commons/tree/v1.1.0) (2017-10-23) [Full Changelog](https://github.com/feathersjs/commons/compare/v1.0.0...v1.1.0) **Merged pull requests:** - Remove unused utilities and add some inline documentation [\#59](https://github.com/feathersjs/commons/pull/59) ([daffl](https://github.com/daffl)) - Add feathers-query-filters [\#58](https://github.com/feathersjs/commons/pull/58) ([daffl](https://github.com/daffl)) ## [v1.0.0](https://github.com/feathersjs/commons/tree/v1.0.0) (2017-10-19) [Full Changelog](https://github.com/feathersjs/commons/compare/v1.0.0-pre.3...v1.0.0) **Merged pull requests:** - Rename repository and add to npm scope [\#57](https://github.com/feathersjs/commons/pull/57) ([daffl](https://github.com/daffl)) - Updates for Feathers v3 \(Buzzard\) [\#56](https://github.com/feathersjs/commons/pull/56) ([daffl](https://github.com/daffl)) ## [v1.0.0-pre.3](https://github.com/feathersjs/commons/tree/v1.0.0-pre.3) (2017-10-18) [Full Changelog](https://github.com/feathersjs/commons/compare/v1.0.0-pre.2...v1.0.0-pre.3) **Merged pull requests:** - Update the client test suite [\#55](https://github.com/feathersjs/commons/pull/55) ([daffl](https://github.com/daffl)) - Update mocha to the latest version 🚀 [\#54](https://github.com/feathersjs/commons/pull/54) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.0-pre.2](https://github.com/feathersjs/commons/tree/v1.0.0-pre.2) (2017-07-11) [Full Changelog](https://github.com/feathersjs/commons/compare/v1.0.0-pre.1...v1.0.0-pre.2) **Merged pull requests:** - Update to new plugin infrastructure [\#53](https://github.com/feathersjs/commons/pull/53) ([daffl](https://github.com/daffl)) ## [v1.0.0-pre.1](https://github.com/feathersjs/commons/tree/v1.0.0-pre.1) (2017-06-28) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.8.7...v1.0.0-pre.1) **Merged pull requests:** - Commons for Feathers v3 [\#52](https://github.com/feathersjs/commons/pull/52) ([daffl](https://github.com/daffl)) - Update chai to the latest version 🚀 [\#51](https://github.com/feathersjs/commons/pull/51) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update semistandard to the latest version 🚀 [\#50](https://github.com/feathersjs/commons/pull/50) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update dependencies to enable Greenkeeper 🌴 [\#49](https://github.com/feathersjs/commons/pull/49) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v0.8.7](https://github.com/feathersjs/commons/tree/v0.8.7) (2016-11-30) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.8.6...v0.8.7) **Closed issues:** - Matcher function blows up with null values [\#46](https://github.com/feathersjs/commons/issues/46) **Merged pull requests:** - matcher now doesn't blow up with null values. Closes \#46 [\#47](https://github.com/feathersjs/commons/pull/47) ([ekryski](https://github.com/ekryski)) ## [v0.8.6](https://github.com/feathersjs/commons/tree/v0.8.6) (2016-11-25) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.8.5...v0.8.6) **Merged pull requests:** - Allow to pass an object to hook object [\#45](https://github.com/feathersjs/commons/pull/45) ([daffl](https://github.com/daffl)) ## [v0.8.5](https://github.com/feathersjs/commons/tree/v0.8.5) (2016-11-19) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.8.4...v0.8.5) **Merged pull requests:** - Deep merge and toObject [\#44](https://github.com/feathersjs/commons/pull/44) ([ekryski](https://github.com/ekryski)) - Expose lodash functions [\#43](https://github.com/feathersjs/commons/pull/43) ([ekryski](https://github.com/ekryski)) - Make url [\#42](https://github.com/feathersjs/commons/pull/42) ([ekryski](https://github.com/ekryski)) - Expect syntax [\#41](https://github.com/feathersjs/commons/pull/41) ([ekryski](https://github.com/ekryski)) ## [v0.8.4](https://github.com/feathersjs/commons/tree/v0.8.4) (2016-11-11) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.8.3...v0.8.4) ## [v0.8.3](https://github.com/feathersjs/commons/tree/v0.8.3) (2016-11-11) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.8.2...v0.8.3) ## [v0.8.2](https://github.com/feathersjs/commons/tree/v0.8.2) (2016-11-11) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.8.1...v0.8.2) **Merged pull requests:** - One more fix for select on arrays [\#40](https://github.com/feathersjs/commons/pull/40) ([daffl](https://github.com/daffl)) ## [v0.8.1](https://github.com/feathersjs/commons/tree/v0.8.1) (2016-11-11) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.8.0...v0.8.1) **Merged pull requests:** - Fixing select utility methods to work with query selector [\#39](https://github.com/feathersjs/commons/pull/39) ([daffl](https://github.com/daffl)) ## [v0.8.0](https://github.com/feathersjs/commons/tree/v0.8.0) (2016-11-09) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.7.8...v0.8.0) **Merged pull requests:** - Implementing lodash utilities and helpers for selecting [\#38](https://github.com/feathersjs/commons/pull/38) ([daffl](https://github.com/daffl)) - jshint —\> semistandard [\#37](https://github.com/feathersjs/commons/pull/37) ([corymsmith](https://github.com/corymsmith)) ## [v0.7.8](https://github.com/feathersjs/commons/tree/v0.7.8) (2016-10-21) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.7.7...v0.7.8) **Merged pull requests:** - Make getting the service in base test dynamic [\#36](https://github.com/feathersjs/commons/pull/36) ([daffl](https://github.com/daffl)) ## [v0.7.7](https://github.com/feathersjs/commons/tree/v0.7.7) (2016-10-21) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.7.6...v0.7.7) **Merged pull requests:** - Allow app in hookObject [\#35](https://github.com/feathersjs/commons/pull/35) ([daffl](https://github.com/daffl)) ## [v0.7.6](https://github.com/feathersjs/commons/tree/v0.7.6) (2016-10-20) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.7.5...v0.7.6) **Merged pull requests:** - Add test for matching and increase code coverage [\#34](https://github.com/feathersjs/commons/pull/34) ([daffl](https://github.com/daffl)) - omit '$select' in matcher [\#33](https://github.com/feathersjs/commons/pull/33) ([beeplin](https://github.com/beeplin)) - adding code coverage [\#32](https://github.com/feathersjs/commons/pull/32) ([ekryski](https://github.com/ekryski)) ## [v0.7.5](https://github.com/feathersjs/commons/tree/v0.7.5) (2016-09-05) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.7.4...v0.7.5) **Closed issues:** - Feathers should accept other type of data beside only the object type. [\#26](https://github.com/feathersjs/commons/issues/26) - Send better error messages for method normalization [\#12](https://github.com/feathersjs/commons/issues/12) **Merged pull requests:** - Allow matching nested $or queries [\#29](https://github.com/feathersjs/commons/pull/29) ([daffl](https://github.com/daffl)) - Add default export to `hooks.js` [\#28](https://github.com/feathersjs/commons/pull/28) ([KenanY](https://github.com/KenanY)) - Update mocha to version 3.0.0 🚀 [\#27](https://github.com/feathersjs/commons/pull/27) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v0.7.4](https://github.com/feathersjs/commons/tree/v0.7.4) (2016-05-29) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.7.3...v0.7.4) **Merged pull requests:** - Use forEach instead of ES6 'for of' loop [\#25](https://github.com/feathersjs/commons/pull/25) ([lopezjurip](https://github.com/lopezjurip)) - mocha@2.5.0 breaks build 🚨 [\#24](https://github.com/feathersjs/commons/pull/24) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update babel-plugin-add-module-exports to version 0.2.0 🚀 [\#23](https://github.com/feathersjs/commons/pull/23) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v0.7.3](https://github.com/feathersjs/commons/tree/v0.7.3) (2016-05-05) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.7.2...v0.7.3) **Merged pull requests:** - Make sure arguments from hook objects are created properly for known … [\#22](https://github.com/feathersjs/commons/pull/22) ([daffl](https://github.com/daffl)) ## [v0.7.2](https://github.com/feathersjs/commons/tree/v0.7.2) (2016-04-26) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.7.1...v0.7.2) **Merged pull requests:** - Update test fixture to use promises and add error cases [\#19](https://github.com/feathersjs/commons/pull/19) ([daffl](https://github.com/daffl)) ## [v0.7.1](https://github.com/feathersjs/commons/tree/v0.7.1) (2016-04-04) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.6.2...v0.7.1) **Merged pull requests:** - Adding functionality and tests for shared query and list handling [\#17](https://github.com/feathersjs/commons/pull/17) ([daffl](https://github.com/daffl)) ## [v0.6.2](https://github.com/feathersjs/commons/tree/v0.6.2) (2016-02-09) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.7.0...v0.6.2) ## [v0.7.0](https://github.com/feathersjs/commons/tree/v0.7.0) (2016-02-08) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.6.1...v0.7.0) ## [v0.6.1](https://github.com/feathersjs/commons/tree/v0.6.1) (2016-02-08) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.6.0...v0.6.1) **Merged pull requests:** - Add NSP check to test script. [\#16](https://github.com/feathersjs/commons/pull/16) ([marshallswain](https://github.com/marshallswain)) ## [v0.6.0](https://github.com/feathersjs/commons/tree/v0.6.0) (2016-01-21) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.5.0...v0.6.0) **Closed issues:** - Rename hooks to hookUtils to make room for common hooks. [\#13](https://github.com/feathersjs/commons/issues/13) **Merged pull requests:** - Remove shared socket functionality [\#15](https://github.com/feathersjs/commons/pull/15) ([daffl](https://github.com/daffl)) - Support socket routes with apps mounted on a path [\#14](https://github.com/feathersjs/commons/pull/14) ([daffl](https://github.com/daffl)) ## [v0.5.0](https://github.com/feathersjs/commons/tree/v0.5.0) (2016-01-10) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.4.0...v0.5.0) ## [v0.4.0](https://github.com/feathersjs/commons/tree/v0.4.0) (2016-01-10) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.3.4...v0.4.0) ## [v0.3.4](https://github.com/feathersjs/commons/tree/v0.3.4) (2016-01-06) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.3.3...v0.3.4) **Merged pull requests:** - Fix SocketIO client iteration for all cases [\#11](https://github.com/feathersjs/commons/pull/11) ([daffl](https://github.com/daffl)) ## [v0.3.3](https://github.com/feathersjs/commons/tree/v0.3.3) (2016-01-06) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.3.2...v0.3.3) **Closed issues:** - Socket.io 1.4.0 broke feathers [\#10](https://github.com/feathersjs/commons/issues/10) ## [v0.3.2](https://github.com/feathersjs/commons/tree/v0.3.2) (2016-01-06) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.3.1...v0.3.2) ## [v0.3.1](https://github.com/feathersjs/commons/tree/v0.3.1) (2016-01-06) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.3.0...v0.3.1) ## [v0.3.0](https://github.com/feathersjs/commons/tree/v0.3.0) (2015-12-11) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.2.11...v0.3.0) **Closed issues:** - babel inside package.json breaks react-native [\#9](https://github.com/feathersjs/commons/issues/9) ## [v0.2.11](https://github.com/feathersjs/commons/tree/v0.2.11) (2015-11-30) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.2.10...v0.2.11) **Merged pull requests:** - getOrRemove did not check id property type [\#8](https://github.com/feathersjs/commons/pull/8) ([daffl](https://github.com/daffl)) ## [v0.2.10](https://github.com/feathersjs/commons/tree/v0.2.10) (2015-11-28) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.2.9...v0.2.10) **Closed issues:** - Remove dependency on lodash [\#6](https://github.com/feathersjs/commons/issues/6) **Merged pull requests:** - Migrate to Babel 6 and remove Lodash dependency [\#7](https://github.com/feathersjs/commons/pull/7) ([daffl](https://github.com/daffl)) ## [v0.2.9](https://github.com/feathersjs/commons/tree/v0.2.9) (2015-11-17) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.2.8...v0.2.9) **Closed issues:** - Event dispatcher context is not being set to the service [\#5](https://github.com/feathersjs/commons/issues/5) - .create with no callback throws error [\#4](https://github.com/feathersjs/commons/issues/4) ## [v0.2.8](https://github.com/feathersjs/commons/tree/v0.2.8) (2015-10-06) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.2.7...v0.2.8) **Closed issues:** - getArguments not exporting correctly [\#1](https://github.com/feathersjs/commons/issues/1) **Merged pull requests:** - Add hookObject utilities and remove Lodash dependency from arguments.js [\#3](https://github.com/feathersjs/commons/pull/3) ([daffl](https://github.com/daffl)) ## [v0.2.7](https://github.com/feathersjs/commons/tree/v0.2.7) (2015-03-07) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.2.6...v0.2.7) ## [v0.2.6](https://github.com/feathersjs/commons/tree/v0.2.6) (2015-03-06) [Full Changelog](https://github.com/feathersjs/commons/compare/v0.2.5...v0.2.6) ## [v0.2.5](https://github.com/feathersjs/commons/tree/v0.2.5) (2015-03-06) [Full Changelog](https://github.com/feathersjs/commons/compare/0.2.3...v0.2.5) ## [0.2.3](https://github.com/feathersjs/commons/tree/0.2.3) (2015-03-06) [Full Changelog](https://github.com/feathersjs/commons/compare/0.2.2...0.2.3) ## [0.2.2](https://github.com/feathersjs/commons/tree/0.2.2) (2015-03-06) [Full Changelog](https://github.com/feathersjs/commons/compare/0.2.1...0.2.2) ## [0.2.1](https://github.com/feathersjs/commons/tree/0.2.1) (2015-03-06) [Full Changelog](https://github.com/feathersjs/commons/compare/0.2.0...0.2.1) ## [0.2.0](https://github.com/feathersjs/commons/tree/0.2.0) (2015-03-06) [Full Changelog](https://github.com/feathersjs/commons/compare/0.1.0...0.2.0) ## [0.1.0](https://github.com/feathersjs/commons/tree/0.1.0) (2015-03-06) \* _This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)_ ================================================ FILE: packages/commons/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/commons/README.md ================================================ # Feathers Commons [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/commons.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/commons) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > Shared Feathers utility functions ## Installation ``` npm install @feathersjs/commons --save ``` ## Documentation Refer to the [Feathers API](https://feathersjs.com/api) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/commons/package.json ================================================ { "name": "@feathersjs/commons", "version": "5.0.42", "description": "Shared Feathers utility functions", "homepage": "https://feathersjs.com", "keywords": [ "feathers" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/commons" }, "author": { "name": "Feathers contributor", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "main": "lib/", "types": "lib/", "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "devDependencies": { "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "mocha": "^11.7.5", "shx": "^0.4.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/commons/src/debug.ts ================================================ /* eslint-disable @typescript-eslint/no-empty-function */ export type DebugFunction = (...args: any[]) => void export type DebugInitializer = (name: string) => DebugFunction const debuggers: { [key: string]: DebugFunction } = {} export function noopDebug(): DebugFunction { return function () {} } let defaultInitializer: DebugInitializer = noopDebug export function setDebug(debug: DebugInitializer) { defaultInitializer = debug Object.keys(debuggers).forEach((name) => { debuggers[name] = debug(name) }) } export function createDebug(name: string) { if (!debuggers[name]) { debuggers[name] = defaultInitializer(name) } return (...args: any[]) => debuggers[name](...args) } ================================================ FILE: packages/commons/src/index.ts ================================================ // Removes all leading and trailing slashes from a path export function stripSlashes(name: string) { return name.replace(/^(\/+)|(\/+)$/g, '') } export type KeyValueCallback = (value: any, key: string) => T // A set of lodash-y utility functions that use ES6 export const _ = { each(obj: any, callback: KeyValueCallback) { if (obj && typeof obj.forEach === 'function') { obj.forEach(callback) } else if (_.isObject(obj)) { Object.keys(obj).forEach((key) => callback(obj[key], key)) } }, some(value: any, callback: KeyValueCallback) { return Object.keys(value) .map((key) => [value[key], key]) .some(([val, key]) => callback(val, key)) }, every(value: any, callback: KeyValueCallback) { return Object.keys(value) .map((key) => [value[key], key]) .every(([val, key]) => callback(val, key)) }, keys(obj: any) { return Object.keys(obj) }, values(obj: any) { return _.keys(obj).map((key) => obj[key]) }, isMatch(obj: any, item: any) { return _.keys(item).every((key) => obj[key] === item[key]) }, isEmpty(obj: any) { return _.keys(obj).length === 0 }, isObject(item: any) { return typeof item === 'object' && !Array.isArray(item) && item !== null }, isObjectOrArray(value: any) { return typeof value === 'object' && value !== null }, extend(first: any, ...rest: any[]) { return Object.assign(first, ...rest) }, omit(obj: any, ...keys: string[]) { const result = _.extend({}, obj) keys.forEach((key) => delete result[key]) return result }, pick(source: any, ...keys: string[]) { return keys.reduce((result: { [key: string]: any }, key) => { if (source[key] !== undefined) { result[key] = source[key] } return result }, {}) }, // Recursively merge the source object into the target object merge(target: any, source: any) { if (_.isObject(target) && _.isObject(source)) { Object.keys(source).forEach((key) => { if (_.isObject(source[key])) { if (!target[key]) { Object.assign(target, { [key]: {} }) } _.merge(target[key], source[key]) } else { Object.assign(target, { [key]: source[key] }) } }) } return target } } // Duck-checks if an object looks like a promise export function isPromise(result: any) { return _.isObject(result) && typeof result.then === 'function' } export function createSymbol(name: string) { return typeof Symbol !== 'undefined' ? Symbol.for(name) : name } export * from './debug' ================================================ FILE: packages/commons/test/debug.test.ts ================================================ import { strict as assert } from 'assert' import { createDebug, setDebug, noopDebug } from '../src' const myDebug = createDebug('hello test') describe('debug', () => { it('default debug does nothing', () => { assert.equal(myDebug('hi', 'there'), undefined) }) it('can set custom debug later', () => { let call const customDebug = (name: string) => (...args: any[]) => { call = [name].concat(args) } setDebug(customDebug) assert.equal(myDebug('hi', 'there'), undefined) assert.deepEqual(call, ['hello test', 'hi', 'there']) const newDebug = createDebug('other test') assert.equal(newDebug('other', 'there'), undefined) assert.deepEqual(call, ['other test', 'other', 'there']) setDebug(noopDebug) }) }) ================================================ FILE: packages/commons/test/module.test.ts ================================================ import { strict as assert } from 'assert' import { _ } from '../src' describe('module', () => { it('is commonjs compatible', () => { // eslint-disable-next-line const commons = require('../lib') assert.equal(typeof commons, 'object') assert.equal(typeof commons.stripSlashes, 'function') assert.equal(typeof commons._, 'object') }) it('exposes lodash methods under _', () => { assert.equal(typeof _.each, 'function') assert.equal(typeof _.some, 'function') assert.equal(typeof _.every, 'function') assert.equal(typeof _.keys, 'function') assert.equal(typeof _.values, 'function') assert.equal(typeof _.isMatch, 'function') assert.equal(typeof _.isEmpty, 'function') assert.equal(typeof _.isObject, 'function') assert.equal(typeof _.extend, 'function') assert.equal(typeof _.omit, 'function') assert.equal(typeof _.pick, 'function') assert.equal(typeof _.merge, 'function') }) }) ================================================ FILE: packages/commons/test/utils.test.ts ================================================ /* tslint:disable:no-unused-expression */ import { strict as assert } from 'assert' import { _, stripSlashes, isPromise, createSymbol } from '../src' describe('@feathersjs/commons utils', () => { it('stripSlashes', () => { assert.equal(stripSlashes('some/thing'), 'some/thing') assert.equal(stripSlashes('/some/thing'), 'some/thing') assert.equal(stripSlashes('some/thing/'), 'some/thing') assert.equal(stripSlashes('/some/thing/'), 'some/thing') assert.equal(stripSlashes('//some/thing/'), 'some/thing') assert.equal(stripSlashes('//some//thing////'), 'some//thing') }) it('isPromise', () => { assert.equal(isPromise(Promise.resolve()), true) assert.ok( isPromise({ then() { return true } }) ) assert.equal(isPromise(null), false) }) it('createSymbol', () => { assert.equal(typeof createSymbol('a test'), 'symbol') }) describe('_', () => { it('isObject', () => { assert.equal(_.isObject({}), true) assert.equal(_.isObject([]), false) assert.equal(_.isObject(null), false) }) it('isObjectOrArray', () => { assert.equal(_.isObjectOrArray({}), true) assert.equal(_.isObjectOrArray([]), true) assert.equal(_.isObjectOrArray(null), false) }) it('each', () => { _.each({ hi: 'there' }, (value, key) => { assert.equal(key, 'hi') assert.equal(value, 'there') }) _.each(['hi'], (value, key) => { assert.equal(key, 0) assert.equal(value, 'hi') }) _.each('moo', () => assert.fail('Should never get here')) }) it('some', () => { assert.ok(_.some(['a', 'b'], (current) => current === 'a')) assert.ok(!_.some(['a', 'b'], (current) => current === 'c')) }) it('every', () => { assert.ok(_.every(['a', 'a'], (current) => current === 'a')) assert.ok(!_.every(['a', 'b'], (current) => current === 'a')) }) it('keys', () => { const data = { hi: 'there', name: 'David' } assert.deepEqual(_.keys(data), ['hi', 'name']) }) it('values', () => { const data = { hi: 'there', name: 'David' } assert.deepEqual(_.values(data), ['there', 'David']) }) it('isMatch', () => { assert.ok( _.isMatch( { test: 'me', hi: 'you', more: true }, { test: 'me', hi: 'you' } ) ) assert.ok( !_.isMatch( { test: 'me', hi: 'you', more: true }, { test: 'me', hi: 'there' } ) ) }) it('isEmpty', () => { assert.ok(_.isEmpty({})) assert.ok(!_.isEmpty({ name: 'David' })) }) it('extend', () => { assert.deepEqual(_.extend({ hi: 'there' }, { name: 'david' }), { hi: 'there', name: 'david' }) }) it('omit', () => { assert.deepEqual( _.omit( { name: 'David', first: 1, second: 2 }, 'first', 'second' ), { name: 'David' } ) }) it('pick', () => { assert.deepEqual( _.pick( { name: 'David', first: 1, second: 2 }, 'first', 'second' ), { first: 1, second: 2 } ) assert.deepEqual( _.pick( { name: 'David', first: 1 }, 'first', 'second' ), { first: 1 } ) }) it('merge', () => { assert.deepEqual(_.merge({ hi: 'there' }, { name: 'david' }), { hi: 'there', name: 'david' }) assert.deepEqual( _.merge( {}, { name: 'david', nested: { obj: true } } ), { name: 'david', nested: { obj: true } } ) assert.deepEqual(_.merge({ name: 'david' }, {}), { name: 'david' }) assert.deepEqual( _.merge( { hi: 'there', my: { name: { is: 'david' }, number: { is: 1 } } }, { my: { name: { is: 'eric' } } } ), { hi: 'there', my: { number: { is: 1 }, name: { is: 'eric' } } } ) assert.equal(_.merge('hello', {}), 'hello') }) }) }) ================================================ FILE: packages/commons/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/configuration/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/configuration ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) - **schema:** Make schemas validation library independent and add TypeBox support ([#2772](https://github.com/feathersjs/feathers/issues/2772)) ([44172d9](https://github.com/feathersjs/feathers/commit/44172d99b566d11d9ceda04f1d0bf72b6d05ce76)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **configuration:** Only validate the initial configuration against the schema ([#2622](https://github.com/feathersjs/feathers/issues/2622)) ([386c5e2](https://github.com/feathersjs/feathers/commit/386c5e2e67bfad4fb4333f2e3e17f7d7e09ac27e)) - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) ### Features - **configuration:** Allow app configuration to be validated against a schema ([#2590](https://github.com/feathersjs/feathers/issues/2590)) ([a268f86](https://github.com/feathersjs/feathers/commit/a268f86da92a8ada14ed11ab456aac0a4bba5bb0)) # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Bug Fixes - **koa:** Use extended query parser for compatibility ([#2397](https://github.com/feathersjs/feathers/issues/2397)) ([b2944ba](https://github.com/feathersjs/feathers/commit/b2944bac3ec6d5ecc80dc518cd4e58093692db74)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) ### Features - **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) **Note:** Version bump only for package @feathersjs/configuration # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) ### Features - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### chore - **configuration:** Remove environment variable substitution ([#1942](https://github.com/feathersjs/feathers/issues/1942)) ([caaa21f](https://github.com/feathersjs/feathers/commit/caaa21ffdc6a8dcac82fb403c91d9d4b781a6c0a)) ### BREAKING CHANGES - **configuration:** Falls back to node-config instead of adding additional functionality like path replacements and automatic environment variable insertion. # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### chore - **configuration:** Remove environment variable substitution ([#1942](https://github.com/feathersjs/feathers/issues/1942)) ([caaa21f](https://github.com/feathersjs/feathers/commit/caaa21ffdc6a8dcac82fb403c91d9d4b781a6c0a)) ### BREAKING CHANGES - **configuration:** Falls back to node-config instead of adding additional functionality like path replacements and automatic environment variable insertion. ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) ### Bug Fixes - **configuration:** Fix handling of config values that start with . or .. but are not actually relative paths; e.g. ".foo" or "..bar" ([#2065](https://github.com/feathersjs/feathers/issues/2065)) ([d07bf59](https://github.com/feathersjs/feathers/commit/d07bf5902e9c8c606f16b9523472972d3d2e9b49)) ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) **Note:** Version bump only for package @feathersjs/configuration ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) **Note:** Version bump only for package @feathersjs/configuration ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) **Note:** Version bump only for package @feathersjs/configuration ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) **Note:** Version bump only for package @feathersjs/configuration ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) **Note:** Version bump only for package @feathersjs/configuration ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/configuration # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) **Note:** Version bump only for package @feathersjs/configuration ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/configuration ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/configuration # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) **Note:** Version bump only for package @feathersjs/configuration ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) **Note:** Version bump only for package @feathersjs/configuration ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/configuration ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) **Note:** Version bump only for package @feathersjs/configuration ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) **Note:** Version bump only for package @feathersjs/configuration ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) **Note:** Version bump only for package @feathersjs/configuration ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) ### Bug Fixes - Small improvements in dependencies and code sturcture ([#1562](https://github.com/feathersjs/feathers/issues/1562)) ([42c13e2](https://github.com/feathersjs/feathers/commit/42c13e2)) ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) **Note:** Version bump only for package @feathersjs/configuration ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) **Note:** Version bump only for package @feathersjs/configuration # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/configuration # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/configuration # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) ### Bug Fixes - Update all dependencies ([7d53a00](https://github.com/feathersjs/feathers/commit/7d53a00)) # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) **Note:** Version bump only for package @feathersjs/configuration # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/configuration # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) **Note:** Version bump only for package @feathersjs/configuration # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) **Note:** Version bump only for package @feathersjs/configuration # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) **Note:** Version bump only for package @feathersjs/configuration # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) **Note:** Version bump only for package @feathersjs/configuration # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) - **package:** update config to version 3.0.0 ([#1100](https://github.com/feathersjs/feathers/issues/1100)) ([c9f4b42](https://github.com/feathersjs/feathers/commit/c9f4b42)) - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - **package:** update debug to version 3.0.0 ([#45](https://github.com/feathersjs/feathers/issues/45)) ([2391434](https://github.com/feathersjs/feathers/commit/2391434)) - **package:** update debug to version 3.0.1 ([#46](https://github.com/feathersjs/feathers/issues/46)) ([f8ada69](https://github.com/feathersjs/feathers/commit/f8ada69)) ### Features - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) ## [2.0.6](https://github.com/feathersjs/feathers/compare/@feathersjs/configuration@2.0.5...@feathersjs/configuration@2.0.6) (2019-01-02) **Note:** Version bump only for package @feathersjs/configuration ## [2.0.5](https://github.com/feathersjs/feathers/compare/@feathersjs/configuration@2.0.4...@feathersjs/configuration@2.0.5) (2018-12-16) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - **package:** update config to version 3.0.0 ([#1100](https://github.com/feathersjs/feathers/issues/1100)) ([c9f4b42](https://github.com/feathersjs/feathers/commit/c9f4b42)) ## [2.0.4](https://github.com/feathersjs/feathers/compare/@feathersjs/configuration@2.0.3...@feathersjs/configuration@2.0.4) (2018-09-21) **Note:** Version bump only for package @feathersjs/configuration ## [2.0.3](https://github.com/feathersjs/feathers/compare/@feathersjs/configuration@2.0.2...@feathersjs/configuration@2.0.3) (2018-09-17) **Note:** Version bump only for package @feathersjs/configuration ## [2.0.2](https://github.com/feathersjs/feathers/compare/@feathersjs/configuration@2.0.1...@feathersjs/configuration@2.0.2) (2018-09-02) **Note:** Version bump only for package @feathersjs/configuration ## 2.0.1 - Migrate to Monorepo ([feathers#462](https://github.com/feathersjs/feathers/issues/462)) ## [v2.0.0](https://github.com/feathersjs/configuration/tree/v2.0.0) (2018-07-30) [Full Changelog](https://github.com/feathersjs/configuration/compare/v1.0.2...v2.0.0) **Closed issues:** - Config adding a value of userName in runtime its overwritten to the OS name [\#58](https://github.com/feathersjs/configuration/issues/58) - Configuration Management [\#26](https://github.com/feathersjs/configuration/issues/26) **Merged pull requests:** - Update config to the latest version 🚀 [\#59](https://github.com/feathersjs/configuration/pull/59) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - misspelling [\#57](https://github.com/feathersjs/configuration/pull/57) ([chaintng](https://github.com/chaintng)) - Update mocha to the latest version 🚀 [\#56](https://github.com/feathersjs/configuration/pull/56) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.2](https://github.com/feathersjs/configuration/tree/v1.0.2) (2018-01-02) [Full Changelog](https://github.com/feathersjs/configuration/compare/v1.0.1...v1.0.2) **Merged pull requests:** - Remove example and update Readme to point directly to the Feathers docs [\#55](https://github.com/feathersjs/configuration/pull/55) ([daffl](https://github.com/daffl)) ## [v1.0.1](https://github.com/feathersjs/configuration/tree/v1.0.1) (2017-11-16) [Full Changelog](https://github.com/feathersjs/configuration/compare/v1.0.0...v1.0.1) **Merged pull requests:** - Add default export for better ES module \(TypeScript\) compatibility [\#53](https://github.com/feathersjs/configuration/pull/53) ([daffl](https://github.com/daffl)) - Update nsp to the latest version 🚀 [\#52](https://github.com/feathersjs/configuration/pull/52) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.0](https://github.com/feathersjs/configuration/tree/v1.0.0) (2017-11-01) [Full Changelog](https://github.com/feathersjs/configuration/compare/v1.0.0-pre.1...v1.0.0) ## [v1.0.0-pre.1](https://github.com/feathersjs/configuration/tree/v1.0.0-pre.1) (2017-10-23) [Full Changelog](https://github.com/feathersjs/configuration/compare/v0.4.2...v1.0.0-pre.1) **Closed issues:** - Move config options to app.config instead of the Express app object. [\#31](https://github.com/feathersjs/configuration/issues/31) **Merged pull requests:** - Update to new plugin infrastructure and npm scopes [\#51](https://github.com/feathersjs/configuration/pull/51) ([daffl](https://github.com/daffl)) ## [v0.4.2](https://github.com/feathersjs/configuration/tree/v0.4.2) (2017-10-15) [Full Changelog](https://github.com/feathersjs/configuration/compare/v0.4.1...v0.4.2) **Closed issues:** - Missing TypeScript declaration file [\#48](https://github.com/feathersjs/configuration/issues/48) - Feathers writing in typescript fails to boot on configuration [\#47](https://github.com/feathersjs/configuration/issues/47) - Prevent automatic expansion of environment variables [\#42](https://github.com/feathersjs/configuration/issues/42) - Getting Env name [\#41](https://github.com/feathersjs/configuration/issues/41) - Nested configuration [\#38](https://github.com/feathersjs/configuration/issues/38) - Stuck in configuration loophole... [\#37](https://github.com/feathersjs/configuration/issues/37) - Docs are wrong [\#36](https://github.com/feathersjs/configuration/issues/36) - Why use "NODE_ENV=development" with default.json? [\#33](https://github.com/feathersjs/configuration/issues/33) **Merged pull requests:** - Create TypeScript definitions [\#50](https://github.com/feathersjs/configuration/pull/50) ([jhanschoo](https://github.com/jhanschoo)) - Update mocha to the latest version 🚀 [\#49](https://github.com/feathersjs/configuration/pull/49) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update debug to the latest version 🚀 [\#46](https://github.com/feathersjs/configuration/pull/46) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update debug to the latest version 🚀 [\#45](https://github.com/feathersjs/configuration/pull/45) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Grammatical change [\#44](https://github.com/feathersjs/configuration/pull/44) ([eugeniaguerrero](https://github.com/eugeniaguerrero)) - More documentation on using and escaping environment variables [\#43](https://github.com/feathersjs/configuration/pull/43) ([daffl](https://github.com/daffl)) - Update semistandard to the latest version 🚀 [\#40](https://github.com/feathersjs/configuration/pull/40) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update dependencies to enable Greenkeeper 🌴 [\#39](https://github.com/feathersjs/configuration/pull/39) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Fix first example [\#35](https://github.com/feathersjs/configuration/pull/35) ([elfey](https://github.com/elfey)) - 👻😱 Node.js 0.10 is unmaintained 😱👻 [\#30](https://github.com/feathersjs/configuration/pull/30) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v0.4.1](https://github.com/feathersjs/configuration/tree/v0.4.1) (2016-10-24) [Full Changelog](https://github.com/feathersjs/configuration/compare/v0.4.0...v0.4.1) **Closed issues:** - Investigate node-config [\#8](https://github.com/feathersjs/configuration/issues/8) **Merged pull requests:** - update readme [\#29](https://github.com/feathersjs/configuration/pull/29) ([slajax](https://github.com/slajax)) - jshint —\> semistandard [\#28](https://github.com/feathersjs/configuration/pull/28) ([corymsmith](https://github.com/corymsmith)) ## [v0.4.0](https://github.com/feathersjs/configuration/tree/v0.4.0) (2016-10-22) [Full Changelog](https://github.com/feathersjs/configuration/compare/v0.3.3...v0.4.0) **Implemented enhancements:** - implement node-config [\#27](https://github.com/feathersjs/configuration/pull/27) ([slajax](https://github.com/slajax)) **Closed issues:** - Deprecate v1 in favour of node-config [\#25](https://github.com/feathersjs/configuration/issues/25) - Make this repo more about managing configuration [\#24](https://github.com/feathersjs/configuration/issues/24) ## [v0.3.3](https://github.com/feathersjs/configuration/tree/v0.3.3) (2016-09-12) [Full Changelog](https://github.com/feathersjs/configuration/compare/v0.3.2...v0.3.3) ## [v0.3.2](https://github.com/feathersjs/configuration/tree/v0.3.2) (2016-09-12) [Full Changelog](https://github.com/feathersjs/configuration/compare/v0.3.1...v0.3.2) **Closed issues:** - A way to have local override [\#20](https://github.com/feathersjs/configuration/issues/20) **Merged pull requests:** - Remove check for development mode [\#21](https://github.com/feathersjs/configuration/pull/21) ([daffl](https://github.com/daffl)) ## [v0.3.1](https://github.com/feathersjs/configuration/tree/v0.3.1) (2016-08-15) [Full Changelog](https://github.com/feathersjs/configuration/compare/v0.3.0...v0.3.1) **Merged pull requests:** - Support `null` values [\#19](https://github.com/feathersjs/configuration/pull/19) ([KenanY](https://github.com/KenanY)) - Update mocha to version 3.0.0 🚀 [\#18](https://github.com/feathersjs/configuration/pull/18) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v0.3.0](https://github.com/feathersjs/configuration/tree/v0.3.0) (2016-05-22) [Full Changelog](https://github.com/feathersjs/configuration/compare/v0.2.3...v0.3.0) **Closed issues:** - \.json config need deep merge options [\#16](https://github.com/feathersjs/configuration/issues/16) **Merged pull requests:** - Add functionality for deeply extending configuration [\#17](https://github.com/feathersjs/configuration/pull/17) ([daffl](https://github.com/daffl)) ## [v0.2.3](https://github.com/feathersjs/configuration/tree/v0.2.3) (2016-04-24) [Full Changelog](https://github.com/feathersjs/configuration/compare/v0.2.2...v0.2.3) **Closed issues:** - PR: Support modules in config [\#12](https://github.com/feathersjs/configuration/issues/12) **Merged pull requests:** - Support modules as configuration files. [\#13](https://github.com/feathersjs/configuration/pull/13) ([wkw](https://github.com/wkw)) - Update all dependencies 🌴 [\#10](https://github.com/feathersjs/configuration/pull/10) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v0.2.2](https://github.com/feathersjs/configuration/tree/v0.2.2) (2016-03-27) [Full Changelog](https://github.com/feathersjs/configuration/compare/v0.2.1...v0.2.2) **Merged pull requests:** - Expanding environment variables in \.json [\#9](https://github.com/feathersjs/configuration/pull/9) ([derek-watson](https://github.com/derek-watson)) ## [v0.2.1](https://github.com/feathersjs/configuration/tree/v0.2.1) (2016-03-12) [Full Changelog](https://github.com/feathersjs/configuration/compare/v0.2.0...v0.2.1) **Merged pull requests:** - Makes sure that arrays get converted properly [\#7](https://github.com/feathersjs/configuration/pull/7) ([daffl](https://github.com/daffl)) ## [v0.2.0](https://github.com/feathersjs/configuration/tree/v0.2.0) (2016-03-09) [Full Changelog](https://github.com/feathersjs/configuration/compare/v0.1.1...v0.2.0) **Closed issues:** - Needs an escape character [\#4](https://github.com/feathersjs/configuration/issues/4) **Merged pull requests:** - Implement an escape character [\#6](https://github.com/feathersjs/configuration/pull/6) ([daffl](https://github.com/daffl)) ## [v0.1.1](https://github.com/feathersjs/configuration/tree/v0.1.1) (2016-03-09) [Full Changelog](https://github.com/feathersjs/configuration/compare/v0.1.0...v0.1.1) **Closed issues:** - Configuration should recursively go through the values [\#2](https://github.com/feathersjs/configuration/issues/2) **Merged pull requests:** - Replace slashes in paths with the separator [\#5](https://github.com/feathersjs/configuration/pull/5) ([daffl](https://github.com/daffl)) - Allow to convert deeply nested environment variables [\#3](https://github.com/feathersjs/configuration/pull/3) ([daffl](https://github.com/daffl)) - Adding nsp check [\#1](https://github.com/feathersjs/configuration/pull/1) ([marshallswain](https://github.com/marshallswain)) ## [v0.1.0](https://github.com/feathersjs/configuration/tree/v0.1.0) (2015-11-14) \* _This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)_ ================================================ FILE: packages/configuration/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/configuration/README.md ================================================ # @feathersjs/configuration [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/configuration.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/configuration) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > A small configuration module for your Feathers application. ## Installation ``` npm install @feathersjs/configuration --save ``` ## Documentation Refer to the [Feathers configuration API documentation](https://feathersjs.com/api/configuration.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/configuration/package.json ================================================ { "name": "@feathersjs/configuration", "description": "A small configuration module for your Feathers application.", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/configuration" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "NODE_CONFIG_DIR=./test/config mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "semistandard": { "env": [ "mocha" ] }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/commons": "^5.0.42", "@feathersjs/feathers": "^5.0.42", "@feathersjs/schema": "^5.0.42", "@types/config": "^3.3.5", "config": "^4.4.1" }, "devDependencies": { "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "mocha": "^11.7.5", "shx": "^0.4.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/configuration/src/index.ts ================================================ import { Application, ApplicationHookContext, NextFunction } from '@feathersjs/feathers' import { createDebug } from '@feathersjs/commons' import { Schema, Validator } from '@feathersjs/schema' import config from 'config' const debug = createDebug('@feathersjs/configuration') export = function init(schema?: Schema | Validator): (app?: Application) => Record { const validator: Validator = typeof schema === 'function' ? schema : schema?.validate.bind(schema) return (app?: Application) => { if (!app) { return config } const configuration: { [key: string]: unknown } = { ...config } debug(`Initializing configuration for ${config.util.getEnv('NODE_ENV')} environment`) Object.keys(configuration).forEach((name) => { const value = configuration[name] debug(`Setting ${name} configuration value to`, value) app.set(name, value) }) if (validator) { app.hooks({ setup: [ async (_context: ApplicationHookContext, next: NextFunction) => { await validator(configuration) await next() } ] }) } return config } } ================================================ FILE: packages/configuration/test/config/default.json ================================================ { "port": 3030, "array": ["one", "two", "three"], "deep": { "base": false }, "nullish": null } ================================================ FILE: packages/configuration/test/index.test.ts ================================================ import { strict as assert } from 'assert' import { feathers, Application } from '@feathersjs/feathers' import { Ajv, schema } from '@feathersjs/schema' import configuration from '../src' describe('@feathersjs/configuration', () => { const app: Application = feathers().configure(configuration()) it('initialized app with default.json', () => { assert.equal(app.get('port'), 3030) assert.deepEqual(app.get('array'), ['one', 'two', 'three']) assert.deepEqual(app.get('deep'), { base: false }) assert.deepEqual(app.get('nullish'), null) }) it('works when called directly', () => { const fn = configuration() const conf = fn() as any assert.strictEqual(conf.port, 3030) }) it('errors on .setup when a schema is passed and the configuration is invalid', async () => { const configurationSchema = schema( { $id: 'ConfigurationSchema', additionalProperties: false, type: 'object', properties: { port: { type: 'number' }, deep: { type: 'object', properties: { base: { type: 'boolean' } } }, array: { type: 'array', items: { type: 'string' } }, nullish: { type: 'string' } } } as const, new Ajv() ) const schemaApp = feathers().configure(configuration(configurationSchema)) await assert.rejects(() => schemaApp.setup(), { data: [ { instancePath: '/nullish', keyword: 'type', message: 'must be string', params: { type: 'string' }, schemaPath: '#/properties/nullish/type' } ] }) }) }) ================================================ FILE: packages/configuration/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/create-feathers/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) **Note:** Version bump only for package create-feathers ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package create-feathers ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package create-feathers ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package create-feathers ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package create-feathers ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package create-feathers ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) **Note:** Version bump only for package create-feathers ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) **Note:** Version bump only for package create-feathers ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) **Note:** Version bump only for package create-feathers ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) **Note:** Version bump only for package create-feathers ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package create-feathers ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) **Note:** Version bump only for package create-feathers ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package create-feathers ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package create-feathers ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package create-feathers ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package create-feathers ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package create-feathers ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package create-feathers ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package create-feathers ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) **Note:** Version bump only for package create-feathers ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package create-feathers ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package create-feathers ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package create-feathers ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) ### Bug Fixes - **cli:** Add JS extension to binaries ([#3398](https://github.com/feathersjs/feathers/issues/3398)) ([aaf181d](https://github.com/feathersjs/feathers/commit/aaf181d924d0cb67c7792a54197082c59109264d)) ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package create-feathers ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package create-feathers ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) ### Bug Fixes - Update npm create feathers to ES module ([#3393](https://github.com/feathersjs/feathers/issues/3393)) ([314ce70](https://github.com/feathersjs/feathers/commit/314ce707332eadbea4505e5e7560397632da6205)) ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package create-feathers ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package create-feathers ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package create-feathers ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package create-feathers ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) **Note:** Version bump only for package create-feathers ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package create-feathers ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package create-feathers ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package create-feathers ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package create-feathers ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package create-feathers ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package create-feathers ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) **Note:** Version bump only for package create-feathers ## [5.0.2](https://github.com/feathersjs/feathers/compare/v5.0.1...v5.0.2) (2023-03-23) **Note:** Version bump only for package create-feathers ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package create-feathers # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package create-feathers # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) ### Features - **generators:** Final tweaks to the generators ([#3060](https://github.com/feathersjs/feathers/issues/3060)) ([1bf1544](https://github.com/feathersjs/feathers/commit/1bf1544fa8deeaa44ba354fb539dc3f1fd187767)) # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package create-feathers # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) **Note:** Version bump only for package create-feathers # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) **Note:** Version bump only for package create-feathers # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) **Note:** Version bump only for package create-feathers # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package create-feathers # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package create-feathers # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) **Note:** Version bump only for package create-feathers # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **cli:** Add ability to `npm init feathers` ([#2755](https://github.com/feathersjs/feathers/issues/2755)) ([d734931](https://github.com/feathersjs/feathers/commit/d734931ffd4f983a05d9e771ce0e43b696c2bc0e)) ================================================ FILE: packages/create-feathers/README.md ================================================ # create-feathers [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/configuration.svg?style=flat-square)](https://www.npmjs.com/package/create-feathers) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > Generate a Feathers application through the CLI ## Usage ``` npm create feathers my-app ``` ## Documentation Refer to the [Feathers guides](https://feathersjs.com/guides/) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/create-feathers/bin/create-feathers.js ================================================ #!/usr/bin/env node 'use strict'; import path from 'path' import { existsSync } from 'fs' import { mkdir } from 'fs/promises' import { Command, commandRunner, chalk } from '@feathersjs/cli' const program = new Command() const generateApp = commandRunner('app') program .name('npm init feathers') .description(`Create a new Feathers application 🕊️ ${chalk.grey('npm init feathers myapp')} `) .argument('', 'The name of your new application') // .version(version) .showHelpAfterError() .action(async (name, options) => { try { const cwd = path.join(process.cwd(), name) if (existsSync(cwd)) { throw new Error(`Can not create Feathers application, the folder "${name}" already exists`) } await mkdir(cwd) await generateApp({ name, cwd, ...options }) console.log(` ${chalk.green('Hooray')}! Your Feathers app is ready to go! 🚀 Go to the ${chalk.grey(name)} folder to get started. To learn more visit ${chalk.grey('https://feathersjs.com/guides')} `) } catch (error) { console.error(`${chalk.red('Error')}: ${error.message}`) process.exit(1) } }) program.parse() ================================================ FILE: packages/create-feathers/package.json ================================================ { "name": "create-feathers", "description": "Create a new Feathers application", "version": "5.0.42", "homepage": "https://feathersjs.com", "bin": { "create-feathers": "./bin/create-feathers.js" }, "type": "module", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 18" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "lib/**", "bin/**", "*.d.ts", "*.js" ], "scripts": { "test": "bin/create-feathers.js --help" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/cli": "^5.0.42" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/errors/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/errors ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/errors ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/errors ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/errors ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/errors ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/errors ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/errors ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/errors ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/errors ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/errors ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/errors ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/errors ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/errors ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/errors ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/errors ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/errors ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/errors ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/errors ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/errors ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/errors ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/errors ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/errors ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/errors ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/errors ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/errors ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/errors ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/errors ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/errors ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/errors ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/errors ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package @feathersjs/errors # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) ### Bug Fixes - **errors:** Allows to pass no error message ([#2794](https://github.com/feathersjs/feathers/issues/2794)) ([f3ddab6](https://github.com/feathersjs/feathers/commit/f3ddab637e269e67e852ffce07b060bab2b085c0)) # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) **Note:** Version bump only for package @feathersjs/errors # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### Bug Fixes - **errors:** Format package.json with spaces ([cbd31c1](https://github.com/feathersjs/feathers/commit/cbd31c10c2c574de63d6ca5e55dbfb73a5fdd758)) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### Bug Fixes - **errors:** Format package.json with spaces ([cbd31c1](https://github.com/feathersjs/feathers/commit/cbd31c10c2c574de63d6ca5e55dbfb73a5fdd758)) - **typescript:** Fix `data` property definition in @feathersjs/errors ([#2018](https://github.com/feathersjs/feathers/issues/2018)) ([ef1398c](https://github.com/feathersjs/feathers/commit/ef1398cd5b19efa50929e8c9511ca5684a18997f)) ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) **Note:** Version bump only for package @feathersjs/errors ## [4.5.10](https://github.com/feathersjs/feathers/compare/v4.5.9...v4.5.10) (2020-11-08) **Note:** Version bump only for package @feathersjs/errors ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) **Note:** Version bump only for package @feathersjs/errors ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) **Note:** Version bump only for package @feathersjs/errors ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) **Note:** Version bump only for package @feathersjs/errors ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) **Note:** Version bump only for package @feathersjs/errors ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) ### Bug Fixes - **errors:** Add 410 Gone to errors ([#1849](https://github.com/feathersjs/feathers/issues/1849)) ([6801428](https://github.com/feathersjs/feathers/commit/6801428f8fd17dbfebcdb6f1b0cd01433a4033dc)) ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) **Note:** Version bump only for package @feathersjs/errors ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/errors # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) **Note:** Version bump only for package @feathersjs/errors ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/errors ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/errors # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) **Note:** Version bump only for package @feathersjs/errors ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) **Note:** Version bump only for package @feathersjs/errors ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/errors ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) ### Bug Fixes - Small type improvements ([#1624](https://github.com/feathersjs/feathers/issues/1624)) ([50162c6](https://github.com/feathersjs/feathers/commit/50162c6e562f0a47c6a280c4f01fff7c3afee293)) ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) **Note:** Version bump only for package @feathersjs/errors ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) **Note:** Version bump only for package @feathersjs/errors ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) **Note:** Version bump only for package @feathersjs/errors ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) **Note:** Version bump only for package @feathersjs/errors ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) **Note:** Version bump only for package @feathersjs/errors # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/errors # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/errors # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) **Note:** Version bump only for package @feathersjs/errors # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) **Note:** Version bump only for package @feathersjs/errors # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/errors # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) **Note:** Version bump only for package @feathersjs/errors # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) **Note:** Version bump only for package @feathersjs/errors # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) ### Bug Fixes - Use `export =` in TypeScript definitions ([#1285](https://github.com/feathersjs/feathers/issues/1285)) ([12d0f4b](https://github.com/feathersjs/feathers/commit/12d0f4b)) # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) ### Bug Fixes - Do not log as errors below a 500 response ([#1256](https://github.com/feathersjs/feathers/issues/1256)) ([33fd0e4](https://github.com/feathersjs/feathers/commit/33fd0e4)) # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - Update 401.html ([#983](https://github.com/feathersjs/feathers/issues/983)) ([cec6bae](https://github.com/feathersjs/feathers/commit/cec6bae)) - Update 404.html ([#984](https://github.com/feathersjs/feathers/issues/984)) ([72132d1](https://github.com/feathersjs/feathers/commit/72132d1)) - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) - **compile-task:** on windows machine ([#60](https://github.com/feathersjs/feathers/issues/60)) ([617e0a4](https://github.com/feathersjs/feathers/commit/617e0a4)) - **package:** update debug to version 3.0.0 ([#86](https://github.com/feathersjs/feathers/issues/86)) ([fd1bb6b](https://github.com/feathersjs/feathers/commit/fd1bb6b)) ### Features - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - Authentication v3 core server implementation ([#1205](https://github.com/feathersjs/feathers/issues/1205)) ([1bd7591](https://github.com/feathersjs/feathers/commit/1bd7591)) ## [3.3.6](https://github.com/feathersjs/feathers/compare/@feathersjs/errors@3.3.5...@feathersjs/errors@3.3.6) (2019-01-02) ### Bug Fixes - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) ## [3.3.5](https://github.com/feathersjs/feathers/compare/@feathersjs/errors@3.3.4...@feathersjs/errors@3.3.5) (2018-12-16) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) ## [3.3.4](https://github.com/feathersjs/feathers/compare/@feathersjs/errors@3.3.3...@feathersjs/errors@3.3.4) (2018-09-21) **Note:** Version bump only for package @feathersjs/errors ## [3.3.3](https://github.com/feathersjs/feathers/compare/@feathersjs/errors@3.3.2...@feathersjs/errors@3.3.3) (2018-09-17) ### Bug Fixes - Update 401.html ([#983](https://github.com/feathersjs/feathers/issues/983)) ([cec6bae](https://github.com/feathersjs/feathers/commit/cec6bae)) - Update 404.html ([#984](https://github.com/feathersjs/feathers/issues/984)) ([72132d1](https://github.com/feathersjs/feathers/commit/72132d1)) ## [3.3.2](https://github.com/feathersjs/feathers/compare/@feathersjs/errors@3.3.1...@feathersjs/errors@3.3.2) (2018-09-02) **Note:** Version bump only for package @feathersjs/errors ## 3.3.1 - Migrate to Monorepo ([feathers#462](https://github.com/feathersjs/feathers/issues/462)) ## [v3.3.0](https://github.com/feathersjs/errors/tree/v3.3.0) (2018-02-12) [Full Changelog](https://github.com/feathersjs/errors/compare/v3.2.2...v3.3.0) **Closed issues:** - How to handling error from Hook function when I use Aync/Await in Hook function [\#106](https://github.com/feathersjs/errors/issues/106) **Merged pull requests:** - Add a verbose flag to notFound handler [\#107](https://github.com/feathersjs/errors/pull/107) ([daffl](https://github.com/daffl)) - Add req.url to notFound handler message [\#105](https://github.com/feathersjs/errors/pull/105) ([FreeLineTM](https://github.com/FreeLineTM)) ## [v3.2.2](https://github.com/feathersjs/errors/tree/v3.2.2) (2018-01-23) [Full Changelog](https://github.com/feathersjs/errors/compare/v3.2.1...v3.2.2) **Closed issues:** - Handling Status Codes [\#103](https://github.com/feathersjs/errors/issues/103) - Override default error page [\#102](https://github.com/feathersjs/errors/issues/102) - wrong npm package in Installation instructions [\#100](https://github.com/feathersjs/errors/issues/100) **Merged pull requests:** - Fix instanceof and prototypical inheritance [\#104](https://github.com/feathersjs/errors/pull/104) ([nikaspran](https://github.com/nikaspran)) - Update mocha to the latest version 🚀 [\#101](https://github.com/feathersjs/errors/pull/101) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - fix installation declaration [\#99](https://github.com/feathersjs/errors/pull/99) ([jasonmacgowan](https://github.com/jasonmacgowan)) ## [v3.2.1](https://github.com/feathersjs/errors/tree/v3.2.1) (2018-01-03) [Full Changelog](https://github.com/feathersjs/errors/compare/v3.2.0...v3.2.1) **Closed issues:** - Error handler usage/setup is mis-documented [\#96](https://github.com/feathersjs/errors/issues/96) **Merged pull requests:** - Update readme to correspond with latest release [\#98](https://github.com/feathersjs/errors/pull/98) ([daffl](https://github.com/daffl)) - Update semistandard to the latest version 🚀 [\#97](https://github.com/feathersjs/errors/pull/97) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v3.2.0](https://github.com/feathersjs/errors/tree/v3.2.0) (2017-11-19) [Full Changelog](https://github.com/feathersjs/errors/compare/v3.1.0...v3.2.0) **Merged pull requests:** - Allow ability to log middleware errors [\#95](https://github.com/feathersjs/errors/pull/95) ([daffl](https://github.com/daffl)) ## [v3.1.0](https://github.com/feathersjs/errors/tree/v3.1.0) (2017-11-18) [Full Changelog](https://github.com/feathersjs/errors/compare/v3.0.0...v3.1.0) **Closed issues:** - feature: allow for mixed files/functions for error-handler options [\#91](https://github.com/feathersjs/errors/issues/91) **Merged pull requests:** - 91 allow mixed config [\#94](https://github.com/feathersjs/errors/pull/94) ([DesignByOnyx](https://github.com/DesignByOnyx)) ## [v3.0.0](https://github.com/feathersjs/errors/tree/v3.0.0) (2017-11-01) [Full Changelog](https://github.com/feathersjs/errors/compare/v3.0.0-pre.1...v3.0.0) **Merged pull requests:** - Update to Buzzard infrastructure [\#93](https://github.com/feathersjs/errors/pull/93) ([daffl](https://github.com/daffl)) ## [v3.0.0-pre.1](https://github.com/feathersjs/errors/tree/v3.0.0-pre.1) (2017-10-21) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.9.2...v3.0.0-pre.1) **Closed issues:** - \[Proposal\] use verror [\#88](https://github.com/feathersjs/errors/issues/88) **Merged pull requests:** - Update to new plugin infrastructure and npm scope [\#92](https://github.com/feathersjs/errors/pull/92) ([daffl](https://github.com/daffl)) - Update mocha to the latest version 🚀 [\#90](https://github.com/feathersjs/errors/pull/90) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update sinon to the latest version 🚀 [\#89](https://github.com/feathersjs/errors/pull/89) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.9.2](https://github.com/feathersjs/errors/tree/v2.9.2) (2017-09-05) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.9.1...v2.9.2) **Closed issues:** - Getting 500 status code when attempting to throw non 500 style errors \(401\) [\#85](https://github.com/feathersjs/errors/issues/85) **Merged pull requests:** - fix typings [\#87](https://github.com/feathersjs/errors/pull/87) ([j2L4e](https://github.com/j2L4e)) - Update debug to the latest version 🚀 [\#86](https://github.com/feathersjs/errors/pull/86) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update sinon to the latest version 🚀 [\#84](https://github.com/feathersjs/errors/pull/84) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.9.1](https://github.com/feathersjs/errors/tree/v2.9.1) (2017-07-21) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.9.0...v2.9.1) **Merged pull requests:** - Add back default error message [\#83](https://github.com/feathersjs/errors/pull/83) ([daffl](https://github.com/daffl)) ## [v2.9.0](https://github.com/feathersjs/errors/tree/v2.9.0) (2017-07-20) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.8.2...v2.9.0) **Closed issues:** - Wrong stack for errors [\#78](https://github.com/feathersjs/errors/issues/78) **Merged pull requests:** - Capture proper stack trace and error messages [\#82](https://github.com/feathersjs/errors/pull/82) ([daffl](https://github.com/daffl)) - Update chai to the latest version 🚀 [\#81](https://github.com/feathersjs/errors/pull/81) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.8.2](https://github.com/feathersjs/errors/tree/v2.8.2) (2017-07-05) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.8.1...v2.8.2) **Merged pull requests:** - Fix wildcard import on ES2015+ [\#80](https://github.com/feathersjs/errors/pull/80) ([coreh](https://github.com/coreh)) - Add more information to error debug [\#79](https://github.com/feathersjs/errors/pull/79) ([kamzil](https://github.com/kamzil)) ## [v2.8.1](https://github.com/feathersjs/errors/tree/v2.8.1) (2017-05-30) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.8.0...v2.8.1) **Merged pull requests:** - Fix errors property being lost when cloning [\#76](https://github.com/feathersjs/errors/pull/76) ([0x6431346e](https://github.com/0x6431346e)) ## [v2.8.0](https://github.com/feathersjs/errors/tree/v2.8.0) (2017-05-08) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.7.1...v2.8.0) **Closed issues:** - Support array objects as data [\#64](https://github.com/feathersjs/errors/issues/64) **Merged pull requests:** - Allow data to be an array [\#75](https://github.com/feathersjs/errors/pull/75) ([0x6431346e](https://github.com/0x6431346e)) ## [v2.7.1](https://github.com/feathersjs/errors/tree/v2.7.1) (2017-04-28) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.7.0...v2.7.1) **Closed issues:** - Object.setPrototypeOf in IE 10 [\#70](https://github.com/feathersjs/errors/issues/70) **Merged pull requests:** - Define property toJSON because just assigning it throws an error in N… [\#74](https://github.com/feathersjs/errors/pull/74) ([daffl](https://github.com/daffl)) ## [v2.7.0](https://github.com/feathersjs/errors/tree/v2.7.0) (2017-04-25) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.6.3...v2.7.0) **Merged pull requests:** - Change back to old Error inheritance [\#73](https://github.com/feathersjs/errors/pull/73) ([daffl](https://github.com/daffl)) - Update semistandard to the latest version 🚀 [\#72](https://github.com/feathersjs/errors/pull/72) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update dependencies to enable Greenkeeper 🌴 [\#71](https://github.com/feathersjs/errors/pull/71) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.6.3](https://github.com/feathersjs/errors/tree/v2.6.3) (2017-04-08) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.6.2...v2.6.3) **Closed issues:** - Make options the same as res.format [\#37](https://github.com/feathersjs/errors/issues/37) **Merged pull requests:** - fix typescript definitions with noImplicitAny [\#69](https://github.com/feathersjs/errors/pull/69) ([JVirant](https://github.com/JVirant)) ## [v2.6.2](https://github.com/feathersjs/errors/tree/v2.6.2) (2017-03-16) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.6.1...v2.6.2) **Closed issues:** - Create a TokenExpired error type [\#53](https://github.com/feathersjs/errors/issues/53) **Merged pull requests:** - Fix declarations for index.d.ts [\#66](https://github.com/feathersjs/errors/pull/66) ([ghost](https://github.com/ghost)) ## [v2.6.1](https://github.com/feathersjs/errors/tree/v2.6.1) (2017-03-06) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.6.0...v2.6.1) **Merged pull requests:** - fix pull request \#62 [\#63](https://github.com/feathersjs/errors/pull/63) ([superbarne](https://github.com/superbarne)) ## [v2.6.0](https://github.com/feathersjs/errors/tree/v2.6.0) (2017-03-04) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.5.0...v2.6.0) **Closed issues:** - Full Validation Error Object not passed to client promise [\#61](https://github.com/feathersjs/errors/issues/61) - More HTTP Statuses [\#48](https://github.com/feathersjs/errors/issues/48) **Merged pull requests:** - add typescript definitions [\#62](https://github.com/feathersjs/errors/pull/62) ([superbarne](https://github.com/superbarne)) - Fix compile npm task on Windows [\#60](https://github.com/feathersjs/errors/pull/60) ([AbraaoAlves](https://github.com/AbraaoAlves)) ## [v2.5.0](https://github.com/feathersjs/errors/tree/v2.5.0) (2016-11-04) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.4.0...v2.5.0) **Closed issues:** - Possible issue with Node 4 [\#51](https://github.com/feathersjs/errors/issues/51) - Consider using restify/errors as base [\#31](https://github.com/feathersjs/errors/issues/31) **Merged pull requests:** - Adding more error types [\#55](https://github.com/feathersjs/errors/pull/55) ([franciscofsales](https://github.com/franciscofsales)) - 👻😱 Node.js 0.10 is unmaintained 😱👻 [\#54](https://github.com/feathersjs/errors/pull/54) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - jshint —\> semistandard [\#52](https://github.com/feathersjs/errors/pull/52) ([corymsmith](https://github.com/corymsmith)) - Update mocha to version 3.0.0 🚀 [\#47](https://github.com/feathersjs/errors/pull/47) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v2.4.0](https://github.com/feathersjs/errors/tree/v2.4.0) (2016-07-17) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.3.0...v2.4.0) **Merged pull requests:** - adding ability to get a feathers error by http status code [\#46](https://github.com/feathersjs/errors/pull/46) ([ekryski](https://github.com/ekryski)) ## [v2.3.0](https://github.com/feathersjs/errors/tree/v2.3.0) (2016-07-10) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.2.0...v2.3.0) **Closed issues:** - Heroku error Reflect.construct [\#44](https://github.com/feathersjs/errors/issues/44) **Merged pull requests:** - Not found [\#45](https://github.com/feathersjs/errors/pull/45) ([ekryski](https://github.com/ekryski)) ## [v2.2.0](https://github.com/feathersjs/errors/tree/v2.2.0) (2016-05-27) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.1.0...v2.2.0) **Closed issues:** - Can not format error to json [\#35](https://github.com/feathersjs/errors/issues/35) **Merged pull requests:** - Add an error conversion method [\#43](https://github.com/feathersjs/errors/pull/43) ([daffl](https://github.com/daffl)) - mocha@2.5.0 breaks build 🚨 [\#42](https://github.com/feathersjs/errors/pull/42) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update babel-plugin-add-module-exports to version 0.2.0 🚀 [\#41](https://github.com/feathersjs/errors/pull/41) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v2.1.0](https://github.com/feathersjs/errors/tree/v2.1.0) (2016-04-03) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.0.2...v2.1.0) **Closed issues:** - Support passing a custom html format function [\#32](https://github.com/feathersjs/errors/issues/32) **Merged pull requests:** - Custom handlers [\#36](https://github.com/feathersjs/errors/pull/36) ([ekryski](https://github.com/ekryski)) - Update all dependencies 🌴 [\#34](https://github.com/feathersjs/errors/pull/34) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v2.0.2](https://github.com/feathersjs/errors/tree/v2.0.2) (2016-03-23) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.0.1...v2.0.2) **Closed issues:** - ReferenceError: Reflect is not defined [\#29](https://github.com/feathersjs/errors/issues/29) - Make error pages opt-in [\#24](https://github.com/feathersjs/errors/issues/24) **Merged pull requests:** - Update package.json [\#33](https://github.com/feathersjs/errors/pull/33) ([marshallswain](https://github.com/marshallswain)) - Fixed typo [\#30](https://github.com/feathersjs/errors/pull/30) ([kulakowka](https://github.com/kulakowka)) ## [v2.0.1](https://github.com/feathersjs/errors/tree/v2.0.1) (2016-02-24) [Full Changelog](https://github.com/feathersjs/errors/compare/v2.0.0...v2.0.1) **Closed issues:** - Error handler is wrapping errors as GeneralErrors [\#27](https://github.com/feathersjs/errors/issues/27) **Merged pull requests:** - adding an explicit error type [\#28](https://github.com/feathersjs/errors/pull/28) ([ekryski](https://github.com/ekryski)) ## [v2.0.0](https://github.com/feathersjs/errors/tree/v2.0.0) (2016-02-24) [Full Changelog](https://github.com/feathersjs/errors/compare/v1.2.4...v2.0.0) **Merged pull requests:** - move error handler out of index [\#26](https://github.com/feathersjs/errors/pull/26) ([ekryski](https://github.com/ekryski)) ## [v1.2.4](https://github.com/feathersjs/errors/tree/v1.2.4) (2016-02-24) [Full Changelog](https://github.com/feathersjs/errors/compare/v1.2.3...v1.2.4) ## [v1.2.3](https://github.com/feathersjs/errors/tree/v1.2.3) (2016-02-21) [Full Changelog](https://github.com/feathersjs/errors/compare/v1.2.2...v1.2.3) **Merged pull requests:** - Adding default error page and make HTML formatting optional [\#25](https://github.com/feathersjs/errors/pull/25) ([daffl](https://github.com/daffl)) ## [v1.2.2](https://github.com/feathersjs/errors/tree/v1.2.2) (2016-02-18) [Full Changelog](https://github.com/feathersjs/errors/compare/v1.2.1...v1.2.2) **Closed issues:** - Add error handler back [\#21](https://github.com/feathersjs/errors/issues/21) **Merged pull requests:** - Make fully CommonJS compatible and add error middleware tests [\#23](https://github.com/feathersjs/errors/pull/23) ([daffl](https://github.com/daffl)) ## [v1.2.1](https://github.com/feathersjs/errors/tree/v1.2.1) (2016-02-16) [Full Changelog](https://github.com/feathersjs/errors/compare/v1.2.0...v1.2.1) ## [v1.2.0](https://github.com/feathersjs/errors/tree/v1.2.0) (2016-02-15) [Full Changelog](https://github.com/feathersjs/errors/compare/v1.1.6...v1.2.0) **Closed issues:** - Check to make sure that errors propagate via web sockets [\#1](https://github.com/feathersjs/errors/issues/1) **Merged pull requests:** - adding error handler back [\#22](https://github.com/feathersjs/errors/pull/22) ([ekryski](https://github.com/ekryski)) ## [v1.1.6](https://github.com/feathersjs/errors/tree/v1.1.6) (2016-01-12) [Full Changelog](https://github.com/feathersjs/errors/compare/v1.1.5...v1.1.6) **Closed issues:** - stacktraces are incorrect when used in an ES6 app [\#20](https://github.com/feathersjs/errors/issues/20) - We shouldn't mutate the error object passed in. [\#19](https://github.com/feathersjs/errors/issues/19) - only one instance of babel-polyfill is allowed [\#17](https://github.com/feathersjs/errors/issues/17) ## [v1.1.5](https://github.com/feathersjs/errors/tree/v1.1.5) (2015-12-18) [Full Changelog](https://github.com/feathersjs/errors/compare/v1.1.4...v1.1.5) ## [v1.1.4](https://github.com/feathersjs/errors/tree/v1.1.4) (2015-12-15) [Full Changelog](https://github.com/feathersjs/errors/compare/v1.1.3...v1.1.4) **Closed issues:** - no method 'setPrototypeOf' in Node 0.10 [\#16](https://github.com/feathersjs/errors/issues/16) ## [v1.1.3](https://github.com/feathersjs/errors/tree/v1.1.3) (2015-12-15) [Full Changelog](https://github.com/feathersjs/errors/compare/v1.1.2...v1.1.3) ## [v1.1.2](https://github.com/feathersjs/errors/tree/v1.1.2) (2015-12-15) [Full Changelog](https://github.com/feathersjs/errors/compare/v1.1.1...v1.1.2) **Closed issues:** - Passing errors as second argument [\#9](https://github.com/feathersjs/errors/issues/9) ## [v1.1.1](https://github.com/feathersjs/errors/tree/v1.1.1) (2015-12-14) [Full Changelog](https://github.com/feathersjs/errors/compare/v1.1.0...v1.1.1) **Closed issues:** - Subclassing Errors using babel don't behave as expected [\#14](https://github.com/feathersjs/errors/issues/14) **Merged pull requests:** - Es6 class fix [\#15](https://github.com/feathersjs/errors/pull/15) ([ekryski](https://github.com/ekryski)) ## [v1.1.0](https://github.com/feathersjs/errors/tree/v1.1.0) (2015-12-12) [Full Changelog](https://github.com/feathersjs/errors/compare/v1.0.0...v1.1.0) ## [v1.0.0](https://github.com/feathersjs/errors/tree/v1.0.0) (2015-12-12) [Full Changelog](https://github.com/feathersjs/errors/compare/0.2.5...v1.0.0) **Closed issues:** - Convert to ES6 [\#12](https://github.com/feathersjs/errors/issues/12) - Drop the error handlers: Breaking Change [\#11](https://github.com/feathersjs/errors/issues/11) - Remove Lodash dependency [\#10](https://github.com/feathersjs/errors/issues/10) - Logging only unhandled errors [\#8](https://github.com/feathersjs/errors/issues/8) **Merged pull requests:** - complete rewrite. Closes \#11 and \#12. [\#13](https://github.com/feathersjs/errors/pull/13) ([ekryski](https://github.com/ekryski)) ## [0.2.5](https://github.com/feathersjs/errors/tree/0.2.5) (2015-02-05) [Full Changelog](https://github.com/feathersjs/errors/compare/0.2.4...0.2.5) ## [0.2.4](https://github.com/feathersjs/errors/tree/0.2.4) (2015-02-05) [Full Changelog](https://github.com/feathersjs/errors/compare/0.2.3...0.2.4) ## [0.2.3](https://github.com/feathersjs/errors/tree/0.2.3) (2015-01-29) [Full Changelog](https://github.com/feathersjs/errors/compare/0.2.2...0.2.3) ## [0.2.2](https://github.com/feathersjs/errors/tree/0.2.2) (2015-01-29) [Full Changelog](https://github.com/feathersjs/errors/compare/0.2.1...0.2.2) ## [0.2.1](https://github.com/feathersjs/errors/tree/0.2.1) (2014-09-03) [Full Changelog](https://github.com/feathersjs/errors/compare/0.2.0...0.2.1) ## [0.2.0](https://github.com/feathersjs/errors/tree/0.2.0) (2014-07-17) [Full Changelog](https://github.com/feathersjs/errors/compare/0.1.7...0.2.0) **Implemented enhancements:** - Handle error objects with an 'errors' object [\#5](https://github.com/feathersjs/errors/issues/5) ## [0.1.7](https://github.com/feathersjs/errors/tree/0.1.7) (2014-07-06) [Full Changelog](https://github.com/feathersjs/errors/compare/0.1.6...0.1.7) ## [0.1.6](https://github.com/feathersjs/errors/tree/0.1.6) (2014-07-05) [Full Changelog](https://github.com/feathersjs/errors/compare/0.1.5...0.1.6) ## [0.1.5](https://github.com/feathersjs/errors/tree/0.1.5) (2014-06-13) [Full Changelog](https://github.com/feathersjs/errors/compare/0.1.4...0.1.5) ## [0.1.4](https://github.com/feathersjs/errors/tree/0.1.4) (2014-06-13) [Full Changelog](https://github.com/feathersjs/errors/compare/0.1.3...0.1.4) **Closed issues:** - Move errors into core [\#2](https://github.com/feathersjs/errors/issues/2) **Merged pull requests:** - Core compatible [\#4](https://github.com/feathersjs/errors/pull/4) ([ekryski](https://github.com/ekryski)) ## [0.1.3](https://github.com/feathersjs/errors/tree/0.1.3) (2014-06-09) [Full Changelog](https://github.com/feathersjs/errors/compare/0.1.2...0.1.3) **Merged pull requests:** - Adding a default error page [\#3](https://github.com/feathersjs/errors/pull/3) ([ekryski](https://github.com/ekryski)) ## [0.1.2](https://github.com/feathersjs/errors/tree/0.1.2) (2014-06-05) [Full Changelog](https://github.com/feathersjs/errors/compare/0.1.1...0.1.2) ## [0.1.1](https://github.com/feathersjs/errors/tree/0.1.1) (2014-06-04) [Full Changelog](https://github.com/feathersjs/errors/compare/v0.1.0...0.1.1) ## [v0.1.0](https://github.com/feathersjs/errors/tree/v0.1.0) (2014-06-04) \* _This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)_ ================================================ FILE: packages/errors/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/errors/README.md ================================================ # @feathersjs/errors [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/errors.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/errors) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > Common error types for feathers apps ## Installation ``` npm install @feathersjs/errors --save ``` ## Documentation Refer to the [Feathers errors API documentation](https://feathersjs.com/api/errors.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/errors/package.json ================================================ { "name": "@feathersjs/errors", "description": "Common error types for Feathers apps", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/errors" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "directories": { "lib": "lib" }, "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "publishConfig": { "access": "public" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "devDependencies": { "@feathersjs/feathers": "^5.0.42", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "mocha": "^11.7.5", "shx": "^0.4.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/errors/src/index.ts ================================================ export interface FeathersErrorJSON { name: string message: string code: number className: string data?: any errors?: any } export type DynamicError = Error & { [key: string]: any } export type ErrorMessage = null | string | DynamicError | { [key: string]: any } | any[] interface ErrorProperties extends Omit { type: string } export class FeathersError extends Error { readonly type: string readonly code: number readonly className: string readonly data: any readonly errors: any constructor(err: ErrorMessage, name: string, code: number, className: string, _data: any) { let msg = typeof err === 'string' ? err : 'Error' const properties: ErrorProperties = { name, code, className, type: 'FeathersError' } if (Array.isArray(_data)) { properties.data = _data } else if (typeof err === 'object' || _data !== undefined) { const { message, errors, ...rest } = err !== null && typeof err === 'object' ? err : _data msg = message || msg properties.errors = errors properties.data = rest } super(msg) Object.assign(this, properties) } toJSON() { const result: FeathersErrorJSON = { name: this.name, message: this.message, code: this.code, className: this.className } if (this.data !== undefined) { result.data = this.data } if (this.errors !== undefined) { result.errors = this.errors } return result } } export class BadRequest extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'BadRequest', 400, 'bad-request', data) } } // 401 - Not Authenticated export class NotAuthenticated extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'NotAuthenticated', 401, 'not-authenticated', data) } } // 402 - Payment Error export class PaymentError extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'PaymentError', 402, 'payment-error', data) } } // 403 - Forbidden export class Forbidden extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'Forbidden', 403, 'forbidden', data) } } // 404 - Not Found export class NotFound extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'NotFound', 404, 'not-found', data) } } // 405 - Method Not Allowed export class MethodNotAllowed extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'MethodNotAllowed', 405, 'method-not-allowed', data) } } // 406 - Not Acceptable export class NotAcceptable extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'NotAcceptable', 406, 'not-acceptable', data) } } // 408 - Timeout export class Timeout extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'Timeout', 408, 'timeout', data) } } // 409 - Conflict export class Conflict extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'Conflict', 409, 'conflict', data) } } // 410 - Gone export class Gone extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'Gone', 410, 'gone', data) } } // 411 - Length Required export class LengthRequired extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'LengthRequired', 411, 'length-required', data) } } // 422 Unprocessable export class Unprocessable extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'Unprocessable', 422, 'unprocessable', data) } } // 429 Too Many Requests export class TooManyRequests extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'TooManyRequests', 429, 'too-many-requests', data) } } // 500 - General Error export class GeneralError extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'GeneralError', 500, 'general-error', data) } } // 501 - Not Implemented export class NotImplemented extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'NotImplemented', 501, 'not-implemented', data) } } // 502 - Bad Gateway export class BadGateway extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'BadGateway', 502, 'bad-gateway', data) } } // 503 - Unavailable export class Unavailable extends FeathersError { constructor(message?: ErrorMessage, data?: any) { super(message, 'Unavailable', 503, 'unavailable', data) } } export interface Errors { FeathersError: FeathersError BadRequest: BadRequest NotAuthenticated: NotAuthenticated PaymentError: PaymentError Forbidden: Forbidden NotFound: NotFound MethodNotAllowed: MethodNotAllowed NotAcceptable: NotAcceptable Timeout: Timeout Conflict: Conflict LengthRequired: LengthRequired Unprocessable: Unprocessable TooManyRequests: TooManyRequests GeneralError: GeneralError NotImplemented: NotImplemented BadGateway: BadGateway Unavailable: Unavailable 400: BadRequest 401: NotAuthenticated 402: PaymentError 403: Forbidden 404: NotFound 405: MethodNotAllowed 406: NotAcceptable 408: Timeout 409: Conflict 411: LengthRequired 422: Unprocessable 429: TooManyRequests 500: GeneralError 501: NotImplemented 502: BadGateway 503: Unavailable } export const errors = { FeathersError, BadRequest, NotAuthenticated, PaymentError, Forbidden, NotFound, MethodNotAllowed, NotAcceptable, Timeout, Conflict, LengthRequired, Unprocessable, TooManyRequests, GeneralError, NotImplemented, BadGateway, Unavailable, 400: BadRequest, 401: NotAuthenticated, 402: PaymentError, 403: Forbidden, 404: NotFound, 405: MethodNotAllowed, 406: NotAcceptable, 408: Timeout, 409: Conflict, 410: Gone, 411: LengthRequired, 422: Unprocessable, 429: TooManyRequests, 500: GeneralError, 501: NotImplemented, 502: BadGateway, 503: Unavailable } export function convert(error: any) { if (!error) { return error } const FeathersError = (errors as any)[error.name] const result = FeathersError ? new FeathersError(error.message, error.data) : new Error(error.message || error) if (typeof error === 'object') { Object.assign(result, error) } return result } ================================================ FILE: packages/errors/test/index.test.ts ================================================ import assert from 'assert' import * as errors from '../src' const { convert } = errors describe('@feathersjs/errors', () => { describe('errors.convert', () => { it('converts objects to feathers errors', () => { const error = convert({ name: 'BadRequest', message: 'Hi', expando: 'Me' }) assert.strictEqual(error.message, 'Hi') assert.strictEqual(error.expando, 'Me') assert.ok(error instanceof errors.BadRequest) }) it('converts other object to error', () => { let error = convert({ message: 'Something went wrong' }) assert.ok(error instanceof Error) assert.strictEqual(error.message, 'Something went wrong') error = convert('Something went wrong') assert.ok(error instanceof Error) assert.strictEqual(error.message, 'Something went wrong') }) it('converts nothing', () => assert.strictEqual(convert(null), null)) }) describe('error types', () => { it('Bad Request', () => { assert.notStrictEqual(typeof errors.BadRequest, 'undefined', 'has BadRequest') }) it('Not Authenticated', () => { assert.notStrictEqual(typeof errors.NotAuthenticated, 'undefined', 'has NotAuthenticated') }) it('Payment Error', () => { assert.notStrictEqual(typeof errors.PaymentError, 'undefined', 'has PaymentError') }) it('Forbidden', () => { assert.notStrictEqual(typeof errors.Forbidden, 'undefined', 'has Forbidden') }) it('Not Found', () => { assert.notStrictEqual(typeof errors.NotFound, 'undefined', 'has NotFound') }) it('Method Not Allowed', () => { assert.notStrictEqual(typeof errors.MethodNotAllowed, 'undefined', 'has MethodNotAllowed') }) it('Not Acceptable', () => { assert.notStrictEqual(typeof errors.NotAcceptable, 'undefined', 'has NotAcceptable') }) it('Timeout', () => { assert.notStrictEqual(typeof errors.Timeout, 'undefined', 'has Timeout') }) it('Conflict', () => { assert.notStrictEqual(typeof errors.Conflict, 'undefined', 'has Conflict') }) it('Gone', () => { assert.notStrictEqual(typeof errors.Gone, 'undefined', 'has Gone') }) it('Length Required', () => { assert.notStrictEqual(typeof errors.LengthRequired, 'undefined', 'has LengthRequired') }) it('Unprocessable', () => { assert.notStrictEqual(typeof errors.Unprocessable, 'undefined', 'has Unprocessable') }) it('Too Many Requests', () => { assert.notStrictEqual(typeof errors.TooManyRequests, 'undefined', 'has TooManyRequests') }) it('General Error', () => { assert.notStrictEqual(typeof errors.GeneralError, 'undefined', 'has GeneralError') }) it('Not Implemented', () => { assert.notStrictEqual(typeof errors.NotImplemented, 'undefined', 'has NotImplemented') }) it('Bad Gateway', () => { assert.notStrictEqual(typeof errors.BadGateway, 'undefined', 'has BadGateway') }) it('Unavailable', () => { assert.notStrictEqual(typeof errors.Unavailable, 'undefined', 'has Unavailable') }) it('400', () => { assert.notStrictEqual(typeof errors.errors[400], 'undefined', 'has BadRequest alias') }) it('401', () => { assert.notStrictEqual(typeof errors.errors[401], 'undefined', 'has NotAuthenticated alias') }) it('402', () => { assert.notStrictEqual(typeof errors.errors[402], 'undefined', 'has PaymentError alias') }) it('403', () => { assert.notStrictEqual(typeof errors.errors[403], 'undefined', 'has Forbidden alias') }) it('404', () => { assert.notStrictEqual(typeof errors.errors[404], 'undefined', 'has NotFound alias') }) it('405', () => { assert.notStrictEqual(typeof errors.errors[405], 'undefined', 'has MethodNotAllowed alias') }) it('406', () => { assert.notStrictEqual(typeof errors.errors[406], 'undefined', 'has NotAcceptable alias') }) it('408', () => { assert.notStrictEqual(typeof errors.errors[408], 'undefined', 'has Timeout alias') }) it('409', () => { assert.notStrictEqual(typeof errors.errors[409], 'undefined', 'has Conflict alias') }) it('410', () => { assert.notStrictEqual(typeof errors.errors[410], 'undefined', 'has Gone alias') }) it('411', () => { assert.notStrictEqual(typeof errors.errors[411], 'undefined', 'has LengthRequired alias') }) it('422', () => { assert.notStrictEqual(typeof errors.errors[422], 'undefined', 'has Unprocessable alias') }) it('429', () => { assert.notStrictEqual(typeof errors.errors[429], 'undefined', 'has TooManyRequests alias') }) it('500', () => { assert.notStrictEqual(typeof errors.errors[500], 'undefined', 'has GeneralError alias') }) it('501', () => { assert.notStrictEqual(typeof errors.errors[501], 'undefined', 'has NotImplemented alias') }) it('502', () => { assert.notStrictEqual(typeof errors.errors[502], 'undefined', 'has BadGateway alias') }) it('503', () => { assert.notStrictEqual(typeof errors.errors[503], 'undefined', 'has Unavailable alias') }) it('instantiates every error', () => { const index: any = errors.errors Object.keys(index).forEach((name) => { const E = index[name] if (E) { // tslint:disable-next-line new E('Something went wrong') } }) }) }) describe('inheritance', () => { it('instanceof differentiates between error types', () => { const error = new errors.MethodNotAllowed() assert.ok(!(error instanceof errors.BadRequest)) }) it('follows the prototypical inheritance chain', () => { const error = new errors.MethodNotAllowed() assert.ok(error instanceof Error) assert.ok(error instanceof errors.FeathersError) }) it('has the correct constructors', () => { const error = new errors.NotFound() assert.ok(error.constructor === errors.NotFound) assert.ok(error.constructor.name === 'NotFound') }) }) describe('successful error creation', () => { describe('without custom message', () => { it('default error', () => { const error = new errors.GeneralError() assert.strictEqual(error.code, 500) assert.strictEqual(error.className, 'general-error') assert.strictEqual(error.message, 'Error') assert.strictEqual(error.data, undefined) assert.strictEqual(error.errors, undefined) assert.notStrictEqual(error.stack, undefined) assert.strictEqual(error instanceof errors.GeneralError, true) assert.strictEqual(error instanceof errors.FeathersError, true) }) it('can wrap an existing error', () => { const error = new errors.BadRequest(new Error()) assert.strictEqual(error.code, 400) assert.strictEqual(error.message, 'Error') }) it('with multiple errors', () => { const data = { errors: { email: 'Email Taken', password: 'Invalid Password' }, foo: 'bar' } const error = new errors.BadRequest(data) assert.strictEqual(error.code, 400) assert.strictEqual(error.message, 'Error') assert.deepStrictEqual(error.errors, { email: 'Email Taken', password: 'Invalid Password' }) assert.deepStrictEqual(error.data, { foo: 'bar' }) }) it('with data', () => { const data = { email: 'Email Taken', password: 'Invalid Password' } const error = new errors.GeneralError(data) assert.strictEqual(error.code, 500) assert.strictEqual(error.message, 'Error') assert.deepStrictEqual(error.data, data) }) }) describe('with custom message', () => { it('contains our message', () => { const error = new errors.BadRequest('Invalid Password') assert.strictEqual(error.code, 400) assert.strictEqual(error.message, 'Invalid Password') }) it('can wrap an existing error', () => { const error = new errors.BadRequest(new Error('Invalid Password')) assert.strictEqual(error.code, 400) assert.strictEqual(error.message, 'Invalid Password') }) it('with data', () => { const data = { email: 'Email Taken', password: 'Invalid Password' } const error = new errors.GeneralError('Custom Error', data) assert.strictEqual(error.code, 500) assert.strictEqual(error.message, 'Custom Error') assert.deepStrictEqual(error.data, data) }) it('with multiple errors', () => { const data = { errors: { email: 'Email Taken', password: 'Invalid Password' }, foo: 'bar' } const error = new errors.BadRequest(data) assert.strictEqual(error.code, 400) assert.strictEqual(error.message, 'Error') assert.deepStrictEqual(error.errors, { email: 'Email Taken', password: 'Invalid Password' }) assert.deepStrictEqual(error.data, { foo: 'bar' }) }) }) it('can return JSON', () => { const data = { errors: { email: 'Email Taken', password: 'Invalid Password' }, foo: 'bar' } const expected = '{"name":"GeneralError","message":"Custom Error","code":500,"className":"general-error","data":{"foo":"bar"},"errors":{"email":"Email Taken","password":"Invalid Password"}}' const error = new errors.GeneralError('Custom Error', data) assert.strictEqual(JSON.stringify(error), expected) }) it('can handle immutable data', () => { const data = { errors: { email: 'Email Taken', password: 'Invalid Password' }, foo: 'bar' } const error = new errors.GeneralError('Custom Error', Object.freeze(data)) assert.strictEqual(error.data.errors, undefined) assert.deepStrictEqual(error.data, { foo: 'bar' }) }) it('allows arrays as data', () => { const data = [ { hello: 'world' } ] const error = new errors.GeneralError('Custom Error', data) assert.strictEqual(error.data.errors, undefined) assert.ok(Array.isArray(error.data)) assert.deepStrictEqual(error.data, [{ hello: 'world' }]) }) it('can be instantiated with `null` (#2789)', () => { const err = new errors.BadRequest(null, {}) assert.strictEqual(err.message, 'Error') }) it('has proper stack trace (#78)', () => { try { throw new errors.NotFound('Not the error you are looking for') } catch (e: any) { const text = 'NotFound: Not the error you are looking for' assert.strictEqual(e.stack.indexOf(text), 0) assert.ok(e.stack.indexOf('index.test.ts') !== -1) const oldCST = Error.captureStackTrace delete Error.captureStackTrace try { throw new errors.NotFound('Not the error you are looking for') } catch (e: any) { assert.ok(e) Error.captureStackTrace = oldCST } } }) }) }) ================================================ FILE: packages/errors/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/express/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/express ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/express ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/express ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/express ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/express ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/express ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) - **express:** Update express to version 4.21.1 ([#3543](https://github.com/feathersjs/feathers/issues/3543)) ([56d6151](https://github.com/feathersjs/feathers/commit/56d6151624f083d6604e76746cf555ed846b6d40)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/express ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/express ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/express ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/express ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/express ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) ### Bug Fixes - Reduce usage of lodash ([#3455](https://github.com/feathersjs/feathers/issues/3455)) ([8ce807a](https://github.com/feathersjs/feathers/commit/8ce807a5ca53ff5b8d5107a0656c6329404e6e6c)) ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/express ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/express ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/express ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/express ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/express ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/express ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/express ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/express ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/express ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/express ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/express ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) ### Bug Fixes - **express:** Re-export Router ([#3349](https://github.com/feathersjs/feathers/issues/3349)) ([0cbdb03](https://github.com/feathersjs/feathers/commit/0cbdb03a2d810f4855da9b21602c96e4fed7fce5)) ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/express ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/express ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/express ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/express ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/express ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/express ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package @feathersjs/express # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Bug Fixes - **core:** `context.type` for around hooks ([#2890](https://github.com/feathersjs/feathers/issues/2890)) ([d606ac6](https://github.com/feathersjs/feathers/commit/d606ac660fd5335c95206784fea36530dd2e851a)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) ### Bug Fixes - **docs:** Review transport API docs and update Express middleware setup ([#2811](https://github.com/feathersjs/feathers/issues/2811)) ([1b97f14](https://github.com/feathersjs/feathers/commit/1b97f14d474f5613482f259eeaa585c24fcfab43)) - **transports:** Add remaining middleware for generated apps to Koa and Express ([#2796](https://github.com/feathersjs/feathers/issues/2796)) ([0d5781a](https://github.com/feathersjs/feathers/commit/0d5781a5c72a0cbb2ec8211bfa099f0aefe115a2)) # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Bug Fixes - **core:** Ensure setup and teardown can be overriden and maintain hook functionality ([#2779](https://github.com/feathersjs/feathers/issues/2779)) ([ab580cb](https://github.com/feathersjs/feathers/commit/ab580cbcaa68d19144d86798c13bf564f9d424a6)) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) ### Features - Add CORS support to oAuth, Express, Koa and generated application ([#2744](https://github.com/feathersjs/feathers/issues/2744)) ([fd218f2](https://github.com/feathersjs/feathers/commit/fd218f289f8ca4c101e9938e8683e2efef6e8131)) - **authentication-oauth:** Koa and transport independent oAuth authentication ([#2737](https://github.com/feathersjs/feathers/issues/2737)) ([9231525](https://github.com/feathersjs/feathers/commit/9231525a24bb790ba9c5d940f2867a9c727691c9)) # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Bug Fixes - **authentication:** Add safe dispatch data for authentication requests ([#2662](https://github.com/feathersjs/feathers/issues/2662)) ([d8104a1](https://github.com/feathersjs/feathers/commit/d8104a19ee9181e6a5ea81014af29ff9a3c28a8a)) ### Features - **cli:** Add support for JavaScript to the new CLI ([#2668](https://github.com/feathersjs/feathers/issues/2668)) ([ebac587](https://github.com/feathersjs/feathers/commit/ebac587f7d00dc7607c3f546352d79f79b89a5d4)) # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) ### Bug Fixes - **express:** Ensure Express options can be set before configuring REST transport ([#2655](https://github.com/feathersjs/feathers/issues/2655)) ([c9b8f74](https://github.com/feathersjs/feathers/commit/c9b8f74a0196acb99be44ac5e0fff3f1128288cd)) # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Bug Fixes - **express:** Fix typo in types reference in package.json ([#2613](https://github.com/feathersjs/feathers/issues/2613)) ([eacf1b3](https://github.com/feathersjs/feathers/commit/eacf1b3474e6d9da69b8671244c23a75cff87d95)) ### Features - **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28)) # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) ### Features - **core:** Add app.teardown functionality ([#2570](https://github.com/feathersjs/feathers/issues/2570)) ([fcdf524](https://github.com/feathersjs/feathers/commit/fcdf524ae1995bb59265d39f12e98b7794bed023)) - **core:** Finalize app.teardown() functionality ([#2584](https://github.com/feathersjs/feathers/issues/2584)) ([1a166f3](https://github.com/feathersjs/feathers/commit/1a166f3ded811ecacf0ae8cb67880bc9fa2eeafa)) - **transport-commons:** add `context.http.response` ([#2524](https://github.com/feathersjs/feathers/issues/2524)) ([5bc9d44](https://github.com/feathersjs/feathers/commit/5bc9d447043c2e2b742c73ed28ecf3b3264dd9e5)) # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) ### Bug Fixes - **express:** Fix application typings to work with typed configuration ([#2539](https://github.com/feathersjs/feathers/issues/2539)) ([b9dfaee](https://github.com/feathersjs/feathers/commit/b9dfaee834b13864c1ed4f2f6a244eb5bb70395b)) # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) ### Features - **express, koa:** make transports similar ([#2486](https://github.com/feathersjs/feathers/issues/2486)) ([26aa937](https://github.com/feathersjs/feathers/commit/26aa937c114fb8596dfefc599b1f53cead69c159)) # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Bug Fixes - missing express types for Request, Response ([#2498](https://github.com/feathersjs/feathers/issues/2498)) ([ee67131](https://github.com/feathersjs/feathers/commit/ee67131bbaa24c54d3d781bdf8820015759ac488)) - **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110)) ### Features - **core:** add `context.http` and move `statusCode` there ([#2496](https://github.com/feathersjs/feathers/issues/2496)) ([b701bf7](https://github.com/feathersjs/feathers/commit/b701bf77fb83048aa1dffa492b3d77dd53f7b72b)) - **core:** Improve legacy hooks integration ([08c8b40](https://github.com/feathersjs/feathers/commit/08c8b40999bf3889c61a4d4fad97a2c4f78bafc9)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) **Note:** Version bump only for package @feathersjs/express # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) ### Features - **koa:** KoaJS transport adapter ([#2315](https://github.com/feathersjs/feathers/issues/2315)) ([2554b57](https://github.com/feathersjs/feathers/commit/2554b57cf05731df58feeba9c12faab18e442107)) # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) ### Features - **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/express # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) **Note:** Version bump only for package @feathersjs/express # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Resolve some type problems ([#2260](https://github.com/feathersjs/feathers/issues/2260)) ([a3d75fa](https://github.com/feathersjs/feathers/commit/a3d75fa29490e8a19412a12bc993ee7bb573068f)) - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) ### Features - **core:** Public custom service methods ([#2270](https://github.com/feathersjs/feathers/issues/2270)) ([e65abfb](https://github.com/feathersjs/feathers/commit/e65abfb5388df6c19a11c565cf1076a29f32668d)) - Application service types default to any ([#1566](https://github.com/feathersjs/feathers/issues/1566)) ([d93ba9a](https://github.com/feathersjs/feathers/commit/d93ba9a17edd20d3397bb00f4f6e82e804e42ed6)) - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) - **core:** Remove Uberproto ([#2178](https://github.com/feathersjs/feathers/issues/2178)) ([ddf8821](https://github.com/feathersjs/feathers/commit/ddf8821f53317e6a378657f7d66acb03a037ee47)) ### BREAKING CHANGES - **core:** Services no longer extend Uberproto objects and `service.mixin()` is no longer available. # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### Features - **core:** use @feathers/hooks and add async type ([#1929](https://github.com/feathersjs/feathers/issues/1929)) ([a5c4756](https://github.com/feathersjs/feathers/commit/a5c47562eae8410c82fe2f6308f26f8e78b6a3e8)) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### Features - **core:** use @feathers/hooks and add async type ([#1929](https://github.com/feathersjs/feathers/issues/1929)) ([a5c4756](https://github.com/feathersjs/feathers/commit/a5c47562eae8410c82fe2f6308f26f8e78b6a3e8)) ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) **Note:** Version bump only for package @feathersjs/express ## [4.5.10](https://github.com/feathersjs/feathers/compare/v4.5.9...v4.5.10) (2020-11-08) ### Bug Fixes - **authentication:** consistent response return between local and jwt strategy ([#2042](https://github.com/feathersjs/feathers/issues/2042)) ([8d25be1](https://github.com/feathersjs/feathers/commit/8d25be101a2593a9e789375c928a07780b9e28cf)) ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) **Note:** Version bump only for package @feathersjs/express ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) **Note:** Version bump only for package @feathersjs/express ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) **Note:** Version bump only for package @feathersjs/express ## [4.5.6](https://github.com/feathersjs/feathers/compare/v4.5.5...v4.5.6) (2020-07-12) **Note:** Version bump only for package @feathersjs/express ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) **Note:** Version bump only for package @feathersjs/express ## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-04-29) **Note:** Version bump only for package @feathersjs/express ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) **Note:** Version bump only for package @feathersjs/express ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) ### Bug Fixes - Updated typings for express middleware ([#1839](https://github.com/feathersjs/feathers/issues/1839)) ([6b8e897](https://github.com/feathersjs/feathers/commit/6b8e8971a9dbb08913edd1be48826624645d9dc1)) ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/express # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) **Note:** Version bump only for package @feathersjs/express ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/express ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/express # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) ### Features - **authentication:** Add parseStrategies to allow separate strategies for creating JWTs and parsing headers ([#1708](https://github.com/feathersjs/feathers/issues/1708)) ([5e65629](https://github.com/feathersjs/feathers/commit/5e65629b924724c3e81d7c81df047e123d1c8bd7)) ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) **Note:** Version bump only for package @feathersjs/express ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/express ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) ### Bug Fixes - Small type improvements ([#1624](https://github.com/feathersjs/feathers/issues/1624)) ([50162c6](https://github.com/feathersjs/feathers/commit/50162c6e562f0a47c6a280c4f01fff7c3afee293)) ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) ### Bug Fixes - Typings for express request and response properties ([#1609](https://github.com/feathersjs/feathers/issues/1609)) ([38cf8c9](https://github.com/feathersjs/feathers/commit/38cf8c950c1a4fb4a6d78d68d70e7fdd63b71c3c)) ## [4.3.5](https://github.com/feathersjs/feathers/compare/v4.3.4...v4.3.5) (2019-10-07) **Note:** Version bump only for package @feathersjs/express ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) **Note:** Version bump only for package @feathersjs/express ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) **Note:** Version bump only for package @feathersjs/express ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) ### Bug Fixes - Add info to express error handler logger type ([#1557](https://github.com/feathersjs/feathers/issues/1557)) ([3e1d26c](https://github.com/feathersjs/feathers/commit/3e1d26c)) ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) **Note:** Version bump only for package @feathersjs/express # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/express # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/express # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) ### Bug Fixes - Update all dependencies ([7d53a00](https://github.com/feathersjs/feathers/commit/7d53a00)) # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) ### Bug Fixes - Add method to reliably get default authentication service ([#1470](https://github.com/feathersjs/feathers/issues/1470)) ([e542cb3](https://github.com/feathersjs/feathers/commit/e542cb3)) # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/express # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) ### Bug Fixes - Remove unnecessary top level export files in @feathersjs/express ([#1442](https://github.com/feathersjs/feathers/issues/1442)) ([73c3fb2](https://github.com/feathersjs/feathers/commit/73c3fb2)) ### Features - @feathersjs/express allow to pass an existing Express application instance ([#1446](https://github.com/feathersjs/feathers/issues/1446)) ([853a6b0](https://github.com/feathersjs/feathers/commit/853a6b0)) # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) ### Bug Fixes - @feathersjs/express: allow middleware arrays ([#1421](https://github.com/feathersjs/feathers/issues/1421)) ([b605ab8](https://github.com/feathersjs/feathers/commit/b605ab8)) - @feathersjs/express: replace `reduce` with `map` ([#1429](https://github.com/feathersjs/feathers/issues/1429)) ([44542e9](https://github.com/feathersjs/feathers/commit/44542e9)) - Clean up hooks code ([#1407](https://github.com/feathersjs/feathers/issues/1407)) ([f25c88b](https://github.com/feathersjs/feathers/commit/f25c88b)) # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) ### Bug Fixes - Use `export =` in TypeScript definitions ([#1285](https://github.com/feathersjs/feathers/issues/1285)) ([12d0f4b](https://github.com/feathersjs/feathers/commit/12d0f4b)) # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) ### Bug Fixes - Always require strategy parameter in authentication ([#1327](https://github.com/feathersjs/feathers/issues/1327)) ([d4a8021](https://github.com/feathersjs/feathers/commit/d4a8021)) - Merge httpStrategies and authStrategies option ([#1308](https://github.com/feathersjs/feathers/issues/1308)) ([afa4d55](https://github.com/feathersjs/feathers/commit/afa4d55)) ### Features - Add params.headers to all transports when available ([#1303](https://github.com/feathersjs/feathers/issues/1303)) ([ebce79b](https://github.com/feathersjs/feathers/commit/ebce79b)) - express use service.methods ([#945](https://github.com/feathersjs/feathers/issues/945)) ([3f0b1c3](https://github.com/feathersjs/feathers/commit/3f0b1c3)) # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) - **chore:** Properly configure and run code linter ([#1092](https://github.com/feathersjs/feathers/issues/1092)) ([fd3fc34](https://github.com/feathersjs/feathers/commit/fd3fc34)) - **package:** update @feathersjs/commons to version 2.0.0 ([#31](https://github.com/feathersjs/feathers/issues/31)) ([c1ef5b1](https://github.com/feathersjs/feathers/commit/c1ef5b1)) - **package:** update debug to version 3.0.0 ([#2](https://github.com/feathersjs/feathers/issues/2)) ([7e19603](https://github.com/feathersjs/feathers/commit/7e19603)) ### Features - @feathersjs/authentication-oauth ([#1299](https://github.com/feathersjs/feathers/issues/1299)) ([656bae7](https://github.com/feathersjs/feathers/commit/656bae7)) - Add AuthenticationBaseStrategy and make authentication option handling more explicit ([#1284](https://github.com/feathersjs/feathers/issues/1284)) ([2667d92](https://github.com/feathersjs/feathers/commit/2667d92)) - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - Allow registering a service at the root level ([#1115](https://github.com/feathersjs/feathers/issues/1115)) ([c73d322](https://github.com/feathersjs/feathers/commit/c73d322)) - Authentication v3 client ([#1240](https://github.com/feathersjs/feathers/issues/1240)) ([65b43bd](https://github.com/feathersjs/feathers/commit/65b43bd)) - Authentication v3 Express integration ([#1218](https://github.com/feathersjs/feathers/issues/1218)) ([82bcfbe](https://github.com/feathersjs/feathers/commit/82bcfbe)) ### BREAKING CHANGES - Rewrite for authentication v3 ## [1.3.1](https://github.com/feathersjs/feathers/compare/@feathersjs/express@1.3.0...@feathersjs/express@1.3.1) (2019-01-02) ### Bug Fixes - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) # [1.3.0](https://github.com/feathersjs/feathers/compare/@feathersjs/express@1.2.7...@feathersjs/express@1.3.0) (2018-12-16) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - **chore:** Properly configure and run code linter ([#1092](https://github.com/feathersjs/feathers/issues/1092)) ([fd3fc34](https://github.com/feathersjs/feathers/commit/fd3fc34)) ### Features - Allow registering a service at the root level ([#1115](https://github.com/feathersjs/feathers/issues/1115)) ([c73d322](https://github.com/feathersjs/feathers/commit/c73d322)) ## [1.2.7](https://github.com/feathersjs/feathers/compare/@feathersjs/express@1.2.6...@feathersjs/express@1.2.7) (2018-09-21) **Note:** Version bump only for package @feathersjs/express ## [1.2.6](https://github.com/feathersjs/feathers/compare/@feathersjs/express@1.2.5...@feathersjs/express@1.2.6) (2018-09-17) **Note:** Version bump only for package @feathersjs/express ## [1.2.5](https://github.com/feathersjs/feathers/compare/@feathersjs/express@1.2.4...@feathersjs/express@1.2.5) (2018-09-02) **Note:** Version bump only for package @feathersjs/express ## 1.2.4 - Migrate to Monorepo ([feathers#462](https://github.com/feathersjs/feathers/issues/462)) ## [v1.2.3](https://github.com/feathersjs/express/tree/v1.2.3) (2018-06-03) [Full Changelog](https://github.com/feathersjs/express/compare/v1.2.2...v1.2.3) **Closed issues:** - Question: How to handle JSON:API [\#26](https://github.com/feathersjs/express/issues/26) - \[Proposal\] Allow multiple express middleware functions to be passed into `app.use` [\#24](https://github.com/feathersjs/express/issues/24) **Merged pull requests:** - Update uberproto to the latest version [\#28](https://github.com/feathersjs/express/pull/28) ([bertho-zero](https://github.com/bertho-zero)) ## [v1.2.2](https://github.com/feathersjs/express/tree/v1.2.2) (2018-04-16) [Full Changelog](https://github.com/feathersjs/express/compare/v1.2.1...v1.2.2) **Merged pull requests:** - Allow multiple express middleware functions to be passed into `app.use` [\#25](https://github.com/feathersjs/express/pull/25) ([eXigentCoder](https://github.com/eXigentCoder)) ## [v1.2.1](https://github.com/feathersjs/express/tree/v1.2.1) (2018-03-29) [Full Changelog](https://github.com/feathersjs/express/compare/v1.2.0...v1.2.1) **Closed issues:** - Error in error hook results in unhandled rejection [\#21](https://github.com/feathersjs/express/issues/21) - Error handler in wrapper hides breaks and hides real error [\#13](https://github.com/feathersjs/express/issues/13) **Merged pull requests:** - Allow to set HTTP status code in a hook [\#23](https://github.com/feathersjs/express/pull/23) ([daffl](https://github.com/daffl)) - Update axios to the latest version 🚀 [\#22](https://github.com/feathersjs/express/pull/22) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.2.0](https://github.com/feathersjs/express/tree/v1.2.0) (2018-02-09) [Full Changelog](https://github.com/feathersjs/express/compare/v1.1.2...v1.2.0) **Closed issues:** - Error in `create` method results in unhandled rejection [\#19](https://github.com/feathersjs/express/issues/19) - @feathersjs/express call without paramaters could returns an instance of express [\#18](https://github.com/feathersjs/express/issues/18) - Feathers-express blows up the feathers application version property and the example doesn't work [\#16](https://github.com/feathersjs/express/issues/16) **Merged pull requests:** - Return an instance of the original Express application when nothing i… [\#20](https://github.com/feathersjs/express/pull/20) ([daffl](https://github.com/daffl)) - Fix README example [\#17](https://github.com/feathersjs/express/pull/17) ([bertho-zero](https://github.com/bertho-zero)) - Update mocha to the latest version 🚀 [\#15](https://github.com/feathersjs/express/pull/15) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update semistandard to the latest version 🚀 [\#14](https://github.com/feathersjs/express/pull/14) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.1.2](https://github.com/feathersjs/express/tree/v1.1.2) (2017-11-16) [Full Changelog](https://github.com/feathersjs/express/compare/v1.1.1...v1.1.2) **Merged pull requests:** - Export default and original Express object [\#12](https://github.com/feathersjs/express/pull/12) ([daffl](https://github.com/daffl)) ## [v1.1.1](https://github.com/feathersjs/express/tree/v1.1.1) (2017-11-06) [Full Changelog](https://github.com/feathersjs/express/compare/v1.1.0...v1.1.1) **Merged pull requests:** - Also add notFound to export [\#11](https://github.com/feathersjs/express/pull/11) ([daffl](https://github.com/daffl)) ## [v1.1.0](https://github.com/feathersjs/express/tree/v1.1.0) (2017-11-05) [Full Changelog](https://github.com/feathersjs/express/compare/v1.0.0...v1.1.0) **Merged pull requests:** - Re-export Express error handler [\#10](https://github.com/feathersjs/express/pull/10) ([daffl](https://github.com/daffl)) ## [v1.0.0](https://github.com/feathersjs/express/tree/v1.0.0) (2017-11-01) [Full Changelog](https://github.com/feathersjs/express/compare/v1.0.0-pre.4...v1.0.0) ## [v1.0.0-pre.4](https://github.com/feathersjs/express/tree/v1.0.0-pre.4) (2017-10-25) [Full Changelog](https://github.com/feathersjs/express/compare/v1.0.0-pre.3...v1.0.0-pre.4) **Merged pull requests:** - Update to better returnHook handling [\#9](https://github.com/feathersjs/express/pull/9) ([daffl](https://github.com/daffl)) ## [v1.0.0-pre.3](https://github.com/feathersjs/express/tree/v1.0.0-pre.3) (2017-10-21) [Full Changelog](https://github.com/feathersjs/express/compare/v1.0.0-pre.2...v1.0.0-pre.3) **Merged pull requests:** - Add REST provider to Express framework bindings [\#8](https://github.com/feathersjs/express/pull/8) ([daffl](https://github.com/daffl)) - Update repository name and move to npm scope [\#7](https://github.com/feathersjs/express/pull/7) ([daffl](https://github.com/daffl)) - Update axios to the latest version 🚀 [\#6](https://github.com/feathersjs/express/pull/6) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.0-pre.2](https://github.com/feathersjs/express/tree/v1.0.0-pre.2) (2017-10-18) [Full Changelog](https://github.com/feathersjs/express/compare/v1.0.0-pre.1...v1.0.0-pre.2) **Merged pull requests:** - Also export Express top level functionality [\#5](https://github.com/feathersjs/express/pull/5) ([daffl](https://github.com/daffl)) - Update mocha to the latest version 🚀 [\#4](https://github.com/feathersjs/express/pull/4) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update debug to the latest version 🚀 [\#2](https://github.com/feathersjs/express/pull/2) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.0-pre.1](https://github.com/feathersjs/express/tree/v1.0.0-pre.1) (2017-07-19) **Merged pull requests:** - Update dependencies to enable Greenkeeper 🌴 [\#1](https://github.com/feathersjs/express/pull/1) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) \* _This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)_ ================================================ FILE: packages/express/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/express/README.md ================================================ # @feathersjs/express [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/express.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/express) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > Feathers Express framework bindings and REST provider ## Installation ``` npm install @feathersjs/client --save ``` ## Documentation Refer to the [Feathers Express API documentation](https://feathersjs.com/api/express.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/express/package.json ================================================ { "name": "@feathersjs/express", "description": "Feathers Express framework bindings and REST provider", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/express" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "public/**" ], "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/authentication": "^5.0.42", "@feathersjs/commons": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/feathers": "^5.0.42", "@feathersjs/transport-commons": "^5.0.42", "@types/compression": "^1.8.1", "@types/cors": "^2.8.19", "@types/express": "^4.17.21", "@types/express-serve-static-core": "^4.19.5", "compression": "^1.8.1", "cors": "^2.8.6", "express": "^4.21.2" }, "devDependencies": { "@feathersjs/authentication-local": "^5.0.42", "@feathersjs/tests": "^5.0.42", "@types/lodash": "^4.17.24", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "axios": "^1.13.6", "lodash": "^4.17.23", "mocha": "^11.7.5", "shx": "^0.4.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/express/public/401.html ================================================ Not Authorized

    401

    Not Authorized

    Powered by

    ================================================ FILE: packages/express/public/404.html ================================================ Page Not Found

    404

    Page Not Found

    Powered by

    ================================================ FILE: packages/express/public/default.html ================================================ Internal Server Error

    Oh no!

    Something went wrong

    Powered by

    ================================================ FILE: packages/express/src/authentication.ts ================================================ import { RequestHandler, Request, Response } from 'express' import { HookContext } from '@feathersjs/feathers' import { createDebug } from '@feathersjs/commons' import { authenticate as AuthenticateHook } from '@feathersjs/authentication' import { Application } from './declarations' const debug = createDebug('@feathersjs/express/authentication') const toHandler = ( func: (req: Request, res: Response, next: () => void) => Promise ): RequestHandler => { return (req, res, next) => func(req, res, next).catch((error) => next(error)) } export type AuthenticationSettings = { service?: string strategies?: string[] } export function parseAuthentication(settings: AuthenticationSettings = {}): RequestHandler { return toHandler(async (req, res, next) => { const app = req.app as any as Application const service = app.defaultAuthentication?.(settings.service) if (!service) { return next() } const config = service.configuration const authStrategies = settings.strategies || config.parseStrategies || config.authStrategies || [] if (authStrategies.length === 0) { debug('No `authStrategies` or `parseStrategies` found in authentication configuration') return next() } const authentication = await service.parse(req, res, ...authStrategies) if (authentication) { debug('Parsed authentication from HTTP header', authentication) req.feathers = { ...req.feathers, authentication } } return next() }) } export function authenticate( settings: string | AuthenticationSettings, ...strategies: string[] ): RequestHandler { const hook = AuthenticateHook(settings, ...strategies) return toHandler(async (req, _res, next) => { const app = req.app as any as Application const params = req.feathers const context = { app, params } as any as HookContext await hook(context) req.feathers = context.params return next() }) } ================================================ FILE: packages/express/src/declarations.ts ================================================ import http from 'http' import express, { Express } from 'express' import { Application as FeathersApplication, Params as FeathersParams, HookContext, ServiceMethods, ServiceInterface, RouteLookup } from '@feathersjs/feathers' interface ExpressUseHandler { ( path: L, ...middlewareOrService: ( | Express | express.RequestHandler | express.RequestHandler[] | (keyof any extends keyof Services ? ServiceInterface : Services[L]) )[] ): T (path: string | RegExp, ...expressHandlers: express.RequestHandler[]): T (...expressHandlers: express.RequestHandler[]): T (handler: Express | express.ErrorRequestHandler): T } export interface ExpressOverrides { listen(port: number, hostname: string, backlog: number, callback?: () => void): Promise listen(port: number, hostname: string, callback?: () => void): Promise listen(port: number | string | any, callback?: () => void): Promise listen(callback?: () => void): Promise use: ExpressUseHandler server?: http.Server } export type Application = Omit & FeathersApplication & ExpressOverrides declare module '@feathersjs/feathers/lib/declarations' { interface ServiceOptions { express?: { before?: express.RequestHandler[] after?: express.RequestHandler[] composed?: express.RequestHandler } } } declare module 'express-serve-static-core' { interface Request { feathers: Partial & { [key: string]: any } lookup?: RouteLookup } interface Response { data?: any hook?: HookContext } interface IRouterMatcher { // eslint-disable-next-line

    ( path: PathParams, ...handlers: (RequestHandler | Partial | Application)[] ): T } } ================================================ FILE: packages/express/src/handlers.ts ================================================ import path from 'path' import { NotFound, GeneralError } from '@feathersjs/errors' import { Request, Response, NextFunction, ErrorRequestHandler, RequestHandler } from 'express' const defaults = { public: path.resolve(__dirname, '..', 'public'), logger: console } const defaultHtmlError = path.resolve(defaults.public, 'default.html') export function notFound({ verbose = false } = {}): RequestHandler { return function (req: Request, _res: Response, next: NextFunction) { const url = `${req.url}` const message = `Page not found${verbose ? ': ' + url : ''}` next(new NotFound(message, { url })) } } export type ErrorHandlerOptions = { public?: string logger?: boolean | { error?: (msg: any) => void; info?: (msg: any) => void } html?: any json?: any } export function errorHandler(_options: ErrorHandlerOptions = {}): ErrorRequestHandler { const options = Object.assign({}, defaults, _options) if (typeof options.html === 'undefined') { options.html = { 401: path.resolve(options.public, '401.html'), 404: path.resolve(options.public, '404.html'), default: defaultHtmlError } } if (typeof options.json === 'undefined') { options.json = {} } return function (error: any, req: Request, res: Response, next: NextFunction) { // Set the error code for HTTP processing semantics error.code = !isNaN(parseInt(error.code, 10)) ? parseInt(error.code, 10) : 500 // Log the error if it didn't come from a service method call if (options.logger && typeof options.logger.error === 'function' && !res.hook) { if (error.code >= 500) { options.logger.error(error) } else { options.logger.info(error) } } if (error.type !== 'FeathersError') { const oldError = error error = oldError.errors ? new GeneralError(oldError.message, { errors: oldError.errors }) : new GeneralError(oldError.message) if (oldError.stack) { error.stack = oldError.stack } } const formatter: { [key: string]: any } = {} // If the developer passed a custom function for ALL html errors if (typeof options.html === 'function') { formatter['text/html'] = options.html } else { let file = options.html[error.code] if (!file) { file = options.html.default || defaultHtmlError } // If the developer passed a custom function for individual html errors if (typeof file === 'function') { formatter['text/html'] = file } else { formatter['text/html'] = function () { res.set('Content-Type', 'text/html') res.sendFile(file) } } } // If the developer passed a custom function for ALL json errors if (typeof options.json === 'function') { formatter['application/json'] = options.json } else { const handler = options.json[error.code] || options.json.default // If the developer passed a custom function for individual json errors if (typeof handler === 'function') { formatter['application/json'] = handler } else { // Don't show stack trace if it is a 404 error if (error.code === 404) { error.stack = null } formatter['application/json'] = function () { const output = Object.assign({}, error.toJSON()) if (process.env.NODE_ENV === 'production') { delete output.stack } res.set('Content-Type', 'application/json') res.json(output) } } } res.status(error.code) const contentType = req.headers['content-type'] || '' const accepts = req.headers.accept || '' // by default just send back json if (contentType.indexOf('json') !== -1 || accepts.indexOf('json') !== -1) { formatter['application/json'](error, req, res, next) } else if (options.html && (contentType.indexOf('html') !== -1 || accepts.indexOf('html') !== -1)) { formatter['text/html'](error, req, res, next) } else { // TODO (EK): Maybe just return plain text formatter['application/json'](error, req, res, next) } } } ================================================ FILE: packages/express/src/index.ts ================================================ import express, { Express } from 'express' import { Application as FeathersApplication, defaultServiceMethods } from '@feathersjs/feathers' import { routing } from '@feathersjs/transport-commons' import { createDebug } from '@feathersjs/commons' import cors from 'cors' import compression from 'compression' import { rest, RestOptions, formatter } from './rest' import { errorHandler, notFound, ErrorHandlerOptions } from './handlers' import { Application, ExpressOverrides } from './declarations' import { AuthenticationSettings, authenticate, parseAuthentication } from './authentication' import { default as original, static as serveStatic, json, raw, text, urlencoded, query, Router } from 'express' export { original, serveStatic, serveStatic as static, json, raw, text, urlencoded, query, rest, Router, RestOptions, formatter, errorHandler, notFound, Application, ErrorHandlerOptions, ExpressOverrides, AuthenticationSettings, parseAuthentication, authenticate, cors, compression } const debug = createDebug('@feathersjs/express') export default function feathersExpress( feathersApp?: FeathersApplication, expressApp: Express = express() ): Application { if (!feathersApp) { return expressApp as any } if (typeof feathersApp.setup !== 'function') { throw new Error('@feathersjs/express requires a valid Feathers application instance') } const app = expressApp as any as Application const { use: expressUse, listen: expressListen } = expressApp as any const { use: feathersUse, teardown: feathersTeardown } = feathersApp Object.assign(app, { use(location: string & keyof S, ...rest: any[]) { let service: any let options = {} const middleware = rest.reduce( function (middleware, arg) { if (typeof arg === 'function' || Array.isArray(arg)) { middleware[service ? 'after' : 'before'].push(arg) } else if (!service) { service = arg } else if (arg.methods || arg.events || arg.express || arg.koa) { options = arg } else { throw new Error('Invalid options passed to app.use') } return middleware }, { before: [], after: [] } ) const hasMethod = (methods: string[]) => methods.some((name) => service && typeof service[name] === 'function') // Check for service (any object with at least one service method) if (hasMethod(['handle', 'set']) || !hasMethod(defaultServiceMethods)) { debug('Passing app.use call to Express app') return expressUse.call(this, location, ...rest) } debug('Registering service with middleware', middleware) // Since this is a service, call Feathers `.use` feathersUse.call(this, location, service, { express: middleware, ...options }) return this }, async listen(...args: any[]) { const server = expressListen.call(this, ...args) this.server = server await this.setup(server) debug('Feathers application listening') return server } } as Application) const appDescriptors = { ...Object.getOwnPropertyDescriptors(Object.getPrototypeOf(app)), ...Object.getOwnPropertyDescriptors(app) } const newDescriptors = { ...Object.getOwnPropertyDescriptors(Object.getPrototypeOf(feathersApp)), ...Object.getOwnPropertyDescriptors(feathersApp) } // Copy all non-existing properties (including non-enumerables) // that don't already exist on the Express app Object.keys(newDescriptors).forEach((prop) => { const appProp = appDescriptors[prop] const newProp = newDescriptors[prop] if (appProp === undefined && newProp !== undefined) { Object.defineProperty(expressApp, prop, newProp) } }) // Assign teardown and setup which will also make sure that hooks are initialized app.setup = feathersApp.setup as any app.teardown = async function teardown(server?: any) { return feathersTeardown.call(this, server).then( () => new Promise((resolve, reject) => { if (this.server) { this.server.close((e) => (e ? reject(e) : resolve(this))) } else { resolve(this) } }) ) } app.configure(routing() as any) app.use((req, _res, next) => { req.feathers = { ...req.feathers, provider: 'rest' } return next() }) return app } if (typeof module !== 'undefined') { module.exports = Object.assign(feathersExpress, module.exports) } ================================================ FILE: packages/express/src/rest.ts ================================================ import { Request, Response, RequestHandler, Router } from 'express' import { MethodNotAllowed } from '@feathersjs/errors' import { createDebug } from '@feathersjs/commons' import { http } from '@feathersjs/transport-commons' import { createContext, defaultServiceMethods, getServiceOptions } from '@feathersjs/feathers' import { AuthenticationSettings, parseAuthentication } from './authentication' import { Application } from './declarations' const debug = createDebug('@feathersjs/express/rest') const toHandler = ( func: (req: Request, res: Response, next: () => void) => Promise ): RequestHandler => { return (req, res, next) => func(req, res, next).catch((error) => next(error)) } const serviceMiddleware = (): RequestHandler => { return toHandler(async (req, res, next) => { const { query, headers, path, body: data, method: httpMethod } = req const methodOverride = req.headers[http.METHOD_HEADER] as string | undefined // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const { service, params: { __id: id = null, ...route } = {} } = req.lookup! const method = http.getServiceMethod(httpMethod, id, methodOverride) const { methods } = getServiceOptions(service) debug(`Found service for path ${path}, attempting to run '${method}' service method`) if (!methods.includes(method) || defaultServiceMethods.includes(methodOverride)) { const error = new MethodNotAllowed(`Method \`${method}\` is not supported by this endpoint.`) res.statusCode = error.code throw error } const createArguments = http.argumentsFor[method as 'get'] || http.argumentsFor.default const params = { query, headers, route, ...req.feathers } const args = createArguments({ id, data, params }) const contextBase = createContext(service, method, { http: {} }) res.hook = contextBase const context = await (service as any)[method](...args, contextBase) res.hook = context const response = http.getResponse(context) res.statusCode = response.status res.set(response.headers) res.data = response.body return next() }) } const servicesMiddleware = (): RequestHandler => { return toHandler(async (req, res, next) => { const app = req.app as any as Application const lookup = app.lookup(req.path) if (!lookup) { return next() } req.lookup = lookup const options = getServiceOptions(lookup.service) const middleware = options.express.composed return middleware(req, res, next) }) } export const formatter: RequestHandler = (_req, res, next) => { if (res.data === undefined) { return next() } res.format({ 'application/json'() { res.json(res.data) } }) } export type RestOptions = { formatter?: RequestHandler authentication?: AuthenticationSettings } export const rest = (options?: RestOptions | RequestHandler) => { options = typeof options === 'function' ? { formatter: options } : options || {} const formatterMiddleware = options.formatter || formatter const authenticationOptions = options.authentication return (app: Application) => { if (typeof app.route !== 'function') { throw new Error('@feathersjs/express/rest needs an Express compatible app.') } app.use(parseAuthentication(authenticationOptions)) app.use(servicesMiddleware()) app.mixins.push((_service, _path, options) => { const { express: { before = [], after = [] } = {} } = options const middlewares = [].concat(before, serviceMiddleware(), after, formatterMiddleware) const middleware = Router().use(middlewares) options.express ||= {} options.express.composed = middleware }) } } ================================================ FILE: packages/express/test/authentication.test.ts ================================================ /* eslint-disable @typescript-eslint/ban-ts-comment */ import omit from 'lodash/omit' import { strict as assert } from 'assert' import { default as _axios } from 'axios' import { feathers } from '@feathersjs/feathers' import { createApplication } from '@feathersjs/authentication-local/test/fixture' import { authenticate, AuthenticationResult } from '@feathersjs/authentication' import * as express from '../src' const expressify = express.default const axios = _axios.create({ baseURL: 'http://localhost:9876/' }) describe('@feathersjs/express/authentication', () => { const email = 'expresstest@authentication.com' const password = 'superexpress' let app: express.Application let user: any let authResult: AuthenticationResult before(async () => { const expressApp = expressify(feathers()).use(express.json()).configure(express.rest()) app = createApplication(expressApp as any) as unknown as express.Application await app.listen(9876) app.use('/dummy', { get(id, params) { return Promise.resolve({ id, params }) } }) // @ts-ignore app.use('/protected', express.authenticate('jwt'), (req, res) => { res.json(req.feathers.user) }) app.use( express.errorHandler({ logger: false }) ) app.service('dummy').hooks({ before: [authenticate('jwt')] }) const result = await app.service('users').create({ email, password }) user = result const res = await axios.post('/authentication', { strategy: 'local', password, email }) authResult = res.data }) after(() => app.teardown()) describe('service authentication', () => { it('successful local authentication', () => { assert.ok(authResult.accessToken) assert.deepStrictEqual(omit(authResult.authentication, 'payload'), { strategy: 'local' }) assert.strictEqual(authResult.user.email, email) assert.strictEqual(authResult.user.password, undefined) }) it('local authentication with wrong password fails', async () => { try { await axios.post('/authentication', { strategy: 'local', password: 'wrong', email }) assert.fail('Should never get here') } catch (error: any) { const { data } = error.response assert.strictEqual(data.name, 'NotAuthenticated') assert.strictEqual(data.message, 'Invalid login') } }) it('authenticating with JWT works but returns same accessToken', async () => { const { accessToken } = authResult const { data } = await axios.post('/authentication', { strategy: 'jwt', accessToken }) assert.strictEqual(data.accessToken, accessToken) assert.strictEqual(data.authentication.strategy, 'jwt') assert.strictEqual(data.authentication.payload.sub, user.id.toString()) assert.strictEqual(data.user.email, email) }) it('can make a protected request with Authorization header', async () => { const { accessToken } = authResult const { data, data: { params } } = await axios.get('/dummy/dave', { headers: { Authorization: accessToken } }) assert.strictEqual(data.id, 'dave') assert.deepStrictEqual(params.user, user) assert.strictEqual(params.authentication.accessToken, accessToken) }) it('errors when there are no authStrategies and parseStrategies', async () => { const { accessToken } = authResult app.get('authentication').authStrategies = [] delete app.get('authentication').parseStrategies try { await axios.get('/dummy/dave', { headers: { Authorization: accessToken } }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.response.data.name, 'NotAuthenticated') app.get('authentication').authStrategies = ['jwt', 'local'] } }) it('can make a protected request with Authorization header and bearer scheme', async () => { const { accessToken } = authResult const { data, data: { params } } = await axios.get('/dummy/dave', { headers: { Authorization: ` Bearer: ${accessToken}` } }) assert.strictEqual(data.id, 'dave') assert.deepStrictEqual(params.user, user) assert.strictEqual(params.authentication.accessToken, accessToken) }) }) describe('authenticate middleware', () => { it('errors without valid strategies', () => { try { // @ts-ignore authenticate() assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'The authenticate hook needs at least one allowed strategy') } }) it('protected endpoint fails when JWT is not present', () => { return axios .get('/protected') .then(() => { assert.fail('Should never get here') }) .catch((error) => { const { data } = error.response assert.strictEqual(data.name, 'NotAuthenticated') assert.strictEqual(data.message, 'Not authenticated') }) }) it.skip('protected endpoint fails with invalid Authorization header', async () => { try { await axios.get('/protected', { headers: { Authorization: 'Bearer: something wrong' } }) assert.fail('Should never get here') } catch (error: any) { const { data } = error.response assert.strictEqual(data.name, 'NotAuthenticated') assert.strictEqual(data.message, 'Not authenticated') } }) it('can request protected endpoint with JWT present', async () => { const { data } = await axios.get('/protected', { headers: { Authorization: `Bearer ${authResult.accessToken}` } }) assert.strictEqual(data.email, user.email) assert.strictEqual(data.id, user.id) assert.strictEqual(data.password, user.password) }) }) }) ================================================ FILE: packages/express/test/error-handler.test.ts ================================================ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */ import { strict as assert } from 'assert' import express, { Request, Response, NextFunction } from 'express' import axios from 'axios' import fs from 'fs' import { join } from 'path' import { BadRequest, NotAcceptable, NotAuthenticated, NotFound, PaymentError } from '@feathersjs/errors' import { errorHandler } from '../src' const content = 'Error' const htmlHandler = function (_error: Error, _req: Request, res: Response, _next: NextFunction) { res.send(content) } const jsonHandler = function (error: Error, _req: Request, res: Response, _next: NextFunction) { res.json(error) } describe('error-handler', () => { describe('supports catch-all custom handlers', function () { before(function () { this.app = express() .get('/error', function (_req: Request, _res: Response, next: NextFunction) { next(new Error('Something went wrong')) }) .use( errorHandler({ html: htmlHandler, json: jsonHandler }) ) this.server = this.app.listen(5050) }) after(function (done) { this.server.close(done) }) describe('JSON handler', () => { const options = { url: 'http://localhost:5050/error', headers: { 'Content-Type': 'application/json', Accept: 'application/json' } } it('can send a custom response', async () => { try { await axios(options) assert.fail('Should never get here') } catch (error: any) { assert.deepEqual(error.response.data, { name: 'GeneralError', message: 'Something went wrong', code: 500, className: 'general-error' }) } }) }) }) describe('supports error-code specific custom handlers', () => { describe('HTML handler', () => { const req = { headers: { 'content-type': 'text/html' } } const makeRes = (errCode: number, props?: any) => { return Object.assign( { set() {}, status(code: number) { assert.equal(code, errCode) } }, props ) } it('if the value is a string, calls res.sendFile', (done) => { const err = new NotAuthenticated() const middleware = errorHandler({ logger: null, html: { 401: 'path/to/401.html' } }) const res = makeRes(401, { sendFile(f: any) { assert.equal(f, 'path/to/401.html') done() } }) ;(middleware as any)(err, req, res) }) it('if the value is a function, calls as middleware ', (done) => { const err = new PaymentError() const res = makeRes(402) const middleware = errorHandler({ logger: null, html: { 402: (_err: any, _req: any, _res: any) => { assert.equal(_err, err) assert.equal(_req, req) assert.equal(_res, res) done() } } }) ;(middleware as any)(err, req, res) }) it('falls back to default if error code config is available', (done) => { const err = new NotAcceptable() const res = makeRes(406) const middleware = errorHandler({ logger: null, html: { default: (_err: any, _req: any, _res: any) => { assert.equal(_err, err) assert.equal(_req, req) assert.equal(_res, res) done() } } }) ;(middleware as any)(err, req, res) }) }) describe('JSON handler', () => { const req = { headers: { 'content-type': 'application/json' } } const makeRes = (errCode: number, props?: any) => { return Object.assign( { set() {}, status(code: number) { assert.equal(code, errCode) } }, props ) } it('calls res.json by default', (done) => { const err = new NotAuthenticated() const middleware = errorHandler({ logger: null, json: {} }) const res = makeRes(401, { json(obj: any) { assert.deepEqual(obj, err.toJSON()) done() } }) ;(middleware as any)(err, req, res) }) it('if the value is a function, calls as middleware ', (done) => { const err = new PaymentError() const res = makeRes(402) const middleware = errorHandler({ logger: null, json: { 402: (_err: any, _req: any, _res: any) => { assert.equal(_err, err) assert.equal(_req, req) assert.equal(_res, res) done() } } }) ;(middleware as any)(err, req, res) }) it('falls back to default if error code config is available', (done) => { const err = new NotAcceptable() const res = makeRes(406) const middleware = errorHandler({ logger: null, json: { default: (_err: any, _req: any, _res: any) => { assert.equal(_err, err) assert.equal(_req, req) assert.equal(_res, res) done() } } }) ;(middleware as any)(err, req, res) }) }) }) describe('use as app error handler', function () { before(function () { this.app = express() .get('/error', function (_req: Request, _res: Response, next: NextFunction) { next(new Error('Something went wrong')) }) .get('/string-error', function (_req: Request, _res: Response, next: NextFunction) { const e: any = new Error('Something was not found') e.code = '404' next(e) }) .get('/bad-request', function (_req: Request, _res: Response, next: NextFunction) { next( new BadRequest({ message: 'Invalid Password', errors: [ { path: 'password', value: null, message: "'password' cannot be 'null'" } ] }) ) }) .use(function (_req: Request, _res: Response, next: NextFunction) { next(new NotFound('File not found')) }) .use( errorHandler({ logger: null }) ) this.server = this.app.listen(5050) }) after(function (done) { this.server.close(done) }) describe('converts an non-feathers error', () => { it('is an instance of GeneralError', async () => { try { await axios({ url: 'http://localhost:5050/error', responseType: 'json' }) assert.fail('Should never get here') } catch (error: any) { assert.equal(error.response.status, 500) assert.deepEqual(error.response.data, { name: 'GeneralError', message: 'Something went wrong', code: 500, className: 'general-error' }) } }) }) describe('text/html format', () => { it('serves a 404.html', (done) => { fs.readFile(join(__dirname, '..', 'public', '404.html'), async function (_err, html) { try { await axios({ url: 'http://localhost:5050/path/to/nowhere', headers: { 'Content-Type': 'text/html', Accept: 'text/html' } }) assert.fail('Should never get here') } catch (error: any) { assert.equal(error.response.status, 404) assert.equal(error.response.data, html.toString()) done() } }) }) it('serves a 500.html', (done) => { fs.readFile(join(__dirname, '..', 'public', 'default.html'), async function (_err, html) { try { await axios({ url: 'http://localhost:5050/error', headers: { 'Content-Type': 'text/html', Accept: 'text/html' } }) assert.fail('Should never get here') } catch (error: any) { assert.equal(error.response.status, 500) assert.equal(error.response.data, html.toString()) done() } }) }) }) describe('application/json format', () => { it('500', async () => { try { await axios({ url: 'http://localhost:5050/error', headers: { 'Content-Type': 'application/json', Accept: 'application/json' } }) assert.fail('Should never get here') } catch (error: any) { assert.equal(error.response.status, 500) assert.deepEqual(error.response.data, { name: 'GeneralError', message: 'Something went wrong', code: 500, className: 'general-error' }) } }) it('404', async () => { try { await axios({ url: 'http://localhost:5050/path/to/nowhere', headers: { 'Content-Type': 'application/json', Accept: 'application/json' } }) assert.fail('Should never get here') } catch (error: any) { assert.equal(error.response.status, 404) assert.deepEqual(error.response.data, { name: 'NotFound', message: 'File not found', code: 404, className: 'not-found' }) } }) it('400', async () => { try { await axios({ url: 'http://localhost:5050/bad-request', headers: { 'Content-Type': 'application/json', Accept: 'application/json' } }) assert.fail('Should never get here') } catch (error: any) { assert.equal(error.response.status, 400) assert.deepEqual(error.response.data, { name: 'BadRequest', message: 'Invalid Password', code: 400, className: 'bad-request', data: {}, errors: [ { path: 'password', value: null, message: "'password' cannot be 'null'" } ] }) } }) }) it('returns JSON by default', async () => { try { await axios('http://localhost:5050/bad-request') assert.fail('Should never get here') } catch (error: any) { assert.equal(error.response.status, 400) assert.deepEqual(error.response.data, { name: 'BadRequest', message: 'Invalid Password', code: 400, className: 'bad-request', data: {}, errors: [ { path: 'password', value: null, message: "'password' cannot be 'null'" } ] }) } }) }) }) ================================================ FILE: packages/express/test/index.test.ts ================================================ /* eslint-disable @typescript-eslint/ban-ts-comment */ import { strict as assert } from 'assert' import express, { Request, Response, NextFunction } from 'express' import axios from 'axios' import fs from 'fs' import path from 'path' import https from 'https' import { feathers, HookContext, Id } from '@feathersjs/feathers' import { default as feathersExpress, rest, notFound, errorHandler, original, serveStatic } from '../src' import { RequestListener } from 'http' describe('@feathersjs/express', () => { const service = { async get(id: Id) { return { id } } } it('exports .default, .original .rest, .notFound and .errorHandler', () => { assert.strictEqual(original, express) assert.strictEqual(typeof rest, 'function') assert.ok(notFound) assert.ok(errorHandler) }) it('returns an Express application, keeps Feathers service and configuration typings typings', () => { type Config = { hostname: string port: number } const app = feathersExpress, Config>(feathers()) app.set('hostname', 'test.com') const hostname = app.get('hostname') assert.strictEqual(hostname, 'test.com') assert.strictEqual(typeof app, 'function') }) it('allows to use an existing Express instance', () => { const expressApp = express() const app = feathersExpress(feathers(), expressApp) assert.strictEqual(app, expressApp) }) it('exports `express.rest`', () => { assert.ok(typeof rest === 'function') }) it('returns a plain express app when no app is provided', () => { const app = feathersExpress() assert.strictEqual(typeof app.use, 'function') assert.strictEqual(typeof app.service, 'undefined') assert.strictEqual(typeof app.services, 'undefined') }) it('errors when app with wrong version is provided', () => { try { // @ts-ignore feathersExpress({}) } catch (e: any) { assert.strictEqual(e.message, '@feathersjs/express requires a valid Feathers application instance') } try { const app = feathers() app.version = '2.9.9' feathersExpress(app) } catch (e: any) { assert.strictEqual( e.message, '@feathersjs/express requires an instance of a Feathers application version 3.x or later (got 2.9.9)' ) } try { const app = feathers() delete app.version feathersExpress(app) } catch (e: any) { assert.strictEqual( e.message, '@feathersjs/express requires an instance of a Feathers application version 3.x or later (got unknown)' ) } }) it('Can use Express sub-apps', () => { const typedApp = feathers>() const app = feathersExpress(typedApp) const child = express() app.use('/path', child) assert.strictEqual((child as any).parent, app) }) it('Can use express.static', () => { const app = feathersExpress(feathers()) app.use('/path', serveStatic(__dirname)) }) it('has Feathers functionality', async () => { const app = feathersExpress(feathers()) app.use('/myservice', service) app.hooks({ after: { get(hook: HookContext) { hook.result.fromAppHook = true } } }) app.service('myservice').hooks({ after: { get(hook: HookContext) { hook.result.fromHook = true } } }) const data = await app.service('myservice').get(10) assert.deepStrictEqual(data, { id: 10, fromHook: true, fromAppHook: true }) }) it('can register a service and start an Express server', async () => { const app = feathersExpress(feathers()) const response = { message: 'Hello world' } app.use('/myservice', service) app.use((_req: Request, res: Response) => res.json(response)) const server = await app.listen(8787) const data = await app.service('myservice').get(10) assert.deepStrictEqual(data, { id: 10 }) const res = await axios.get('http://localhost:8787') assert.deepStrictEqual(res.data, response) await new Promise((resolve) => server.close(() => resolve(server))) }) it('.listen calls .setup', async () => { const app = feathersExpress(feathers()) let called = false app.use('/myservice', { async get(id: Id) { return { id } }, async setup(appParam, path) { assert.strictEqual(appParam, app) assert.strictEqual(path, 'myservice') called = true } }) const server = await app.listen(8787) assert.ok(called) await new Promise((resolve) => server.close(() => resolve(server))) }) it('.teardown closes http server', async () => { const app = feathersExpress(feathers()) let called = false const server = await app.listen(8787) server.on('close', () => { called = true }) await app.teardown() assert.ok(called) }) it('passes middleware as options', () => { const feathersApp = feathers() const app = feathersExpress(feathersApp) const oldUse = feathersApp.use const a = (_req: Request, _res: Response, next: NextFunction) => next() const b = (_req: Request, _res: Response, next: NextFunction) => next() const c = (_req: Request, _res: Response, next: NextFunction) => next() const service = { async get(id: Id) { return { id } } } feathersApp.use = function (path, serviceArg, options) { assert.strictEqual(path, '/myservice') assert.strictEqual(serviceArg, service) assert.deepStrictEqual(options.express, { before: [a, b], after: [c] }) // eslint-disable-next-line prefer-rest-params return (oldUse as any).apply(this, arguments) } app.use('/myservice', a, b, service, c) }) it('Express wrapped and context.app are the same', async () => { const app = feathersExpress(feathers()) app.use('/test', { async get(id: Id) { return { id } } }) app.service('test').hooks({ before: { get: [ (context) => { assert.ok(context.app === app) } ] } }) assert.deepStrictEqual(await app.service('test').get('testing'), { id: 'testing' }) }) it('Works with HTTPS', (done) => { const todoService = { async get(name: Id) { return { id: name, description: `You have to do ${name}!` } } } const app = feathersExpress(feathers()).configure(rest()) app.use('/secureTodos', todoService) const httpsServer = https .createServer( { key: fs.readFileSync(path.join(__dirname, '..', '..', 'tests', 'resources', 'privatekey.pem')), cert: fs.readFileSync(path.join(__dirname, '..', '..', 'tests', 'resources', 'certificate.pem')), rejectUnauthorized: false, requestCert: false }, app as unknown as RequestListener ) .listen(7889) app.setup(httpsServer) httpsServer.on('listening', function () { const instance = axios.create({ httpsAgent: new https.Agent({ rejectUnauthorized: false }) }) instance .get('https://localhost:7889/secureTodos/dishes') .then((response) => { assert.ok(response.status === 200, 'Got OK status code') assert.strictEqual(response.data.description, 'You have to do dishes!') httpsServer.close(() => done()) }) .catch(done) }) }) }) ================================================ FILE: packages/express/test/not-found-handler.test.ts ================================================ import { strict as assert } from 'assert' import { NotFound } from '@feathersjs/errors' import { notFound } from '../src' const handler = notFound as any describe('not-found-handler', () => { it('returns NotFound error', (done) => { handler()( { url: 'some/where', headers: {} }, {}, function (error: any) { assert.ok(error instanceof NotFound) assert.equal(error.message, 'Page not found') assert.deepEqual(error.data, { url: 'some/where' }) done() } ) }) it('returns NotFound error with URL when verbose', (done) => { handler({ verbose: true })( { url: 'some/where', headers: {} }, {}, function (error: any) { assert.ok(error instanceof NotFound) assert.equal(error.message, 'Page not found: some/where') assert.deepEqual(error.data, { url: 'some/where' }) done() } ) }) }) ================================================ FILE: packages/express/test/rest.test.ts ================================================ /* eslint-disable @typescript-eslint/no-unused-vars */ import { strict as assert } from 'assert' import axios, { AxiosRequestConfig } from 'axios' import { Server } from 'http' import { Request, Response, NextFunction } from 'express' import { ApplicationHookMap, feathers, HookContext, Id, Params } from '@feathersjs/feathers' import { Service, restTests } from '@feathersjs/tests' import { BadRequest } from '@feathersjs/errors' import * as express from '../src' const expressify = express.default const { rest } = express const errorHandler = express.errorHandler({ logger: false }) describe('@feathersjs/express/rest provider', () => { describe('base functionality', () => { it('throws an error if you did not expressify', () => { const app = feathers() try { app.configure(rest() as any) assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, '@feathersjs/express/rest needs an Express compatible app.') } }) it('lets you set the handler manually', async () => { const app = expressify(feathers()) app .configure( rest(function (_req, res) { res.format({ 'text/plain'() { res.end(`The todo is: ${res.data.description}`) } }) }) ) .use('/todo', { async get(id: Id) { return { description: `You have to do ${id}` } } }) const server = await app.listen(4776) const res = await axios.get('http://localhost:4776/todo/dishes') assert.strictEqual(res.data, 'The todo is: You have to do dishes') server.close() }) it('lets you set no handler', async () => { const app = expressify(feathers()) const data = { fromHandler: true } app .configure(rest(null)) .use('/todo', { async get(id: Id) { return { description: `You have to do ${id}` } } }) .use((_req: Request, res: Response) => res.json(data)) const server = await app.listen(5775) const res = await axios.get('http://localhost:5775/todo-handler/dishes') assert.deepStrictEqual(res.data, data) server.close() }) }) describe('CRUD', () => { let app: express.Application before(async () => { app = expressify(feathers()) .use(express.cors()) .use(express.json()) .configure(rest(express.formatter)) .use('codes', { async get(id: Id) { return { id } }, async create(data: any) { return data } }) .use('/', new Service()) .use('todo', new Service()) app.hooks({ setup: [ async (context, next) => { assert.ok(context.app) await next() } ], teardown: [ async (context, next) => { assert.ok(context.app) await next() } ] } as ApplicationHookMap) await app.listen(4777, () => app.use('tasks', new Service())) }) after(() => app.teardown()) restTests('Services', 'todo', 4777) restTests('Root Service', '/', 4777) restTests('Dynamic Services', 'tasks', 4777) describe('res.hook', () => { const convertHook = (hook: HookContext) => { const result: any = Object.assign({}, hook.toJSON()) delete result.self delete result.service delete result.app delete result.error return result } it('sets the actual hook object in res.hook', async () => { const params = { route: {}, query: { test: 'param' }, provider: 'rest' } app.use( '/hook', { async get(id) { return { description: `You have to do ${id}` } } }, function (_req: Request, res: Response, next: NextFunction) { res.data = convertHook(res.hook) next() } ) app.service('hook').hooks({ after(hook: HookContext) { hook.addedProperty = true } }) const res = await axios.get('http://localhost:4777/hook/dishes?test=param') const paramsWithHeaders = { ...params, headers: res.data.params.headers } assert.deepStrictEqual(res.data, { id: 'dishes', params: paramsWithHeaders, arguments: ['dishes', paramsWithHeaders], type: 'around', method: 'get', path: 'hook', http: {}, event: null, result: { description: 'You have to do dishes' }, addedProperty: true }) }) it('can use hook.dispatch', async () => { app.use('/hook-dispatch', { async get() { return {} } }) app.service('hook-dispatch').hooks({ after(hook: HookContext) { hook.dispatch = { id: hook.id, fromDispatch: true } } }) const res = await axios.get('http://localhost:4777/hook-dispatch/dishes') assert.deepStrictEqual(res.data, { id: 'dishes', fromDispatch: true }) }) it('allows to set statusCode in a hook', async () => { app.use('/hook-status', { async get() { return {} } }) app.service('hook-status').hooks({ after(hook: HookContext) { hook.http.status = 206 } }) const res = await axios.get('http://localhost:4777/hook-status/dishes') assert.strictEqual(res.status, 206) }) it('allows to set response headers in a hook', async () => { app.use('/hook-headers', { async get() { return {} } }) app.service('hook-headers').hooks({ after(hook: HookContext) { hook.http.headers = { foo: 'first', bar: ['second', 'third'] } } }) const res = await axios.get('http://localhost:4777/hook-headers/dishes') assert.strictEqual(res.headers.foo, 'first') assert.strictEqual(res.headers.bar, 'second, third') }) it('sets the hook object in res.hook on error', async () => { const params = { route: {}, query: {}, provider: 'rest' } app.use('/hook-error', { async get() { throw new Error('I blew up') } }) app.use(function (error: Error, _req: Request, res: Response, _next: NextFunction) { res.status(500) res.json({ hook: convertHook(res.hook), error: { message: error.message } }) }) try { await axios('http://localhost:4777/hook-error/dishes') assert.fail('Should never get here') } catch (error: any) { const { data } = error.response const paramsWithHeaders = { ...params, headers: data.hook.params.headers } assert.deepStrictEqual(error.response.data, { hook: { id: 'dishes', params: paramsWithHeaders, arguments: ['dishes', paramsWithHeaders], type: 'around', event: null, method: 'get', path: 'hook-error', http: {} }, error: { message: 'I blew up' } }) } }) }) }) describe('middleware', () => { it('sets service parameters and provider type', async () => { const service = { async get(_id: Id, params: Params) { return params } } const app = expressify(feathers()) .use(function (req: Request, _res: Response, next: NextFunction) { req.feathers.test = 'Happy' next() }) .configure(rest(express.formatter)) .use('service', service) const server = await app.listen(4778) const res = await axios.get('http://localhost:4778/service/bla?some=param&another=thing') const expected = { headers: res.data.headers, test: 'Happy', provider: 'rest', route: {}, query: { some: 'param', another: 'thing' } } assert.ok(res.status === 200, 'Got OK status code') assert.deepStrictEqual(res.data, expected, 'Got params object back') server.close() }) it('Lets you configure your own middleware before the handler (#40)', async () => { const data = { description: 'Do dishes!', id: 'dishes' } const app = expressify(feathers()) app .use(function defaultContentTypeMiddleware(req, _res, next) { req.headers['content-type'] = req.headers['content-type'] || 'application/json' next() }) .use(express.json()) .configure(rest(express.formatter)) .use('/todo', { async create(data: any) { return data } }) const server = await app.listen(4775) const res = await axios({ url: 'http://localhost:4775/todo', method: 'post', data, headers: { 'content-type': '' } }) assert.deepStrictEqual(res.data, data) server.close() }) it('allows middleware before and after a service', async () => { const app = expressify(feathers()) app .use(express.json()) .configure(rest()) .use( '/todo', function (req, _res, next) { req.body.before = ['before first'] next() }, function (req, _res, next) { req.body.before.push('before second') next() }, { async create(data: any) { return data } }, function (_req, res, next) { res.data.after = ['after first'] next() }, function (_req, res, next) { res.data.after.push('after second') next() } ) const server = await app.listen(4776) const res = await axios.post('http://localhost:4776/todo', { text: 'Do dishes' }) assert.deepStrictEqual(res.data, { text: 'Do dishes', before: ['before first', 'before second'], after: ['after first', 'after second'] }) server.close() }) it('allows middleware arrays before and after a service', async () => { const app = expressify(feathers()) app.use(express.json()) app.configure(rest()) app.use( '/todo', [ function (req: Request, _res: Response, next: NextFunction) { req.body.before = ['before first'] next() }, function (req: Request, _res: Response, next: NextFunction) { req.body.before.push('before second') next() } ], { async create(data) { return data } }, [ function (_req: Request, res: Response, next: NextFunction) { res.data.after = ['after first'] next() } ], function (_req: Request, res: Response, next: NextFunction) { res.data.after.push('after second') next() } ) const server = await app.listen(4776) const res = await axios.post('http://localhost:4776/todo', { text: 'Do dishes' }) assert.deepStrictEqual(res.data, { text: 'Do dishes', before: ['before first', 'before second'], after: ['after first', 'after second'] }) server.close() }) it('allows an array of middleware without a service', async () => { const app = expressify(feathers()) const middlewareArray = [ function (_req: Request, res: Response, next: NextFunction) { res.data = ['first'] next() }, function (_req: Request, res: Response, next: NextFunction) { res.data.push('second') next() }, function (req: Request, res: Response) { res.data.push(req.body.text) res.status(200).json(res.data) } ] app.use(express.json()).configure(rest()).use('/array-middleware', middlewareArray) const server = await app.listen(4776) const res = await axios.post('http://localhost:4776/array-middleware', { text: 'Do dishes' }) assert.deepStrictEqual(res.data, ['first', 'second', 'Do dishes']) server.close() }) it('formatter does nothing when there is no res.data', async () => { const data = { message: 'It worked' } const app = expressify(feathers()).use('/test', express.formatter, (_req: Request, res: Response) => res.json(data) ) const server = await app.listen(7988) const res = await axios.get('http://localhost:7988/test') assert.deepStrictEqual(res.data, data) server.close() }) }) describe('HTTP status codes', () => { let app: express.Application let server: Server before(async () => { app = expressify(feathers()) .configure(rest(express.formatter)) .use('todo', { async get(id: Id) { return { description: `You have to do ${id}` } }, async patch() { throw new Error('Not implemented') }, async find() { return null } }) app.use(function (_req, res, next) { if (typeof res.data !== 'undefined') { next(new Error('Should never get here')) } else { next() } }) // Error handler app.use(function (error: Error, _req: Request, res: Response, _next: NextFunction) { if (res.statusCode < 400) { res.status(500) } res.json({ message: error.message }) }) server = await app.listen(4780) }) after((done) => server.close(done)) it('throws a 405 for undefined service methods (#99)', async () => { const res = await axios.get('http://localhost:4780/todo/dishes') assert.ok(res.status === 200, 'Got OK status code for .get') assert.deepStrictEqual( res.data, { description: 'You have to do dishes' }, 'Got expected object' ) try { await axios.post('http://localhost:4780/todo') assert.fail('Should never get here') } catch (error: any) { assert.ok(error.response.status === 405, 'Got 405 for .create') assert.deepStrictEqual( error.response.data, { message: 'Method `create` is not supported by this endpoint.' }, 'Error serialized as expected' ) } }) it('throws a 404 for undefined route', async () => { try { await axios.get('http://localhost:4780/todo/foo/bar') assert.fail('Should never get here') } catch (error: any) { assert.ok(error.response.status === 404, 'Got Not Found code') } }) it('empty response sets 204 status codes, does not run other middleware (#391)', async () => { const res = await axios.get('http://localhost:4780/todo') assert.ok(res.status === 204, 'Got empty status code') }) }) describe('route parameters', () => { let server: Server let app: express.Application before(async () => { app = expressify(feathers()) .configure(rest()) .use('/:appId/:id/todo', { async get(id: Id, params: Params) { if (params.query.error) { throw new BadRequest('Not good') } return { id, route: params.route } } }) .use(errorHandler) server = await app.listen(6880) }) after((done) => server.close(done)) it('adds route params as `params.route` and allows id property (#76, #407)', async () => { const expected = { id: 'dishes', route: { appId: 'theApp', id: 'myId' } } const res = await axios.get(`http://localhost:6880/theApp/myId/todo/${expected.id}`) assert.ok(res.status === 200, 'Got OK status code') assert.deepStrictEqual(expected, res.data) }) it('properly serializes error for nested routes (#1096)', async () => { try { await axios.get('http://localhost:6880/theApp/myId/todo/test?error=true') assert.fail('Should never het here') } catch (error: any) { const { response } = error assert.strictEqual(response.status, 400) assert.deepStrictEqual(response.data, { name: 'BadRequest', message: 'Not good', code: 400, className: 'bad-request' }) } }) }) describe('Custom methods', () => { let server: Server let app: express.Application before(async () => { app = expressify(feathers()) .use(express.json()) .configure(rest()) .use('/todo', new Service(), { methods: ['find', 'customMethod'] }) .use(errorHandler) server = await app.listen(4781) }) after((done) => server.close(done)) it('calls .customMethod with X-Service-Method header', async () => { const payload = { text: 'Do dishes' } const res = await axios.post('http://localhost:4781/todo', payload, { headers: { 'X-Service-Method': 'customMethod' } }) assert.deepEqual(res.data, { data: payload, method: 'customMethod', provider: 'rest' }) }) it('throws MethodNotImplement for .setup, non option and default methods', async () => { const options: AxiosRequestConfig = { method: 'POST', url: 'http://localhost:4781/todo', data: { text: 'Do dishes' } } const testMethod = (name: string) => { return assert.rejects( () => axios({ ...options, headers: { 'X-Service-Method': name } }), (error: any) => { assert.deepEqual(error.response.data, { name: 'MethodNotAllowed', message: `Method \`${name}\` is not supported by this endpoint.`, code: 405, className: 'method-not-allowed' }) return true } ) } await testMethod('setup') await testMethod('internalMethod') await testMethod('nonExisting') await testMethod('create') await testMethod('find') }) }) }) ================================================ FILE: packages/express/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/feathers/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **core:** context.path is now typed correctly ([#3303](https://github.com/feathersjs/feathers/issues/3303)) ([ff18b3f](https://github.com/feathersjs/feathers/commit/ff18b3f8b7c8dbc97be588f699d539226785343a)) - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) ### Bug Fixes - **core:** Ensure .service does not access Object properties ([#3235](https://github.com/feathersjs/feathers/issues/3235)) ([c0b670a](https://github.com/feathersjs/feathers/commit/c0b670ac4c7bf145e36b59ea89d1387b5514c237)) ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/feathers ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) ### Bug Fixes - **core:** Add PaginationParams to general find method ([#3095](https://github.com/feathersjs/feathers/issues/3095)) ([8ebdcf5](https://github.com/feathersjs/feathers/commit/8ebdcf5107fae5fa23920390052b871033de3a0a)) # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - **feathers:** Run after all hooks first, and then after method hooks ([#3004](https://github.com/feathersjs/feathers/issues/3004)) ([3692fd5](https://github.com/feathersjs/feathers/commit/3692fd57f70564492cef8bbaf78d264627a9bf0a)) - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Bug Fixes - **core:** `context.type` for around hooks ([#2890](https://github.com/feathersjs/feathers/issues/2890)) ([d606ac6](https://github.com/feathersjs/feathers/commit/d606ac660fd5335c95206784fea36530dd2e851a)) - **core:** Allow services with no external methods ([#2921](https://github.com/feathersjs/feathers/issues/2921)) ([df56918](https://github.com/feathersjs/feathers/commit/df569183d1a9ed0a9e0ea5bf8d7dab52d326a33d)) - **core:** Improve service option usage and method option typings ([#2902](https://github.com/feathersjs/feathers/issues/2902)) ([164d75c](https://github.com/feathersjs/feathers/commit/164d75c0f11139a316baa91f1762de8f8eb7da2d)) ### Features - **adapter:** Add patch data type to adapters and refactor AdapterBase usage ([#2906](https://github.com/feathersjs/feathers/issues/2906)) ([9ddc2e6](https://github.com/feathersjs/feathers/commit/9ddc2e6b028f026f939d6af68125847e5c6734b4)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) ### Bug Fixes - **docs:** Review transport API docs and update Express middleware setup ([#2811](https://github.com/feathersjs/feathers/issues/2811)) ([1b97f14](https://github.com/feathersjs/feathers/commit/1b97f14d474f5613482f259eeaa585c24fcfab43)) ### Features - **docs:** New website and documentation pages ([#2802](https://github.com/feathersjs/feathers/issues/2802)) ([ae85fa2](https://github.com/feathersjs/feathers/commit/ae85fa216f12f7ff5d15e7039640e27a09989ea4)) # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) ### Features - **cli:** Generate full client test suite and improve typed client ([#2788](https://github.com/feathersjs/feathers/issues/2788)) ([57119b6](https://github.com/feathersjs/feathers/commit/57119b6bb2797f7297cf054268a248c093ecd538)) # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Bug Fixes - **core:** Ensure setup and teardown can be overriden and maintain hook functionality ([#2779](https://github.com/feathersjs/feathers/issues/2779)) ([ab580cb](https://github.com/feathersjs/feathers/commit/ab580cbcaa68d19144d86798c13bf564f9d424a6)) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) ### Features - **cli:** Adding ClientService to CLI ([#2750](https://github.com/feathersjs/feathers/issues/2750)) ([1d45427](https://github.com/feathersjs/feathers/commit/1d45427988521ac028755cbe128685fcdf34f636)) # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) - **core:** Get hooks to work reliably with custom methods ([#2714](https://github.com/feathersjs/feathers/issues/2714)) ([8d7e04a](https://github.com/feathersjs/feathers/commit/8d7e04acd0f0e2af9f4c13efee652d296dd3bc51)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Features - **authentication-local:** Add passwordHash property resolver ([#2660](https://github.com/feathersjs/feathers/issues/2660)) ([b41279b](https://github.com/feathersjs/feathers/commit/b41279b55eea3771a6fa4983a37be2413287bbc6)) - **cli:** Add typed client to a generated app ([#2669](https://github.com/feathersjs/feathers/issues/2669)) ([5b801b5](https://github.com/feathersjs/feathers/commit/5b801b5017ddc3eaa95622b539f51d605916bc86)) # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) ### Features - **client:** Improve client side custom method support ([#2654](https://github.com/feathersjs/feathers/issues/2654)) ([c138acf](https://github.com/feathersjs/feathers/commit/c138acf50affbe6b66177d084d3c7a3e9220f09f)) - **core:** Rename async hooks to around hooks, allow usual registration format ([#2652](https://github.com/feathersjs/feathers/issues/2652)) ([2a485a0](https://github.com/feathersjs/feathers/commit/2a485a07929184261f27437fc0fdfe5a44694834)) # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) ### Bug Fixes - **schema:** Allows resolveData with different resolvers based on method ([#2644](https://github.com/feathersjs/feathers/issues/2644)) ([be71fa2](https://github.com/feathersjs/feathers/commit/be71fa2fe260e05b7dcc0d5f439e33f2e9ec2434)) # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) ### Bug Fixes - **core:** Do not throw missing method error for regular hook methods ([#2636](https://github.com/feathersjs/feathers/issues/2636)) ([afe9a3b](https://github.com/feathersjs/feathers/commit/afe9a3b3d49897eff045ee237ca2937a6b975291)) # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Features - **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5)) - **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28)) # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) ### Bug Fixes - **core:** Ensure that dynamically registered services are always set up ([#2593](https://github.com/feathersjs/feathers/issues/2593)) ([27cc7d0](https://github.com/feathersjs/feathers/commit/27cc7d08321861cd69e6b66e1fdfa43c50664820)) ### Features - **authentication:** Add setup method for auth strategies ([#1611](https://github.com/feathersjs/feathers/issues/1611)) ([a3c3581](https://github.com/feathersjs/feathers/commit/a3c35814dccdbbf6de96f04f60b226ce206c6dbe)) - **core:** Add app.setup and app.teardown hook support ([#2585](https://github.com/feathersjs/feathers/issues/2585)) ([ae4ebee](https://github.com/feathersjs/feathers/commit/ae4ebee5d39957651473007c4d3adb210160e040)) - **core:** Add app.teardown functionality ([#2570](https://github.com/feathersjs/feathers/issues/2570)) ([fcdf524](https://github.com/feathersjs/feathers/commit/fcdf524ae1995bb59265d39f12e98b7794bed023)) - **core:** Finalize app.teardown() functionality ([#2584](https://github.com/feathersjs/feathers/issues/2584)) ([1a166f3](https://github.com/feathersjs/feathers/commit/1a166f3ded811ecacf0ae8cb67880bc9fa2eeafa)) - **transport-commons:** add `context.http.response` ([#2524](https://github.com/feathersjs/feathers/issues/2524)) ([5bc9d44](https://github.com/feathersjs/feathers/commit/5bc9d447043c2e2b742c73ed28ecf3b3264dd9e5)) # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) ### Features - **express, koa:** make transports similar ([#2486](https://github.com/feathersjs/feathers/issues/2486)) ([26aa937](https://github.com/feathersjs/feathers/commit/26aa937c114fb8596dfefc599b1f53cead69c159)) # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Bug Fixes - **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110)) ### Features - **core:** add `context.http` and move `statusCode` there ([#2496](https://github.com/feathersjs/feathers/issues/2496)) ([b701bf7](https://github.com/feathersjs/feathers/commit/b701bf77fb83048aa1dffa492b3d77dd53f7b72b)) - **core:** Improve legacy hooks integration ([08c8b40](https://github.com/feathersjs/feathers/commit/08c8b40999bf3889c61a4d4fad97a2c4f78bafc9)) - **transport-commons:** Ability to register routes with custom params ([#2482](https://github.com/feathersjs/feathers/issues/2482)) ([497990a](https://github.com/feathersjs/feathers/commit/497990ae4a980e5a52a1f0f932db12cd0e6e254a)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) ### Bug Fixes - **core:** Allow to return a new hook context in basic hooks ([#2462](https://github.com/feathersjs/feathers/issues/2462)) ([422b6fc](https://github.com/feathersjs/feathers/commit/422b6fc11cf9e42f4234f0823a0b06a4df50982d)) # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) ### Bug Fixes - **core:** Clean up readme ([eb3b4f2](https://github.com/feathersjs/feathers/commit/eb3b4f248c0816c92a2300cceed18a6f2518508a)) - **core:** Set version back to development ([b328767](https://github.com/feathersjs/feathers/commit/b3287676cd773e164fd646ba4cffbf81983a9157)) # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Bug Fixes - **core:** Add list of protected methods that can not be used for custom methods ([#2390](https://github.com/feathersjs/feathers/issues/2390)) ([6584a21](https://github.com/feathersjs/feathers/commit/6584a216e5a7d5f2a45822be6bfcb91c35cc2252)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) ### Bug Fixes - **typescript:** Move Paginated type back for better compatibility ([#2350](https://github.com/feathersjs/feathers/issues/2350)) ([2917d05](https://github.com/feathersjs/feathers/commit/2917d05fffb4716d3c4cdaa5ac6a1aee0972e8a6)) # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) ### Features - **deno:** Feathers core build for Deno ([#2299](https://github.com/feathersjs/feathers/issues/2299)) ([dece8fb](https://github.com/feathersjs/feathers/commit/dece8fbc0e7601f1505ce8bbb1e4e69cc26e8f98)) - **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/feathers # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) ### Bug Fixes - **dependencies:** Fix transport-commons dependency and update other dependencies ([#2284](https://github.com/feathersjs/feathers/issues/2284)) ([05b03b2](https://github.com/feathersjs/feathers/commit/05b03b27b40604d956047e3021d8053c3a137616)) - **feathers:** Always enable hooks on default service methods ([#2275](https://github.com/feathersjs/feathers/issues/2275)) ([827cc9b](https://github.com/feathersjs/feathers/commit/827cc9b752eecdaf63605d7dffd86f531b7e4af3)) # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Resolve some type problems ([#2260](https://github.com/feathersjs/feathers/issues/2260)) ([a3d75fa](https://github.com/feathersjs/feathers/commit/a3d75fa29490e8a19412a12bc993ee7bb573068f)) - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) ### Features - **core:** Public custom service methods ([#2270](https://github.com/feathersjs/feathers/issues/2270)) ([e65abfb](https://github.com/feathersjs/feathers/commit/e65abfb5388df6c19a11c565cf1076a29f32668d)) - Application service types default to any ([#1566](https://github.com/feathersjs/feathers/issues/1566)) ([d93ba9a](https://github.com/feathersjs/feathers/commit/d93ba9a17edd20d3397bb00f4f6e82e804e42ed6)) - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) - **core:** Remove Uberproto ([#2178](https://github.com/feathersjs/feathers/issues/2178)) ([ddf8821](https://github.com/feathersjs/feathers/commit/ddf8821f53317e6a378657f7d66acb03a037ee47)) ### BREAKING CHANGES - **core:** Services no longer extend Uberproto objects and `service.mixin()` is no longer available. # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### Features - **core:** Migrate @feathersjs/feathers to TypeScript ([#1963](https://github.com/feathersjs/feathers/issues/1963)) ([7812529](https://github.com/feathersjs/feathers/commit/7812529ff0f1008e21211f1d01efbc49795dbe55)) - **core:** use @feathers/hooks and add async type ([#1929](https://github.com/feathersjs/feathers/issues/1929)) ([a5c4756](https://github.com/feathersjs/feathers/commit/a5c47562eae8410c82fe2f6308f26f8e78b6a3e8)) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### Features - **core:** Migrate @feathersjs/feathers to TypeScript ([#1963](https://github.com/feathersjs/feathers/issues/1963)) ([7812529](https://github.com/feathersjs/feathers/commit/7812529ff0f1008e21211f1d01efbc49795dbe55)) - **core:** use @feathers/hooks and add async type ([#1929](https://github.com/feathersjs/feathers/issues/1929)) ([a5c4756](https://github.com/feathersjs/feathers/commit/a5c47562eae8410c82fe2f6308f26f8e78b6a3e8)) ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) **Note:** Version bump only for package @feathersjs/feathers ## [4.5.10](https://github.com/feathersjs/feathers/compare/v4.5.9...v4.5.10) (2020-11-08) ### Bug Fixes - **typescript:** Add user property to the Params. ([#2090](https://github.com/feathersjs/feathers/issues/2090)) ([1e94265](https://github.com/feathersjs/feathers/commit/1e942651fbaaf07fc66c159225fbc992a0174bf4)) ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) **Note:** Version bump only for package @feathersjs/feathers ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) **Note:** Version bump only for package @feathersjs/feathers ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) ### Bug Fixes - **typescript:** Revert add overload types for `find` service methods ([#1972](https://github.com/feathersjs/feathers/issues/1972))" ([#2025](https://github.com/feathersjs/feathers/issues/2025)) ([a9501ac](https://github.com/feathersjs/feathers/commit/a9501acb4d3ef58dfb87d62c57a9bf76569da281)) ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) ### Bug Fixes - **typescript:** add overload types for `find` service methods ([#1972](https://github.com/feathersjs/feathers/issues/1972)) ([ef55af0](https://github.com/feathersjs/feathers/commit/ef55af088d05d9d36aba9d9f8d6c2c908a4f20dd)) ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) ### Bug Fixes - **typescript:** Use stricter type for HookContext 'method' prop ([#1896](https://github.com/feathersjs/feathers/issues/1896)) ([24a41b7](https://github.com/feathersjs/feathers/commit/24a41b74486ddadccad18f3ae63afdac5bd373c7)) ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) ### Bug Fixes - **typescript:** Make HookMap and HookObject generics. ([#1815](https://github.com/feathersjs/feathers/issues/1815)) ([d10145d](https://github.com/feathersjs/feathers/commit/d10145d91a09aef7bce5af80805a3c0fa9d94f26)) ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/feathers # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) ### Bug Fixes - Add `params.authentication` type, remove `hook.connection` type ([#1732](https://github.com/feathersjs/feathers/issues/1732)) ([d46b7b2](https://github.com/feathersjs/feathers/commit/d46b7b2abac8862c0e4dbfce20d71b8b8a96692f)) ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/feathers ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/feathers # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) ### Bug Fixes - **core:** Improve hook missing parameter message by adding the service name ([#1703](https://github.com/feathersjs/feathers/issues/1703)) ([2331c2a](https://github.com/feathersjs/feathers/commit/2331c2a3dd70d432db7d62a76ed805d359cbbba5)) - **typescript:** Allow specific service typings for `Hook` and `HookContext` ([#1688](https://github.com/feathersjs/feathers/issues/1688)) ([f5d0ddd](https://github.com/feathersjs/feathers/commit/f5d0ddd9724bf5778355535d2103d59daaad6294)) ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) **Note:** Version bump only for package @feathersjs/feathers ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/feathers ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) ### Bug Fixes - Small type improvements ([#1624](https://github.com/feathersjs/feathers/issues/1624)) ([50162c6](https://github.com/feathersjs/feathers/commit/50162c6e562f0a47c6a280c4f01fff7c3afee293)) ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) ### Bug Fixes - improve Service and AdapterService types ([#1567](https://github.com/feathersjs/feathers/issues/1567)) ([baad6a2](https://github.com/feathersjs/feathers/commit/baad6a26f0f543b712ccb40359b3933ad3a21392)) ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) ### Bug Fixes - Reset version number after every publish ([#1596](https://github.com/feathersjs/feathers/issues/1596)) ([f24f82f](https://github.com/feathersjs/feathers/commit/f24f82f)) ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) ### Bug Fixes - Small improvements in dependencies and code sturcture ([#1562](https://github.com/feathersjs/feathers/issues/1562)) ([42c13e2](https://github.com/feathersjs/feathers/commit/42c13e2)) ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) **Note:** Version bump only for package @feathersjs/feathers ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) **Note:** Version bump only for package @feathersjs/feathers # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/feathers # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/feathers # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) **Note:** Version bump only for package @feathersjs/feathers # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) ### Bug Fixes - Improve Params typing ([#1474](https://github.com/feathersjs/feathers/issues/1474)) ([54a3aa7](https://github.com/feathersjs/feathers/commit/54a3aa7)) # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/feathers # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) **Note:** Version bump only for package @feathersjs/feathers # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) ### Bug Fixes - Clean up hooks code ([#1407](https://github.com/feathersjs/feathers/issues/1407)) ([f25c88b](https://github.com/feathersjs/feathers/commit/f25c88b)) - Fix @feathersjs/feathers typings http import ([abbc07b](https://github.com/feathersjs/feathers/commit/abbc07b)) - Updated typings for ServiceMethods ([#1409](https://github.com/feathersjs/feathers/issues/1409)) ([b5ee7e2](https://github.com/feathersjs/feathers/commit/b5ee7e2)) # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Typings fix and improvements. ([#1364](https://github.com/feathersjs/feathers/issues/1364)) ([515b916](https://github.com/feathersjs/feathers/commit/515b916)) - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) ### Bug Fixes - **typescript:** finally should be optional ([#1350](https://github.com/feathersjs/feathers/issues/1350)) ([f439a9e](https://github.com/feathersjs/feathers/commit/f439a9e)) - Fix versioning tests. Closes [#1346](https://github.com/feathersjs/feathers/issues/1346) ([dd519f6](https://github.com/feathersjs/feathers/commit/dd519f6)) - Use `export =` in TypeScript definitions ([#1285](https://github.com/feathersjs/feathers/issues/1285)) ([12d0f4b](https://github.com/feathersjs/feathers/commit/12d0f4b)) # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) ### Bug Fixes - Update version number check ([53575c5](https://github.com/feathersjs/feathers/commit/53575c5)) - Updated HooksObject typings ([#1300](https://github.com/feathersjs/feathers/issues/1300)) ([b28058c](https://github.com/feathersjs/feathers/commit/b28058c)) # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Do not inherit app object from Object prototype ([#1153](https://github.com/feathersjs/feathers/issues/1153)) ([ed8c2e4](https://github.com/feathersjs/feathers/commit/ed8c2e4)) - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - Normalize params to object even when it is falsy ([#1012](https://github.com/feathersjs/feathers/issues/1012)) ([af97818](https://github.com/feathersjs/feathers/commit/af97818)) - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) ### Features - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - Allow registering a service at the root level ([#1115](https://github.com/feathersjs/feathers/issues/1115)) ([c73d322](https://github.com/feathersjs/feathers/commit/c73d322)) - Allow to skip sending service events ([#1270](https://github.com/feathersjs/feathers/issues/1270)) ([b487bbd](https://github.com/feathersjs/feathers/commit/b487bbd)) - Remove (hook, next) signature and SKIP support ([#1269](https://github.com/feathersjs/feathers/issues/1269)) ([211c0f8](https://github.com/feathersjs/feathers/commit/211c0f8)) ## [3.3.1](https://github.com/feathersjs/feathers/compare/@feathersjs/feathers@3.3.0...@feathersjs/feathers@3.3.1) (2019-01-02) ### Bug Fixes - Do not inherit app object from Object prototype ([#1153](https://github.com/feathersjs/feathers/issues/1153)) ([ed8c2e4](https://github.com/feathersjs/feathers/commit/ed8c2e4)) - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) # [3.3.0](https://github.com/feathersjs/feathers/compare/@feathersjs/feathers@3.2.3...@feathersjs/feathers@3.3.0) (2018-12-16) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) ### Features - Allow registering a service at the root level ([#1115](https://github.com/feathersjs/feathers/issues/1115)) ([c73d322](https://github.com/feathersjs/feathers/commit/c73d322)) ## [3.2.3](https://github.com/feathersjs/feathers/compare/@feathersjs/feathers@3.2.2...@feathersjs/feathers@3.2.3) (2018-09-21) ### Bug Fixes - Normalize params to object even when it is falsy ([#1012](https://github.com/feathersjs/feathers/issues/1012)) ([af97818](https://github.com/feathersjs/feathers/commit/af97818)) ## [3.2.2](https://github.com/feathersjs/feathers/compare/@feathersjs/feathers@3.2.1...@feathersjs/feathers@3.2.2) (2018-09-17) **Note:** Version bump only for package @feathersjs/feathers ## [3.2.1](https://github.com/feathersjs/feathers/compare/@feathersjs/express@1.2.4...@feathersjs/feather@3.2.1) (2018-09-02) **Note:** Version bump only for package @feathersjs/express - Migrate to Monorepo ([feathers#462](https://github.com/feathersjs/feathers/issues/462)) ## [v3.2.0](https://github.com/feathersjs/feathers/tree/v3.2.0-pre.1) (2018-08-19) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.1.7...v3.2.0-pre.1) **Merged pull requests:** - Add breaking test [\#931](https://github.com/feathersjs/feathers/pull/931) ([bertho-zero](https://github.com/bertho-zero)) - Some refactoring for custom method hooks [\#930](https://github.com/feathersjs/feathers/pull/930) ([daffl](https://github.com/daffl)) - Allow adding hooks to other service methods [\#924](https://github.com/feathersjs/feathers/pull/924) ([bertho-zero](https://github.com/bertho-zero)) ## [v3.1.7](https://github.com/feathersjs/feathers/tree/v3.1.7) (2018-06-16) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.1.6...v3.1.7) **Merged pull requests:** - Update to latest Uberproto and other dependencies [\#889](https://github.com/feathersjs/feathers/pull/889) ([daffl](https://github.com/daffl)) ## [v3.1.6](https://github.com/feathersjs/feathers/tree/v3.1.6) (2018-06-03) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.1.5...v3.1.6) **Merged pull requests:** - Update uberproto to the latest version 🚀 [\#881](https://github.com/feathersjs/feathers/pull/881) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Add 'services conserve Symbols' test [\#880](https://github.com/feathersjs/feathers/pull/880) ([bertho-zero](https://github.com/bertho-zero)) - Update events to the latest version 🚀 [\#872](https://github.com/feathersjs/feathers/pull/872) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Add Greenkeeper badge 🌴 [\#867](https://github.com/feathersjs/feathers/pull/867) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v3.1.5](https://github.com/feathersjs/feathers/tree/v3.1.5) (2018-05-04) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.1.4...v3.1.5) **Merged pull requests:** - Allow methods to return a null result [\#865](https://github.com/feathersjs/feathers/pull/865) ([bertho-zero](https://github.com/bertho-zero)) ## [v3.1.4](https://github.com/feathersjs/feathers/tree/v3.1.4) (2018-03-26) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.1.3...v3.1.4) **Merged pull requests:** - Make sure error hooks always have the original context information [\#842](https://github.com/feathersjs/feathers/pull/842) ([daffl](https://github.com/daffl)) ## [v3.1.3](https://github.com/feathersjs/feathers/tree/v3.1.3) (2018-02-16) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.1.2...v3.1.3) **Merged pull requests:** - Update events to the latest version 🚀 [\#810](https://github.com/feathersjs/feathers/pull/810) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v3.1.2](https://github.com/feathersjs/feathers/tree/v3.1.2) (2018-02-10) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.1.1...v3.1.2) **Merged pull requests:** - Handle errors in error hooks properly [\#819](https://github.com/feathersjs/feathers/pull/819) ([daffl](https://github.com/daffl)) ## [v3.1.1](https://github.com/feathersjs/feathers/tree/v3.1.1) (2018-02-08) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.1.0...v3.1.1) **Merged pull requests:** - Turn argument validation into the first hook [\#818](https://github.com/feathersjs/feathers/pull/818) ([daffl](https://github.com/daffl)) - Add Russian Telegram community [\#814](https://github.com/feathersjs/feathers/pull/814) ([vodniciarv](https://github.com/vodniciarv)) ## [v3.1.0](https://github.com/feathersjs/feathers/tree/v3.1.0) (2018-01-26) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.0.5...v3.1.0) **Merged pull requests:** - Update mocha to the latest version 🚀 [\#793](https://github.com/feathersjs/feathers/pull/793) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Add ability to skip all following hooks [\#792](https://github.com/feathersjs/feathers/pull/792) ([sylvainlap](https://github.com/sylvainlap)) ## [v3.0.5](https://github.com/feathersjs/feathers/tree/v3.0.5) (2018-01-04) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.2.4...v3.0.5) **Merged pull requests:** - Add backers & sponsors from Open Collective [\#504](https://github.com/feathersjs/feathers/pull/504) ([piamancini](https://github.com/piamancini)) ## [v2.2.4](https://github.com/feathersjs/feathers/tree/v2.2.4) (2018-01-04) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.0.4...v2.2.4) ## [v3.0.4](https://github.com/feathersjs/feathers/tree/v3.0.4) (2018-01-03) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.0.3...v3.0.4) **Merged pull requests:** - Update Readme to correspond with latest release [\#772](https://github.com/feathersjs/feathers/pull/772) ([daffl](https://github.com/daffl)) ## [v3.0.3](https://github.com/feathersjs/feathers/tree/v3.0.3) (2018-01-02) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.0.2...v3.0.3) **Merged pull requests:** - Properly resolve the promise in error hooks if returnHook is set. [\#769](https://github.com/feathersjs/feathers/pull/769) ([daffl](https://github.com/daffl)) - Update semistandard to the latest version 🚀 [\#768](https://github.com/feathersjs/feathers/pull/768) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v3.0.2](https://github.com/feathersjs/feathers/tree/v3.0.2) (2017-12-05) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.0.1...v3.0.2) **Merged pull requests:** - Updated to handle array emit for service results. [\#743](https://github.com/feathersjs/feathers/pull/743) ([superlazycoder](https://github.com/superlazycoder)) ## [v3.0.1](https://github.com/feathersjs/feathers/tree/v3.0.1) (2017-11-16) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.0.0...v3.0.1) **Merged pull requests:** - Updated readme.md [\#732](https://github.com/feathersjs/feathers/pull/732) ([andlewis](https://github.com/andlewis)) - Add default export for better ES module \(TypeScript\) compatibility [\#731](https://github.com/feathersjs/feathers/pull/731) ([daffl](https://github.com/daffl)) - Throw an error for invalid service paths [\#729](https://github.com/feathersjs/feathers/pull/729) ([daffl](https://github.com/daffl)) - Update nsp to the latest version 🚀 [\#723](https://github.com/feathersjs/feathers/pull/723) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Rename expressify to express [\#719](https://github.com/feathersjs/feathers/pull/719) ([bertho-zero](https://github.com/bertho-zero)) ## [v3.0.0](https://github.com/feathersjs/feathers/tree/v3.0.0) (2017-11-01) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.0.0-pre.3...v3.0.0) **Merged pull requests:** - Update dependencies to enable Greenkeeper 🌴 [\#708](https://github.com/feathersjs/feathers/pull/708) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Feathers v3 core \(Buzzard\) [\#697](https://github.com/feathersjs/feathers/pull/697) ([daffl](https://github.com/daffl)) ## [v3.0.0-pre.3](https://github.com/feathersjs/feathers/tree/v3.0.0-pre.3) (2017-10-25) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.0.0-pre.2...v3.0.0-pre.3) **Merged pull requests:** - Better logic for returning the hook object from method call [\#706](https://github.com/feathersjs/feathers/pull/706) ([daffl](https://github.com/daffl)) - Codeclimate Updates [\#704](https://github.com/feathersjs/feathers/pull/704) ([ekryski](https://github.com/ekryski)) - Add more inline documentation [\#703](https://github.com/feathersjs/feathers/pull/703) ([daffl](https://github.com/daffl)) ## [v3.0.0-pre.2](https://github.com/feathersjs/feathers/tree/v3.0.0-pre.2) (2017-10-20) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.2.3...v3.0.0-pre.2) **Merged pull requests:** - Move to @feathersjs npm scope [\#699](https://github.com/feathersjs/feathers/pull/699) ([daffl](https://github.com/daffl)) - Also pass app object as parameter to configure callbacks [\#698](https://github.com/feathersjs/feathers/pull/698) ([daffl](https://github.com/daffl)) ## [v2.2.3](https://github.com/feathersjs/feathers/tree/v2.2.3) (2017-10-20) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.2.2...v2.2.3) **Merged pull requests:** - Move Typescript declaration dependency into devDependencies [\#696](https://github.com/feathersjs/feathers/pull/696) ([daffl](https://github.com/daffl)) - Add changelog back [\#695](https://github.com/feathersjs/feathers/pull/695) ([daffl](https://github.com/daffl)) - Add support for Feathers v3 sub-apps [\#694](https://github.com/feathersjs/feathers/pull/694) ([daffl](https://github.com/daffl)) - Feature/typescript fix [\#692](https://github.com/feathersjs/feathers/pull/692) ([TimMensch](https://github.com/TimMensch)) - Update mocha to the latest version 🚀 [\#685](https://github.com/feathersjs/feathers/pull/685) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.2.2](https://github.com/feathersjs/feathers/tree/v2.2.2) (2017-09-30) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.2.1...v2.2.2) **Merged pull requests:** - Update to latest secure dependencies [\#684](https://github.com/feathersjs/feathers/pull/684) ([daffl](https://github.com/daffl)) ## [v2.2.1](https://github.com/feathersjs/feathers/tree/v2.2.1) (2017-09-25) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.2.0...v2.2.1) **Merged pull requests:** - \[typings\] Make generic type of Service default to any [\#681](https://github.com/feathersjs/feathers/pull/681) ([j2L4e](https://github.com/j2L4e)) - Update readme.md [\#668](https://github.com/feathersjs/feathers/pull/668) ([damosse31](https://github.com/damosse31)) ## [v2.2.0](https://github.com/feathersjs/feathers/tree/v2.2.0) (2017-09-01) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.0.0-pre.1...v2.2.0) **Merged pull requests:** - No longer pollutes the global scope [\#662](https://github.com/feathersjs/feathers/pull/662) ([bertho-zero](https://github.com/bertho-zero)) - Update debug to the latest version 🚀 [\#641](https://github.com/feathersjs/feathers/pull/641) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Examples url is tinny \(broken\) [\#634](https://github.com/feathersjs/feathers/pull/634) ([rayfoss](https://github.com/rayfoss)) ## [v3.0.0-pre.1](https://github.com/feathersjs/feathers/tree/v3.0.0-pre.1) (2017-07-19) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.1.7...v3.0.0-pre.1) **Merged pull requests:** - Add a missing configure\(\) method in typescript definition [\#624](https://github.com/feathersjs/feathers/pull/624) ([jansel369](https://github.com/jansel369)) ## [v2.1.7](https://github.com/feathersjs/feathers/tree/v2.1.7) (2017-07-16) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.1.6...v2.1.7) ## [v2.1.6](https://github.com/feathersjs/feathers/tree/v2.1.6) (2017-07-16) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.1.4...v2.1.6) **Merged pull requests:** - Allows error hooks to swallow error by setting the result [\#621](https://github.com/feathersjs/feathers/pull/621) ([daffl](https://github.com/daffl)) - typings: properly overload .create\(\) [\#619](https://github.com/feathersjs/feathers/pull/619) ([j2L4e](https://github.com/j2L4e)) - Update to new plugin infrastructure [\#614](https://github.com/feathersjs/feathers/pull/614) ([daffl](https://github.com/daffl)) - Allow flag to return the hook object [\#607](https://github.com/feathersjs/feathers/pull/607) ([daffl](https://github.com/daffl)) - Use inline version Babel plugin [\#606](https://github.com/feathersjs/feathers/pull/606) ([daffl](https://github.com/daffl)) - Initial changes for Feathers v3 [\#605](https://github.com/feathersjs/feathers/pull/605) ([daffl](https://github.com/daffl)) - Update index.d.ts [\#603](https://github.com/feathersjs/feathers/pull/603) ([j2L4e](https://github.com/j2L4e)) ## [v2.1.4](https://github.com/feathersjs/feathers/tree/v2.1.4) (2017-06-26) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.1.3...v2.1.4) **Merged pull requests:** - Return types needed [\#602](https://github.com/feathersjs/feathers/pull/602) ([Creiger](https://github.com/Creiger)) - Remove TypeScript typings [\#598](https://github.com/feathersjs/feathers/pull/598) ([daffl](https://github.com/daffl)) - Remove explicit loading of babel-polyfill [\#597](https://github.com/feathersjs/feathers/pull/597) ([daffl](https://github.com/daffl)) - Add feathers-hooks to core [\#596](https://github.com/feathersjs/feathers/pull/596) ([daffl](https://github.com/daffl)) - Revert update to security links [\#590](https://github.com/feathersjs/feathers/pull/590) ([alaycock](https://github.com/alaycock)) ## [v2.1.3](https://github.com/feathersjs/feathers/tree/v2.1.3) (2017-05-29) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.1.2...v2.1.3) **Merged pull requests:** - Fix typings [\#587](https://github.com/feathersjs/feathers/pull/587) ([cranesandcaff](https://github.com/cranesandcaff)) - Update feathers-socketio to the latest version 🚀 [\#576](https://github.com/feathersjs/feathers/pull/576) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.1.2](https://github.com/feathersjs/feathers/tree/v2.1.2) (2017-05-09) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.1.1...v2.1.2) **Merged pull requests:** - Fix typescript defnition of Service. All the service methods should be [\#573](https://github.com/feathersjs/feathers/pull/573) ([harish2704](https://github.com/harish2704)) - Update socket.io-client to the latest version 🚀 [\#572](https://github.com/feathersjs/feathers/pull/572) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update dependencies to enable Greenkeeper 🌴 [\#551](https://github.com/feathersjs/feathers/pull/551) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Fix pagination type definition. [\#527](https://github.com/feathersjs/feathers/pull/527) ([asdacap](https://github.com/asdacap)) ## [v2.1.1](https://github.com/feathersjs/feathers/tree/v2.1.1) (2017-03-03) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.1.0...v2.1.1) **Merged pull requests:** - No Pagination in Typescript \#520 [\#522](https://github.com/feathersjs/feathers/pull/522) ([superbarne](https://github.com/superbarne)) ## [v2.1.0](https://github.com/feathersjs/feathers/tree/v2.1.0) (2017-03-01) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.0.3...v2.1.0) **Merged pull requests:** - Typescript Definitions [\#507](https://github.com/feathersjs/feathers/pull/507) ([AbraaoAlves](https://github.com/AbraaoAlves)) - Auto Dependency Updates ... [\#492](https://github.com/feathersjs/feathers/pull/492) ([lguzzon](https://github.com/lguzzon)) - debug@2.4.0 breaks build 🚨 [\#476](https://github.com/feathersjs/feathers/pull/476) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v2.0.3](https://github.com/feathersjs/feathers/tree/v2.0.3) (2016-12-10) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.0.2...v2.0.3) **Merged pull requests:** - Update feathers-commons to use latest [\#473](https://github.com/feathersjs/feathers/pull/473) ([daffl](https://github.com/daffl)) - Create .codeclimate.yml [\#468](https://github.com/feathersjs/feathers/pull/468) ([larkinscott](https://github.com/larkinscott)) - Update feathers-commons to version 0.8.0 🚀 [\#459](https://github.com/feathersjs/feathers/pull/459) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - adding .github folder and templates [\#442](https://github.com/feathersjs/feathers/pull/442) ([ekryski](https://github.com/ekryski)) - Remove .jshintrc [\#434](https://github.com/feathersjs/feathers/pull/434) ([marshallswain](https://github.com/marshallswain)) - jshint —\> semistandard [\#430](https://github.com/feathersjs/feathers/pull/430) ([marshallswain](https://github.com/marshallswain)) - Increase code coverage [\#429](https://github.com/feathersjs/feathers/pull/429) ([daffl](https://github.com/daffl)) - Remove NPM badges and fix code climate badge [\#428](https://github.com/feathersjs/feathers/pull/428) ([daffl](https://github.com/daffl)) - adding code coverage config, badges and LTS section [\#427](https://github.com/feathersjs/feathers/pull/427) ([ekryski](https://github.com/ekryski)) ## [v2.0.2](https://github.com/feathersjs/feathers/tree/v2.0.2) (2016-09-15) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.0.1...v2.0.2) **Merged pull requests:** - Create an app reference on service event hook object [\#406](https://github.com/feathersjs/feathers/pull/406) ([kaiquewdev](https://github.com/kaiquewdev)) - Update mocha to version 3.0.0 🚀 [\#375](https://github.com/feathersjs/feathers/pull/375) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update contributing.md [\#370](https://github.com/feathersjs/feathers/pull/370) ([MichaelErmer](https://github.com/MichaelErmer)) - mocha@2.5.0 breaks build 🚨 [\#338](https://github.com/feathersjs/feathers/pull/338) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update babel-plugin-add-module-exports to version 0.2.0 🚀 [\#326](https://github.com/feathersjs/feathers/pull/326) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - socket.io-client@1.4.6 breaks build 🚨 [\#322](https://github.com/feathersjs/feathers/pull/322) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Set rejectUnauthorized explicitly [\#321](https://github.com/feathersjs/feathers/pull/321) ([daffl](https://github.com/daffl)) ## [v2.0.1](https://github.com/feathersjs/feathers/tree/v2.0.1) (2016-04-28) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.0.0...v2.0.1) **Merged pull requests:** - Test and fix for allowing services with only a setup method [\#308](https://github.com/feathersjs/feathers/pull/308) ([daffl](https://github.com/daffl)) - Remove JSON loading from the client version [\#306](https://github.com/feathersjs/feathers/pull/306) ([daffl](https://github.com/daffl)) - Update readme.md [\#302](https://github.com/feathersjs/feathers/pull/302) ([marshallswain](https://github.com/marshallswain)) - Fix link to docs [\#268](https://github.com/feathersjs/feathers/pull/268) ([lepiaf](https://github.com/lepiaf)) - Update feathers-client to version 1.0.0 🚀 [\#263](https://github.com/feathersjs/feathers/pull/263) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - New site [\#252](https://github.com/feathersjs/feathers/pull/252) ([ekryski](https://github.com/ekryski)) ## [v2.0.0](https://github.com/feathersjs/feathers/tree/v2.0.0) (2016-02-22) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.0.0-pre.4...v2.0.0) **Merged pull requests:** - Update feathers-commons to version 0.7.0 🚀 [\#223](https://github.com/feathersjs/feathers/pull/223) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-commons to version 0.6.0 🚀 [\#210](https://github.com/feathersjs/feathers/pull/210) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Explicitly import /index files to work with Steal. [\#208](https://github.com/feathersjs/feathers/pull/208) ([marshallswain](https://github.com/marshallswain)) - Appending `nsp check` to test script. [\#205](https://github.com/feathersjs/feathers/pull/205) ([marshallswain](https://github.com/marshallswain)) ## [v2.0.0-pre.4](https://github.com/feathersjs/feathers/tree/v2.0.0-pre.4) (2016-01-16) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.0.0-pre.3...v2.0.0-pre.4) **Merged pull requests:** - Fixing .npmignore entries [\#203](https://github.com/feathersjs/feathers/pull/203) ([corymsmith](https://github.com/corymsmith)) ## [v2.0.0-pre.3](https://github.com/feathersjs/feathers/tree/v2.0.0-pre.3) (2016-01-16) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.0.0-pre.2...v2.0.0-pre.3) **Merged pull requests:** - Reorganizing packages to not load Express [\#202](https://github.com/feathersjs/feathers/pull/202) ([daffl](https://github.com/daffl)) - Update feathers-client to version 0.5.1 🚀 [\#200](https://github.com/feathersjs/feathers/pull/200) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-commons to version 0.5.0 🚀 [\#198](https://github.com/feathersjs/feathers/pull/198) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v2.0.0-pre.2](https://github.com/feathersjs/feathers/tree/v2.0.0-pre.2) (2016-01-10) [Full Changelog](https://github.com/feathersjs/feathers/compare/v2.0.0-pre.1...v2.0.0-pre.2) **Merged pull requests:** - Make Feathers universal [\#193](https://github.com/feathersjs/feathers/pull/193) ([daffl](https://github.com/daffl)) - Remove Lodash [\#192](https://github.com/feathersjs/feathers/pull/192) ([daffl](https://github.com/daffl)) ## [v2.0.0-pre.1](https://github.com/feathersjs/feathers/tree/v2.0.0-pre.1) (2016-01-05) [Full Changelog](https://github.com/feathersjs/feathers/compare/v1.3.0...v2.0.0-pre.1) **Merged pull requests:** - Migration to ES6 and API providers in separate modules [\#188](https://github.com/feathersjs/feathers/pull/188) ([daffl](https://github.com/daffl)) ## [v1.3.0](https://github.com/feathersjs/feathers/tree/v1.3.0) (2015-12-16) [Full Changelog](https://github.com/feathersjs/feathers/compare/v1.2.1...v1.3.0) ## [v1.2.1](https://github.com/feathersjs/feathers/tree/v1.2.1) (2015-12-12) [Full Changelog](https://github.com/feathersjs/feathers/compare/v1.2.0...v1.2.1) **Merged pull requests:** - Add ability to create, update, patch and remove many [\#179](https://github.com/feathersjs/feathers/pull/179) ([daffl](https://github.com/daffl)) - Handle middleware passed after the service to app.use [\#178](https://github.com/feathersjs/feathers/pull/178) ([dbkaplun](https://github.com/dbkaplun)) - Adding tests to make sure that dispatcher context is set properly. [\#172](https://github.com/feathersjs/feathers/pull/172) ([daffl](https://github.com/daffl)) ## [v1.2.0](https://github.com/feathersjs/feathers/tree/v1.2.0) (2015-11-07) [Full Changelog](https://github.com/feathersjs/feathers/compare/v1.1.1...v1.2.0) **Merged pull requests:** - Make sure event hookups happens after method normalization [\#151](https://github.com/feathersjs/feathers/pull/151) ([daffl](https://github.com/daffl)) - Add rubberduck args to service events parameters [\#148](https://github.com/feathersjs/feathers/pull/148) ([loris](https://github.com/loris)) - Debug should be for socket.io instead of primus [\#147](https://github.com/feathersjs/feathers/pull/147) ([marshallswain](https://github.com/marshallswain)) ## [v1.1.1](https://github.com/feathersjs/feathers/tree/v1.1.1) (2015-09-22) [Full Changelog](https://github.com/feathersjs/feathers/compare/v1.1.0...v1.1.1) **Merged pull requests:** - Fix 404 not being properly thrown by REST provider [\#146](https://github.com/feathersjs/feathers/pull/146) ([loris](https://github.com/loris)) ## [v1.1.0](https://github.com/feathersjs/feathers/tree/v1.1.0) (2015-07-22) [Full Changelog](https://github.com/feathersjs/feathers/compare/1.1.0-pre.0...v1.1.0) **Merged pull requests:** - New homepage updates [\#140](https://github.com/feathersjs/feathers/pull/140) ([daffl](https://github.com/daffl)) - New site [\#137](https://github.com/feathersjs/feathers/pull/137) ([ekryski](https://github.com/ekryski)) - Allow to register remote services [\#136](https://github.com/feathersjs/feathers/pull/136) ([daffl](https://github.com/daffl)) ## [1.1.0-pre.0](https://github.com/feathersjs/feathers/tree/1.1.0-pre.0) (2015-04-10) [Full Changelog](https://github.com/feathersjs/feathers/compare/1.0.2...1.1.0-pre.0) **Merged pull requests:** - Run Socket configurations before service setup \(\#131\) [\#132](https://github.com/feathersjs/feathers/pull/132) ([daffl](https://github.com/daffl)) - Allow services to dispatch custom events. [\#128](https://github.com/feathersjs/feathers/pull/128) ([daffl](https://github.com/daffl)) - Moving documentation into the main repository. [\#127](https://github.com/feathersjs/feathers/pull/127) ([daffl](https://github.com/daffl)) - Adding contributing guidelines and updating build process. [\#126](https://github.com/feathersjs/feathers/pull/126) ([daffl](https://github.com/daffl)) - Service method call normalization [\#124](https://github.com/feathersjs/feathers/pull/124) ([daffl](https://github.com/daffl)) - Tests for socket message validation and errors. [\#123](https://github.com/feathersjs/feathers/pull/123) ([daffl](https://github.com/daffl)) - Migrating shared functionality into the feathers-commons module [\#122](https://github.com/feathersjs/feathers/pull/122) ([daffl](https://github.com/daffl)) - Adding debug module and messages. [\#117](https://github.com/feathersjs/feathers/pull/117) ([daffl](https://github.com/daffl)) - Fix duplicate events in dynamic services. [\#115](https://github.com/feathersjs/feathers/pull/115) ([marshallswain](https://github.com/marshallswain)) - Make sure .setup\(\) runs on dynamic services. [\#110](https://github.com/feathersjs/feathers/pull/110) ([marshallswain](https://github.com/marshallswain)) - Add a Gitter chat badge to readme.md [\#109](https://github.com/feathersjs/feathers/pull/109) ([gitter-badger](https://github.com/gitter-badger)) - Support for registering services dynamically [\#107](https://github.com/feathersjs/feathers/pull/107) ([marshallswain](https://github.com/marshallswain)) ## [1.0.2](https://github.com/feathersjs/feathers/tree/1.0.2) (2015-02-04) [Full Changelog](https://github.com/feathersjs/feathers/compare/1.0.1...1.0.2) **Merged pull requests:** - Use Uberproto extended instance when creating services [\#105](https://github.com/feathersjs/feathers/pull/105) ([daffl](https://github.com/daffl)) - Make sure that mixins are specific to each new app [\#104](https://github.com/feathersjs/feathers/pull/104) ([daffl](https://github.com/daffl)) ## [1.0.1](https://github.com/feathersjs/feathers/tree/1.0.1) (2014-12-31) [Full Changelog](https://github.com/feathersjs/feathers/compare/1.0.0...1.0.1) **Merged pull requests:** - Rename Uberproto .create to avoid conflicts with service method [\#100](https://github.com/feathersjs/feathers/pull/100) ([daffl](https://github.com/daffl)) ## [1.0.0](https://github.com/feathersjs/feathers/tree/1.0.0) (2014-10-03) [Full Changelog](https://github.com/feathersjs/feathers/compare/1.0.0-pre.5...1.0.0) **Merged pull requests:** - Version 1.0 homepage [\#95](https://github.com/feathersjs/feathers/pull/95) ([daffl](https://github.com/daffl)) - Remove app.lookup and make the functionality available as app.service [\#94](https://github.com/feathersjs/feathers/pull/94) ([daffl](https://github.com/daffl)) - Allow not passing parameters in socket calls [\#92](https://github.com/feathersjs/feathers/pull/92) ([daffl](https://github.com/daffl)) - Add \_setup method [\#91](https://github.com/feathersjs/feathers/pull/91) ([daffl](https://github.com/daffl)) - Better bodyParser usage, fix typo. [\#90](https://github.com/feathersjs/feathers/pull/90) ([olegskl](https://github.com/olegskl)) - Throw an error when registering a service after application start [\#78](https://github.com/feathersjs/feathers/pull/78) ([daffl](https://github.com/daffl)) - Use URI parameters as service params and remove bodyParser dependendency [\#77](https://github.com/feathersjs/feathers/pull/77) ([daffl](https://github.com/daffl)) - Send socket parameters as params.query [\#72](https://github.com/feathersjs/feathers/pull/72) ([daffl](https://github.com/daffl)) - Send HTTP 201 and 204 status codes [\#71](https://github.com/feathersjs/feathers/pull/71) ([daffl](https://github.com/daffl)) - Upgrade to SocketIO 1.0 [\#70](https://github.com/feathersjs/feathers/pull/70) ([daffl](https://github.com/daffl)) - Allow service methods to return a promise [\#59](https://github.com/feathersjs/feathers/pull/59) ([daffl](https://github.com/daffl)) - Allow to register services with custom middleware. [\#56](https://github.com/feathersjs/feathers/pull/56) ([daffl](https://github.com/daffl)) - Upgrade to Express 4 [\#55](https://github.com/feathersjs/feathers/pull/55) ([daffl](https://github.com/daffl)) ## [1.0.0-pre.5](https://github.com/feathersjs/feathers/tree/1.0.0-pre.5) (2014-06-13) [Full Changelog](https://github.com/feathersjs/feathers/compare/1.0.0-pre.1...1.0.0-pre.5) **Merged pull requests:** - requiring feathers-errors in core [\#81](https://github.com/feathersjs/feathers/pull/81) ([ekryski](https://github.com/ekryski)) ## [1.0.0-pre.1](https://github.com/feathersjs/feathers/tree/1.0.0-pre.1) (2014-06-04) [Full Changelog](https://github.com/feathersjs/feathers/compare/0.4.0...1.0.0-pre.1) ## [0.4.0](https://github.com/feathersjs/feathers/tree/0.4.0) (2014-04-08) [Full Changelog](https://github.com/feathersjs/feathers/compare/0.3.2...0.4.0) **Merged pull requests:** - Allow to configure REST handler manually [\#52](https://github.com/feathersjs/feathers/pull/52) ([daffl](https://github.com/daffl)) - Event filtering and params extension for Primus [\#51](https://github.com/feathersjs/feathers/pull/51) ([daffl](https://github.com/daffl)) - SocketIO event filtering [\#50](https://github.com/feathersjs/feathers/pull/50) ([daffl](https://github.com/daffl)) - Adding SocketIO handshake data to service call parameters [\#49](https://github.com/feathersjs/feathers/pull/49) ([daffl](https://github.com/daffl)) - Added patch support [\#47](https://github.com/feathersjs/feathers/pull/47) ([mlaug](https://github.com/mlaug)) ## [0.3.2](https://github.com/feathersjs/feathers/tree/0.3.2) (2014-03-28) [Full Changelog](https://github.com/feathersjs/feathers/compare/0.3.1...0.3.2) **Merged pull requests:** - Use feathers/express apps [\#46](https://github.com/feathersjs/feathers/pull/46) ([bredele](https://github.com/bredele)) - Upgrading dependencies and switching to Lodash [\#42](https://github.com/feathersjs/feathers/pull/42) ([daffl](https://github.com/daffl)) ## [0.3.1](https://github.com/feathersjs/feathers/tree/0.3.1) (2014-02-19) [Full Changelog](https://github.com/feathersjs/feathers/compare/0.3.0...0.3.1) **Merged pull requests:** - Updating REST provider [\#35](https://github.com/feathersjs/feathers/pull/35) ([daffl](https://github.com/daffl)) ## [0.3.0](https://github.com/feathersjs/feathers/tree/0.3.0) (2014-01-06) [Full Changelog](https://github.com/feathersjs/feathers/compare/0.2.0...0.3.0) **Merged pull requests:** - Primus provider [\#34](https://github.com/feathersjs/feathers/pull/34) ([daffl](https://github.com/daffl)) - Add app.setup\(\) to support HTTPS [\#33](https://github.com/feathersjs/feathers/pull/33) ([daffl](https://github.com/daffl)) - Remove middleware: connect.bodyParser\(\) [\#27](https://github.com/feathersjs/feathers/pull/27) ([sbruchmann](https://github.com/sbruchmann)) ## [0.2.0](https://github.com/feathersjs/feathers/tree/0.2.0) (2013-09-27) [Full Changelog](https://github.com/feathersjs/feathers/compare/0.1.0...0.2.0) **Merged pull requests:** - Allows registering services with slashes [\#18](https://github.com/feathersjs/feathers/pull/18) ([daffl](https://github.com/daffl)) - Allows setting service params in middleware [\#17](https://github.com/feathersjs/feathers/pull/17) ([daffl](https://github.com/daffl)) ## [0.1.0](https://github.com/feathersjs/feathers/tree/0.1.0) (2013-08-27) [Full Changelog](https://github.com/feathersjs/feathers/compare/0.0.5...0.1.0) ## [0.0.5](https://github.com/feathersjs/feathers/tree/0.0.5) (2013-08-27) [Full Changelog](https://github.com/feathersjs/feathers/compare/0.0.4...0.0.5) ## [0.0.4](https://github.com/feathersjs/feathers/tree/0.0.4) (2013-08-27) [Full Changelog](https://github.com/feathersjs/feathers/compare/0.0.3...0.0.4) **Merged pull requests:** - Major refactoring and simplification [\#16](https://github.com/feathersjs/feathers/pull/16) ([daffl](https://github.com/daffl)) ## [0.0.3](https://github.com/feathersjs/feathers/tree/0.0.3) (2013-08-26) [Full Changelog](https://github.com/feathersjs/feathers/compare/0.0.2...0.0.3) **Merged pull requests:** - Improved Mixin organization, updated tests and examples. [\#15](https://github.com/feathersjs/feathers/pull/15) ([daffl](https://github.com/daffl)) ## [0.0.2](https://github.com/feathersjs/feathers/tree/0.0.2) (2013-07-13) **Merged pull requests:** - Added a couple examples. Started to add a mongo adapter. [\#2](https://github.com/feathersjs/feathers/pull/2) ([ekryski](https://github.com/ekryski)) \* _This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)_ ================================================ FILE: packages/feathers/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/feathers/README.md ================================================ Feathers logo ## The API and real-time application framework [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/feathers.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/feathers) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) Feathers is a lightweight web-framework for creating APIs and real-time applications using TypeScript or JavaScript. Feathers can interact with any backend technology, supports many databases out of the box and works with any frontend technology like React, VueJS, Angular, React Native, Android or iOS. ## Getting started You can build your first real-time and REST API in just 4 commands: ```bash $ npm create feathers my-new-app $ cd my-new-app $ npm start ``` ## Documentation To learn more about Feathers visit the website at [feathersjs.com](http://feathersjs.com) or jump right into [the Feathers guides](http://feathersjs.com/guides). ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/feathers/package.json ================================================ { "name": "@feathersjs/feathers", "description": "A framework for real-time applications and REST API with JavaScript and TypeScript", "version": "5.0.42", "homepage": "http://feathersjs.com", "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/feathers" }, "keywords": [ "feathers", "REST", "socket.io", "realtime" ], "main": "lib/", "types": "lib/", "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "directories": { "lib": "lib" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "scripts": { "write-version": "node -e \"console.log('export default \\'' + require('./package.json').version + '\\'')\" > src/version.ts", "reset-version": "node -e \"console.log('export default \\'development\\'')\" > src/version.ts", "prepublish": "npm run compile", "version": "npm run write-version", "publish": "npm run reset-version", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/" }, "engines": { "node": ">= 12" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/commons": "^5.0.42", "@feathersjs/hooks": "^0.9.0", "events": "^3.3.0" }, "devDependencies": { "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "mocha": "^11.7.5", "shx": "^0.4.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/feathers/src/application.ts ================================================ import version from './version' import { EventEmitter } from 'events' import { stripSlashes, createDebug } from '@feathersjs/commons' import { HOOKS, hooks, middleware } from '@feathersjs/hooks' import { eventHook, eventMixin } from './events' import { hookMixin } from './hooks' import { wrapService, getServiceOptions, protectedMethods } from './service' import { FeathersApplication, ServiceMixin, Service, ServiceOptions, ServiceInterface, Application, FeathersService, ApplicationHookOptions } from './declarations' import { enableHooks } from './hooks' const debug = createDebug('@feathersjs/feathers') export class Feathers extends EventEmitter implements FeathersApplication { services: Services = {} as Services settings: Settings = {} as Settings mixins: ServiceMixin>[] = [hookMixin, eventMixin] version: string = version _isSetup = false protected registerHooks: (this: any, allHooks: any) => any constructor() { super() this.registerHooks = enableHooks(this) this.registerHooks({ around: [eventHook] }) } get(name: L): Settings[L] { return this.settings[name] } set(name: L, value: Settings[L]) { this.settings[name] = value return this } configure(callback: (this: this, app: this) => void) { callback.call(this, this) return this } defaultService(location: string): ServiceInterface { throw new Error(`Can not find service '${location}'`) } service( location: L ): FeathersService { const path = (stripSlashes(location) || '/') as L const current = this.services.hasOwnProperty(path) ? this.services[path] : undefined if (typeof current === 'undefined') { this.use(path, this.defaultService(path) as any) return this.service(path) } return current as any } protected _setup() { this._isSetup = true return Object.keys(this.services) .reduce( (current, path) => current.then(() => { const service: any = this.service(path as any) if (typeof service.setup === 'function') { debug(`Setting up service for \`${path}\``) return service.setup(this, path) } }), Promise.resolve() ) .then(() => this) } get setup() { return this._setup } set setup(value) { this._setup = (value as any)[HOOKS] ? value : hooks( value, middleware().params('server').props({ app: this }) ) } protected _teardown() { this._isSetup = false return Object.keys(this.services) .reduce( (current, path) => current.then(() => { const service: any = this.service(path as any) if (typeof service.teardown === 'function') { debug(`Tearing down service for \`${path}\``) return service.teardown(this, path) } }), Promise.resolve() ) .then(() => this) } get teardown() { return this._teardown } set teardown(value) { this._teardown = (value as any)[HOOKS] ? value : hooks( value, middleware().params('server').props({ app: this }) ) } use( path: L, service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L], options?: ServiceOptions ): this { if (typeof path !== 'string') { throw new Error(`'${path}' is not a valid service path.`) } const location = (stripSlashes(path) || '/') as L const subApp = service as Application const isSubApp = typeof subApp.service === 'function' && subApp.services if (isSubApp) { Object.keys(subApp.services).forEach((subPath) => this.use(`${location}/${subPath}` as any, subApp.service(subPath) as any) ) return this } const protoService = wrapService(location, service, options as ServiceOptions) const serviceOptions = getServiceOptions(protoService) for (const name of protectedMethods) { if (serviceOptions.methods.includes(name)) { throw new Error(`'${name}' on service '${location}' is not allowed as a custom method name`) } } debug(`Registering new service at \`${location}\``) // Add all the mixins this.mixins.forEach((fn) => fn.call(this, protoService, location, serviceOptions)) this.services[location] = protoService // If we ran setup already, set this service up explicitly, this will not `await` if (this._isSetup && typeof protoService.setup === 'function') { debug(`Setting up service for \`${location}\``) protoService.setup(this, location) } return this } async unuse( location: L ): Promise> { const path = (stripSlashes(location) || '/') as L const service = this.services[path] as Service if (service && typeof service.teardown === 'function') { await service.teardown(this as any, path) } delete this.services[path] return service as any } hooks(hookMap: ApplicationHookOptions) { const untypedMap = hookMap as any if (untypedMap.before || untypedMap.after || untypedMap.error || untypedMap.around) { // regular hooks for all service methods this.registerHooks(untypedMap) } else if (untypedMap.setup || untypedMap.teardown) { // .setup and .teardown application hooks hooks(this, untypedMap) } else { // Other registration formats are just `around` hooks this.registerHooks({ around: untypedMap }) } return this } } ================================================ FILE: packages/feathers/src/declarations.ts ================================================ import { EventEmitter } from 'events' import { NextFunction, HookContext as BaseHookContext } from '@feathersjs/hooks' type SelfOrArray = S | S[] type OptionalPick = Pick> type Entries = { [K in keyof T]: [K, T[K]] }[keyof T][] type GetKeyByValue = Extract[number], [PropertyKey, Value]>[0] export type { NextFunction } /** * The object returned from `.find` call by standard database adapters */ export interface Paginated { total: number limit: number skip: number data: T[] } /** * Options that can be passed when registering a service via `app.use(name, service, options)` */ export interface ServiceOptions { /** * A list of custom events that this service emits to clients */ events?: string[] | readonly string[] /** * A list of service methods that should be available __externally__ to clients */ methods?: MethodTypes[] | readonly MethodTypes[] /** * Provide a full list of events that this service should emit to clients. * Unlike the `events` option, this will not be merged with the default events. */ serviceEvents?: string[] | readonly string[] /** * Initial data to always add as route params to this service. */ routeParams?: { [key: string]: any } } export interface ClientService< Result = any, Data = Partial, PatchData = Data, FindResult = Paginated, P = Params > { find(params?: P): Promise get(id: Id, params?: P): Promise create(data: Data[], params?: P): Promise create(data: Data, params?: P): Promise update(id: Id, data: Data, params?: P): Promise update(id: NullableId, data: Data, params?: P): Promise update(id: null, data: Data, params?: P): Promise patch(id: NullableId, data: PatchData, params?: P): Promise patch(id: Id, data: PatchData, params?: P): Promise patch(id: null, data: PatchData, params?: P): Promise remove(id: NullableId, params?: P): Promise remove(id: Id, params?: P): Promise remove(id: null, params?: P): Promise } export interface ServiceMethods< Result = any, Data = Partial, ServiceParams = Params, PatchData = Partial > { find(params?: ServiceParams & { paginate?: PaginationParams }): Promise get(id: Id, params?: ServiceParams): Promise create(data: Data, params?: ServiceParams): Promise update(id: NullableId, data: Data, params?: ServiceParams): Promise patch(id: NullableId, data: PatchData, params?: ServiceParams): Promise remove(id: NullableId, params?: ServiceParams): Promise setup?(app: Application, path: string): Promise teardown?(app: Application, path: string): Promise } export interface ServiceOverloads< Result = any, Data = Partial, ServiceParams = Params, PatchData = Partial > { create?(data: Data[], params?: ServiceParams): Promise update?(id: Id, data: Data, params?: ServiceParams): Promise update?(id: null, data: Data, params?: ServiceParams): Promise patch?(id: Id, data: PatchData, params?: ServiceParams): Promise patch?(id: null, data: PatchData, params?: ServiceParams): Promise remove?(id: Id, params?: ServiceParams): Promise remove?(id: null, params?: ServiceParams): Promise } /** * A complete service interface. The `ServiceInterface` type should be preferred for customs service * implementations */ export type Service< Result = any, Data = Partial, ServiceParams = Params, PatchData = Partial > = ServiceMethods & ServiceOverloads /** * The `Service` service interface but with none of the methods required. */ export type ServiceInterface< Result = any, Data = Partial, ServiceParams = Params, PatchData = Partial > = Partial> export interface ServiceAddons extends EventEmitter { id?: string hooks(options: HookOptions): this } export interface ServiceHookOverloads { find(params: P & { paginate?: PaginationParams }, context: HookContext): Promise get(id: Id, params: P, context: HookContext): Promise create( data: ServiceGenericData | ServiceGenericData[], params: P, context: HookContext ): Promise update(id: NullableId, data: ServiceGenericData, params: P, context: HookContext): Promise patch(id: NullableId, data: ServiceGenericData, params: P, context: HookContext): Promise remove(id: NullableId, params: P, context: HookContext): Promise } export type FeathersService = S & ServiceAddons & OptionalPick, keyof S> export type CustomMethods = { [K in keyof T]: (data: T[K][0], params?: Params) => Promise } /** * An interface usually use by transport clients that represents a e.g. HTTP or websocket * connection that can be configured on the application. */ export type TransportConnection = { (app: Application): void Service: any service: ( name: L ) => keyof any extends keyof Services ? ServiceInterface : Services[L] } /** * A real-time connection object */ export interface RealTimeConnection { [key: string]: any } /** * The interface for a custom service method. Can e.g. be used to type client side services. */ export type CustomMethod = (data: T, params?: P) => Promise export type ServiceMixin = (service: FeathersService, path: string, options: ServiceOptions) => void export type ServiceGenericType = S extends ServiceInterface ? T : any export type ServiceGenericData = S extends ServiceInterface ? D : any export type ServiceGenericParams = S extends ServiceInterface ? P : any export interface FeathersApplication { /** * The Feathers application version */ version: string /** * A list of callbacks that run when a new service is registered */ mixins: ServiceMixin>[] /** * The index of all services keyed by their path. * * __Important:__ Services should always be retrieved via `app.service('name')` * not via `app.services`. */ services: Services /** * The application settings that can be used via * `app.get` and `app.set` */ settings: Settings /** * A private-ish indicator if `app.setup()` has been called already */ _isSetup: boolean /** * Retrieve an application setting by name * * @param name The setting name */ get(name: L): Settings[L] /** * Set an application setting * * @param name The setting name * @param value The setting value */ set(name: L, value: Settings[L]): this /** * Runs a callback configure function with the current application instance. * * @param callback The callback `(app: Application) => {}` to run */ configure(callback: (this: this, app: this) => void): this /** * Returns a fallback service instance that will be registered * when no service was found. Usually throws a `NotFound` error * but also used to instantiate client side services. * * @param location The path of the service */ defaultService(location: string): ServiceInterface /** * Register a new service or a sub-app. When passed another * Feathers application, all its services will be re-registered * with the `path` prefix. * * @param path The path for the service to register * @param service The service object to register or another * Feathers application to use a sub-app under the `path` prefix. * @param options The options for this service */ use( path: L, service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L], options?: ServiceOptions ): this /** * Unregister an existing service. * * @param path The name of the service to unregister */ unuse( path: L ): Promise> /** * Get the Feathers service instance for a path. This will * be the service originally registered with Feathers functionality * like hooks and events added. * * @param path The name of the service. */ service( path: L ): FeathersService /** * Set up the application and call all services `.setup` method if available. * * @param server A server instance (optional) */ setup(server?: any): Promise /** * Tear down the application and call all services `.teardown` method if available. * * @param server A server instance (optional) */ teardown(server?: any): Promise /** * Register application level hooks. * * @param map The application hook settings. */ hooks(map: ApplicationHookOptions): this } // This needs to be an interface instead of a type // so that the declaration can be extended by other modules export interface Application extends FeathersApplication, EventEmitter {} export type Id = number | string export type NullableId = Id | null export interface Query { [key: string]: any } export interface Params { query?: Q provider?: string route?: { [key: string]: any } headers?: { [key: string]: any } } export interface PaginationOptions { default?: number max?: number } export type PaginationParams = false | PaginationOptions export interface Http { /** * A writeable, optional property with status code override. */ status?: number /** * A writeable, optional property with headers. */ headers?: { [key: string]: string | string[] } /** * A writeable, optional property with `Location` header's value. */ location?: string } export type HookType = 'before' | 'after' | 'error' | 'around' type Serv = FA extends Application ? S : never export interface HookContext extends BaseHookContext> { /** * A read only property that contains the Feathers application object. This can be used to * retrieve other services (via context.app.service('name')) or configuration values. */ readonly app: A /** * A read only property with the name of the service method (one of find, get, * create, update, patch, remove). */ readonly method: string /** * A read only property and contains the service name (or path) without leading or * trailing slashes. */ path: 0 extends 1 & S ? keyof Serv & string : GetKeyByValue, S> & string /** * A read only property and contains the service this hook currently runs on. */ readonly service: S /** * A read only property with the hook type (one of 'around', 'before', 'after' or 'error'). */ readonly type: HookType /** * The list of method arguments. Should not be modified, modify the * `params`, `data` and `id` properties instead. */ readonly arguments: any[] /** * A writeable property containing the data of a create, update and patch service * method call. */ data?: ServiceGenericData /** * A writeable property with the error object that was thrown in a failed method call. * It is only available in error hooks. */ error?: any /** * A writeable property and the id for a get, remove, update and patch service * method call. For remove, update and patch context.id can also be null when * modifying multiple entries. In all other cases it will be undefined. */ id?: Id /** * A writeable property that contains the service method parameters (including * params.query). */ params: ServiceGenericParams /** * A writeable property containing the result of the successful service method call. * It is only available in after hooks. * * `context.result` can also be set in * * - A before hook to skip the actual service method (database) call * - An error hook to swallow the error and return a result instead */ result?: ServiceGenericType /** * A writeable, optional property and contains a 'safe' version of the data that * should be sent to any client. If context.dispatch has not been set context.result * will be sent to the client instead. */ dispatch?: ServiceGenericType /** * A writeable, optional property that allows to override the standard HTTP status * code that should be returned. * * @deprecated Use `http.status` instead. */ statusCode?: number /** * A writeable, optional property with options specific to HTTP transports. */ http?: Http /** * The event emitted by this method. Can be set to `null` to skip event emitting. */ event: string | null } // Regular hook typings export type HookFunction = ( this: S, context: HookContext ) => Promise | void> | HookContext | void export type Hook = HookFunction type HookMethodMap = { [L in keyof S]?: SelfOrArray> } & { all?: SelfOrArray> } type HookTypeMap = SelfOrArray> | HookMethodMap // New @feathersjs/hook typings export type AroundHookFunction = ( context: HookContext, next: NextFunction ) => Promise export type AroundHookMap = { [L in keyof S]?: AroundHookFunction[] } & { all?: AroundHookFunction[] } export type HookMap = { around?: AroundHookMap before?: HookTypeMap after?: HookTypeMap error?: HookTypeMap } export type HookOptions = AroundHookMap | AroundHookFunction[] | HookMap export interface ApplicationHookContext extends BaseHookContext { app: A server: any } export type ApplicationHookFunction = ( context: ApplicationHookContext, next: NextFunction ) => Promise export type ApplicationHookMap = { setup?: ApplicationHookFunction[] teardown?: ApplicationHookFunction[] } export type ApplicationHookOptions = HookOptions | ApplicationHookMap ================================================ FILE: packages/feathers/src/events.ts ================================================ import { EventEmitter } from 'events' import { NextFunction } from '@feathersjs/hooks' import { HookContext, FeathersService } from './declarations' import { getServiceOptions, defaultEventMap } from './service' export function eventHook(context: HookContext, next: NextFunction) { const { events } = getServiceOptions((context as any).self) const defaultEvent = (defaultEventMap as any)[context.method] || null context.event = defaultEvent return next().then(() => { // Send the event only if the service does not do so already (indicated in the `events` option) // This is used for custom events and for client services receiving event from the server if (typeof context.event === 'string' && !events.includes(context.event)) { const results = Array.isArray(context.result) ? context.result : [context.result] results.forEach((element) => (context as any).self.emit(context.event, element, context)) } }) } export function eventMixin(service: FeathersService) { const isEmitter = typeof service.on === 'function' && typeof service.emit === 'function' if (!isEmitter) { Object.assign(service, EventEmitter.prototype) } return service } ================================================ FILE: packages/feathers/src/hooks.ts ================================================ import { getManager, HookContextData, HookManager, HookMap as BaseHookMap, hooks, Middleware, collect } from '@feathersjs/hooks' import { Service, ServiceOptions, HookContext, FeathersService, HookMap, AroundHookFunction, HookFunction, HookType } from './declarations' import { defaultServiceArguments, getHookMethods } from './service' type ConvertedMap = { [type in HookType]: ReturnType } type HookStore = { around: { [method: string]: AroundHookFunction[] } before: { [method: string]: HookFunction[] } after: { [method: string]: HookFunction[] } error: { [method: string]: HookFunction[] } collected: { [method: string]: AroundHookFunction[] } collectedAll: { before?: AroundHookFunction[]; after?: AroundHookFunction[] } } type HookEnabled = { __hooks: HookStore } const types: HookType[] = ['before', 'after', 'error', 'around'] const isType = (value: any): value is HookType => types.includes(value) // Converts different hook registration formats into the // same internal format export function convertHookData(input: any) { const result: { [method: string]: HookFunction[] | AroundHookFunction[] } = {} if (Array.isArray(input)) { result.all = input } else if (typeof input !== 'object') { result.all = [input] } else { for (const key of Object.keys(input)) { const value = input[key] result[key] = Array.isArray(value) ? value : [value] } } return result } export function collectHooks(target: HookEnabled, method: string) { const { collected, collectedAll, around } = target.__hooks return [ ...(around.all || []), ...(around[method] || []), ...(collectedAll.before || []), ...(collected[method] || []), ...(collectedAll.after || []) ] as AroundHookFunction[] } // Add `.hooks` functionality to an object export function enableHooks(object: any) { const store: HookStore = { around: {}, before: {}, after: {}, error: {}, collected: {}, collectedAll: {} } Object.defineProperty(object, '__hooks', { configurable: true, value: store, writable: true }) return function registerHooks(this: HookEnabled, input: HookMap) { const store = this.__hooks const map = Object.keys(input).reduce((map, type) => { if (!isType(type)) { throw new Error(`'${type}' is not a valid hook type`) } map[type] = convertHookData(input[type]) return map }, {} as ConvertedMap) const types = Object.keys(map) as HookType[] types.forEach((type) => Object.keys(map[type]).forEach((method) => { const mapHooks = map[type][method] const storeHooks: any[] = (store[type][method] ||= []) storeHooks.push(...mapHooks) if (method === 'all') { if (store.before[method] || store.error[method]) { const beforeAll = collect({ before: store.before[method] || [], error: store.error[method] || [] }) store.collectedAll.before = [beforeAll] } if (store.after[method]) { const afterAll = collect({ after: store.after[method] || [] }) store.collectedAll.after = [afterAll] } } else { if (store.before[method] || store.after[method] || store.error[method]) { const collected = collect({ before: store.before[method] || [], after: store.after[method] || [], error: store.error[method] || [] }) store.collected[method] = [collected] } } }) ) return this } } export function createContext(service: Service, method: string, data: HookContextData = {}) { const createContext = (service as any)[method].createContext if (typeof createContext !== 'function') { throw new Error(`Can not create context for method ${method}`) } return createContext(data) as HookContext } export class FeathersHookManager extends HookManager { constructor( public app: A, public method: string ) { super() this._middleware = [] } collectMiddleware(self: any, args: any[]): Middleware[] { const appHooks = collectHooks(this.app as any as HookEnabled, this.method) const middleware = super.collectMiddleware(self, args) const methodHooks = collectHooks(self, this.method) return [...appHooks, ...middleware, ...methodHooks] } initializeContext(self: any, args: any[], context: HookContext) { const ctx = super.initializeContext(self, args, context) ctx.params = ctx.params || {} return ctx } middleware(mw: Middleware[]) { this._middleware.push(...mw) return this } } export function hookMixin(this: A, service: FeathersService, path: string, options: ServiceOptions) { if (typeof service.hooks === 'function') { return service } const hookMethods = getHookMethods(service, options) const serviceMethodHooks = hookMethods.reduce((res, method) => { const params = (defaultServiceArguments as any)[method] || ['data', 'params'] res[method] = new FeathersHookManager(this, method).params(...params).props({ app: this, path, method, service, event: null, type: 'around', get statusCode() { return this.http?.status }, set statusCode(value: number) { this.http = this.http || {} this.http.status = value } }) return res }, {} as BaseHookMap) const registerHooks = enableHooks(service) hooks(service, serviceMethodHooks) service.hooks = function (this: any, hookOptions: any) { if (hookOptions.before || hookOptions.after || hookOptions.error || hookOptions.around) { return registerHooks.call(this, hookOptions) } if (Array.isArray(hookOptions)) { return hooks(this, hookOptions) } Object.keys(hookOptions).forEach((method) => { const manager = getManager(this[method]) if (!(manager instanceof FeathersHookManager)) { throw new Error(`Method ${method} is not a Feathers hooks enabled service method`) } manager.middleware(hookOptions[method]) }) return this } return service } ================================================ FILE: packages/feathers/src/index.ts ================================================ import { setDebug } from '@feathersjs/commons' import version from './version' import { Feathers } from './application' import { Application } from './declarations' export function feathers() { return new Feathers() as Application } feathers.setDebug = setDebug export { version, Feathers } export * from './hooks' export * from './declarations' export * from './service' if (typeof module !== 'undefined') { module.exports = Object.assign(feathers, module.exports) } ================================================ FILE: packages/feathers/src/service.ts ================================================ import { EventEmitter } from 'events' import { createSymbol } from '@feathersjs/commons' import { ServiceOptions } from './declarations' export const SERVICE = createSymbol('@feathersjs/service') export const defaultServiceArguments = { find: ['params'], get: ['id', 'params'], create: ['data', 'params'], update: ['id', 'data', 'params'], patch: ['id', 'data', 'params'], remove: ['id', 'params'] } export const defaultServiceMethods = ['find', 'get', 'create', 'update', 'patch', 'remove'] export const defaultEventMap = { create: 'created', update: 'updated', patch: 'patched', remove: 'removed' } export const defaultServiceEvents = Object.values(defaultEventMap) export const protectedMethods = Object.keys(Object.prototype) .concat(Object.keys(EventEmitter.prototype)) .concat(['all', 'around', 'before', 'after', 'error', 'hooks', 'setup', 'teardown', 'publish']) export function getHookMethods(service: any, options: ServiceOptions) { const { methods } = options return (defaultServiceMethods as any as string[]) .filter((m) => typeof service[m] === 'function' && !methods.includes(m)) .concat(methods) } export function getServiceOptions(service: any): ServiceOptions { return service[SERVICE] } export const normalizeServiceOptions = (service: any, options: ServiceOptions = {}): ServiceOptions => { const { methods = defaultServiceMethods.filter((method) => typeof service[method] === 'function'), events = service.events || [] } = options const serviceEvents = options.serviceEvents || defaultServiceEvents.concat(events) return { ...options, events, methods, serviceEvents } } export function wrapService(location: string, service: any, options: ServiceOptions) { // Do nothing if this is already an initialized if (service[SERVICE]) { return service } const protoService = Object.create(service) const serviceOptions = normalizeServiceOptions(service, options) if ( Object.keys(serviceOptions.methods).length === 0 && ![...defaultServiceMethods, 'setup', 'teardown'].some((method) => typeof service[method] === 'function') ) { throw new Error(`Invalid service object passed for path \`${location}\``) } Object.defineProperty(protoService, SERVICE, { value: serviceOptions }) return protoService } ================================================ FILE: packages/feathers/src/version.ts ================================================ export default 'development' ================================================ FILE: packages/feathers/test/application.test.ts ================================================ /* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-empty-function */ import assert from 'assert' import { feathers, Feathers, getServiceOptions, Id, version } from '../src' describe('Feathers application', () => { it('initializes', () => { const app = feathers() assert.ok(app instanceof Feathers) }) it('sets the version on main and app instance', () => { const app = feathers() assert.ok(version > '5.0.0') assert.ok(app.version > '5.0.0') }) it('is an event emitter', (done) => { const app = feathers() const original = { hello: 'world' } app.on('test', (data: any) => { assert.deepStrictEqual(original, data) done() }) app.emit('test', original) }) it('uses .defaultService if available', async () => { const app = feathers() assert.throws(() => app.service('/todos/'), { message: "Can not find service 'todos'" }) app.defaultService = function (location: string) { assert.strictEqual(location, 'todos') return { async get(id: string) { return { id, description: `You have to do ${id}!` } } } } const data = await app.service('/todos/').get('dishes') assert.deepStrictEqual(data, { id: 'dishes', description: 'You have to do dishes!' }) }) it('additionally passes `app` as .configure parameter (#558)', (done) => { feathers().configure(function (app) { assert.strictEqual(this, app) done() }) }) describe('Services', () => { it('calling .use with invalid path throws', () => { const app = feathers() //@ts-ignore assert.throws(() => app.use(null, {}), { message: "'null' is not a valid service path." }) // @ts-ignore assert.throws(() => app.use({}, {}), { message: "'[object Object]' is not a valid service path." }) }) it('calling .use with a non service object throws', () => { const app = feathers() // @ts-ignore assert.throws(() => app.use('/bla', function () {}), { message: 'Invalid service object passed for path `bla`' }) }) it('registers and wraps a new service and can unregister (#2035)', async () => { const dummyService = { async setup(this: any, _app: any, path: string) { this.path = path }, async teardown(this: any, _app: any, path: string) { this.path = path }, async create(data: any) { return data } } const app = feathers<{ dummy: typeof dummyService }>().use('dummy', dummyService) const wrappedService = app.service('dummy') assert.strictEqual( Object.getPrototypeOf(wrappedService), dummyService, 'Object points to original service prototype' ) const data = await wrappedService.create({ message: 'Test message' }) assert.strictEqual(data.message, 'Test message') await app.unuse('dummy') assert.strictEqual(Object.keys(app.services).length, 0) assert.throws(() => app.service('dummy'), { message: "Can not find service 'dummy'" }) }) it('can not register custom methods on a protected methods', async () => { const dummyService = { async create(data: any) { return data }, async removeListener(data: any) { return data }, async setup() {}, async teardown() {} } assert.throws( () => feathers().use('/dummy', dummyService, { methods: ['create', 'removeListener'] }), { message: "'removeListener' on service 'dummy' is not allowed as a custom method name" } ) assert.throws( () => feathers().use('/dummy', dummyService, { methods: ['create', 'setup'] }), { message: "'setup' on service 'dummy' is not allowed as a custom method name" } ) assert.throws( () => feathers().use('/dummy', dummyService, { methods: ['create', 'teardown'] }), { message: "'teardown' on service 'dummy' is not allowed as a custom method name" } ) }) it('can register service with no external methods', async () => { const dummyService = { async create(data: any) { return data } } feathers().use('dummy', dummyService, { methods: [] }) }) it('can use a root level service', async () => { const app = feathers().use('/', { async get(id: string) { return { id } } }) const result = await app.service('/').get('test') assert.deepStrictEqual(result, { id: 'test' }) }) it('services can be re-used (#566)', (done) => { const service = { async create(data: any) { return data } } const app1 = feathers<{ dummy: typeof service; testing: any }>() const app2 = feathers<{ dummy: typeof service; testing: any }>() app2.use('dummy', { async create(data: any) { return data } }) const dummy = app2.service('dummy') dummy.hooks({ before: { create: [ (hook) => { hook.data.fromHook = true } ] } }) dummy.on('created', (data: any) => { assert.deepStrictEqual(data, { message: 'Hi', fromHook: true }) done() }) app1.use('testing', app2.service('dummy')) app1.service('testing').create({ message: 'Hi' }) }) it('async hooks run before regular hooks', async () => { const service = { async create(data: any) { return data } } const app = feathers<{ dummy: typeof service }>() app.use('dummy', service) const dummy = app.service('dummy') dummy.hooks({ before: { create(ctx) { ctx.data.order.push('before') } } }) dummy.hooks([ async (ctx: any, next: any) => { ctx.data.order = ['async'] await next() } ]) const result = await dummy.create({ message: 'hi' }) assert.deepStrictEqual(result, { message: 'hi', order: ['async', 'before'] }) }) it('services conserve Symbols', () => { const TEST = Symbol('test') const dummyService = { [TEST]: true, async setup(this: any, _app: any, path: string) { this.path = path }, async create(data: any) { return data } } const app = feathers().use('/dummy', dummyService) const wrappedService = app.service('dummy') assert.ok((wrappedService as any)[TEST]) }) it('methods conserve Symbols', () => { const TEST = Symbol('test') const dummyService = { async setup(this: any, _app: any, path: string) { this.path = path }, async create(data: any) { return data } } ;(dummyService.create as any)[TEST] = true const app = feathers().use('/dummy', dummyService) const wrappedService = app.service('dummy') assert.ok((wrappedService.create as any)[TEST]) }) it('.service does does not access object properties', async () => { const app = feathers() assert.throws(() => app.service('something'), { message: "Can not find service 'something'" }) assert.throws(() => app.service('__proto__'), { message: "Can not find service '__proto__'" }) assert.throws(() => app.service('toString'), { message: "Can not find service 'toString'" }) }) }) describe('Express app options compatibility', function () { describe('.set()', () => { it('should set a value', () => { const app = feathers() app.set('foo', 'bar') assert.strictEqual(app.get('foo'), 'bar') }) it('should return the app', () => { const app = feathers() assert.strictEqual(app.set('foo', 'bar'), app) }) it('should return the app when undefined', () => { const app = feathers() assert.strictEqual(app.set('foo', undefined), app) }) }) describe('.get()', () => { it('should return undefined when unset', () => { const app = feathers() assert.strictEqual(app.get('foo'), undefined) }) it('should otherwise return the value', () => { const app = feathers() app.set('foo', 'bar') assert.strictEqual(app.get('foo'), 'bar') }) }) }) describe('.setup and .teardown', () => { it('app.setup and app.teardown calls .setup and .teardown on all services', async () => { const app = feathers() let setupCount = 0 let teardownCount = 0 app.use('/dummy', { async setup(appRef: any, path: any) { setupCount++ assert.strictEqual(appRef, app) assert.strictEqual(path, 'dummy') }, async teardown(appRef: any, path: any) { teardownCount++ assert.strictEqual(appRef, app) assert.strictEqual(path, 'dummy') } }) app.use('/simple', { get(id: string) { return Promise.resolve({ id }) } }) app.use('/dummy2', { async setup(appRef: any, path: any) { setupCount++ assert.strictEqual(appRef, app) assert.strictEqual(path, 'dummy2') }, async teardown(appRef: any, path: any) { teardownCount++ assert.strictEqual(appRef, app) assert.strictEqual(path, 'dummy2') } }) await app.setup() assert.ok((app as any)._isSetup) assert.strictEqual(setupCount, 2) await app.teardown() assert.ok(!(app as any)._isSetup) assert.strictEqual(teardownCount, 2) }) it('registering app.setup but while still pending will be set up', (done) => { const app = feathers() app.setup() app.use('/dummy', { async setup(appRef: any, path: any) { assert.ok((app as any)._isSetup) assert.strictEqual(appRef, app) assert.strictEqual(path, 'dummy') done() } }) }) }) describe('.teardown', () => { it('app.teardown calls .teardown on all services', async () => { const app = feathers() let teardownCount = 0 app.use('/dummy', { async setup() {}, async teardown(appRef: any, path: any) { teardownCount++ assert.strictEqual(appRef, app) assert.strictEqual(path, 'dummy') } }) app.use('/simple', { get(id: string) { return Promise.resolve({ id }) } }) app.use('/dummy2', { async setup() {}, async teardown(appRef: any, path: any) { teardownCount++ assert.strictEqual(appRef, app) assert.strictEqual(path, 'dummy2') } }) await app.setup() await app.teardown() assert.equal((app as any)._isSetup, false) assert.strictEqual(teardownCount, 2) }) }) describe('mixins', () => { class Dummy { dummy = true async get(id: Id) { return { id } } } it('are getting called with a service and default options', () => { const app = feathers() let mixinRan = false app.mixins.push(function (service: any, location: any, options: any) { assert.ok(service.dummy) assert.strictEqual(location, 'dummy') assert.deepStrictEqual(options, getServiceOptions(service)) mixinRan = true }) app.use('/dummy', new Dummy()) assert.ok(mixinRan) app.setup() }) it('are getting called with a service and service options', () => { const app = feathers() const opts = { events: ['bla'] } let mixinRan = false app.mixins.push(function (service: any, location: any, options: any) { assert.ok(service.dummy) assert.strictEqual(location, 'dummy') assert.deepStrictEqual(options, getServiceOptions(service)) mixinRan = true }) app.use('/dummy', new Dummy(), opts) assert.ok(mixinRan) app.setup() }) }) describe('sub apps', () => { it('re-registers sub-app services with prefix', (done) => { const app = feathers() const subApp = feathers() subApp .use('/service1', { async get(id: string) { return { id, name: 'service1' } } }) .use('/service2', { async get(id: string) { return { id, name: 'service2' } }, async create(data: any) { return data } }) app.use('/api/', subApp) app.service('/api/service2').once('created', (data: any) => { assert.deepStrictEqual(data, { message: 'This is a test' }) subApp.service('service2').once('created', (data: any) => { assert.deepStrictEqual(data, { message: 'This is another test' }) done() }) app.service('api/service2').create({ message: 'This is another test' }) }) ;(async () => { let data = await app.service('/api/service1').get(10) assert.strictEqual(data.name, 'service1') data = await app.service('/api/service2').get(1) assert.strictEqual(data.name, 'service2') await subApp.service('service2').create({ message: 'This is a test' }) })() }) }) }) ================================================ FILE: packages/feathers/test/declarations.test.ts ================================================ import assert from 'assert' import { hooks } from '@feathersjs/hooks' import { feathers, ServiceInterface, Application, HookContext, NextFunction } from '../src' interface Todo { id: number message: string completed: boolean } interface TodoData { message: string completed?: boolean } class TodoService implements ServiceInterface { constructor(public todos: Todo[] = []) {} async find() { return this.todos } async create(data: TodoData) { const { completed = false } = data const todo: Todo = { id: this.todos.length, completed, message: data.message } this.todos.push(todo) return todo } async setup(app: Application) { assert.ok(app) } } interface Configuration { port: number } interface Services { todos: TodoService v2: Application, Configuration> } type MainApp = Application const myHook = async (context: HookContext, next: NextFunction) => { assert.ok(context.app.service('todos')) await next() } hooks(TodoService.prototype, [ async (_ctx: HookContext, next) => { await next() } ]) hooks(TodoService, { create: [myHook] }) describe('Feathers typings', () => { it('initializes the app with proper types', async () => { const app: MainApp = feathers() const app2 = feathers, Configuration>() app.set('port', 80) app.use('todos', new TodoService(), { methods: ['find', 'create'] }) app.use('v2', app2) const service = app.service('todos') service.on('created', (data) => { assert.ok(data) }) service.hooks({ before: { all: [], create: [ async (context) => { const { result, data, service } = context assert.ok(service instanceof TodoService) assert.ok(result) assert.ok(data) assert.ok(context.app.service('todos')) } ] } }) service.hooks({ create: [ async (context, next) => { assert.ok(context) await next() }, async (context, next) => { assert.ok(context) await next() }, myHook ] }) }) }) ================================================ FILE: packages/feathers/test/events.test.ts ================================================ import assert from 'assert' import { EventEmitter } from 'events' import { feathers } from '../src' describe('Service events', () => { it('app is an event emitter', (done) => { const app = feathers() assert.strictEqual(typeof app.on, 'function') app.on('test', (data: any) => { assert.deepStrictEqual(data, { message: 'app' }) done() }) app.emit('test', { message: 'app' }) }) it('works with service that is already an EventEmitter', (done) => { const app = feathers() const service: any = new EventEmitter() service.create = async function (data: any) { return data } service.on('created', (data: any) => { assert.deepStrictEqual(data, { message: 'testing' }) done() }) app.use('/emitter', service) app.service('emitter').create({ message: 'testing' }) }) describe('emits event data on a service', () => { it('.create and created', (done) => { const app = feathers().use('/creator', { async create(data: any) { return data } }) const service = app.service('creator') service.on('created', (data: any) => { assert.deepStrictEqual(data, { message: 'Hello' }) done() }) service.create({ message: 'Hello' }) }) it('allows to skip event emitting', (done) => { const app = feathers().use('/creator', { async create(data: any) { return data } }) const service = app.service('creator') service.hooks({ before: { create(context: any) { context.event = null return context } } }) service.on('created', () => { done(new Error('Should never get here')) }) service.create({ message: 'Hello' }).then(() => done()) }) it('.update and updated', (done) => { const app = feathers().use('/creator', { async update(id: any, data: any) { return Object.assign({ id }, data) } }) const service = app.service('creator') service.on('updated', (data: any) => { assert.deepStrictEqual(data, { id: 10, message: 'Hello' }) done() }) service.update(10, { message: 'Hello' }) }) it('.patch and patched', (done) => { const app = feathers().use('/creator', { async patch(id: any, data: any) { return Object.assign({ id }, data) } }) const service = app.service('creator') service.on('patched', (data: any) => { assert.deepStrictEqual(data, { id: 12, message: 'Hello' }) done() }) service.patch(12, { message: 'Hello' }) }) it('.remove and removed', (done) => { const app = feathers().use('/creator', { async remove(id: any) { return { id } } }) const service = app.service('creator') service.on('removed', (data: any) => { assert.deepStrictEqual(data, { id: 22 }) done() }) service.remove(22) }) }) describe('emits event data arrays on a service', () => { it('.create and created with array', async () => { const app = feathers().use('/creator', { async create(data: any) { if (Array.isArray(data)) { return Promise.all(data.map((current) => (this as any).create(current))) } return data } }) const service = app.service('creator') const createItems = [{ message: 'Hello 0' }, { message: 'Hello 1' }] const events = Promise.all( createItems.map((element, index) => { return new Promise((resolve) => { service.on('created', (data: any) => { if (data.message === element.message) { assert.deepStrictEqual(data, { message: `Hello ${index}` }) resolve() } }) }) }) ) await service.create(createItems) await events }) it('.update and updated with array', async () => { const app = feathers().use('/creator', { async update(id: any, data: any) { if (Array.isArray(data)) { return Promise.all(data.map((current, index) => (this as any).update(index, current))) } return Object.assign({ id }, data) } }) const service = app.service('creator') const updateItems = [{ message: 'Hello 0' }, { message: 'Hello 1' }] const events = Promise.all( updateItems.map((element, index) => { return new Promise((resolve) => { service.on('updated', (data: any) => { if (data.message === element.message) { assert.deepStrictEqual(data, { id: index, message: `Hello ${index}` }) resolve() } }) }) }) ) await service.update(null, updateItems) await events }) it('.patch and patched with array', async () => { const app = feathers().use('/creator', { async patch(id: any, data: any) { if (Array.isArray(data)) { return Promise.all(data.map((current, index) => (this as any).patch(index, current))) } return Object.assign({ id }, data) } }) const service = app.service('creator') const patchItems = [{ message: 'Hello 0' }, { message: 'Hello 1' }] const events = Promise.all( patchItems.map((element, index) => { return new Promise((resolve) => { service.on('patched', (data: any) => { if (data.message === element.message) { assert.deepStrictEqual(data, { id: index, message: `Hello ${index}` }) resolve() } }) }) }) ) await service.patch(null, patchItems) await events }) it('.remove and removed with array', async () => { const removeItems = [{ message: 'Hello 0' }, { message: 'Hello 1' }] const app = feathers().use('/creator', { async remove(id: any, data: any) { if (id === null) { return Promise.all(removeItems.map((current, index) => (this as any).remove(index, current))) } return Object.assign({ id }, data) } }) const service = app.service('creator') const events = Promise.all( removeItems.map((element, index) => { return new Promise((resolve) => { service.on('removed', (data: any) => { if (data.message === element.message) { assert.deepStrictEqual(data, { id: index, message: `Hello ${index}` }) resolve() } }) }) }) ) await service.remove(null) await events }) }) describe('event format', () => { it('also emits the actual hook object', (done) => { const app = feathers().use('/creator', { async create(data: any) { return data } }) const service = app.service('creator') service.hooks({ after(hook: any) { hook.changed = true } }) service.on('created', (data: any, hook: any) => { try { assert.deepStrictEqual(data, { message: 'Hi' }) assert.ok(hook.changed) assert.strictEqual(hook.service, service) assert.strictEqual(hook.method, 'create') assert.strictEqual(hook.type, 'around') done() } catch (error: any) { done(error) } }) service.create({ message: 'Hi' }) }) it('events indicated by the service are not sent automatically', (done) => { class Creator { events = ['created'] async create(data: any) { return data } } const app = feathers().use('/creator', new Creator()) const service = app.service('creator') service.on('created', (data: any) => { assert.deepStrictEqual(data, { message: 'custom event' }) done() }) service.create({ message: 'hello' }) service.emit('created', { message: 'custom event' }) }) }) }) ================================================ FILE: packages/feathers/test/hooks/after.test.ts ================================================ import assert from 'assert' import { feathers, Id } from '../../src' describe('`after` hooks', () => { it('.after hooks can return a promise', async () => { const app = feathers().use('/dummy', { async get(id: Id) { return { id, description: `You have to do ${id}` } }, async find() { return [] } }) const service = app.service('dummy') service.hooks({ after: { async get(hook) { hook.result.ran = true return hook }, async find() { throw new Error('You can not see this') } } }) const data = await service.get('laundry', {}) assert.deepStrictEqual(data, { id: 'laundry', description: 'You have to do laundry', ran: true }) await assert.rejects(() => service.find({}), { message: 'You can not see this' }) }) it('.after hooks do not need to return anything', async () => { const app = feathers().use('/dummy', { async get(id: Id) { return { id, description: `You have to do ${id}` } }, async find() { return [] } }) const service = app.service('dummy') service.hooks({ after: { get(context) { context.result.ran = true }, find() { throw new Error('You can not see this') } } }) const data = await service.get('laundry') assert.deepStrictEqual(data, { id: 'laundry', description: 'You have to do laundry', ran: true }) await assert.rejects(() => service.find(), { message: 'You can not see this' }) }) it('gets mixed into a service and modifies data', async () => { const dummyService = { async create(data: any) { return data } } const app = feathers().use('/dummy', dummyService) const service = app.service('dummy') service.hooks({ after: { create(context) { assert.strictEqual(context.type, 'after') context.result.some = 'thing' return context } } }) const data = await service.create({ my: 'data' }) assert.deepStrictEqual({ my: 'data', some: 'thing' }, data, 'Got modified data') }) it('also makes the app available at hook.app', async () => { const dummyService = { async create(data: any) { return data } } const app = feathers().use('/dummy', dummyService) const service = app.service('dummy') service.hooks({ after: { create(context) { context.result.appPresent = typeof context.app !== 'undefined' assert.strictEqual(context.result.appPresent, true) return context } } }) const data = await service.create({ my: 'data' }) assert.deepStrictEqual({ my: 'data', appPresent: true }, data, 'The app was present in the hook.') }) it('returns errors', async () => { const dummyService = { async update(_id: any, data: any) { return data } } const app = feathers().use('/dummy', dummyService) const service = app.service('dummy') service.hooks({ after: { update() { throw new Error('This did not work') } } }) await assert.rejects(() => service.update(1, { my: 'data' }), { message: 'This did not work' }) }) it('does not run after hook when there is an error', async () => { const dummyService = { async remove() { throw new Error('Error removing item') } } const app = feathers().use('/dummy', dummyService) const service = app.service('dummy') service.hooks({ after: { remove() { assert.ok(false, 'This should never get called') } } }) await assert.rejects(() => service.remove(1, {}), { message: 'Error removing item' }) }) it('adds .after() and chains multiple hooks for the same method', async () => { const dummyService = { async create(data: any) { return data } } const app = feathers().use('/dummy', dummyService) const service = app.service('dummy') service.hooks({ after: { create(context) { context.result.some = 'thing' return context } } }) service.hooks({ after: { create(context) { context.result.other = 'stuff' } } }) const data = await service.create({ my: 'data' }) assert.deepStrictEqual( { my: 'data', some: 'thing', other: 'stuff' }, data, 'Got modified data' ) }) it('chains multiple after hooks using array syntax', async () => { const dummyService = { async create(data: any) { return data } } const app = feathers().use('/dummy', dummyService) const service = app.service('dummy') service.hooks({ after: { create: [ function (context) { context.result.some = 'thing' return context }, function (context) { context.result.other = 'stuff' return context } ] } }) const data = await service.create({ my: 'data' }) assert.deepStrictEqual( { my: 'data', some: 'thing', other: 'stuff' }, data, 'Got modified data' ) }) it('.after hooks run in the correct order (#13)', async () => { const app = feathers().use('/dummy', { async get(id: any) { return { id } } }) const service = app.service('dummy') service.hooks({ after: { get(context) { context.result.items = ['first'] return context } } }) service.hooks({ after: { get: [ function (context) { context.result.items.push('second') return context }, function (context) { context.result.items.push('third') return context } ] } }) const data = await service.get(10) assert.deepStrictEqual(data.items, ['first', 'second', 'third']) }) it('after all hooks (#11)', async () => { const app = feathers().use('/dummy', { async get(id: any) { const items: any[] = [] return { id, items } }, async find() { return [] } }) const service = app.service('dummy') service.hooks({ after: { all(context) { context.result.afterAllObject = true return context } } }) service.hooks({ after: [ function (context) { context.result.afterAllMethodArray = true return context } ] }) let data = await service.find({}) assert.ok(data.afterAllObject) assert.ok(data.afterAllMethodArray) data = await service.get(1, {}) assert.ok(data.afterAllObject) assert.ok(data.afterAllMethodArray) }) it('after hooks have service as context and keep it in service method (#17)', async () => { class Dummy { number = 42 async get(id: any) { return { id, number: this.number } } } const app = feathers().use('/dummy', new Dummy()) const service = app.service('dummy') service.hooks({ after: { get(this: any, hook) { hook.result.test = this.number + 1 return hook } } }) const data = await service.get(10) assert.deepStrictEqual(data, { id: 10, number: 42, test: 43 }) }) it('.after all and method specific hooks run in the correct order (#3002)', async () => { const app = feathers().use('/dummy', { async get(id: any) { return { id, items: [] as any } } }) const service = app.service('dummy') service.hooks({ after: { all(context) { context.result.items.push('first') return context }, get: [ function (context) { context.result.items.push('second') return context }, function (context) { context.result.items.push('third') return context } ] } }) const data = await service.get(10) assert.deepStrictEqual(data.items, ['first', 'second', 'third']) }) }) ================================================ FILE: packages/feathers/test/hooks/app.test.ts ================================================ import assert from 'assert' import { feathers, Application, ApplicationHookMap, ServiceInterface, Params } from '../../src' type Todo = { id?: string params?: TodoParams data?: any test?: string order?: string[] } interface TodoParams extends Params { order: string[] ran: boolean } type TodoService = ServiceInterface & { customMethod(data: any, params?: TodoParams): Promise } type App = Application<{ todos: TodoService }> describe('app.hooks', () => { let app: App beforeEach(() => { app = feathers<{ todos: TodoService }>().use( 'todos', { async get(id: any, params: any) { if (id === 'error') { throw new Error('Something went wrong') } return { id, params } }, async create(data: any, params: any) { return { data, params } }, async customMethod(data: any, params: TodoParams) { return { data, params } } }, { methods: ['get', 'create', 'customMethod'] } ) }) it('app has the .hooks method', () => { assert.strictEqual(typeof app.hooks, 'function') }) it('.setup and .teardown special hooks', async () => { const app = feathers() // Test that setup and teardown can be overwritten const oldSetup = app.setup app.setup = function (arg: any) { return oldSetup.call(this, arg) } const oldTeardown = app.teardown app.teardown = function (arg: any) { return oldTeardown.call(this, arg) } const order: string[] = [] const hooks: ApplicationHookMap = { setup: [ async (context, next) => { assert.strictEqual(context.app, app) order.push('setup 1') await next() }, async (_context, next) => { order.push('setup 2') await next() order.push('setup after') } ], teardown: [ async (context, next) => { assert.strictEqual(context.app, app) order.push('teardown 1') await next() }, async (_context, next) => { order.push('teardown 2') await next() } ] } app.hooks(hooks) await app.setup() await app.teardown() assert.deepStrictEqual(order, ['setup 1', 'setup 2', 'setup after', 'teardown 1', 'teardown 2']) }) describe('app.hooks([ async ])', () => { it('basic app async hook, works with custom method', async () => { const service = app.service('todos') app.hooks([ async (context, next) => { assert.strictEqual(context.app, app) await next() context.params.ran = true } ]) let result = await service.get('test') assert.deepStrictEqual(result, { id: 'test', params: { ran: true } }) const data = { test: 'hi' } result = await service.create(data) assert.deepStrictEqual(result, { data, params: { ran: true } }) result = await service.customMethod('custom test') assert.deepStrictEqual(result, { data: 'custom test', params: { ran: true } }) }) }) describe('app.hooks({ method: [ async ] })', () => { it('basic app async method hook', async () => { const service = app.service('todos') app.hooks({ get: [ async (context, next) => { assert.strictEqual(context.app, app) await next() context.params.ran = true } ] }) const result = await service.get('test') assert.deepStrictEqual(result, { id: 'test', params: { ran: true } }) }) }) describe('app.hooks({ before })', () => { it('basic app before hook, works with custom method', async () => { const service = app.service('todos') app.hooks({ before(context) { assert.strictEqual(context.app, app) context.params.ran = true } }) let result = await service.get('test') assert.deepStrictEqual(result, { id: 'test', params: { ran: true } }) const data = { test: 'hi' } result = await service.create(data) assert.deepStrictEqual(result, { data, params: { ran: true } }) result = await service.customMethod('custom with before') assert.deepStrictEqual(result, { data: 'custom with before', params: { ran: true } }) }) it('app before hooks always run first', async () => { app.service('todos').hooks({ before(context) { assert.strictEqual(context.app, app) context.params.order.push('service.before') } }) app.service('todos').hooks({ before(context) { assert.strictEqual(context.app, app) context.params.order.push('service.before 1') } }) app.hooks({ before(context) { assert.strictEqual(context.app, app) context.params.order = [] context.params.order.push('app.before') } }) const result = await app.service('todos').get('test') assert.deepStrictEqual(result, { id: 'test', params: { order: ['app.before', 'service.before', 'service.before 1'] } }) }) }) describe('app.hooks({ after })', () => { it('basic app after hook', async () => { app.hooks({ after(context) { assert.strictEqual(context.app, app) context.result.ran = true } }) const result = await app.service('todos').get('test') assert.deepStrictEqual(result, { id: 'test', params: {}, ran: true }) }) it('app after hooks always run last', async () => { app.hooks({ after(context) { assert.strictEqual(context.app, app) context.result.order.push('app.after') } }) app.service('todos').hooks({ after(context) { assert.strictEqual(context.app, app) context.result!.order = [] context.result!.order.push('service.after') } }) app.service('todos').hooks({ after(context) { assert.strictEqual(context.app, app) context.result.order.push('service.after 1') } }) const result = await app.service('todos').get('test') assert.deepStrictEqual(result, { id: 'test', params: {}, order: ['service.after', 'service.after 1', 'app.after'] }) }) }) describe('app.hooks({ error })', () => { it('basic app error hook', async () => { app.hooks({ error(context) { assert.strictEqual(context.app, app) context.error = new Error('App hook ran') } }) await assert.rejects(() => app.service('todos').get('error'), { message: 'App hook ran' }) }) it('app error hooks always run last', async () => { app.hooks({ error(context) { assert.strictEqual(context.app, app) context.error = new Error(`${context.error.message} app.after`) } }) app.service('todos').hooks({ error(context) { assert.strictEqual(context.app, app) context.error = new Error(`${context.error.message} service.after`) } }) app.service('todos').hooks({ error(context) { assert.strictEqual(context.app, app) context.error = new Error(`${context.error.message} service.after 1`) } }) await assert.rejects(() => app.service('todos').get('error'), { message: 'Something went wrong service.after service.after 1 app.after' }) }) }) }) ================================================ FILE: packages/feathers/test/hooks/around.test.ts ================================================ import assert from 'assert' import { feathers, Params, ServiceInterface } from '../../src' describe('`around` hooks', () => { it('around hooks can set hook.result which will skip service method', async () => { const app = feathers().use('/dummy', { async get() { assert.ok(false, 'This should never run') } }) const service = app.service('dummy') service.hooks({ get: [ async (hook, next) => { hook.result = { id: hook.id, message: 'Set from hook' } await next() } ] }) const data = await service.get(10, {}) assert.deepStrictEqual(data, { id: 10, message: 'Set from hook' }) }) it('works with traditional registration format, all syntax and app hooks', async () => { const app = feathers().use('/dummy', { async get() { assert.ok(false, 'This should never run') } }) const service = app.service('dummy') app.hooks([ async function (this: any, hook, next) { hook.result = { id: hook.id, app: 'Set from app around all' } await next() } ]) service.hooks({ around: { all: [ async (hook, next) => { hook.result = { ...hook.result, all: 'Set from around all' } await next() } ], get: [ async (hook, next) => { hook.result = { ...hook.result, get: 'Set from around get' } await next() } ] } }) const data = await service.get(10, {}) assert.deepStrictEqual(data, { id: 10, app: 'Set from app around all', all: 'Set from around all', get: 'Set from around get' }) }) it('gets mixed into a service and modifies data', async () => { const dummyService = { async create(data: any, params?: any) { assert.deepStrictEqual( data, { some: 'thing', modified: 'data' }, 'Data modified' ) assert.deepStrictEqual( params, { modified: 'params' }, 'Params modified' ) return data } } const app = feathers<{ dummy: typeof dummyService }>().use('dummy', dummyService) const service = app.service('dummy') service.hooks({ create: [ async (hook, next) => { assert.strictEqual(hook.type, 'around') hook.data.modified = 'data' Object.assign(hook.params, { modified: 'params' }) await next() } ] }) const data = await service.create({ some: 'thing' }) assert.deepStrictEqual( data, { some: 'thing', modified: 'data' }, 'Data got modified' ) }) it('contains the app object at hook.app', async () => { const someServiceConfig = { async create(data: any) { return data } } const app = feathers<{ 'some-service': typeof someServiceConfig }>().use( 'some-service', someServiceConfig ) const someService = app.service('some-service') someService.hooks({ create: [ async (hook, next) => { hook.data.appPresent = typeof hook.app !== 'undefined' assert.strictEqual(hook.data.appPresent, true) return next() } ] }) const data = await someService.create({ some: 'thing' }) assert.deepStrictEqual( data, { some: 'thing', appPresent: true }, 'App object was present' ) }) it('passes errors', async () => { const dummyService = { update() { assert.ok(false, 'Never should be called') } } const app = feathers().use('/dummy', dummyService) const service = app.service('dummy') service.hooks({ update: [ async () => { throw new Error('You are not allowed to update') } ] }) await assert.rejects(() => service.update(1, {}), { message: 'You are not allowed to update' }) }) it('does not run after hook when there is an error', async () => { const dummyService = { async remove() { throw new Error('Error removing item') } } const app = feathers().use('/dummy', dummyService) const service = app.service('dummy') service.hooks({ remove: [ async (_context, next) => { await next() assert.ok(false, 'This should never get called') } ] }) await assert.rejects(() => service.remove(1, {}), { message: 'Error removing item' }) }) it('adds .hooks() and chains multiple hooks for the same method', async () => { interface DummyParams extends Params { modified: string } class DummyService implements ServiceInterface { create(data: any, params?: any) { assert.deepStrictEqual( data, { some: 'thing', modified: 'second data' }, 'Data modified' ) assert.deepStrictEqual( params, { modified: 'params' }, 'Params modified' ) return Promise.resolve(data) } } const app = feathers<{ dummy: DummyService }>().use('dummy', new DummyService()) const service = app.service('dummy') service.hooks({ create: [ async (hook, next) => { hook.params.modified = 'params' await next() }, async (hook, next) => { hook.data.modified = 'second data' next() } ] }) await service.create({ some: 'thing' }) }) it('around hooks run in the correct order', async () => { interface DummyParams extends Params<{ name: string }> { items: string[] } class DummyService implements ServiceInterface { async get(id: any, params?: DummyParams) { assert.deepStrictEqual(params!.items, ['first', 'second', 'third']) return { id, items: [] as string[] } } } const app = feathers<{ dummy: DummyService }>().use('dummy', new DummyService()) const service = app.service('dummy') service.hooks({ get: [ async (hook, next) => { hook.params.items = ['first'] await next() } ] }) service.hooks({ get: [ async function (hook, next) { hook.params.items.push('second') next() }, async function (hook, next) { hook.params.items.push('third') next() } ] }) await service.get(10) }) it('around all hooks (#11)', async () => { interface DummyParams extends Params { asyncAllObject: boolean asyncAllMethodArray: boolean } type DummyService = ServiceInterface const app = feathers<{ dummy: DummyService }>().use('dummy', { async get(id: any, params: any) { assert.ok(params.asyncAllObject) assert.ok(params.asyncAllMethodArray) return { id, items: [] } }, async find(params: any) { assert.ok(params.asyncAllObject) assert.ok(params.asyncAllMethodArray) return [] } }) const service = app.service('dummy') service.hooks([ async (hook, next) => { hook.params.asyncAllObject = true next() } ]) service.hooks([ async function (hook, next) { hook.params.asyncAllMethodArray = true next() } ]) await service.find() }) it('around hooks have service as context and keep it in service method (#17)', async () => { interface DummyParams extends Params { test: number } class Dummy implements ServiceInterface { number = 42 async get(id: any, params?: DummyParams) { return { id, number: (this as any).number, test: params!.test } } } const app = feathers<{ dummy: Dummy }>().use('dummy', new Dummy()) const service = app.service('dummy') service.hooks({ get: [ async function (this: any, hook, next) { hook.params.test = this.number + 2 await next() } ] }) const data = await service.get(10) assert.deepStrictEqual(data, { id: 10, number: 42, test: 44 }) }) }) ================================================ FILE: packages/feathers/test/hooks/before.test.ts ================================================ import assert from 'assert' import { feathers, Params, ServiceInterface } from '../../src' describe('`before` hooks', () => { it('.before hooks can return a promise', async () => { interface DummyParams extends Params { ran: boolean } type DummyService = ServiceInterface const app = feathers<{ dummy: DummyService }>().use('dummy', { async get(id: any, params: DummyParams) { assert.ok(params.ran, 'Ran through promise hook') return { id, description: `You have to do ${id}` } }, async remove() { assert.ok(false, 'Should never get here') } }) const service = app.service('dummy') service.hooks({ before: { get(context) { return new Promise((resolve) => { context.params.ran = true resolve() }) }, remove() { return new Promise((_resolve, reject) => { reject(new Error('This did not work')) }) }, find: [] } }) await service.get('dishes') await assert.rejects(() => service.remove(10), { message: 'This did not work' }) }) it('.before hooks do not need to return anything', async () => { interface DummyParams extends Params { ran: boolean } type DummyService = ServiceInterface const app = feathers<{ dummy: DummyService }>().use('dummy', { async get(id: any, params: any) { assert.ok(params.ran, 'Ran through promise hook') return { id, description: `You have to do ${id}` } }, async remove() { assert.ok(false, 'Should never get here') } }) const service = app.service('dummy') service.hooks({ before: { get(context) { context.params.ran = true }, remove() { throw new Error('This did not work') } } }) await service.get('dishes') await assert.rejects(() => service.remove(10), { message: 'This did not work' }) }) it('.before hooks can set context.result which will skip service method', async () => { const app = feathers().use('/dummy', { async get() { assert.ok(false, 'This should never run') } }) const service = app.service('dummy') service.hooks({ before: { get(context) { context.result = { id: context.id, message: 'Set from hook' } } } }) const data = await service.get(10, {}) assert.deepStrictEqual(data, { id: 10, message: 'Set from hook' }) }) it('gets mixed into a service and modifies data', async () => { const dummyService = { async create(data: any, params?: any) { assert.deepStrictEqual( data, { some: 'thing', modified: 'data' }, 'Data modified' ) assert.deepStrictEqual( params, { modified: 'params' }, 'Params modified' ) return data } } const app = feathers<{ dummy: typeof dummyService }>().use('dummy', dummyService) const service = app.service('dummy') service.hooks({ before: { create(context) { assert.strictEqual(context.type, 'before') context.data.modified = 'data' Object.assign(context.params, { modified: 'params' }) return context } } }) const data = await service.create({ some: 'thing' }) assert.deepStrictEqual( data, { some: 'thing', modified: 'data' }, 'Data got modified' ) }) it('contains the app object at context.app', async () => { const someServiceConfig = { async create(data: any) { return data } } const app = feathers<{ 'some-service': typeof someServiceConfig }>().use( 'some-service', someServiceConfig ) const someService = app.service('some-service') someService.hooks({ before: { create(context) { context.data.appPresent = typeof context.app !== 'undefined' assert.strictEqual(context.data.appPresent, true) return context } } }) const data = await someService.create({ some: 'thing' }) assert.deepStrictEqual( data, { some: 'thing', appPresent: true }, 'App object was present' ) }) it('passes errors', async () => { const dummyService = { update() { assert.ok(false, 'Never should be called') } } const app = feathers().use('/dummy', dummyService) const service = app.service('dummy') service.hooks({ before: { update() { throw new Error('You are not allowed to update') } } }) await assert.rejects(() => service.update(1, {}), { message: 'You are not allowed to update' }) }) it('calling back with no arguments uses the old ones', async () => { interface DummyParams extends Params { my: string } type DummyService = ServiceInterface const dummyService = { async remove(id: any, params: any) { assert.strictEqual(id, 1, 'Got id') assert.deepStrictEqual(params, { my: 'param' }) return { id } } } const app = feathers<{ dummy: DummyService }>().use('dummy', dummyService) const service = app.service('dummy') service.hooks({ before: { remove(context) { return context } } }) await service.remove(1, { my: 'param' }) }) it('adds .hooks() and chains multiple hooks for the same method', async () => { interface DummyParams extends Params { modified: string } type DummyService = ServiceInterface const dummyService = { async create(data: any, params: any) { assert.deepStrictEqual( data, { some: 'thing', modified: 'second data' }, 'Data modified' ) assert.deepStrictEqual( params, { modified: 'params' }, 'Params modified' ) return data } } const app = feathers<{ dummy: DummyService }>().use('dummy', dummyService) const service = app.service('dummy') service.hooks({ before: { create(context) { context.params.modified = 'params' return context } } }) service.hooks({ before: { create(context) { context.data.modified = 'second data' return context } } }) await service.create({ some: 'thing' }) }) it('chains multiple before hooks using array syntax', async () => { interface DummyParams extends Params { modified: string } type DummyService = ServiceInterface const dummyService = { async create(data: any, params: any) { assert.deepStrictEqual( data, { some: 'thing', modified: 'second data' }, 'Data modified' ) assert.deepStrictEqual( params, { modified: 'params' }, 'Params modified' ) return data } } const app = feathers<{ dummy: DummyService }>().use('dummy', dummyService) const service = app.service('dummy') service.hooks({ before: { create: [ function (context) { context.params.modified = 'params' return context }, function (context) { context.data.modified = 'second data' return context } ] } }) await service.create({ some: 'thing' }) }) it('.before hooks run in the correct order (#13)', async () => { interface DummyParams extends Params { items: string[] } type DummyService = ServiceInterface const app = feathers<{ dummy: DummyService }>().use('dummy', { async get(id: any, params: any) { assert.deepStrictEqual(params.items, ['first', 'second', 'third']) return { id, items: [] } } }) const service = app.service('dummy') service.hooks({ before: { get(context) { context.params.items = ['first'] return context } } }) service.hooks({ before: { get: [ function (context) { context.params.items.push('second') return context }, function (context) { context.params.items.push('third') return context } ] } }) await service.get(10) }) it('before all hooks (#11)', async () => { interface DummyParams extends Params { beforeAllObject: boolean beforeAllMethodArray: boolean } type DummyService = ServiceInterface const app = feathers<{ dummy: DummyService }>().use('dummy', { async get(id: any, params: any) { assert.ok(params.beforeAllObject) assert.ok(params.beforeAllMethodArray) return { id, items: [] } }, async find(params: any) { assert.ok(params.beforeAllObject) assert.ok(params.beforeAllMethodArray) return [] } }) const service = app.service('dummy') service.hooks({ before: { all(context) { context.params.beforeAllObject = true return context } } }) service.hooks({ before: [ function (context) { context.params.beforeAllMethodArray = true return context } ] }) await service.find() }) it('before hooks have service as context and keep it in service method (#17)', async () => { interface DummyParams extends Params { test: number } class Dummy implements ServiceInterface { number = 42 async get(id: any, params?: DummyParams) { return { id, number: this.number, test: params.test } } } const app = feathers<{ dummy: Dummy }>().use('dummy', new Dummy()) const service = app.service('dummy') service.hooks({ before: { get(this: any, context) { context.params.test = this.number + 2 return context } } }) const data = await service.get(10) assert.deepStrictEqual(data, { id: 10, number: 42, test: 44 }) }) }) ================================================ FILE: packages/feathers/test/hooks/error.test.ts ================================================ import assert from 'assert' import { feathers, Application, FeathersService } from '../../src' describe('`error` hooks', () => { describe('on direct service method errors', () => { const errorMessage = 'Something else went wrong' const app = feathers().use('/dummy', { async get() { throw new Error('Something went wrong') } }) const service = app.service('dummy') afterEach(() => { const s = service as any s.__hooks.error.get = undefined s.__hooks.collected.get = [] }) it('basic error hook', async () => { service.hooks({ error: { get(context) { assert.strictEqual(context.type, 'error') assert.strictEqual(context.id, 'test') assert.strictEqual(context.method, 'get') assert.strictEqual(context.app, app) assert.strictEqual(context.error.message, 'Something went wrong') } } }) await assert.rejects(() => service.get('test'), { message: 'Something went wrong' }) }) it('can change the error', async () => { service.hooks({ error: { get(context) { context.error = new Error(errorMessage) } } }) await assert.rejects(() => service.get('test'), { message: errorMessage }) }) it('throwing an error', async () => { service.hooks({ error: { get() { throw new Error(errorMessage) } } }) await assert.rejects(() => service.get('test'), { message: errorMessage }) }) it('rejecting a promise', async () => { service.hooks({ error: { async get() { throw new Error(errorMessage) } } }) await assert.rejects(() => service.get('test'), { message: errorMessage }) }) it('can chain multiple hooks', async () => { service.hooks({ error: { get: [ function (context) { context.error = new Error(errorMessage) context.error.first = true }, function (context) { context.error.second = true return Promise.resolve(context) }, function (context) { context.error.third = true return context } ] } }) await assert.rejects(() => service.get('test'), { message: errorMessage, first: true, second: true, third: true }) }) it('setting `context.result` will return result', async () => { const data = { message: 'It worked' } service.hooks({ error: { get(context) { context.result = data } } }) const result = await service.get(10) assert.deepStrictEqual(result, data) }) it('allows to set `context.result = null` in error hooks (#865)', async () => { const app = feathers().use('/dummy', { async get() { throw new Error('Damnit') } }) app.service('dummy').hooks({ error: { get(context: any) { context.result = null } } }) const result = await app.service('dummy').get(1) assert.strictEqual(result, null) }) it('uses the current hook object if thrown in a service method', async () => { const app = feathers().use('/dummy', { async get() { throw new Error('Something went wrong') } }) const service = app.service('dummy') service.hooks({ before(context) { context.id = 42 }, error(context) { assert.strictEqual(context.id, 42) } }) await assert.rejects(() => service.get(1), { message: 'Something went wrong' }) }) }) describe('error in hooks', () => { const errorMessage = 'before hook broke' let app: Application let service: FeathersService beforeEach(() => { app = feathers().use('/dummy', { async get(id: any) { return { id, text: `You have to do ${id}` } } }) service = app.service('dummy') }) it('in before hook', async () => { service .hooks({ before() { throw new Error(errorMessage) } }) .hooks({ error(context) { assert.strictEqual(context.original.type, 'before', 'Original hook still set') assert.strictEqual(context.id, 'dishes') assert.strictEqual(context.error.message, errorMessage) } }) await assert.rejects(() => service.get('dishes'), { message: errorMessage }) }) it('in after hook', async () => { service.hooks({ after() { throw new Error(errorMessage) }, error(context) { assert.strictEqual(context.original.type, 'after', 'Original hook still set') assert.strictEqual(context.id, 'dishes') assert.deepStrictEqual(context.original.result, { id: 'dishes', text: 'You have to do dishes' }) assert.strictEqual(context.error.message, errorMessage) } }) await assert.rejects(() => service.get('dishes'), { message: errorMessage }) }) it('uses the current hook object if thrown in a hook and sets context.original', async () => { service.hooks({ after(context) { context.modified = true throw new Error(errorMessage) }, error(context) { assert.ok(context.modified) assert.strictEqual(context.original.type, 'after') } }) await assert.rejects(() => service.get('laundry'), { message: errorMessage }) }) }) it('Error in before hook causes inter-service calls to have wrong hook context (#841)', async () => { const app = feathers() let service1Params: any let service2Params: any app.use('/service1', { async find() { return { message: 'service1 success' } } }) app.service('service1').hooks({ before(context: any) { service1Params = context.params throw new Error('Error in service1 before hook') } }) app.use('/service2', { async find() { await app.service('/service1').find({}) return { message: 'service2 success' } } }) app.service('service2').hooks({ before(context: any) { service2Params = context.params context.params.foo = 'bar' }, error(context: any) { assert.ok(service1Params !== context.params) assert.ok(service2Params === context.params) assert.strictEqual(context.path, 'service2') assert.strictEqual(context.params.foo, 'bar') } }) await assert.rejects(() => app.service('/service2').find(), { message: 'Error in service1 before hook' }) }) }) ================================================ FILE: packages/feathers/test/hooks/hooks.test.ts ================================================ import assert from 'assert' import { hooks, NextFunction } from '@feathersjs/hooks' import { HookContext, createContext, feathers, Id, Params, ServiceInterface } from '../../src' describe('hooks basics', () => { it('mix @feathersjs/hooks and .hooks', async () => { interface SimpleParams extends Params { chain: string[] } class SimpleService { async get(id: Id, params: SimpleParams) { return { id, chain: params.chain } } } hooks(SimpleService.prototype, [ async (ctx: HookContext, next: NextFunction) => { ctx.params.chain.push('@hooks all before') await next() ctx.params.chain.push('@hooks all after') } ]) hooks(SimpleService, { get: [ async (ctx: HookContext, next: NextFunction) => { assert.ok(ctx.app) assert.ok(ctx.service) ctx.params.chain.push('@hooks get before') await next() ctx.params.chain.push('@hooks get after') } ] }) const app = feathers().use('/dummy', new SimpleService()) const service = app.service('dummy') app.hooks([ async function appHook(ctx: HookContext, next: NextFunction) { assert.ok(ctx.app) assert.ok(ctx.service) ctx.params.chain = ['app.hooks before'] await next() ctx.params.chain.push('app.hooks after') } ]) app.hooks({ before: [ (ctx: HookContext) => { ctx.params.chain.push('app.hooks regular before') } ], after: [ (ctx: HookContext) => { ctx.params.chain.push('app.hooks regular after') } ] }) service.hooks({ before: { get: (ctx: HookContext) => { ctx.params.chain.push('service.hooks regular before') } }, after: { get: (ctx: HookContext) => { ctx.params.chain.push('service.hooks regular after') } } }) service.hooks({ get: [ async (ctx: HookContext, next: NextFunction) => { ctx.params.chain.push('service.hooks get before') await next() ctx.params.chain.push('service.hooks get after') } ] }) service.hooks({ before: { get: (ctx: HookContext) => { ctx.params.chain.push('service.hooks 2 regular before') } }, after: { get: (ctx: HookContext) => { ctx.params.chain.push('service.hooks 2 regular after') } } }) const { chain } = await service.get(1, {}) assert.deepStrictEqual(chain, [ 'app.hooks before', 'app.hooks regular before', '@hooks all before', '@hooks get before', 'service.hooks get before', 'service.hooks regular before', 'service.hooks 2 regular before', 'service.hooks regular after', 'service.hooks 2 regular after', 'service.hooks get after', '@hooks get after', '@hooks all after', 'app.hooks regular after', 'app.hooks after' ]) }) // it('validates arguments', async () => { // const app = feathers().use('/dummy', { // async get (id: any, params: any) { // return { id, user: params.user }; // }, // async create (data: any) { // return data; // } // }); // await assert.rejects(() => app.service('dummy').get(), { // message: 'An id must be provided to the \'dummy.get\' method' // }); // await assert.rejects(() => app.service('dummy').create(), { // message: 'A data object must be provided to the \'dummy.create\' method' // }); // }); it('works with services that return a promise (feathers-hooks#28)', async () => { interface DummyParams extends Params { user: string } const app = feathers<{ dummy: ServiceInterface }>().use('dummy', { async get(id: any, params: any) { return { id, user: params.user } } }) const service = app.service('dummy') service.hooks({ before: { get(context) { context.params.user = 'David' } }, after: { get(context) { context.result.after = true } } }) const data = await service.get(10) assert.deepStrictEqual(data, { id: 10, user: 'David', after: true }) }) it('has context.app, context.service and context.path', async () => { const app = feathers().use('/dummy', { async get(id: any) { return { id } } }) const service = app.service('dummy') service.hooks({ before(context) { assert.strictEqual(this, service) assert.strictEqual(context.service, service) assert.strictEqual(context.app, app) assert.strictEqual(context.path, 'dummy') } }) await service.get('test') }) it('does not error when result is null', async () => { const app = feathers().use('/dummy', { async get(id: any) { return { id } } }) const service = app.service('dummy') service.hooks({ after: { get: [ function (context) { context.result = null return context } ] } }) const result = await service.get(1) assert.strictEqual(result, null) }) it('registering an already hooked service works (#154)', () => { const app = feathers().use('/dummy', { async get(id: any, params: any) { return { id, params } } }) app.use('/dummy2', app.service('dummy')) }) describe('returns the context when passing it as last parameter', () => { it('on normal method call', async () => { const app = feathers().use('/dummy', { async get(id: any, params: any) { return { id, params } } }) const service = app.service('dummy') const context = createContext(service, 'get') const returnedContext = await app.service('dummy').get(10, {}, context) assert.strictEqual(returnedContext.service, app.service('dummy')) assert.strictEqual(returnedContext.type, 'around') assert.strictEqual(returnedContext.path, 'dummy') assert.deepStrictEqual(returnedContext.result, { id: 10, params: {} }) }) it.skip('on error', async () => { const app = feathers().use('/dummy', { get() { throw new Error('Something went wrong') } }) const service = app.service('dummy') const context = createContext(service, 'get') await assert.rejects(() => service.get(10, {}, context), { service: app.service('dummy'), type: null, path: 'dummy' }) }) // it('on argument validation error (https://github.com/feathersjs/express/issues/19)', async () => { // const app = feathers().use('/dummy', { // async get (id: string) { // return { id }; // } // }); // await assert.rejects(() => app.service('dummy').get(undefined, {}, true), context => { // assert.strictEqual(context.service, app.service('dummy')); // assert.strictEqual(context.type, 'error'); // assert.strictEqual(context.path, 'dummy'); // assert.strictEqual(context.error.message, 'An id must be provided to the \'dummy.get\' method'); // return true; // }); // }); // it('on error in error hook (https://github.com/feathersjs/express/issues/21)', async () => { // const app = feathers().use('/dummy', { // async get () { // throw new Error('Nope'); // } // }); // app.service('dummy').hooks({ // error: { // get () { // throw new Error('Error in error hook'); // } // } // }); // await assert.rejects(() => app.service('dummy').get(10, {}, true), context => { // assert.strictEqual(context.service, app.service('dummy')); // assert.strictEqual(context.type, 'error'); // assert.strictEqual(context.path, 'dummy'); // assert.strictEqual(context.error.message, 'Error in error hook'); // return true; // }); // }); it('still swallows error if context.result is set', async () => { const result = { message: 'this is a test' } const app = feathers().use('/dummy', { async get() { throw new Error('Something went wrong') } }) app.service('dummy').hooks({ error(context: any) { context.result = result } }) const service = app.service('dummy') const context = createContext(service, 'get') const returnedContext = await service.get(10, {}, context) assert.ok(returnedContext.error) assert.deepStrictEqual(returnedContext.result, result) }) }) it('can register hooks on a custom method, still adds hooks to default methods', async () => { class Dummy { async get(id: Id) { return { id } } async create(data: any) { return data } async custom(data: any) { return data } } const app = feathers<{ dummy: Dummy }>().use('dummy', new Dummy(), { methods: ['get', 'custom'] }) app.service('dummy').hooks({ custom: [ async (context, next) => { context.data.fromHook = true await next() } ], create: [async (_context, next) => next()] }) assert.deepStrictEqual( await app.service('dummy').custom({ message: 'testing' }), { message: 'testing', fromHook: true } ) }) it('normalizes params to object even when it is falsy (#1001)', async () => { const app = feathers().use('/dummy', { async get(id: Id, params: Params) { return { id, params } } }) const result = await app.service('dummy').get('test', null) assert.deepStrictEqual(result, { id: 'test', params: {} }) }) it('allows to return new context in basic hooks (#2451)', async () => { const app = feathers().use('/dummy', { async get() { return {} } }) const service = app.service('dummy') service.hooks({ before: { get: [ (context) => { return { ...context, value: 'something' } }, (context) => { assert.strictEqual(context.value, 'something') } ] }, after: { get: [ (context) => { context.result = { value: context.value } } ] } }) const data = await service.get(10) assert.deepStrictEqual(data, { value: 'something' }) }) }) ================================================ FILE: packages/feathers/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/generators/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/generators ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/generators ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/generators ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/generators ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/generators ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) - **generators:** typebox generated schema resolver generic ([#3622](https://github.com/feathersjs/feathers/issues/3622)) ([55a4a9b](https://github.com/feathersjs/feathers/commit/55a4a9b6bb021c369fb65b50fa13869311587c3f)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) ### Bug Fixes - **generators:** Add FeathersGeneratorError ([#3556](https://github.com/feathersjs/feathers/issues/3556)) ([2a81a20](https://github.com/feathersjs/feathers/commit/2a81a204eb55c95d20fc45bf091c0131eff5a25d)) ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/generators ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) ### Bug Fixes - **generators:** Fix generating of gitignore ([#3514](https://github.com/feathersjs/feathers/issues/3514)) ([cabc397](https://github.com/feathersjs/feathers/commit/cabc397d2e4378c4bce79a60f2d196713cce4d8c)) ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/generators ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/generators ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) ### Bug Fixes - **generators:** Fix migrate:make script in generated app ([#3490](https://github.com/feathersjs/feathers/issues/3490)) ([c7b0111](https://github.com/feathersjs/feathers/commit/c7b011150152e62a35f3f8ab04d6dde6d6727583)) ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) ### Bug Fixes - **generators:** better types for enabled methods ([#3474](https://github.com/feathersjs/feathers/issues/3474)) ([bdb3d3a](https://github.com/feathersjs/feathers/commit/bdb3d3a308322bfed3caa4214e4b6a72f1a84944)) ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) ### Bug Fixes - **generators:** Use module format for JS Knex migrations ([#3444](https://github.com/feathersjs/feathers/issues/3444)) ([3feaa71](https://github.com/feathersjs/feathers/commit/3feaa719443aa30b1121d928ba5b7b8f43837ffb)) ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/generators ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/generators ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) ### Bug Fixes - **generators:** Use cross-platform ES module \_\_dirname ([#3402](https://github.com/feathersjs/feathers/issues/3402)) ([0ac4882](https://github.com/feathersjs/feathers/commit/0ac4882663bb6a78622be0d903ae6508ecb516ad)) ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/generators ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) ### Bug Fixes - **cli:** Another fix for CLI ES module loading ([#3397](https://github.com/feathersjs/feathers/issues/3397)) ([3cb3bc9](https://github.com/feathersjs/feathers/commit/3cb3bc9a32602d82193b781b583ed0f37044e778)) ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/generators ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/generators ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) ### Bug Fixes - **generators:** Move generators and CLI to featherscloud/pinion ([#3386](https://github.com/feathersjs/feathers/issues/3386)) ([eb87c99](https://github.com/feathersjs/feathers/commit/eb87c9922db56c5610e5b808f3ffe033c830e2b2)) ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) ### Bug Fixes - **generators:** Harden mongodb.js to reliably extract database from any connection string ([#3264](https://github.com/feathersjs/feathers/issues/3264)) ([7b0f82c](https://github.com/feathersjs/feathers/commit/7b0f82c631ff5549cdc9a8e0ffcc705d067c2157)) ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/generators ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) ### Bug Fixes - **generators:** use `export type` vs `export` ([#3246](https://github.com/feathersjs/feathers/issues/3246)) ([82d30fd](https://github.com/feathersjs/feathers/commit/82d30fd37914e61935e068e89fc389f6bf47aaad)) ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) - **schema:** HookContext is now typed in schema ([#3306](https://github.com/feathersjs/feathers/issues/3306)) ([65fab86](https://github.com/feathersjs/feathers/commit/65fab86407b813122f24db928a59986c7286f270)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/generators ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) ### Bug Fixes - **generators:** Fix configure channels when not real-time app ([#3271](https://github.com/feathersjs/feathers/issues/3271)) ([c619ab2](https://github.com/feathersjs/feathers/commit/c619ab2c57f692c419fee610c269c1502b124852)) ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/generators ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) ### Bug Fixes - **generators:** Fix channel/service configuration order for Koa based apps ([580344e](https://github.com/feathersjs/feathers/commit/580344e96fe8a2f17fd53476af5a0c7ddefac0b6)) ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/generators ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) ### Bug Fixes - **generators:** Add sourceMap to tsconfig.json template ([#3166](https://github.com/feathersjs/feathers/issues/3166)) ([3049b7a](https://github.com/feathersjs/feathers/commit/3049b7a425d01cdd3058442c7183307a06cfc87a)) ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) - **generators:** Properly log unhandled rejection ([#3149](https://github.com/feathersjs/feathers/issues/3149)) ([eda8f78](https://github.com/feathersjs/feathers/commit/eda8f78fa5084c3247ad10b051610b3c51a13d24)) ## [5.0.2](https://github.com/feathersjs/feathers/compare/v5.0.1...v5.0.2) (2023-03-23) ### Bug Fixes - **generators:** Make sure TypeScript version in generated app matches ([#3122](https://github.com/feathersjs/feathers/issues/3122)) ([f0acfdf](https://github.com/feathersjs/feathers/commit/f0acfdf9d33337bf40ca12126c2550f56e31fa3b)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) ### Bug Fixes - **generators:** Conditionally import channels in Express app ([#3106](https://github.com/feathersjs/feathers/issues/3106)) ([c2dbaaa](https://github.com/feathersjs/feathers/commit/c2dbaaa4d1d5a5675b5812a7ed2317076ac414fe)) # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) ### Bug Fixes - **generators:** Fix typo in service client generator ([#3068](https://github.com/feathersjs/feathers/issues/3068)) ([612032e](https://github.com/feathersjs/feathers/commit/612032eced24ecbcf255d51ff0d537d74227cfd7)) # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) ### Features - **generators:** Final tweaks to the generators ([#3060](https://github.com/feathersjs/feathers/issues/3060)) ([1bf1544](https://github.com/feathersjs/feathers/commit/1bf1544fa8deeaa44ba354fb539dc3f1fd187767)) - **schema:** Add schema helper for handling Object ids ([#3058](https://github.com/feathersjs/feathers/issues/3058)) ([1393bed](https://github.com/feathersjs/feathers/commit/1393bed81a9ee814de6aab0e537af83e667591a2)) # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) ### Bug Fixes - **generators:** Add schema selection to CI test matrix ([#3035](https://github.com/feathersjs/feathers/issues/3035)) ([7484b16](https://github.com/feathersjs/feathers/commit/7484b164fba4ac2ee379dc5c6363f964f45e94d3)) - **generators:** Fix Knex migration generated filename ([#3033](https://github.com/feathersjs/feathers/issues/3033)) ([1ac18a7](https://github.com/feathersjs/feathers/commit/1ac18a7143173d973af982772678834f7a7334f7)) - **generators:** Generated app does not start when choosing JSON schema ([#3034](https://github.com/feathersjs/feathers/issues/3034)) ([7b8250b](https://github.com/feathersjs/feathers/commit/7b8250bd535c3c5ec7429a65139335ad43616ae0)) ### Features - **mongodb:** Add Object ID keyword converter and update MongoDB CLI & docs ([#3041](https://github.com/feathersjs/feathers/issues/3041)) ([ca0994e](https://github.com/feathersjs/feathers/commit/ca0994eaecb5a31f310bc980d106834e11f24f41)) # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - **generators:** Add main schema to all validators ([#2997](https://github.com/feathersjs/feathers/issues/2997)) ([5854dea](https://github.com/feathersjs/feathers/commit/5854dea7f610262121a49623ec5bbd474dcd3ef3)) - **generators:** Add TypeScript as normal instead of dev dependency ([#3011](https://github.com/feathersjs/feathers/issues/3011)) ([2f67398](https://github.com/feathersjs/feathers/commit/2f673987f38b199e75aff629b7cdfcaebfd69c4c)) - **generators:** Do not removeAdditional in queries ([#3000](https://github.com/feathersjs/feathers/issues/3000)) ([ef501bc](https://github.com/feathersjs/feathers/commit/ef501bcfa528119168787e9d857f1bb90e0c3114)) - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) ### Features - **generators:** Add service file for shared information ([#3008](https://github.com/feathersjs/feathers/issues/3008)) ([0a1665d](https://github.com/feathersjs/feathers/commit/0a1665d23e002afadb40ed99bf0168f0fceb0054)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) ================================================ FILE: packages/generators/README.md ================================================ # @feathersjs/generators [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/generators.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/cli) > Feathers core code generators used by the CLI powered by [Pinion](https://github.com/feathershq/pinion/) ## Installation ``` npm install @feathersjs/generators --save-dev ``` ## Documentation Refer to the [Feathers CLI guide](https://feathersjs.com/guides/cli/) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/generators/package.json ================================================ { "name": "@feathersjs/generators", "version": "5.0.42", "description": "Feathers CLI core generators, powered by Pinion", "homepage": "https://feathersjs.com", "keywords": [ "feathers", "pinion" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/commons" }, "author": { "name": "Feathers contributor", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 16" }, "main": "lib/index.js", "types": "lib/", "type": "module", "files": [ "CHANGELOG.md", "LICENSE", "README.md", "lib/**", "*.d.ts", "*.js" ], "scripts": { "prepublish": "npm run compile", "compile": "shx rm -rf lib/ && tsc", "test": "npm run compile && mocha --config ../../.mocharc.json --require tsx --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@featherscloud/pinion": "^0.5.5", "chalk": "^5.6.2", "lodash": "^4.17.23", "prettier": "^3.8.1", "typescript": "^5.9.3" }, "devDependencies": { "@feathersjs/adapter-commons": "^5.0.42", "@feathersjs/authentication": "^5.0.42", "@feathersjs/authentication-client": "^5.0.42", "@feathersjs/authentication-local": "^5.0.42", "@feathersjs/authentication-oauth": "^5.0.42", "@feathersjs/configuration": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/express": "^5.0.42", "@feathersjs/feathers": "^5.0.42", "@feathersjs/knex": "^5.0.42", "@feathersjs/koa": "^5.0.42", "@feathersjs/mongodb": "^5.0.42", "@feathersjs/rest-client": "^5.0.42", "@feathersjs/schema": "^5.0.42", "@feathersjs/socketio": "^5.0.42", "@feathersjs/transport-commons": "^5.0.42", "@feathersjs/typebox": "^5.0.42", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "@types/prettier": "^2.7.3", "axios": "^1.13.6", "knex": "^3.1.0", "mocha": "^11.7.5", "mongodb": "^6.19.0", "mssql": "^12.2.0", "mysql": "^2.18.1", "pg": "^8.19.0", "shx": "^0.4.0", "sqlite3": "^5.1.7", "tsx": "^4.21.0", "type-fest": "^5.4.4", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/generators/src/app/index.ts ================================================ import { sep, dirname } from 'path' import chalk from 'chalk' import { prompt, runGenerators } from '@featherscloud/pinion' import { fileURLToPath } from 'url' import { FeathersBaseContext, FeathersAppInfo, initializeBaseContext, addVersions, install } from '../commons.js' import { generate as connectionGenerator, prompts as connectionPrompts } from '../connection/index.js' // Set __dirname in es module const __dirname = dirname(fileURLToPath(import.meta.url)) export interface AppGeneratorData extends FeathersAppInfo { /** * The application name */ name: string /** * A short description of the app */ description: string /** * The database connection string */ connectionString: string /** * The source folder where files are put */ lib: string /** * Generate a client */ client: boolean } export type AppGeneratorContext = FeathersBaseContext & AppGeneratorData & { dependencies: string[] devDependencies: string[] } export type AppGeneratorArguments = FeathersBaseContext & Partial export const generate = (ctx: AppGeneratorArguments) => Promise.resolve(ctx) .then(initializeBaseContext()) .then((ctx) => ({ ...ctx, dependencies: [] as string[], devDependencies: [] as string[] })) .then( prompt((ctx) => [ { name: 'language', type: 'list', message: 'Do you want to use JavaScript or TypeScript?', when: !ctx.language, choices: [ { name: 'TypeScript', value: 'ts' }, { name: 'JavaScript', value: 'js' } ] }, { name: 'name', type: 'input', when: !ctx.name, message: 'What is the name of your application?', default: ctx.cwd.split(sep).pop(), validate: (input) => { if (ctx.dependencyVersions[input]) { return `Application can not have the same name as a dependency` } return true } }, { name: 'description', type: 'input', when: !ctx.description, message: 'Write a short description' }, { type: 'list', name: 'framework', when: !ctx.framework, message: 'Which HTTP framework do you want to use?', choices: [ { value: 'koa', name: `KoaJS ${chalk.grey('(recommended)')}` }, { value: 'express', name: 'Express' } ] }, { type: 'checkbox', name: 'transports', when: !ctx.transports, message: 'What APIs do you want to offer?', choices: [ { value: 'rest', name: 'HTTP (REST)', checked: true }, { value: 'websockets', name: 'Real-time', checked: true } ] }, { name: 'packager', type: 'list', when: !ctx.packager, message: 'Which package manager are you using?', choices: [ { value: 'npm', name: 'npm' }, { value: 'yarn', name: 'Yarn' }, { value: 'pnpm', name: 'pnpm' } ] }, { name: 'client', type: 'confirm', when: ctx.client === undefined, message: (answers) => `Generate ${answers.language === 'ts' ? 'end-to-end typed ' : ''}client?`, suffix: chalk.grey(' Can be used with React, Angular, Vue, React Native, Node.js etc.') }, { type: 'list', name: 'schema', when: !ctx.schema, message: 'What is your preferred schema (model) definition format?', suffix: chalk.grey( ' Schemas allow to type, validate, secure and populate your data and configuration' ), choices: [ { value: 'typebox', name: `TypeBox ${chalk.grey('(recommended)')}` }, { value: 'json', name: 'JSON schema' }, { value: false, name: `No schema ${chalk.grey('(not recommended)')}` } ] }, ...connectionPrompts(ctx) ]) ) .then(runGenerators(__dirname, 'templates')) .then(initializeBaseContext()) .then(async (ctx) => { const { dependencies } = await connectionGenerator(ctx) return { ...ctx, dependencies } }) .then( install( ({ transports, framework, dependencyVersions, dependencies, schema }) => { const hasSocketio = transports.includes('websockets') dependencies.push( '@feathersjs/feathers', '@feathersjs/errors', '@feathersjs/schema', '@feathersjs/configuration', '@feathersjs/transport-commons', '@feathersjs/adapter-commons', '@feathersjs/authentication', '@feathersjs/authentication-client', 'winston' ) if (hasSocketio) { dependencies.push('@feathersjs/socketio') } if (framework === 'koa') { dependencies.push('@feathersjs/koa') } if (framework === 'express') { dependencies.push('@feathersjs/express', 'compression') } if (schema === 'typebox') { dependencies.push('@feathersjs/typebox') } return addVersions(dependencies, dependencyVersions) }, false, ({ packager }) => packager ) ) .then( install( ({ language, devDependencies, dependencyVersions }) => { devDependencies.push( 'nodemon', 'axios', 'mocha', 'cross-env', 'prettier', '@feathersjs/cli', '@feathersjs/rest-client' ) if (language === 'ts') { devDependencies.push('@types/mocha', '@types/node', 'nodemon', 'ts-node', 'typescript', 'shx') } return addVersions(devDependencies, dependencyVersions) }, true, ({ packager }) => packager ) ) ================================================ FILE: packages/generators/src/app/templates/app.test.tpl.ts ================================================ import { toFile } from '@featherscloud/pinion' import { renderSource } from '../../commons.js' import { AppGeneratorContext } from '../index.js' const template = ({ lib }: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/app.test.html import assert from 'assert' import axios from 'axios' import type { Server } from 'http' import { app } from '../${lib}/app' const port = app.get('port') const appUrl = \`http://\${app.get('host')}:\${port}\` describe('Feathers application tests', () => { let server: Server before(async () => { server = await app.listen(port) }) after(async () => { await app.teardown() }) it('starts and shows the index page', async () => { const { data } = await axios.get(appUrl) assert.ok(data.indexOf('') !== -1) }) it('shows a 404 JSON error', async () => { try { await axios.get(\`\${appUrl}/path/to/nowhere\`, { responseType: 'json' }) assert.fail('should never get here') } catch (error: any) { const { response } = error assert.strictEqual(response?.status, 404) assert.strictEqual(response?.data?.code, 404) assert.strictEqual(response?.data?.name, 'NotFound') } }) }) ` export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx).then(renderSource(template, toFile('test', 'app.test'))) ================================================ FILE: packages/generators/src/app/templates/app.tpl.ts ================================================ import { toFile } from '@featherscloud/pinion' import { renderSource } from '../../commons.js' import { AppGeneratorContext } from '../index.js' const tsKoaApp = ({ transports, schema }: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/application.html import { feathers } from '@feathersjs/feathers' import configuration from '@feathersjs/configuration' import { koa, rest, bodyParser, errorHandler, parseAuthentication, cors, serveStatic } from '@feathersjs/koa' ${transports.includes('websockets') ? "import socketio from '@feathersjs/socketio'" : ''} ${schema !== false ? `import { configurationValidator } from './configuration'` : ''} import type { Application } from './declarations' import { logError } from './hooks/log-error' import { services } from './services/index' ${transports.includes('websockets') ? `import { channels } from './channels'` : ''} const app: Application = koa(feathers()) // Load our app configuration (see config/ folder) app.configure(configuration(${schema !== false ? 'configurationValidator' : ''})) // Set up Koa middleware app.use(cors()) app.use(serveStatic(app.get('public'))) app.use(errorHandler()) app.use(parseAuthentication()) app.use(bodyParser()) // Configure services and transports app.configure(rest()) ${ transports.includes('websockets') ? `app.configure(socketio({ cors: { origin: app.get('origins') } }))` : '' } app.configure(services) ${transports.includes('websockets') ? 'app.configure(channels)' : ''} // Register hooks that run on all service methods app.hooks({ around: { all: [ logError ] }, before: {}, after: {}, error: {} }) // Register application setup and teardown hooks here app.hooks({ setup: [], teardown: [] }) export { app } ` const tsExpressApp = ({ transports, schema }: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/application.html import { feathers } from '@feathersjs/feathers' import express, { rest, json, urlencoded, cors, serveStatic, notFound, errorHandler } from '@feathersjs/express' import configuration from '@feathersjs/configuration' ${transports.includes('websockets') ? "import socketio from '@feathersjs/socketio'" : ''} import type { Application } from './declarations' ${schema !== false ? `import { configurationValidator } from './configuration'` : ''} import { logger } from './logger' import { logError } from './hooks/log-error' import { services } from './services/index' ${transports.includes('websockets') ? `import { channels } from './channels'` : ''} const app: Application = express(feathers()) // Load app configuration app.configure(configuration(${schema !== false ? 'configurationValidator' : ''})) app.use(cors()) app.use(json()) app.use(urlencoded({ extended: true })) // Host the public folder app.use('/', serveStatic(app.get('public'))) // Configure services and real-time functionality app.configure(rest()) ${ transports.includes('websockets') ? `app.configure(socketio({ cors: { origin: app.get('origins') } }))` : '' } app.configure(services) ${transports.includes('websockets') ? 'app.configure(channels)' : ''} // Configure a middleware for 404s and the error handler app.use(notFound()) app.use(errorHandler({ logger })) // Register hooks that run on all service methods app.hooks({ around: { all: [ logError ] }, before: {}, after: {}, error: {} }) // Register application setup and teardown hooks here app.hooks({ setup: [], teardown: [] }) export { app } ` const template = (ctx: AppGeneratorContext) => ctx.framework === 'express' ? tsExpressApp(ctx) : tsKoaApp(ctx) export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx).then( renderSource( template, toFile(({ lib }) => lib, 'app') ) ) ================================================ FILE: packages/generators/src/app/templates/channels.tpl.ts ================================================ import { toFile, when } from '@featherscloud/pinion' import { renderSource } from '../../commons.js' import { AppGeneratorContext } from '../index.js' const template = ({ language }: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/channels.html import type { RealTimeConnection, Params } from '@feathersjs/feathers' import type { AuthenticationResult } from '@feathersjs/authentication' import '@feathersjs/transport-commons' import type { Application, HookContext } from './declarations' import { logger } from './logger' export const channels = (app: Application) => { logger.warn('Publishing all events to all authenticated users. See \`channels.${language}\` and https://dove.feathersjs.com/api/channels.html for more information.') app.on('connection', (connection: RealTimeConnection) => { // On a new real-time connection, add it to the anonymous channel app.channel('anonymous').join(connection) }) app.on('login', (authResult: AuthenticationResult, { connection }: Params) => { // connection can be undefined if there is no // real-time connection, e.g. when logging in via REST if(connection) { // The connection is no longer anonymous, remove it app.channel('anonymous').leave(connection) // Add it to the authenticated user channel app.channel('authenticated').join(connection) } }) // eslint-disable-next-line no-unused-vars app.publish((data: any, context: HookContext) => { // Here you can add event publishers to channels set up in \`channels.js\` // To publish only for a specific event use \`app.publish(eventname, () => {})\` // e.g. to publish all service events to all authenticated users use return app.channel('authenticated') }) } ` export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx).then( when( ({ transports }) => transports.includes('websockets'), renderSource( template, toFile(({ lib }) => lib, 'channels') ) ) ) ================================================ FILE: packages/generators/src/app/templates/client.test.tpl.ts ================================================ import { toFile, when } from '@featherscloud/pinion' import { renderSource } from '../../commons.js' import { AppGeneratorContext } from '../index.js' const template = ({ lib }: AppGeneratorContext) => /* ts */ `import assert from 'assert' import axios from 'axios' import type { Server } from 'http' import { app } from '../${lib}/app' import { createClient } from '../${lib}/client' import rest from '@feathersjs/rest-client' const port = app.get('port') const appUrl = \`http://\${app.get('host')}:\${port}\` describe('client tests', () => { const client = createClient(rest(appUrl).axios(axios)) it('initialized the client', () => { assert.ok(client) }) }) ` export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx).then( when((ctx) => ctx.client, renderSource(template, toFile('test', 'client.test'))) ) ================================================ FILE: packages/generators/src/app/templates/client.tpl.ts ================================================ import { toFile, when } from '@featherscloud/pinion' import { renderSource } from '../../commons.js' import { AppGeneratorContext } from '../index.js' const template = ({ name, language }: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/client.html import { feathers } from '@feathersjs/feathers' import type { TransportConnection, Application } from '@feathersjs/feathers' import authenticationClient from '@feathersjs/authentication-client' import type { AuthenticationClientOptions } from '@feathersjs/authentication-client' export interface Configuration { connection: TransportConnection } export interface ServiceTypes {} export type ClientApplication = Application /** * Returns a ${language === 'ts' ? 'typed' : ''} client for the ${name} app. * * @param connection The REST or Socket.io Feathers client connection * @param authenticationOptions Additional settings for the authentication client * @see https://dove.feathersjs.com/api/client.html * @returns The Feathers client application */ export const createClient = ( connection: TransportConnection, authenticationOptions: Partial = {} ) => { const client: ClientApplication = feathers() client.configure(connection) client.configure(authenticationClient(authenticationOptions)) client.set('connection', connection) return client } ` export const generate = async (ctx: AppGeneratorContext) => Promise.resolve(ctx).then( when( (ctx) => ctx.client, renderSource( template, toFile(({ lib }) => lib, 'client') ) ) ) ================================================ FILE: packages/generators/src/app/templates/configuration.tpl.ts ================================================ import { toFile, when, writeJSON } from '@featherscloud/pinion' import { renderSource } from '../../commons.js' import { AppGeneratorContext } from '../index.js' const defaultConfig = ({}: AppGeneratorContext) => ({ host: 'localhost', port: 3030, public: './public/', origins: ['http://localhost:3030'], paginate: { default: 10, max: 50 } }) const customEnvironment = { port: { __name: 'PORT', __format: 'number' }, host: 'HOSTNAME', authentication: { secret: 'FEATHERS_SECRET' } } const testConfig = { port: 8998 } const configurationJsonTemplate = ({}: AppGeneratorContext) => `import { defaultAppSettings, getValidator } from '@feathersjs/schema' import type { FromSchema } from '@feathersjs/schema' import { dataValidator } from './validators' export const configurationSchema = { $id: 'configuration', type: 'object', additionalProperties: false, required: [ 'host', 'port', 'public' ], properties: { ...defaultAppSettings, host: { type: 'string' }, port: { type: 'number' }, public: { type: 'string' } } } as const export const configurationValidator = getValidator(configurationSchema, dataValidator) export type ApplicationConfiguration = FromSchema ` const configurationTypeboxTemplate = ({}: AppGeneratorContext) => `import { Type, getValidator, defaultAppConfiguration } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' import { dataValidator } from './validators' export const configurationSchema = Type.Intersect([ defaultAppConfiguration, Type.Object({ host: Type.String(), port: Type.Number(), public: Type.String() }) ]) export type ApplicationConfiguration = Static export const configurationValidator = getValidator(configurationSchema, dataValidator) ` export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx) .then(writeJSON(defaultConfig, toFile('config', 'default.json'))) .then(writeJSON(testConfig, toFile('config', 'test.json'))) .then(writeJSON(customEnvironment, toFile('config', 'custom-environment-variables.json'))) .then( when( (ctx) => ctx.schema !== false, renderSource( async (ctx) => ctx.schema === 'typebox' ? configurationTypeboxTemplate(ctx) : configurationJsonTemplate(ctx), toFile(({ lib }) => lib, 'configuration') ) ) ) ================================================ FILE: packages/generators/src/app/templates/declarations.tpl.ts ================================================ import { toFile, when, renderTemplate } from '@featherscloud/pinion' import { AppGeneratorContext } from '../index.js' const template = ({ framework, schema }: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/typescript.html import { HookContext as FeathersHookContext, NextFunction } from '@feathersjs/feathers' import { Application as FeathersApplication } from '@feathersjs/${framework}' ${ schema === false ? `type ApplicationConfiguration = any` : `import { ApplicationConfiguration } from './configuration'` } export type { NextFunction } // The types for app.get(name) and app.set(name) // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface Configuration extends ApplicationConfiguration {} // A mapping of service names to types. Will be extended in service files. // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface ServiceTypes {} // The application instance type that will be used everywhere else export type Application = FeathersApplication // The context for hook functions - can be typed with a service class export type HookContext = FeathersHookContext ` export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx).then( when( ({ language }) => language === 'ts', renderTemplate( template, toFile(({ lib }) => lib, 'declarations.ts') ) ) ) ================================================ FILE: packages/generators/src/app/templates/gitignore.tpl.ts ================================================ import { renderTemplate, toFile } from '@featherscloud/pinion' import { AppGeneratorContext } from '..' const template = `# Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* lerna-debug.log* .pnpm-debug.log* # Diagnostic reports (https://nodejs.org/api/report.html) report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage *.lcov # nyc test coverage .nyc_output # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) .grunt # Bower dependency directory (https://bower.io/) bower_components # node-waf configuration .lock-wscript # Compiled binary addons (https://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules/ jspm_packages/ # Snowpack dependency directory (https://snowpack.dev/) web_modules/ # TypeScript cache *.tsbuildinfo # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Microbundle cache .rpt2_cache/ .rts2_cache_cjs/ .rts2_cache_es/ .rts2_cache_umd/ # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env .env.test .env.production # parcel-bundler cache (https://parceljs.org/) .cache .parcel-cache # Next.js build output .next out # Nuxt.js build / generate output .nuxt dist # Gatsby files .cache/ # Comment in the public line in if your project uses Gatsby and not Next.js # https://nextjs.org/blog/next-9-1#public-directory-support # public # vuepress build output .vuepress/dist # Serverless directories .serverless/ # FuseBox cache .fusebox/ # DynamoDB Local files .dynamodb/ # TernJS port file .tern-port # Stores VSCode versions used for testing VSCode extensions .vscode-test # yarn v2 .yarn/cache .yarn/unplugged .yarn/build-state.yml .yarn/install-state.gz .pnp.* .sqlite lib/ ` export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx).then(renderTemplate(template, toFile('.gitignore'))) ================================================ FILE: packages/generators/src/app/templates/index.html.tpl.ts ================================================ import { renderTemplate, toFile } from '@featherscloud/pinion' import { AppGeneratorContext } from '../index.js' const template = ({ name, description }: AppGeneratorContext) => /* html */ ` ${name} ` export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx).then(renderTemplate(template, toFile('public', 'index.html'))) ================================================ FILE: packages/generators/src/app/templates/index.tpl.ts ================================================ import { toFile } from '@featherscloud/pinion' import { renderSource } from '../../commons.js' import { AppGeneratorContext } from '../index.js' const template = ({}: AppGeneratorContext) => /* ts */ `import { app } from './app' import { logger } from './logger' const port = app.get('port') const host = app.get('host') process.on('unhandledRejection', (reason) => logger.error('Unhandled Rejection %O', reason) ) app.listen(port).then(() => { logger.info(\`Feathers app listening on http://\${host}:\${port}\`) }) ` export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx).then( renderSource( template, toFile(({ lib }) => lib, 'index') ) ) ================================================ FILE: packages/generators/src/app/templates/logger.tpl.ts ================================================ import { toFile } from '@featherscloud/pinion' import { renderSource } from '../../commons.js' import { AppGeneratorContext } from '../index.js' const template = ({}: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/logging.html import { createLogger, format, transports } from 'winston' // Configure the Winston logger. For the complete documentation see https://github.com/winstonjs/winston export const logger = createLogger({ // To see more detailed errors, change this to 'debug' level: 'info', format: format.combine( format.splat(), format.simple() ), transports: [ new transports.Console() ] }) ` export const logErrorTemplate = /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/log-error.html import type { HookContext, NextFunction } from '../declarations' import { logger } from '../logger' export const logError = async (context: HookContext, next: NextFunction) => { try { await next() } catch (error: any) { logger.error(error.stack) // Log validation errors if (error.data) { logger.error('Data: %O', error.data) } throw error } } ` export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx) .then( renderSource( template, toFile(({ lib }) => lib, 'logger') ) ) .then( renderSource( logErrorTemplate, toFile(({ lib }) => lib, 'hooks', 'log-error') ) ) ================================================ FILE: packages/generators/src/app/templates/package.json.tpl.ts ================================================ import { toFile, writeJSON } from '@featherscloud/pinion' import { AppGeneratorContext } from '../index.js' const jsPackageJson = (lib: string) => ({ type: 'module', scripts: { start: `node ${lib}`, dev: `nodemon ${lib}/`, prettier: 'npx prettier "**/*.js" --write', mocha: 'cross-env NODE_ENV=test mocha test/ --recursive --exit', test: 'npm run mocha', 'bundle:client': 'npm pack --pack-destination ./public' } }) const tsPackageJson = (lib: string) => ({ scripts: { dev: `nodemon -x ts-node ${lib}/index.ts`, compile: 'shx rm -rf lib/ && tsc', start: 'node lib/', prettier: 'npx prettier "**/*.ts" --write', mocha: 'cross-env NODE_ENV=test mocha test/ --require ts-node/register --recursive --extension .ts --exit', test: 'npm run mocha', 'bundle:client': 'npm run compile && npm pack --pack-destination ./public' } }) const packageJson = ({ name, description, client, language, packager, database, framework, transports, lib, test, schema }: AppGeneratorContext) => ({ name, description, version: '0.0.0', homepage: '', private: true, keywords: ['feathers'], author: {}, contributors: [] as string[], bugs: {}, engines: { node: `>= ${process.version.substring(1)}` }, feathers: { language, packager, database, framework, transports, schema }, directories: { lib, test }, ...(client ? { files: ['lib/client.js', 'lib/**/*.d.ts', 'lib/**/*.shared.js'], main: language === 'ts' ? 'lib/client' : `${lib}/client` } : { main: 'lib/index' }), ...(language === 'ts' ? tsPackageJson(lib) : jsPackageJson(lib)) }) export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx).then(writeJSON(packageJson, toFile('package.json'))) ================================================ FILE: packages/generators/src/app/templates/prettierrc.tpl.ts ================================================ import { toFile, writeJSON } from '@featherscloud/pinion' import { AppGeneratorContext } from '../index.js' import { PRETTIERRC } from '../../commons.js' export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx).then( writeJSON( (ctx) => ({ ...PRETTIERRC, parser: ctx.language === 'ts' ? 'typescript' : 'babel' }), toFile('.prettierrc') ) ) ================================================ FILE: packages/generators/src/app/templates/readme.md.tpl.ts ================================================ import { renderTemplate, toFile } from '@featherscloud/pinion' import { AppGeneratorContext } from '../index.js' const template = ({ name, description, language, database }: AppGeneratorContext) => /* md */ `# ${name} > ${description} ## About This project uses [Feathers](http://feathersjs.com). An open source framework for building APIs and real-time applications. ## Getting Started 1. Make sure you have [NodeJS](https://nodejs.org/) and [npm](https://www.npmjs.com/) installed. 2. Install your dependencies \`\`\` cd path/to/${name} npm install \`\`\` 3. Start your app \`\`\`${ language === 'ts' ? ` npm run compile # Compile TypeScript source` : '' }${ database !== 'mongodb' ? ` npm run migrate # Run migrations to set up the database` : '' } npm start \`\`\` ## Testing Run \`npm test\` and all your tests in the \`test/\` directory will be run. ## Scaffolding This app comes with a powerful command line interface for Feathers. Here are a few things it can do: \`\`\` $ npx feathers help # Show all commands $ npx feathers generate service # Generate a new Service \`\`\` ## Help For more information on all the things you can do with Feathers visit [docs.feathersjs.com](http://docs.feathersjs.com). ` export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx).then(renderTemplate(template, toFile('readme.md'))) ================================================ FILE: packages/generators/src/app/templates/services.tpl.ts ================================================ import { toFile } from '@featherscloud/pinion' import { renderSource } from '../../commons.js' import { AppGeneratorContext } from '../index.js' const template = ({}: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/application.html#configure-functions import type { Application } from '../declarations' export const services = (app: Application) => { // All services will be registered here } ` export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx).then( renderSource( template, toFile(({ lib }) => lib, 'services', 'index') ) ) ================================================ FILE: packages/generators/src/app/templates/tsconfig.json.tpl.ts ================================================ import { toFile, when, writeJSON } from '@featherscloud/pinion' import { AppGeneratorContext } from '../index.js' export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx).then( when( (ctx) => ctx.language === 'ts', writeJSON( ({ lib }) => ({ 'ts-node': { files: true }, compilerOptions: { target: 'es2020', module: 'commonjs', outDir: './lib', rootDir: `./${lib}`, declaration: true, strict: true, esModuleInterop: true, sourceMap: true, skipLibCheck: true }, include: [lib], exclude: ['test'] }), toFile('tsconfig.json') ) ) ) ================================================ FILE: packages/generators/src/app/templates/validators.tpl.ts ================================================ import { toFile } from '@featherscloud/pinion' import { renderSource } from '../../commons.js' import { AppGeneratorContext } from '../index.js' const validatorTemplate = /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/validators.html import { Ajv, addFormats } from '@feathersjs/schema' import type { FormatsPluginOptions } from '@feathersjs/schema' const formats: FormatsPluginOptions = [ 'date-time', 'time', 'date', 'email', 'hostname', 'ipv4', 'ipv6', 'uri', 'uri-reference', 'uuid', 'uri-template', 'json-pointer', 'relative-json-pointer', 'regex' ] export const dataValidator: Ajv = addFormats(new Ajv({}), formats) export const queryValidator: Ajv = addFormats(new Ajv({ coerceTypes: true }), formats) ` export const generate = (ctx: AppGeneratorContext) => Promise.resolve(ctx).then( renderSource( validatorTemplate, toFile(({ lib }) => lib, 'validators') ) ) ================================================ FILE: packages/generators/src/authentication/index.ts ================================================ import chalk from 'chalk' import { dirname } from 'path' import { runGenerators, prompt } from '@featherscloud/pinion' import { fileURLToPath } from 'url' import { addVersions, checkPreconditions, FeathersBaseContext, initializeBaseContext, install } from '../commons.js' import { generate as serviceGenerator, ServiceGeneratorContext } from '../service/index.js' // Set __dirname in es module const __dirname = dirname(fileURLToPath(import.meta.url)) export interface AuthenticationGeneratorContext extends ServiceGeneratorContext { service: string entity: string authStrategies: string[] dependencies: string[] } export type AuthenticationGeneratorArguments = FeathersBaseContext & Partial> export const generate = (ctx: AuthenticationGeneratorArguments) => Promise.resolve(ctx) .then(initializeBaseContext()) .then(checkPreconditions()) .then( prompt((ctx: AuthenticationGeneratorArguments) => [ { type: 'checkbox', name: 'authStrategies', when: !ctx.authStrategies, message: 'Which authentication methods do you want to use?', suffix: chalk.grey(' Other methods and providers can be added at any time.'), choices: [ { name: 'Email + Password', value: 'local', checked: true }, { name: 'Google', value: 'google' }, { name: 'Facebook', value: 'facebook' }, { name: 'Twitter', value: 'twitter' }, { name: 'GitHub', value: 'github' }, { name: 'Auth0', value: 'auth0' } ] }, { name: 'service', type: 'input', when: !ctx.service, message: 'What is your authentication service name?', default: 'user' }, { name: 'path', type: 'input', when: !ctx.path, message: 'What path should the service be registered on?', default: 'users' } ]) ) .then(async (ctx) => { const serviceContext = await serviceGenerator({ ...ctx, name: ctx.service, isEntityService: true }) return { ...ctx, entity: ctx.service, ...serviceContext } }) .then(runGenerators(__dirname, 'templates')) .then((ctx) => ctx as AuthenticationGeneratorContext) .then((ctx) => { const dependencies: string[] = [] dependencies.push('@feathersjs/authentication-oauth') if (ctx.authStrategies.includes('local')) { dependencies.push('@feathersjs/authentication-local') } if (ctx.dependencies) { return { ...ctx, dependencies: [...ctx.dependencies, ...dependencies] } } return install( addVersions(dependencies, ctx.dependencyVersions), false, ctx.feathers.packager )(ctx) }) ================================================ FILE: packages/generators/src/authentication/templates/authentication.tpl.ts ================================================ import { before, toFile } from '@featherscloud/pinion' import { injectSource, renderSource } from '../../commons.js' import { AuthenticationGeneratorContext } from '../index.js' import { localTemplate, oauthTemplate } from '../../commons.js' const template = ({ authStrategies }: AuthenticationGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/authentication.html import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication' ${localTemplate(authStrategies, `import { LocalStrategy } from '@feathersjs/authentication-local'`)} ${oauthTemplate(authStrategies, `import { oauth, OAuthStrategy } from '@feathersjs/authentication-oauth'`)} import type { Application } from './declarations' declare module './declarations' { interface ServiceTypes { 'authentication': AuthenticationService } } export const authentication = (app: Application) => { const authentication = new AuthenticationService(app) authentication.register('jwt', new JWTStrategy()) ${authStrategies .map( (strategy) => ` authentication.register('${strategy}', ${ strategy === 'local' ? `new LocalStrategy()` : `new OAuthStrategy()` })` ) .join('\n')} app.use('authentication', authentication) ${oauthTemplate(authStrategies, `app.configure(oauth())`)} } ` const importTemplate = "import { authentication } from './authentication'" const configureTemplate = 'app.configure(authentication)' const toAppFile = toFile(({ lib }) => [lib, 'app']) export const generate = (ctx: AuthenticationGeneratorContext) => Promise.resolve(ctx) .then( renderSource( template, toFile(({ lib }) => lib, 'authentication') ) ) .then(injectSource(importTemplate, before('import { services } from'), toAppFile)) .then(injectSource(configureTemplate, before('app.configure(services)'), toAppFile)) ================================================ FILE: packages/generators/src/authentication/templates/client.test.tpl.ts ================================================ import { toFile, when } from '@featherscloud/pinion' import { fileExists, renderSource } from '../../commons.js' import { AuthenticationGeneratorContext } from '../index.js' import { localTemplate } from '../../commons.js' const template = ({ authStrategies, upperName, type, lib }: AuthenticationGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/client.test.html import assert from 'assert' import axios from 'axios' import rest from '@feathersjs/rest-client' ${localTemplate(authStrategies, `import authenticationClient from '@feathersjs/authentication-client'`)} import { app } from '../${lib}/app' import { createClient } from '../${lib}/client' ${localTemplate(authStrategies, `import type { ${upperName}Data } from '../${lib}/client'`)} const port = app.get('port') const appUrl = \`http://\${app.get('host')}:\${port}\` describe('application client tests', () => { const client = createClient(rest(appUrl).axios(axios)) before(async () => { await app.listen(port) }) after(async () => { await app.teardown() }) it('initialized the client', () => { assert.ok(client) }) ${localTemplate( authStrategies, ` it('creates and authenticates a user with email and password', async () => { const userData: ${upperName}Data = { email: 'someone@example.com', password: 'supersecret' } await client.service('users').create(userData) const { user, accessToken } = await client.authenticate({ strategy: 'local', ...userData }) assert.ok(accessToken, 'Created access token for user') assert.ok(user, 'Includes user in authentication data') assert.strictEqual(user.password, undefined, 'Password is hidden to clients') await client.logout() // Remove the test user on the server await app.service('users').remove(user.${type === 'mongodb' ? '_id' : 'id'}) })` )} }) ` export const generate = (ctx: AuthenticationGeneratorContext) => Promise.resolve(ctx).then( when( ({ lib, language }) => fileExists(lib, `client.${language}`), renderSource( template, toFile(({ test }) => test, 'client.test'), { force: true } ) ) ) ================================================ FILE: packages/generators/src/authentication/templates/config.tpl.ts ================================================ import crypto from 'crypto' import { toFile, mergeJSON } from '@featherscloud/pinion' import { AuthenticationGeneratorContext } from '../index.js' export const generate = (ctx: AuthenticationGeneratorContext) => Promise.resolve(ctx) .then( mergeJSON( ({ authStrategies }) => { const authentication: any = { entity: ctx.entity, service: ctx.path, secret: crypto.randomBytes(24).toString('base64'), authStrategies: ['jwt'], jwtOptions: { header: { typ: 'access' }, audience: 'https://yourdomain.com', algorithm: 'HS256', expiresIn: '1d' } } if (authStrategies.includes('local')) { authentication.authStrategies.push('local') authentication.local = { usernameField: 'email', passwordField: 'password' } } const oauthStrategies = authStrategies.filter((name) => name !== 'local') if (oauthStrategies.length) { authentication.oauth = oauthStrategies.reduce((oauth, name) => { oauth[name] = { key: '', secret: '' } return oauth }, {} as any) } return { authentication } }, toFile('config', 'default.json') ) ) .then( mergeJSON( { authentication: { secret: 'FEATHERS_SECRET' } }, toFile('config', 'custom-environment-variables.json') ) ) ================================================ FILE: packages/generators/src/authentication/templates/declarations.tpl.ts ================================================ import { inject, before, toFile, when, append } from '@featherscloud/pinion' import { AuthenticationGeneratorContext } from '../index.js' const importTemplate = ({ upperName, folder, fileName }: AuthenticationGeneratorContext) => /* ts */ `import { ${upperName} } from './services/${folder.join( '/' )}/${fileName}' ` const paramsTemplate = ({ entity, upperName }: AuthenticationGeneratorContext) => /* ts */ `// Add the ${entity} as an optional property to all params declare module '@feathersjs/feathers' { interface Params { ${entity}?: ${upperName} } } ` const toDeclarationFile = toFile(({ lib }) => lib, 'declarations.ts') export const generate = (ctx: AuthenticationGeneratorContext) => Promise.resolve(ctx) .then( when( (ctx) => ctx.language === 'ts', inject( importTemplate, before(/export \{ NextFunction \}|export type \{ NextFunction \}/), toDeclarationFile ) ) ) .then(when((ctx) => ctx.language === 'ts', inject(paramsTemplate, append(), toDeclarationFile))) ================================================ FILE: packages/generators/src/commons.ts ================================================ import fs from 'fs' import { join, dirname } from 'path' import { PackageJson } from 'type-fest' import { readFile, writeFile } from 'fs/promises' import { Callable, PinionContext, loadJSON, fromFile, getCallable, renderTemplate, inject, Location, exec } from '@featherscloud/pinion' import ts from 'typescript' import prettier, { Options as PrettierOptions } from 'prettier' import path from 'path' import { fileURLToPath } from 'url' // Set __dirname in es module const __dirname = dirname(fileURLToPath(import.meta.url)) export const { version } = JSON.parse(fs.readFileSync(join(__dirname, '..', 'package.json')).toString()) export type DependencyVersions = { [key: string]: string } export const DATABASE_TYPES = ['mongodb', 'mysql', 'postgresql', 'sqlite', 'mssql', 'other'] as const /** * The database types supported by this generator */ export type DatabaseType = (typeof DATABASE_TYPES)[number] /** * Returns the name of the Feathers database adapter for a supported database type * * @param database The type of the database * @returns The name of the adapter */ export const getDatabaseAdapter = (database: DatabaseType) => (database === 'mongodb' ? 'mongodb' : 'knex') export type FeathersAppInfo = { /** * The application language */ language: 'ts' | 'js' /** * The main database */ database: DatabaseType /** * The package manager used */ packager: 'yarn' | 'npm' | 'pnpm' /** * A list of all chosen transports */ transports: ('rest' | 'websockets')[] /** * The HTTP framework used */ framework: 'koa' | 'express' /** * The main schema definition format */ schema: 'typebox' | 'json' | false } export interface AppPackageJson extends PackageJson { feathers?: FeathersAppInfo } export interface FeathersBaseContext extends PinionContext { /** * Information about the Feathers application (like chosen language, database etc.) * usually taken from `package.json` */ feathers: FeathersAppInfo /** * The package.json file */ pkg: AppPackageJson /** * The folder where source files are put */ lib: string /** * The folder where test files are put */ test: string /** * The language the app is generated in */ language: 'js' | 'ts' /** * A list dependencies that should be installed with a certain version. * Used for installing development dependencies during testing. */ dependencyVersions?: DependencyVersions } /** * Returns dependencies with the versions from the context attached (if available) * * @param dependencies The dependencies to install * @param versions The dependency version list * @returns A list of dependencies with their versions */ export const addVersions = ( dependencies: string[], versions: DependencyVersions, defaultVersion = 'latest' ): string[] => dependencies.map((dep) => `${dep}@${versions[dep] || defaultVersion}`) /** * Loads the application package.json and populates information like the library and test directory * and Feathers app specific information. * * @returns The updated context */ export const initializeBaseContext = () => (ctx: C) => Promise.resolve(ctx) .then(loadJSON(fromFile('package.json'), (pkg) => ({ pkg }), {})) .then( loadJSON(path.join(__dirname, '..', 'package.json'), (pkg: PackageJson) => ({ dependencyVersions: { ...pkg.devDependencies, ...ctx.dependencyVersions, '@feathersjs/cli': version } })) ) .then((ctx) => ({ ...ctx, lib: ctx.pkg?.directories?.lib || 'src', test: ctx.pkg?.directories?.test || 'test', language: ctx.language || ctx.pkg?.feathers?.language, feathers: ctx.pkg?.feathers })) /** * A special error that can be thrown by generators. It contains additional * information about the error that can be used to display a more helpful * error message to the user. */ export class FeathersGeneratorError extends Error { /** * Additional information about the error. This can include things like * the reason for the error and suggested actions to take. */ context?: Record /** * Creates a new FeathersGeneratorError * @param message The error message * @param context Additional information about the error */ constructor(message: string, context?: Record) { super(message) this.name = 'FeathersGeneratorError' this.context = context } } /** * Checks if the current context contains a valid generated application. This is necesary for most * generators (besides the app generator). * * @param ctx The context to check against * @returns Throws an error or returns the original context */ export const checkPreconditions = () => async (ctx: T) => { if (!ctx.feathers) { throw new FeathersGeneratorError('Invalid Feathers application context', { reason: 'Missing Feathers configuration', suggestedAction: 'Verify package.json contains Feathers metadata' }) } return ctx } const importRegex = /from '(\..*)'/g const escapeNewLines = (code: string) => code.replace(/\n\n/g, '\n/* :newline: */') const restoreNewLines = (code: string) => code.replace(/\/\* :newline: \*\//g, '\n') const fixLocalImports = (code: string) => code.replace(importRegex, "from '$1.js'") /** * Returns the transpiled and prettified JavaScript for a TypeScript source code * * @param typescript The TypeScript source code * @param options TypeScript transpilation options * @returns The formatted JavaScript source code */ export const getJavaScript = (typescript: string, options: ts.TranspileOptions = {}) => { const source = escapeNewLines(typescript) const transpiled = ts.transpileModule(source, { ...options, compilerOptions: { module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.ES2020, preserveValueImports: true, ...options.compilerOptions } }) const { outputText } = transpiled if (outputText.startsWith('export {}') && typescript.startsWith('import')) { return fixLocalImports(typescript) } return fixLocalImports(restoreNewLines(transpiled.outputText)) } const getFileName = async ( target: Callable, ctx: C ) => `${await getCallable(target, ctx)}.${ctx.language}` /** * The default configuration for prettifying files */ export const PRETTIERRC: PrettierOptions = { tabWidth: 2, useTabs: false, printWidth: 110, semi: false, trailingComma: 'none', singleQuote: true, arrowParens: 'avoid', bracketSpacing: true, endOfLine: 'auto', jsxSingleQuote: false, quoteProps: 'as-needed' } /* * Format a source file using Prettier. Will use the local configuration, the settings set in * `options` or a default configuration * * @param target The file to prettify * @param options The Prettier options * @returns The updated context */ export const prettify = ( target: Callable, options: PrettierOptions = PRETTIERRC ) => async (ctx: C) => { const fileName = await getFileName(target, ctx) const config = (await prettier.resolveConfig(ctx.cwd)) || options const content = (await readFile(fileName)).toString() try { await writeFile( fileName, await prettier.format(content, { parser: ctx.language === 'ts' ? 'typescript' : 'babel', ...config }) ) } catch (error: any) { throw new Error(`Error prettifying ${fileName}: ${error.message}`) } return ctx } /** * Render a source file template for the language set in the context. * * @param templates The JavaScript and TypeScript template to render * @param target The target filename without extension (will be added based on language) * @returns The updated context */ export const renderSource = ( template: Callable, target: Callable, options?: { force: boolean } ) => async (ctx: C) => { const { language } = ctx const fileName = await getFileName(target, ctx) const content = language === 'js' ? getJavaScript(await getCallable(template, ctx)) : template const renderer = renderTemplate(content, fileName, options) return renderer(ctx).then(prettify(target)) } export const install = ( dependencies: Callable, dev: Callable, packager: Callable ) => async (ctx: C) => { const dependencyList = await getCallable(dependencies, ctx) const packageManager = await getCallable(packager, ctx) const flags = dev ? [packageManager === 'yarn' ? '--dev' : '--save-dev'] : [] return exec(packager, [packageManager === 'yarn' ? 'add' : 'install', ...dependencyList, ...flags])(ctx) } /** * Inject a source template as the language set in the context. * * @param template The source template to render * @param location The location to inject the code to. Must use the target language. * @param target The target file name * @param transpile Set to `false` if the code should not be transpiled to JavaScript * @returns */ export const injectSource = ( template: Callable, location: Location, target: Callable, transpile = true ) => async (ctx: C) => { const { language } = ctx const source = language === 'js' && transpile ? getJavaScript(await getCallable(template, ctx)) : template const fileName = await getFileName(target, ctx) const injector = inject(source, location, fileName) return injector(ctx).then(prettify(target)) } /** * Synchronously checks if a file exits * @param context The base context * @param filenames The filenames to check * @returns Wether the file exists or not */ export const fileExists = (...filenames: string[]) => fs.existsSync(join(...filenames)) /** * The helper used by Knex to create migration names * @returns The current date and time in the format `YYYYMMDDHHMMSS` */ export const yyyymmddhhmmss = (offset = 0) => { const now = new Date(Date.now() + offset) return ( now.getUTCFullYear().toString() + (now.getUTCMonth() + 1).toString().padStart(2, '0') + now.getUTCDate().toString().padStart(2, '0') + now.getUTCHours().toString().padStart(2, '0') + now.getUTCMinutes().toString().padStart(2, '0') + now.getUTCSeconds().toString().padStart(2, '0') ) } /** * Render a template if `local` authentication strategy has been selected * @param authStrategies The list of selected authentication strategies * @param content The content to render if `local` is selected * @param alt The content to render if `local` is not selected * @returns */ export const localTemplate = (authStrategies: string[], content: string, alt = '') => authStrategies.includes('local') ? content : alt /** * Render a template if an `oauth` authentication strategy has been selected * @param authStrategies * @param content * @returns */ export const oauthTemplate = (authStrategies: string[], content: string) => authStrategies.filter((s) => s !== 'local').length > 0 ? content : '' ================================================ FILE: packages/generators/src/connection/index.ts ================================================ import { dirname } from 'path' import { runGenerator, prompt, mergeJSON, toFile, when } from '@featherscloud/pinion' import { fileURLToPath } from 'url' import chalk from 'chalk' import { install, FeathersBaseContext, DatabaseType, getDatabaseAdapter, addVersions, checkPreconditions, initializeBaseContext } from '../commons.js' // Set __dirname in es module const __dirname = dirname(fileURLToPath(import.meta.url)) export interface ConnectionGeneratorContext extends FeathersBaseContext { name?: string database: DatabaseType connectionString: string dependencies: string[] } export type ConnectionGeneratorArguments = FeathersBaseContext & Partial> export const defaultConnectionString = (type: DatabaseType, name: string) => { const connectionStrings = { mongodb: `mongodb://127.0.0.1:27017/${name}`, mysql: `mysql://root:@localhost:3306/${name}`, postgresql: `postgres://postgres:@localhost:5432/${name}`, sqlite: `${name}.sqlite`, mssql: `mssql://root:password@localhost:1433/${name}`, other: '' } return connectionStrings[type] } export const prompts = ({ database, connectionString, pkg, name }: ConnectionGeneratorArguments) => [ { name: 'database', type: 'list', when: !database, message: 'Which database are you connecting to?', suffix: chalk.grey(' Databases can be added at any time'), choices: [ { value: 'sqlite', name: 'SQLite' }, { value: 'mongodb', name: 'MongoDB' }, { value: 'postgresql', name: 'PostgreSQL' }, { value: 'mysql', name: 'MySQL/MariaDB' }, { value: 'mssql', name: 'Microsoft SQL' }, { value: 'other', name: `Another database ${chalk.grey('(not configured automatically, use with custom services)')}` } ] }, { name: 'connectionString', type: 'input', when: (answers: ConnectionGeneratorContext) => !connectionString && database !== 'other' && answers.database !== 'other', message: 'Enter your database connection string', default: (answers: ConnectionGeneratorContext) => defaultConnectionString(answers.database, answers.name || name || pkg.name) } ] export const DATABASE_CLIENTS = { mongodb: 'mongodb', sqlite: 'sqlite3', postgresql: 'pg', mysql: 'mysql', mssql: 'mssql' } export const getDatabaseClient = (database: DatabaseType) => database === 'other' ? null : DATABASE_CLIENTS[database] export const generate = (ctx: ConnectionGeneratorArguments) => Promise.resolve(ctx) .then(initializeBaseContext()) .then(checkPreconditions()) .then(prompt(prompts)) .then((ctx) => ctx as ConnectionGeneratorContext) .then( when( (ctx) => ctx.database !== 'other', runGenerator( __dirname, 'templates', ({ database }) => `${getDatabaseAdapter(database)}.tpl.js` ), mergeJSON( ({ connectionString, database }) => getDatabaseAdapter(database) === 'knex' ? { [database]: { client: getDatabaseClient(database), connection: connectionString, ...(database === 'sqlite' ? { useNullAsDefault: true } : {}) } } : { [database]: connectionString }, toFile('config', 'default.json') ), async (ctx: ConnectionGeneratorContext) => { const dependencies: string[] = [] const adapter = getDatabaseAdapter(ctx.database) const dbClient = getDatabaseClient(ctx.database) dependencies.push(`@feathersjs/${adapter}`) if (adapter === 'knex') { dependencies.push('knex') } dependencies.push(dbClient) if (ctx.dependencies) { return { ...ctx, dependencies: [...ctx.dependencies, ...dependencies] } } return install( addVersions(dependencies, ctx.dependencyVersions), false, ctx.feathers.packager )(ctx) } ) ) ================================================ FILE: packages/generators/src/connection/templates/knex.tpl.ts ================================================ import { toFile, before, mergeJSON } from '@featherscloud/pinion' import { ConnectionGeneratorContext } from '../index.js' import { injectSource, renderSource } from '../../commons.js' import { mkdir } from 'fs/promises' import path from 'path' const template = ({ database }: ConnectionGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html import knex from 'knex' import type { Knex } from 'knex' import type { Application } from './declarations' declare module './declarations' { interface Configuration { ${database}Client: Knex } } export const ${database} = (app: Application) => { const config = app.get('${database}') const db = knex(config!) app.set('${database}Client', db) } ` const knexfile = ({ lib, language, database }: ConnectionGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html import { app } from './${lib}/app' // Load our database connection info from the app configuration const config = app.get('${database}') ${language === 'js' ? 'export default config' : 'module.exports = config'} ` const importTemplate = ({ database }: ConnectionGeneratorContext) => `import { ${database} } from './${database}'` const configureTemplate = ({ database }: ConnectionGeneratorContext) => `app.configure(${database})` const toAppFile = toFile(({ lib }) => [lib, 'app']) export const generate = (ctx: ConnectionGeneratorContext) => Promise.resolve(ctx) .then( renderSource( template, toFile(({ lib, database }) => [lib, database]) ) ) .then(renderSource(knexfile, toFile('knexfile'))) .then( mergeJSON( (ctx) => ({ scripts: { migrate: 'knex migrate:latest', 'migrate:make': 'knex migrate:make' + (ctx.language === 'js' ? ' -x mjs' : ''), test: 'cross-env NODE_ENV=test npm run migrate && npm run mocha' } }), toFile('package.json') ) ) .then(injectSource(importTemplate, before('import { services } from'), toAppFile)) .then(injectSource(configureTemplate, before('app.configure(services)'), toAppFile)) .then(async (ctx) => { await mkdir(path.join(ctx.cwd, 'migrations')) return ctx }) ================================================ FILE: packages/generators/src/connection/templates/mongodb.tpl.ts ================================================ import { toFile, before, prepend, append } from '@featherscloud/pinion' import { ConnectionGeneratorContext } from '../index.js' import { injectSource, renderSource } from '../../commons.js' const template = ({ database }: ConnectionGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html import { MongoClient } from 'mongodb' import type { Db } from 'mongodb' import type { Application } from './declarations' declare module './declarations' { interface Configuration { ${database}Client: Promise } } export const ${database} = (app: Application) => { const connection = app.get('${database}') as string const database = new URL(connection).pathname.substring(1) const mongoClient = MongoClient.connect(connection) .then(client => client.db(database)) app.set('${database}Client', mongoClient) } ` const keywordImport = `import { keywordObjectId } from '@feathersjs/mongodb'` const keywordTemplate = `dataValidator.addKeyword(keywordObjectId) queryValidator.addKeyword(keywordObjectId)` const importTemplate = ({ database }: ConnectionGeneratorContext) => `import { ${database} } from './${database}'` const configureTemplate = ({ database }: ConnectionGeneratorContext) => `app.configure(${database})` const toAppFile = toFile(({ lib }) => [lib, 'app']) const toValidatorFile = toFile(({ lib }) => [lib, 'validators']) export const generate = (ctx: ConnectionGeneratorContext) => Promise.resolve(ctx) .then( renderSource( template, toFile(({ lib, database }) => [lib, database]) ) ) .then(injectSource(importTemplate, before('import { services } from'), toAppFile)) .then(injectSource(configureTemplate, before('app.configure(services)'), toAppFile)) .then(injectSource(keywordImport, prepend(), toValidatorFile)) .then(injectSource(keywordTemplate, append(), toValidatorFile)) ================================================ FILE: packages/generators/src/hook/index.ts ================================================ import { dirname } from 'path' import { fileURLToPath } from 'url' import { prompt, runGenerators } from '@featherscloud/pinion' import _ from 'lodash' import { checkPreconditions, FeathersBaseContext, initializeBaseContext } from '../commons.js' // Set __dirname in es module const __dirname = dirname(fileURLToPath(import.meta.url)) export interface HookGeneratorContext extends FeathersBaseContext { name: string camelName: string kebabName: string type: 'regular' | 'around' } export const generate = (ctx: HookGeneratorContext) => Promise.resolve(ctx) .then(initializeBaseContext()) .then(checkPreconditions()) .then( prompt(({ type, name }) => [ { type: 'input', name: 'name', message: 'What is the name of the hook?', when: !name }, { name: 'type', type: 'list', when: !type, message: 'What kind of hook is it?', choices: [ { value: 'around', name: 'Around' }, { value: 'regular', name: 'Before, After or Error' } ] } ]) ) .then((ctx) => { const { name } = ctx const kebabName = _.kebabCase(name) const camelName = _.camelCase(name) return { ...ctx, kebabName, camelName } }) .then(runGenerators(__dirname, 'templates')) ================================================ FILE: packages/generators/src/hook/templates/hook.tpl.ts ================================================ import { toFile } from '@featherscloud/pinion' import { HookGeneratorContext } from '../index.js' import { renderSource } from '../../commons.js' const aroundTemplate = ({ camelName, name }: HookGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/hook.html import type { HookContext, NextFunction } from '../declarations' export const ${camelName} = async (context: HookContext, next: NextFunction) => { console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`) await next() } ` const regularTemplate = ({ camelName, name }: HookGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/hook.html import type { HookContext } from '../declarations' export const ${camelName} = async (context: HookContext) => { console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`) }` export const generate = (ctx: HookGeneratorContext) => Promise.resolve(ctx).then( renderSource( (ctx) => (ctx.type === 'around' ? aroundTemplate(ctx) : regularTemplate(ctx)), toFile(({ lib, kebabName }) => [lib, 'hooks', kebabName]) ) ) ================================================ FILE: packages/generators/src/index.ts ================================================ export * from '@featherscloud/pinion' export * from './commons.js' export * as app from './app/index.js' export * as authentication from './authentication/index.js' export * as connection from './connection/index.js' export * as hook from './hook/index.js' export * as service from './service/index.js' ================================================ FILE: packages/generators/src/service/index.ts ================================================ import { dirname } from 'path' import _ from 'lodash' import { runGenerator, runGenerators, prompt } from '@featherscloud/pinion' import { fileURLToPath } from 'url' import chalk from 'chalk' import { checkPreconditions, DATABASE_TYPES, FeathersBaseContext, fileExists, getDatabaseAdapter, initializeBaseContext } from '../commons.js' // Set __dirname in es module const __dirname = dirname(fileURLToPath(import.meta.url)) export interface ServiceGeneratorContext extends FeathersBaseContext { /** * The chosen service name */ name: string /** * The path the service is registered on */ path: string /** * The list of subfolders this service is in */ folder: string[] /** * The `camelCase` service name starting with a lowercase letter */ camelName: string /** * The `CamelCase` service name starting with an uppercase letter */ upperName: string /** * The service class name combined as `CamelCaseService` */ className: string /** * A kebab-cased (filename friendly) version of the service name */ kebabName: string /** * The actual filename (the last element of the path) */ fileName: string /** * The kebab-cased name of the path. Will be used for e.g. database names */ kebabPath: string /** * Indicates how many file paths we should go up to import other things (e.g. `../../`) */ relative: string /** * The chosen service type */ type: 'knex' | 'mongodb' | 'custom' /** * Which schema definition format to use */ schema: 'typebox' | 'json' | false /** * Wether this service uses authentication */ authentication: boolean /** * Set to true if this service is for an authentication entity */ isEntityService?: boolean /** * The authentication strategies (if it is an entity service) */ authStrategies: string[] } /** * Parameters the generator is called with */ export type ServiceGeneratorArguments = FeathersBaseContext & Partial< Pick > export const generate = (ctx: ServiceGeneratorArguments) => Promise.resolve(ctx) .then(initializeBaseContext()) .then(checkPreconditions()) .then( prompt(({ name, path, type, schema, authentication, isEntityService, feathers, lib, language }) => { const sqlDisabled = DATABASE_TYPES.every( (name) => name === 'mongodb' || name === 'other' || !fileExists(lib, `${name}.${language}`) ) const mongodbDisabled = !fileExists(lib, `mongodb.${language}`) return [ { name: 'name', type: 'input', when: !name, message: 'What is the name of your service?', validate: (input: any) => { if (!input || input === 'authentication') { return 'Invalid service name' } return true } }, { name: 'path', type: 'input', when: !path, message: 'Which path should the service be registered on?', default: (answers: ServiceGeneratorArguments) => `${_.kebabCase(answers.name)}`, validate: (input: any) => { if (!input || input === 'authentication') { return 'Invalid service path' } return true } }, { name: 'authentication', type: 'confirm', when: authentication === undefined && !isEntityService, message: 'Does this service require authentication?' }, { name: 'type', type: 'list', when: !type, message: 'What database is the service using?', default: getDatabaseAdapter(feathers?.database), choices: [ { value: 'knex', name: `SQL${sqlDisabled ? chalk.gray(' (connection not available)') : ''}`, disabled: sqlDisabled }, { value: 'mongodb', name: `MongoDB${mongodbDisabled ? chalk.gray(' (connection not available)') : ''}`, disabled: mongodbDisabled }, { value: 'custom', name: 'A custom service' } ] }, { name: 'schema', type: 'list', when: schema === undefined, message: 'Which schema definition format do you want to use?', suffix: chalk.grey(' Schemas allow to type, validate, secure and populate data'), default: feathers?.schema, choices: (answers: ServiceGeneratorContext) => [ { value: 'typebox', name: `TypeBox ${chalk.gray(' (recommended)')}` }, { value: 'json', name: 'JSON schema' }, { value: false, name: `No schema${ answers.type !== 'custom' ? chalk.gray(' (not recommended with a database)') : '' }` } ] } ] }) ) .then(async (ctx): Promise => { const { name, path, type, authStrategies = [] } = ctx as any as ServiceGeneratorContext const kebabName = _.kebabCase(name) const camelName = _.camelCase(name) const upperName = _.upperFirst(camelName) const className = `${upperName}Service` const folder = path.split('/').filter((el) => el !== '') const relative = ['', ...folder].map(() => '..').join('/') const fileName = _.last(folder) const kebabPath = _.kebabCase(path) return { name, type, path, folder, fileName, upperName, className, kebabName, camelName, kebabPath, relative, authStrategies, ...ctx } as ServiceGeneratorContext }) .then(runGenerators(__dirname, 'templates')) .then(runGenerator(__dirname, 'type', ({ type }) => `${type}.tpl.js`)) ================================================ FILE: packages/generators/src/service/templates/client.tpl.ts ================================================ import { toFile, after, before, when } from '@featherscloud/pinion' import { fileExists, injectSource } from '../../commons.js' import { ServiceGeneratorContext } from '../index.js' const importTemplate = ({ upperName, folder, fileName, camelName }: ServiceGeneratorContext) => /* ts */ ` import { ${camelName}Client } from './services/${folder.join('/')}/${fileName}.shared' export type { ${upperName}, ${upperName}Data, ${upperName}Query, ${upperName}Patch } from './services/${folder.join('/')}/${fileName}.shared' ` const registrationTemplate = ({ camelName }: ServiceGeneratorContext) => ` client.configure(${camelName}Client)` const toClientFile = toFile(({ lib }) => [lib, 'client']) export const generate = async (ctx: ServiceGeneratorContext) => Promise.resolve(ctx).then( when( ({ lib, language }) => fileExists(lib, `client.${language}`), injectSource(registrationTemplate, before('return client'), toClientFile), injectSource( importTemplate, after(({ language }) => language === 'ts' ? 'import type { AuthenticationClientOptions }' : 'import authenticationClient' ), toClientFile ) ) ) ================================================ FILE: packages/generators/src/service/templates/schema.json.tpl.ts ================================================ import { toFile, when } from '@featherscloud/pinion' import { fileExists, localTemplate, renderSource } from '../../commons.js' import { ServiceGeneratorContext } from '../index.js' const authFieldsTemplate = (authStrategies: string[]) => authStrategies .map((name) => name === 'local' ? ` email: { type: 'string' }, password: { type: 'string' }` : ` ${name}Id: { type: 'string' }` ) .join(',\n') const template = ({ camelName, upperName, fileName, relative, authStrategies, isEntityService, type, cwd, lib }: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html import { resolve, getValidator, querySyntax } from '@feathersjs/schema'${ type === 'mongodb' ? ` import { ObjectIdSchema } from '@feathersjs/schema'` : '' } import type { FromSchema } from '@feathersjs/schema' ${localTemplate(authStrategies, `import { passwordHash } from '@feathersjs/authentication-local'`)} import type { HookContext } from '${relative}/declarations' import { dataValidator, queryValidator } from '${relative}/${ fileExists(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility }validators' import type { ${upperName}Service } from './${fileName}.class' // Main data model schema export const ${camelName}Schema = { $id: '${upperName}', type: 'object', additionalProperties: false, required: [ '${type === 'mongodb' ? '_id' : 'id'}', ${localTemplate(authStrategies, `'email'`, `'text'`)} ], properties: { ${type === 'mongodb' ? `_id: ObjectIdSchema(),` : `id: { type: 'number' },`} ${ isEntityService ? authFieldsTemplate(authStrategies) : ` text: { type: 'string' }` } } } as const export type ${upperName} = FromSchema export const ${camelName}Validator = getValidator(${camelName}Schema, dataValidator) export const ${camelName}Resolver = resolve<${upperName}, HookContext<${upperName}Service>>({}) export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext<${upperName}Service>>({ ${localTemplate( authStrategies, `// The password should never be visible externally password: async () => undefined` )} }) // Schema for creating new data export const ${camelName}DataSchema = { $id: '${upperName}Data', type: 'object', additionalProperties: false, required: [ ${localTemplate(authStrategies, `'email'`, `'text'`)} ], properties: { ...${camelName}Schema.properties } } as const export type ${upperName}Data = FromSchema export const ${camelName}DataValidator = getValidator(${camelName}DataSchema, dataValidator) export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext<${upperName}Service>>({ ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)} }) // Schema for updating existing data export const ${camelName}PatchSchema = { $id: '${upperName}Patch', type: 'object', additionalProperties: false, required: [], properties: { ...${camelName}Schema.properties } } as const export type ${upperName}Patch = FromSchema export const ${camelName}PatchValidator = getValidator(${camelName}PatchSchema, dataValidator) export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext<${upperName}Service>>({ ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)} }) // Schema for allowed query properties export const ${camelName}QuerySchema = { $id: '${upperName}Query', type: 'object', additionalProperties: false, properties: { ...querySyntax(${camelName}Schema.properties) } } as const export type ${upperName}Query = FromSchema export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator) export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext<${upperName}Service>>({ ${ isEntityService ? ` // If there is a user (e.g. with authentication), they are only allowed to see their own data ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => { if (context.params.user) { return context.params.user.${type === 'mongodb' ? '_id' : 'id'} } return value }` : '' } }) ` export const generate = (ctx: ServiceGeneratorContext) => Promise.resolve(ctx).then( when( ({ schema }) => schema === 'json', renderSource( template, toFile(({ lib, folder, fileName }: ServiceGeneratorContext) => [ lib, 'services', ...folder, `${fileName}.schema` ]) ) ) ) ================================================ FILE: packages/generators/src/service/templates/schema.typebox.tpl.ts ================================================ import { toFile, when } from '@featherscloud/pinion' import { fileExists, localTemplate, renderSource } from '../../commons.js' import { ServiceGeneratorContext } from '../index.js' const authFieldsTemplate = (authStrategies: string[]) => authStrategies .map((name) => name === 'local' ? ` email: Type.String(), password: Type.Optional(Type.String())` : ` ${name}Id: Type.Optional(Type.String())` ) .join(',\n') const template = ({ camelName, upperName, fileName, relative, authStrategies, isEntityService, type, cwd, lib }: ServiceGeneratorContext) => /* ts */ `// // For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html import { resolve } from '@feathersjs/schema' import { Type, getValidator, querySyntax } from '@feathersjs/typebox'${ type === 'mongodb' ? ` import { ObjectIdSchema } from '@feathersjs/typebox'` : '' } import type { Static } from '@feathersjs/typebox' ${localTemplate(authStrategies, `import { passwordHash } from '@feathersjs/authentication-local'`)} import type { HookContext } from '${relative}/declarations' import { dataValidator, queryValidator } from '${relative}/${ fileExists(cwd, lib, 'schemas') ? 'schemas/' : '' // This is for legacy backwards compatibility }validators' import type { ${upperName}Service } from './${fileName}.class' // Main data model schema export const ${camelName}Schema = Type.Object({ ${type === 'mongodb' ? '_id: ObjectIdSchema()' : 'id: Type.Number()'}, ${isEntityService ? authFieldsTemplate(authStrategies) : `text: Type.String()`} }, { $id: '${upperName}', additionalProperties: false }) export type ${upperName} = Static export const ${camelName}Validator = getValidator(${camelName}Schema, dataValidator) export const ${camelName}Resolver = resolve<${upperName}Query, HookContext<${upperName}Service>>({}) export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext<${upperName}Service>>({ ${localTemplate( authStrategies, `// The password should never be visible externally password: async () => undefined` )} }) // Schema for creating new entries export const ${camelName}DataSchema = Type.Pick(${camelName}Schema, [ ${ isEntityService ? authStrategies.map((name) => (name === 'local' ? `'email', 'password'` : `'${name}Id'`)).join(', ') : `'text'` } ], { $id: '${upperName}Data' }) export type ${upperName}Data = Static export const ${camelName}DataValidator = getValidator(${camelName}DataSchema, dataValidator) export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext<${upperName}Service>>({ ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)} }) // Schema for updating existing entries export const ${camelName}PatchSchema = Type.Partial(${camelName}Schema, { $id: '${upperName}Patch' }) export type ${upperName}Patch = Static export const ${camelName}PatchValidator = getValidator(${camelName}PatchSchema, dataValidator) export const ${camelName}PatchResolver = resolve<${upperName}Patch, HookContext<${upperName}Service>>({ ${localTemplate(authStrategies, `password: passwordHash({ strategy: 'local' })`)} }) // Schema for allowed query properties export const ${camelName}QueryProperties = Type.Pick(${camelName}Schema, [ '${type === 'mongodb' ? '_id' : 'id'}', ${ isEntityService ? authStrategies.map((name) => (name === 'local' ? `'email'` : `'${name}Id'`)).join(', ') : `'text'` } ]) export const ${camelName}QuerySchema = Type.Intersect([ querySyntax(${camelName}QueryProperties), // Add additional query properties here Type.Object({}, { additionalProperties: false }) ], { additionalProperties: false }) export type ${upperName}Query = Static export const ${camelName}QueryValidator = getValidator(${camelName}QuerySchema, queryValidator) export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext<${upperName}Service>>({ ${ isEntityService ? ` // If there is a user (e.g. with authentication), they are only allowed to see their own data ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => { if (context.params.user) { return context.params.user.${type === 'mongodb' ? '_id' : 'id'} } return value }` : '' } }) ` export const generate = (ctx: ServiceGeneratorContext) => Promise.resolve(ctx).then( when( ({ schema }) => schema === 'typebox', renderSource( template, toFile(({ lib, folder, fileName }: ServiceGeneratorContext) => [ lib, 'services', ...folder, `${fileName}.schema` ]) ) ) ) ================================================ FILE: packages/generators/src/service/templates/service.tpl.ts ================================================ import { toFile, after, prepend } from '@featherscloud/pinion' import { fileExists, injectSource, renderSource } from '../../commons.js' import { ServiceGeneratorContext } from '../index.js' export const template = ({ camelName, authentication, isEntityService, path, lib, language, className, relative, schema, fileName }: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.html ${authentication || isEntityService ? `import { authenticate } from '@feathersjs/authentication'` : ''} ${ schema ? ` import { hooks as schemaHooks } from '@feathersjs/schema' import { ${camelName}DataValidator, ${camelName}PatchValidator, ${camelName}QueryValidator, ${camelName}Resolver, ${camelName}ExternalResolver, ${camelName}DataResolver, ${camelName}PatchResolver, ${camelName}QueryResolver } from './${fileName}.schema' ` : '' } import type { Application } from '${relative}/declarations' import { ${className}, getOptions } from './${fileName}.class' ${ fileExists(lib, `client.${language}`) ? `import { ${camelName}Path, ${camelName}Methods } from './${fileName}.shared'` : ` export const ${camelName}Path = '${path}' export const ${camelName}Methods: Array = ['find', 'get', 'create', 'patch', 'remove']` } export * from './${fileName}.class' ${schema ? `export * from './${fileName}.schema'` : ''} // A configure function that registers the service and its hooks via \`app.configure\` export const ${camelName} = (app: Application) => { // Register our service on the Feathers application app.use(${camelName}Path, new ${className}(getOptions(app)), { // A list of all methods this service exposes externally methods: ${camelName}Methods, // You can add additional custom events to be sent to clients here events: [] }) // Initialize hooks app.service(${camelName}Path).hooks({ around: { all: [${ authentication ? ` authenticate('jwt'),` : '' } ${ schema ? ` schemaHooks.resolveExternal(${camelName}ExternalResolver), schemaHooks.resolveResult(${camelName}Resolver),` : '' } ],${ isEntityService ? ` find: [authenticate('jwt')], get: [authenticate('jwt')], create: [], update: [authenticate('jwt')], patch: [authenticate('jwt')], remove: [authenticate('jwt')]` : '' } }, before: { all: [${ schema ? ` schemaHooks.validateQuery(${camelName}QueryValidator), schemaHooks.resolveQuery(${camelName}QueryResolver) ` : '' }], find: [], get: [], create: [${ schema ? ` schemaHooks.validateData(${camelName}DataValidator), schemaHooks.resolveData(${camelName}DataResolver) ` : '' }], patch: [${ schema ? ` schemaHooks.validateData(${camelName}PatchValidator), schemaHooks.resolveData(${camelName}PatchResolver) ` : '' }], remove: [] }, after: { all: [] }, error: { all: [] } }) } // Add this service to the service type index declare module '${relative}/declarations' { interface ServiceTypes { [${camelName}Path]: ${className} } } ` const toServiceIndex = toFile(({ lib }: ServiceGeneratorContext) => [lib, 'services', `index`]) export const generate = (ctx: ServiceGeneratorContext) => Promise.resolve(ctx) .then( renderSource( template, toFile(({ lib, fileName, folder }: ServiceGeneratorContext) => [ lib, 'services', ...folder, `${fileName}` ]) ) ) .then( injectSource( ({ camelName, folder, fileName }) => `import { ${camelName} } from './${folder.join('/')}/${fileName}'`, prepend(), toServiceIndex ) ) .then( injectSource( ({ camelName }) => ` app.configure(${camelName})`, after('export const services'), toServiceIndex ) ) ================================================ FILE: packages/generators/src/service/templates/shared.tpl.ts ================================================ import { toFile, when } from '@featherscloud/pinion' import { fileExists, renderSource } from '../../commons.js' import { ServiceGeneratorContext } from '../index.js' const sharedTemplate = ({ camelName, upperName, className, fileName, relative, path }: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.shared.html import type { Params } from '@feathersjs/feathers' import type { ClientApplication } from '${relative}/client' import type { ${upperName}, ${upperName}Data, ${upperName}Patch, ${upperName}Query, ${className} } from './${fileName}.class' export type { ${upperName}, ${upperName}Data, ${upperName}Patch, ${upperName}Query } export type ${upperName}ClientService = Pick< ${className}>, typeof ${camelName}Methods[number] > export const ${camelName}Path = '${path}' export const ${camelName}Methods: Array = ['find', 'get', 'create', 'patch', 'remove'] export const ${camelName}Client = (client: ClientApplication) => { const connection = client.get('connection') client.use(${camelName}Path, connection.service(${camelName}Path), { methods: ${camelName}Methods }) } // Add this service to the client service type index declare module '${relative}/client' { interface ServiceTypes { [${camelName}Path]: ${upperName}ClientService } } ` export const generate = async (ctx: ServiceGeneratorContext) => Promise.resolve(ctx).then( when( ({ lib, language }) => fileExists(lib, `client.${language}`), renderSource( sharedTemplate, toFile(({ lib, folder, fileName }: ServiceGeneratorContext) => [ lib, 'services', ...folder, `${fileName}.shared` ]) ) ) ) ================================================ FILE: packages/generators/src/service/templates/test.tpl.ts ================================================ import { toFile } from '@featherscloud/pinion' import { renderSource } from '../../commons.js' import { ServiceGeneratorContext } from '../index.js' const template = ({ relative, lib, path }: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.test.html import assert from 'assert' import { app } from '../${relative}/${lib}/app' describe('${path} service', () => { it('registered the service', () => { const service = app.service('${path}') assert.ok(service, 'Registered the service') }) }) ` export const generate = (ctx: ServiceGeneratorContext) => Promise.resolve(ctx).then( renderSource( template, toFile(({ test, folder, fileName }) => [ test, 'services', ...folder, `${fileName}.test` ]) ) ) ================================================ FILE: packages/generators/src/service/type/custom.tpl.ts ================================================ import { toFile } from '@featherscloud/pinion' import { renderSource } from '../../commons.js' import { ServiceGeneratorContext } from '../index.js' export const template = ({ className, upperName, schema, fileName, relative }: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.class.html#custom-services import type { Id, NullableId, Params, ServiceInterface } from '@feathersjs/feathers' import type { Application } from '${relative}/declarations' ${ schema ? `import type { ${upperName}, ${upperName}Data, ${upperName}Patch, ${upperName}Query } from './${fileName}.schema' ` : ` type ${upperName} = any type ${upperName}Data = any type ${upperName}Patch = any type ${upperName}Query = any ` } export type { ${upperName}, ${upperName}Data, ${upperName}Patch, ${upperName}Query } export interface ${className}Options { app: Application } export interface ${upperName}Params extends Params<${upperName}Query> { } // This is a skeleton for a custom service class. Remove or add the methods you need here export class ${className} implements ServiceInterface<${upperName}, ${upperName}Data, ServiceParams, ${upperName}Patch> { constructor (public options: ${className}Options) { } async find (_params?: ServiceParams): Promise<${upperName}[]> { return [] } async get (id: Id, _params?: ServiceParams): Promise<${upperName}> { return { id: 0, text: \`A new message with ID: \${id}!\` } } async create (data: ${upperName}Data, params?: ServiceParams): Promise<${upperName}> async create (data: ${upperName}Data[], params?: ServiceParams): Promise<${upperName}[]> async create (data: ${upperName}Data|${upperName}Data[], params?: ServiceParams): Promise<${upperName}|${upperName}[]> { if (Array.isArray(data)) { return Promise.all(data.map(current => this.create(current, params))); } return { id: 0, ...data } } // This method has to be added to the 'methods' option to make it available to clients async update (id: NullableId, data: ${upperName}Data, _params?: ServiceParams): Promise<${upperName}> { return { id: 0, ...data } } async patch (id: NullableId, data: ${upperName}Patch, _params?: ServiceParams): Promise<${upperName}> { return { id: 0, text: \`Fallback for \${id}\`, ...data } } async remove (id: NullableId, _params?: ServiceParams): Promise<${upperName}> { return { id: 0, text: 'removed' } } } export const getOptions = (app: Application) => { return { app } } ` export const generate = (ctx: ServiceGeneratorContext) => Promise.resolve(ctx).then( renderSource( template, toFile(({ lib, folder, fileName }) => [ lib, 'services', ...folder, `${fileName}.class` ]) ) ) ================================================ FILE: packages/generators/src/service/type/knex.tpl.ts ================================================ import { toFile } from '@featherscloud/pinion' import { renderSource, yyyymmddhhmmss } from '../../commons.js' import { ServiceGeneratorContext } from '../index.js' const migrationTemplate = ({ kebabPath, authStrategies, isEntityService }: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/knexfile.html import type { Knex } from 'knex' export async function up(knex: Knex): Promise { await knex.schema.createTable('${kebabPath}', table => { table.increments('id') ${ isEntityService ? authStrategies .map((name) => name === 'local' ? ` table.string('email').unique() table.string('password')` : ` table.string('${name}Id')` ) .join('\n') : ` table.string('text')` } }) } export async function down(knex: Knex): Promise { await knex.schema.dropTable('${kebabPath}') } ` export const template = ({ className, upperName, feathers, schema, fileName, relative }: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.class.html#database-services import type { Params } from '@feathersjs/feathers' import { KnexService } from '@feathersjs/knex' import type { KnexAdapterParams, KnexAdapterOptions } from '@feathersjs/knex' import type { Application } from '${relative}/declarations' ${ schema ? `import type { ${upperName}, ${upperName}Data, ${upperName}Patch, ${upperName}Query } from './${fileName}.schema' ` : ` type ${upperName} = any type ${upperName}Data = any type ${upperName}Patch = any type ${upperName}Query = any ` } export type { ${upperName}, ${upperName}Data, ${upperName}Patch, ${upperName}Query } export interface ${upperName}Params extends KnexAdapterParams<${upperName}Query> { } // By default calls the standard Knex adapter service methods but can be customized with your own functionality. export class ${className} extends KnexService<${upperName}, ${upperName}Data, ${upperName}Params, ${upperName}Patch> { } export const getOptions = (app: Application): KnexAdapterOptions => { return { paginate: app.get('paginate'), Model: app.get('${feathers.database}Client'), name: '${fileName}' } } ` export const generate = (ctx: ServiceGeneratorContext) => Promise.resolve(ctx) .then( renderSource( template, toFile(({ lib, folder, fileName }) => [ lib, 'services', ...folder, `${fileName}.class` ]) ) ) .then( renderSource( migrationTemplate, toFile('migrations', ({ kebabName }) => `${yyyymmddhhmmss()}_${kebabName}`) ) ) ================================================ FILE: packages/generators/src/service/type/mongodb.tpl.ts ================================================ import { toFile } from '@featherscloud/pinion' import { renderSource } from '../../commons.js' import { ServiceGeneratorContext } from '../index.js' export const template = ({ className, upperName, schema, fileName, kebabPath, relative }: ServiceGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/service.class.html#database-services import type { Params } from '@feathersjs/feathers' import { MongoDBService } from \'@feathersjs/mongodb\' import type { MongoDBAdapterParams, MongoDBAdapterOptions } from \'@feathersjs/mongodb\' import type { Application } from '${relative}/declarations' ${ schema ? `import type { ${upperName}, ${upperName}Data, ${upperName}Patch, ${upperName}Query } from './${fileName}.schema' ` : ` type ${upperName} = any type ${upperName}Data = any type ${upperName}Patch = any type ${upperName}Query = any ` } export type { ${upperName}, ${upperName}Data, ${upperName}Patch, ${upperName}Query } export interface ${upperName}Params extends MongoDBAdapterParams<${upperName}Query> { } // By default calls the standard MongoDB adapter service methods but can be customized with your own functionality. export class ${className} extends MongoDBService<${upperName}, ${upperName}Data, ${upperName}Params, ${upperName}Patch> { } export const getOptions = (app: Application): MongoDBAdapterOptions => { return { paginate: app.get('paginate'), Model: app.get('mongodbClient').then(db => db.collection('${kebabPath}')) } } ` export const generate = (ctx: ServiceGeneratorContext) => Promise.resolve(ctx).then( renderSource( template, toFile(({ lib, folder, fileName }) => [ lib, 'services', ...folder, `${fileName}.class` ]) ) ) ================================================ FILE: packages/generators/test/build/.gitkeep ================================================ ================================================ FILE: packages/generators/test/commons.test.ts ================================================ import { strictEqual } from 'assert' import { getJavaScript } from '../lib/commons' describe('common tests', () => { it('getJavaScript returns transpiled JavaScript', () => { const transpiled = getJavaScript( `import bla from 'bla' import something from './file' type X = { name: string } function test (arg: X) { bla(something) } // This is a comment const otherThing: string = "Hello" ` ) strictEqual( transpiled, `import bla from 'bla'; import something from './file.js'; function test(arg) { bla(something); } // This is a comment const otherThing = "Hello"; ` ) strictEqual( getJavaScript(`import { authentication } from './authentication'`), `import { authentication } from './authentication.js'` ) }) }) ================================================ FILE: packages/generators/test/generators.test.ts ================================================ /* eslint-disable @typescript-eslint/prefer-for-of */ import os from 'os' import path from 'path' import { mkdtemp } from 'fs/promises' import assert from 'assert' import { getContext } from '@featherscloud/pinion' import { AppGeneratorContext } from '../src/app' import { FeathersBaseContext } from '../src/commons' import { ConnectionGeneratorArguments } from '../src/connection' import { ServiceGeneratorArguments } from '../src/service' import { combinate, dependencyVersions } from './utils' import { generate as generateApp } from '../lib/app' import { generate as generateConnection } from '../lib/connection' import { generate as generateAuthentication } from '../lib/authentication' import { generate as generateService } from '../lib/service' import { listAllFiles } from '@featherscloud/pinion/lib/utils' import { AuthenticationGeneratorArguments } from '../lib/authentication' const matrix = { language: ['js', 'ts'] as const, framework: ['koa', 'express'] as const, schema: ['typebox', 'json'] as const } const defaultCombination = { language: process.env.FEATHERS_LANGUAGE || 'ts', framework: process.env.FEATHERS_FRAMEWORK || 'koa', schema: process.env.FEATHERS_SCHEMA || 'typebox' } const combinations = process.version > 'v16.0.0' ? (process.env.CI ? combinate(matrix as any) : [defaultCombination]) : [] describe('@feathersjs/generators', () => { for (const { language, framework, schema } of combinations) { describe(`${language} ${framework} app`, () => { const name = `feathers_${language}_${framework}_${schema}` let context: FeathersBaseContext let cwd: string before(async () => { cwd = await mkdtemp(path.join(os.tmpdir(), name + '-')) console.log(`\nGenerating test application to\n${cwd}\n\n`) try { context = await generateApp( getContext( { name, framework, language, dependencyVersions, client: true, lib: 'src', description: 'A Feathers test app', packager: 'npm', database: 'sqlite', connectionString: `${name}.sqlite`, transports: ['rest', 'websockets'], schema }, { cwd } ) ) } catch (error: any) { console.error(error.stack) console.error((await listAllFiles(cwd)).join('\n')) throw error } }) it('generated app with SQLite and passes tests', async () => { const testResult = await context.pinion.exec('npm', ['test'], { cwd }) assert.ok(context) assert.strictEqual(testResult, 0) }) it('generates authentication with SQLite and passes tests', async () => { const authContext = await generateAuthentication( getContext( { dependencyVersions, authStrategies: ['local', 'github'], service: 'user', path: 'users', type: 'knex', schema }, { cwd } ) ) const testResult = await context.pinion.exec('npm', ['test'], { cwd }) assert.ok(authContext) assert.strictEqual(testResult, 0) }) it('generates a MongoDB connection and service and passes tests', async () => { const connectionContext = await generateConnection( getContext( { dependencyVersions, database: 'mongodb' as const, connectionString: `mongodb://127.0.0.1:27017/${name}` }, { cwd } ) ) const mongoService1Context = await generateService( getContext( { dependencyVersions, name: 'testing', path: 'path/to/test', authentication: true, type: 'mongodb', schema: false }, { cwd } ) ) const messageServiceContext = await generateService( getContext( { dependencyVersions, name: 'message', path: 'messages', authentication: true, type: 'mongodb', schema }, { cwd } ) ) const testResult = await context.pinion.exec('npm', ['test'], { cwd }) assert.ok(connectionContext) assert.ok(mongoService1Context) assert.ok(messageServiceContext) assert.strictEqual(testResult, 0) }) it('generates a custom service and passes tests', async () => { const customServiceContext = await generateService( getContext( { dependencyVersions, name: 'Custom', path: 'customized', authentication: false, type: 'custom', schema }, { cwd } ) ) const testResult = await context.pinion.exec('npm', ['test'], { cwd }) assert.ok(customServiceContext) assert.strictEqual(testResult, 0) }) it('compiles successfully', async () => { if (language === 'ts' && framework === 'koa') { const testResult = await context.pinion.exec('npm', ['run', 'compile'], { cwd }) assert.strictEqual(testResult, 0) } }) }) } }) ================================================ FILE: packages/generators/test/utils.ts ================================================ import path from 'path' import pkg from '../package.json' import { DependencyVersions } from '../src/commons' import { readFileSync } from 'fs' // Set __dirname in es module const __dirname = path.dirname(new URL(import.meta.url).pathname) export function combinate>(obj: O) { let combos: { [k in keyof O]: O[k][number] }[] = [] for (const key of Object.keys(obj)) { const values = obj[key] const all: any[] = [] for (let i = 0; i < values.length; i++) { for (let j = 0; j < (combos.length || 1); j++) { const newCombo = { ...combos[j], [key]: values[i] } all.push(newCombo) } } combos = all } return combos } export const dependencyVersions = Object.keys(pkg.devDependencies as any) .filter((dep) => dep.startsWith('@feathersjs/')) .reduce((acc, dep) => { const [, name] = dep.split('/') const { version } = JSON.parse( readFileSync(path.join(__dirname, '..', '..', name, 'package.json'), 'utf8').toString() ) acc[dep] = path.join(__dirname, 'build', `feathersjs-${name}-${version}.tgz`) return acc }, {} as DependencyVersions) ================================================ FILE: packages/generators/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib", "module": "ESNext", "moduleResolution": "Node" } } ================================================ FILE: packages/knex/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/knex ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/knex ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/knex ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/knex ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/knex ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - **knex:** Add support for extended operators in query builder ([#3578](https://github.com/feathersjs/feathers/issues/3578)) ([c355ae3](https://github.com/feathersjs/feathers/commit/c355ae3184f07b15b4a313aa64fb9e7fdd0524d5)) - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) - **knex:** Add tableOptions parameter for inheritance on knex adapter options to pass on knex builder ([#3539](https://github.com/feathersjs/feathers/issues/3539)) ([ba5621b](https://github.com/feathersjs/feathers/commit/ba5621bfe5e7ab01189b6b7bccb00891bc2b14c7)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/knex ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) ### Bug Fixes - **knex:** use driver name to identify client ([#3527](https://github.com/feathersjs/feathers/issues/3527)) ([bb075ec](https://github.com/feathersjs/feathers/commit/bb075ec8beb3ac9b0a1a8aebc3c3756d970cc6a4)) ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/knex ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/knex ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/knex ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/knex ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) ### Bug Fixes - **knex:** Update commited to boolean type ([#3458](https://github.com/feathersjs/feathers/issues/3458)) ([5fa4dbc](https://github.com/feathersjs/feathers/commit/5fa4dbc06d0126ac18f5643562d0b74f03502caa)) ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/knex ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) ### Bug Fixes - **knex:** Fix Knex adapter date comparison queries ([#3429](https://github.com/feathersjs/feathers/issues/3429)) ([23bafe1](https://github.com/feathersjs/feathers/commit/23bafe1204f79ce2ab0eaaa5544fab1a3ffb5f41)) ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/knex ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/knex ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/knex ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/knex ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/knex ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/knex ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) ### Bug Fixes - **generators:** Move generators and CLI to featherscloud/pinion ([#3386](https://github.com/feathersjs/feathers/issues/3386)) ([eb87c99](https://github.com/feathersjs/feathers/commit/eb87c9922db56c5610e5b808f3ffe033c830e2b2)) - **knex:** Add sqlite to returning clients ([#3389](https://github.com/feathersjs/feathers/issues/3389)) ([59fb40b](https://github.com/feathersjs/feathers/commit/59fb40b9eb34950ef2dd35b7de4762f224a171f1)) ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) ### Bug Fixes - **knex:** Add Error Handler to knex \_update function ([#3371](https://github.com/feathersjs/feathers/issues/3371)) ([210f103](https://github.com/feathersjs/feathers/commit/210f1037bf69c641d4fd335cd4f084cbbac0a922)) ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/knex ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) ### Bug Fixes - allow \_patch to modify the entire base schema ([#3300](https://github.com/feathersjs/feathers/issues/3300)) ([0f41622](https://github.com/feathersjs/feathers/commit/0f41622307589b3a0b62ac411a73e6a601bda171)) - **knex:** Add includeTriggerModifications for MSSQL support ([#3355](https://github.com/feathersjs/feathers/issues/3355)) ([cbe44b0](https://github.com/feathersjs/feathers/commit/cbe44b0e91506ab06c86355af67f83d5197bd896)) ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/knex ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/knex ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/knex ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/knex ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/knex ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/knex ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) - **knex:** Ensure that columns are selected unambigiously and avoid duplicate id selection ([#3144](https://github.com/feathersjs/feathers/issues/3144)) ([3eb7428](https://github.com/feathersjs/feathers/commit/3eb7428f888f0e8a0fbc09f5261bff3e68a0ed63)) - **knex:** Get by id and transactions should work with params.knex ([#3146](https://github.com/feathersjs/feathers/issues/3146)) ([b172b5e](https://github.com/feathersjs/feathers/commit/b172b5ea9b461642874eb7d2ba01dc4cfc275155)) - **knex:** Only apply default order for MSSQL ([#3145](https://github.com/feathersjs/feathers/issues/3145)) ([28c2627](https://github.com/feathersjs/feathers/commit/28c26279befea6cf43cedd3af628234b170b8c91)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) ### Bug Fixes - **core:** Use Symbol.for to instantiate shared symbols ([#3087](https://github.com/feathersjs/feathers/issues/3087)) ([7f3fc21](https://github.com/feathersjs/feathers/commit/7f3fc2167576f228f8183568eb52b077160e8d65)) # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/knex # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/knex # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) ### Bug Fixes - **knex:** The method getModel in the knex adapter ([#3043](https://github.com/feathersjs/feathers/issues/3043)) ([77e14dd](https://github.com/feathersjs/feathers/commit/77e14dd3f4a29adff8beb805d0e6186ead59e4fe)) # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - **databases:** Ensure that query sanitization is not necessary when using query schemas ([#3022](https://github.com/feathersjs/feathers/issues/3022)) ([dbf514e](https://github.com/feathersjs/feathers/commit/dbf514e85d1508b95c007462a39b3cadd4ff391d)) - **databases:** Improve documentation for adapters and allow dynamic Knex adapter options ([#3019](https://github.com/feathersjs/feathers/issues/3019)) ([66c4b5e](https://github.com/feathersjs/feathers/commit/66c4b5e72000dd03acb57fca1cad4737c85c9c9e)) - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) ### Features - **database:** Add and to the query syntax ([#3021](https://github.com/feathersjs/feathers/issues/3021)) ([00cb0d9](https://github.com/feathersjs/feathers/commit/00cb0d9c302ae951ae007d3d6ceba33e254edd9c)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Bug Fixes - **databases:** Make sure adapter method signatures are exported properly ([#2943](https://github.com/feathersjs/feathers/issues/2943)) ([458d668](https://github.com/feathersjs/feathers/commit/458d66859e256c5854e7590f0b4a11b233fe0374)) - **knex:** Ensure custom ids are returned on create ([#2934](https://github.com/feathersjs/feathers/issues/2934)) ([c4fa3cf](https://github.com/feathersjs/feathers/commit/c4fa3cf812d59e6e8e3831ab098bb8768c92e8f4)) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Features - **adapter:** Add patch data type to adapters and refactor AdapterBase usage ([#2906](https://github.com/feathersjs/feathers/issues/2906)) ([9ddc2e6](https://github.com/feathersjs/feathers/commit/9ddc2e6b028f026f939d6af68125847e5c6734b4)) - **cli:** Use separate patch schema and types ([#2916](https://github.com/feathersjs/feathers/issues/2916)) ([7088af6](https://github.com/feathersjs/feathers/commit/7088af64a539dc7f1a016d832b77b98aaaf92603)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/knex # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/knex # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) ### Features - **cli:** Generate full client test suite and improve typed client ([#2788](https://github.com/feathersjs/feathers/issues/2788)) ([57119b6](https://github.com/feathersjs/feathers/commit/57119b6bb2797f7297cf054268a248c093ecd538)) - **cli:** Improve generated schema definitions ([#2783](https://github.com/feathersjs/feathers/issues/2783)) ([474a9fd](https://github.com/feathersjs/feathers/commit/474a9fda2107e9bcf357746320a8e00cda8182b6)) # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) **Note:** Version bump only for package @feathersjs/knex # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) - **knex:** Fix PostgreSQL integration issues and run CI tests against pg ([#2698](https://github.com/feathersjs/feathers/issues/2698)) ([1f71d78](https://github.com/feathersjs/feathers/commit/1f71d7884656c1494004931f4979ad59d23e4ee6)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/knex # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/knex # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) ### Bug Fixes - **cli:** Generator fixes to work with the new guide ([#2674](https://github.com/feathersjs/feathers/issues/2674)) ([b773fa5](https://github.com/feathersjs/feathers/commit/b773fa5dbd7ff450cfb2f7b93e64882592262712)) # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Features - **knex:** Add KnexJS SQL database adapter to core ([#2671](https://github.com/feathersjs/feathers/issues/2671)) ([9380fff](https://github.com/feathersjs/feathers/commit/9380fff58596e8bb90b8bb098d2795b7eadfec20)) ================================================ FILE: packages/knex/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/knex/README.md ================================================ # @feathersjs/knex [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/mongodb.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/mongodb) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > Feathers SQL service adapter using KnexJS ## Installation ``` npm install @feathersjs/knex --save ``` ## Documentation Refer to the [Feathers Knex adapter documentation](https://feathersjs.com/api/databases/knex.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/knex/package.json ================================================ { "name": "@feathersjs/knex", "description": "Feathers SQL service adapter using KnexJS", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 14" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/adapter-commons": "^5.0.42", "@feathersjs/commons": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/feathers": "^5.0.42" }, "peerDependencies": { "knex": ">=3.1.0" }, "devDependencies": { "@feathersjs/adapter-tests": "^5.0.42", "@feathersjs/schema": "^5.0.42", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "knex": "^3.1.0", "mocha": "^11.7.5", "pg": "^8.19.0", "shx": "^0.4.0", "sqlite3": "^5.1.7", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/knex/src/adapter.ts ================================================ import { Id, NullableId, Paginated, Query } from '@feathersjs/feathers' import { _ } from '@feathersjs/commons' import { AdapterBase, PaginationOptions, AdapterQuery, getLimit } from '@feathersjs/adapter-commons' import { BadRequest, MethodNotAllowed, NotFound } from '@feathersjs/errors' import { Knex } from 'knex' import { errorHandler } from './error-handler' import { KnexAdapterOptions, KnexAdapterParams } from './declarations' const METHODS = { $ne: 'whereNot', $in: 'whereIn', $nin: 'whereNotIn', $or: 'orWhere', $and: 'andWhere' } const OPERATORS = { $lt: '<', $lte: '<=', $gt: '>', $gte: '>=', $like: 'like', $notlike: 'not like', $ilike: 'ilike' } const RETURNING_CLIENTS = ['postgresql', 'pg', 'oracledb', 'mssql', 'sqlite3'] export class KnexAdapter< Result, Data = Partial, ServiceParams extends KnexAdapterParams = KnexAdapterParams, PatchData = Partial > extends AdapterBase { schema?: string constructor(options: KnexAdapterOptions) { if (!options || !options.Model) { throw new Error('You must provide a Model (the initialized knex object)') } if (typeof options.name !== 'string') { throw new Error('No table name specified.') } super({ id: 'id', ...options, filters: { ...options.filters, $and: (value: any) => value }, operators: [ ...(options.operators || []), ...Object.keys(options.extendedOperators || {}), '$like', '$notlike', '$ilike' ] }) } get fullName() { const { name, schema } = this.getOptions({} as ServiceParams) return schema ? `${schema}.${name}` : name } get Model() { return this.getModel() } getModel(params: ServiceParams = {} as ServiceParams) { const { Model } = this.getOptions(params) return Model } db(params?: ServiceParams) { const { Model, name, schema, tableOptions } = this.getOptions(params) if (params && params.transaction && params.transaction.trx) { const { trx } = params.transaction // debug('ran %s with transaction %s', fullName, id) return schema ? (trx.withSchema(schema).table(name) as Knex.QueryBuilder) : trx(name) } return schema ? (Model.withSchema(schema).table(name) as Knex.QueryBuilder) : Model(name, tableOptions) } knexify(knexQuery: Knex.QueryBuilder, query: Query = {}, parentKey?: string): Knex.QueryBuilder { const knexify = this.knexify.bind(this) const { extendedOperators = {} } = this.getOptions({} as ServiceParams) const operatorsMap = { ...OPERATORS, ...extendedOperators } return Object.keys(query || {}).reduce((currentQuery, key) => { const value = query[key] if (_.isObject(value) && !(value instanceof Date)) { return knexify(currentQuery, value, key) } const column = parentKey || key const method = METHODS[key as keyof typeof METHODS] if (method) { if (key === '$or' || key === '$and') { // This will create a nested query currentQuery.where(function (this: any) { for (const condition of value) { this[method](function (this: Knex.QueryBuilder) { knexify(this, condition) }) } }) return currentQuery } return (currentQuery as any)[method](column, value) } const operator = operatorsMap[key as keyof typeof operatorsMap] || '=' return operator === '=' ? currentQuery.where(column, value) : currentQuery.where(column, operator, value) }, knexQuery) } createQuery(params: ServiceParams = {} as ServiceParams) { const { name, id } = this.getOptions(params) const { filters, query } = this.filterQuery(params) const builder = this.db(params) // $select uses a specific find syntax, so it has to come first. if (filters.$select) { const select = filters.$select.map((column) => (column.includes('.') ? column : `${name}.${column}`)) // always select the id field, but make sure we only select it once builder.select(...new Set([...select, `${name}.${id}`])) } else { builder.select(`${name}.*`) } // build up the knex query out of the query params, include $and and $or filters this.knexify(builder, { ...query, ..._.pick(filters, '$and', '$or') }) // Handle $sort if (filters.$sort) { return Object.keys(filters.$sort).reduce( (currentQuery, key) => currentQuery.orderBy(key, filters.$sort[key] === 1 ? 'asc' : 'desc'), builder ) } return builder } filterQuery(params: ServiceParams) { const options = this.getOptions(params) const { $select, $sort, $limit: _limit, $skip = 0, ...query } = (params.query || {}) as AdapterQuery const $limit = getLimit(_limit, options.paginate) return { paginate: options.paginate, filters: { $select, $sort, $limit, $skip }, query } } async _find(params?: ServiceParams & { paginate?: PaginationOptions }): Promise> async _find(params?: ServiceParams & { paginate: false }): Promise async _find(params?: ServiceParams): Promise | Result[]> async _find(params: ServiceParams = {} as ServiceParams): Promise | Result[]> { const { filters, paginate } = this.filterQuery(params) const { name, id } = this.getOptions(params) const builder = params.knex ? params.knex.clone() : this.createQuery(params) const countBuilder = builder.clone().clearSelect().clearOrder().count(`${name}.${id} as total`) // Handle $limit if (filters.$limit) { builder.limit(filters.$limit) } // Handle $skip if (filters.$skip) { builder.offset(filters.$skip) } // provide default sorting if its not set if (!filters.$sort && builder.client.driverName === 'mssql') { builder.orderBy(`${name}.${id}`, 'asc') } const data = filters.$limit === 0 ? [] : await builder.catch(errorHandler) if (paginate && paginate.default) { const total = await countBuilder.then((count) => parseInt(count[0] ? count[0].total : 0)) return { total, limit: filters.$limit, skip: filters.$skip || 0, data } } return data } async _findOrGet(id: NullableId, params?: ServiceParams) { if (id !== null) { const { name, id: idField } = this.getOptions(params) const builder = params.knex ? params.knex.clone() : this.createQuery(params) const idQuery = builder.andWhere(`${name}.${idField}`, '=', id).catch(errorHandler) return idQuery as Promise } return this._find({ ...params, paginate: false }) } async _get(id: Id, params: ServiceParams = {} as ServiceParams): Promise { const data = await this._findOrGet(id, params) if (data.length !== 1) { throw new NotFound(`No record found for id '${id}'`) } return data[0] } async _create(data: Data, params?: ServiceParams): Promise async _create(data: Data[], params?: ServiceParams): Promise async _create(data: Data | Data[], _params?: ServiceParams): Promise async _create( _data: Data | Data[], params: ServiceParams = {} as ServiceParams ): Promise { const data = _data as any if (Array.isArray(data)) { return Promise.all(data.map((current) => this._create(current, params))) } const { client } = this.db(params) const returning = RETURNING_CLIENTS.includes(client.driverName) ? [this.id] : [] const rows: any = await this.db(params) .insert(data, returning, { includeTriggerModifications: true }) .catch(errorHandler) const id = data[this.id] || rows[0][this.id] || rows[0] if (!id) { return rows as Result[] } return this._get(id, { ...params, query: _.pick(params?.query || {}, '$select') }) } async _patch(id: null, data: PatchData | Partial, params?: ServiceParams): Promise async _patch(id: Id, data: PatchData | Partial, params?: ServiceParams): Promise async _patch( id: NullableId, data: PatchData | Partial, _params?: ServiceParams ): Promise async _patch( id: NullableId, raw: PatchData | Partial, params: ServiceParams = {} as ServiceParams ): Promise { if (id === null && !this.allowsMulti('patch', params)) { throw new MethodNotAllowed('Can not patch multiple entries') } const { name, id: idField } = this.getOptions(params) const data = _.omit(raw, this.id) const results = await this._findOrGet(id, { ...params, query: { ...params?.query, $select: [`${name}.${idField}`] } }) const idList = results.map((current: any) => current[idField]) const updateParams = { ...params, query: { [`${name}.${idField}`]: { $in: idList }, ...(params?.query?.$select ? { $select: params?.query?.$select } : {}) } } const builder = this.createQuery(updateParams) await builder.update(data, [], { includeTriggerModifications: true }) const items = await this._findOrGet(null, updateParams) if (id !== null) { if (items.length === 1) { return items[0] } else { throw new NotFound(`No record found for id '${id}'`) } } return items } async _update(id: Id, _data: Data, params: ServiceParams = {} as ServiceParams): Promise { if (id === null || Array.isArray(_data)) { throw new BadRequest("You can not replace multiple instances. Did you mean 'patch'?") } const data = _.omit(_data, this.id) const oldData = await this._get(id, params) const newObject = Object.keys(oldData).reduce((result: any, key) => { if (key !== this.id) { // We don't want the id field to be changed result[key] = data[key] === undefined ? null : data[key] } return result }, {}) await this.db(params) .update(newObject, '*', { includeTriggerModifications: true }) .where(this.id, id) .catch(errorHandler) return this._get(id, params) } async _remove(id: null, params?: ServiceParams): Promise async _remove(id: Id, params?: ServiceParams): Promise async _remove(id: NullableId, _params?: ServiceParams): Promise async _remove(id: NullableId, params: ServiceParams = {} as ServiceParams): Promise { if (id === null && !this.allowsMulti('remove', params)) { throw new MethodNotAllowed('Can not remove multiple entries') } const items = await this._findOrGet(id, params) const { query } = this.filterQuery(params) const q = this.db(params) const idList = items.map((current: any) => current[this.id]) query[this.id] = { $in: idList } // build up the knex query out of the query params this.knexify(q, query) await q.delete([], { includeTriggerModifications: true }).catch(errorHandler) if (id !== null) { if (items.length === 1) { return items[0] } throw new NotFound(`No record found for id '${id}'`) } return items } } ================================================ FILE: packages/knex/src/declarations.ts ================================================ import { Knex } from 'knex' import { AdapterServiceOptions, AdapterParams, AdapterQuery } from '@feathersjs/adapter-commons' export interface KnexAdapterOptions extends AdapterServiceOptions { Model: Knex name: string schema?: string tableOptions?: { only?: boolean } extendedOperators?: { [key: string]: string } } export interface KnexAdapterTransaction { starting: boolean parent?: KnexAdapterTransaction committed?: Promise resolve?: any trx?: Knex.Transaction id?: number promise?: Promise } export interface KnexAdapterParams extends AdapterParams> { knex?: Knex.QueryBuilder transaction?: KnexAdapterTransaction } ================================================ FILE: packages/knex/src/error-handler.ts ================================================ import { errors } from '@feathersjs/errors' export const ERROR = Symbol.for('@feathersjs/knex/error') export function errorHandler(error: any) { const { message } = error let feathersError = error if (error.sqlState && error.sqlState.length) { // remove SQLSTATE marker (#) and pad/truncate SQLSTATE to 5 chars const sqlState = ('00000' + error.sqlState.replace('#', '')).slice(-5) switch (sqlState.slice(0, 2)) { case '02': feathersError = new errors.NotFound(message) break case '28': feathersError = new errors.Forbidden(message) break case '08': case '0A': case '0K': feathersError = new errors.Unavailable(message) break case '20': case '21': case '22': case '23': case '24': case '25': case '40': case '42': case '70': feathersError = new errors.BadRequest(message) break default: feathersError = new errors.GeneralError(message) } } else if (error.code === 'SQLITE_ERROR') { // NOTE (EK): Error codes taken from // https://www.sqlite.org/c3ref/c_abort.html switch (error.errno) { case 1: case 8: case 18: case 19: case 20: feathersError = new errors.BadRequest(message) break case 2: feathersError = new errors.Unavailable(message) break case 3: case 23: feathersError = new errors.Forbidden(message) break case 12: feathersError = new errors.NotFound(message) break default: feathersError = new errors.GeneralError(message) break } } else if (typeof error.code === 'string' && error.severity && error.routine) { // NOTE: Error codes taken from // https://www.postgresql.org/docs/9.6/static/errcodes-appendix.html // Omit query information const messages = (error.message || '').split('-') error.message = messages[messages.length - 1] switch (error.code.slice(0, 2)) { case '22': feathersError = new errors.NotFound(message) break case '23': feathersError = new errors.BadRequest(message) break case '28': feathersError = new errors.Forbidden(message) break case '3D': case '3F': case '42': feathersError = new errors.Unprocessable(message) break default: feathersError = new errors.GeneralError(message) break } } else if (!(error instanceof errors.FeathersError)) { feathersError = new errors.GeneralError(message) } feathersError[ERROR] = error throw feathersError } ================================================ FILE: packages/knex/src/hooks.ts ================================================ import { createDebug } from '@feathersjs/commons' import { HookContext } from '@feathersjs/feathers' import { Knex } from 'knex' import { KnexAdapterTransaction } from './declarations' const debug = createDebug('feathers-knex-transaction') const ROLLBACK = { rollback: true } export const getKnex = (context: HookContext): Knex => { const knex = context.params?.knex ? context.params.knex : typeof context.service.getModel === 'function' && context.service.getModel(context.params) return knex && typeof knex.transaction === 'function' ? knex : undefined } export const start = () => async (context: HookContext): Promise => { const { transaction } = context.params const parent = transaction const knex: Knex = transaction ? transaction.trx : getKnex(context) if (!knex) { return } return new Promise((resolve, reject) => { const transaction: KnexAdapterTransaction = { starting: true } if (parent) { transaction.parent = parent transaction.committed = parent.committed } else { transaction.committed = new Promise((resolve) => { transaction.resolve = resolve }) } transaction.starting = true transaction.promise = knex .transaction((trx) => { transaction.trx = trx transaction.id = Date.now() context.params = { ...context.params, transaction } debug('started a new transaction %s', transaction.id) resolve() }) .catch((error) => { if (transaction.starting) { reject(error) } else if (error !== ROLLBACK) { throw error } }) }) } export const end = () => (context: HookContext) => { const { transaction } = context.params if (!transaction) { return } const { trx, id, promise, parent } = transaction context.params = { ...context.params, transaction: parent } transaction.starting = false return trx .commit() .then(() => promise) .then(() => transaction.resolve && transaction.resolve(true)) .then(() => debug('ended transaction %s', id)) .then(() => context) } export const rollback = () => (context: HookContext) => { const { transaction } = context.params if (!transaction) { return } const { trx, id, promise, parent } = transaction context.params = { ...context.params, transaction: parent } transaction.starting = false return trx .rollback(ROLLBACK) .then(() => promise) .then(() => transaction.resolve && transaction.resolve(false)) .then(() => debug('rolled back transaction %s', id)) .then(() => context) } ================================================ FILE: packages/knex/src/index.ts ================================================ import { PaginationOptions } from '@feathersjs/adapter-commons' import { MethodNotAllowed } from '@feathersjs/errors/lib' import { Paginated, ServiceMethods, Id, NullableId, Params } from '@feathersjs/feathers' import { KnexAdapter } from './adapter' import { KnexAdapterParams } from './declarations' export * from './declarations' export * from './adapter' export * from './error-handler' export * as transaction from './hooks' export class KnexService< Result = any, Data = Partial, ServiceParams extends Params = KnexAdapterParams, PatchData = Partial > extends KnexAdapter implements ServiceMethods, Data, ServiceParams, PatchData> { async find(params?: ServiceParams & { paginate?: PaginationOptions }): Promise> async find(params?: ServiceParams & { paginate: false }): Promise async find(params?: ServiceParams): Promise | Result[]> async find(params?: ServiceParams): Promise | Result[]> { return this._find({ ...params, query: await this.sanitizeQuery(params) }) } async get(id: Id, params?: ServiceParams): Promise { return this._get(id, { ...params, query: await this.sanitizeQuery(params) }) } async create(data: Data, params?: ServiceParams): Promise async create(data: Data[], params?: ServiceParams): Promise async create(data: Data | Data[], params?: ServiceParams): Promise async create(data: Data | Data[], params?: ServiceParams): Promise { if (Array.isArray(data) && !this.allowsMulti('create', params)) { throw new MethodNotAllowed('Can not create multiple entries') } return this._create(data, params) } async update(id: Id, data: Data, params?: ServiceParams): Promise { return this._update(id, data, { ...params, query: await this.sanitizeQuery(params) }) } async patch(id: Id, data: PatchData, params?: ServiceParams): Promise async patch(id: null, data: PatchData, params?: ServiceParams): Promise async patch(id: NullableId, data: PatchData, params?: ServiceParams): Promise async patch(id: NullableId, data: PatchData, params?: ServiceParams): Promise { const { $limit, ...query } = await this.sanitizeQuery(params) return this._patch(id, data, { ...params, query }) } async remove(id: Id, params?: ServiceParams): Promise async remove(id: null, params?: ServiceParams): Promise async remove(id: NullableId, params?: ServiceParams): Promise async remove(id: NullableId, params?: ServiceParams): Promise { const { $limit, ...query } = await this.sanitizeQuery(params) return this._remove(id, { ...params, query }) } } ================================================ FILE: packages/knex/test/connection.ts ================================================ export default (DB: string) => { if (DB === 'mysql') { return { client: 'mysql', connection: { host: '127.0.0.1', user: 'root', password: '', database: 'feathers_knex' } } } if (DB === 'postgres') { return { client: 'postgresql', connection: { host: 'localhost', database: 'feathers', user: 'postgres', password: 'postgres' } } } return { client: 'sqlite3', connection: { filename: './db.sqlite' } } } ================================================ FILE: packages/knex/test/error-handler.test.ts ================================================ import assert from 'assert' import { errorHandler } from '../src' describe('Knex Error handler', () => { it('sqlState', () => { assert.throws( () => errorHandler({ sqlState: '#23503' }), { name: 'BadRequest' } ) }) it('sqliteError', () => { assert.throws( () => errorHandler({ code: 'SQLITE_ERROR', errno: 1 }), { name: 'BadRequest' } ) assert.throws(() => errorHandler({ code: 'SQLITE_ERROR', errno: 2 }), { name: 'Unavailable' }) assert.throws(() => errorHandler({ code: 'SQLITE_ERROR', errno: 3 }), { name: 'Forbidden' }) assert.throws(() => errorHandler({ code: 'SQLITE_ERROR', errno: 12 }), { name: 'NotFound' }) assert.throws(() => errorHandler({ code: 'SQLITE_ERROR', errno: 13 }), { name: 'GeneralError' }) }) it('postgresqlError', () => { assert.throws( () => errorHandler({ code: '22P02', message: 'Key (id)=(1) is not present in table "users".', severity: 'ERROR', routine: 'ExecConstraints' }), { name: 'NotFound' } ) assert.throws( () => errorHandler({ code: '2874', message: 'Something', severity: 'ERROR', routine: 'ExecConstraints' }), { name: 'Forbidden' } ) assert.throws( () => errorHandler({ code: '3D74', message: 'Something', severity: 'ERROR', routine: 'ExecConstraints' }), { name: 'Unprocessable' } ) assert.throws(() => errorHandler({ code: 'XYZ', severity: 'ERROR', routine: 'ExecConstraints' }), { name: 'GeneralError' }) }) }) ================================================ FILE: packages/knex/test/index.test.ts ================================================ import knex, { Knex } from 'knex' import assert from 'assert' import { feathers, HookContext, Service } from '@feathersjs/feathers' import adapterTests from '@feathersjs/adapter-tests' import { errors } from '@feathersjs/errors' import { Ajv, getValidator, querySyntax, hooks } from '@feathersjs/schema' import connection from './connection' import { ERROR, KnexAdapterParams, KnexService, transaction } from '../src/index' import { AdapterQuery } from '@feathersjs/adapter-commons/lib' const testSuite = adapterTests([ '.options', '.events', '._get', '._find', '._create', '._update', '._patch', '._remove', '.get', '.get + $select', '.get + id + query', '.get + NotFound', '.get + id + query id', '.find', '.remove', '.remove + $select', '.remove + id + query', '.remove + multi', '.remove + multi no pagination', '.remove + id + query id', '.update', '.update + $select', '.update + id + query', '.update + NotFound', '.update + query + NotFound', '.update + id + query id', '.patch', '.patch + $select', '.patch + id + query', '.patch multiple', '.patch multiple no pagination', '.patch multi query same', '.patch multi query changed', '.patch + NotFound', '.patch + query + NotFound', '.patch + id + query id', '.create', '.create ignores query', '.create + $select', '.create multi', 'internal .find', 'internal .get', 'internal .create', 'internal .update', 'internal .patch', 'internal .remove', '.find + equal', '.find + equal multiple', '.find + $sort', '.find + $sort + string', '.find + $limit', '.find + $limit 0', '.find + $skip', '.find + $select', '.find + $or', '.find + $and', '.find + $in', '.find + $nin', '.find + $lt', '.find + $lte', '.find + $gt', '.find + $gte', '.find + $ne', '.find + $gt + $lt + $sort', '.find + $or nested + $sort', '.find + $and + $or', 'params.adapter + paginate', 'params.adapter + multi', '.find + paginate', '.find + paginate + query', '.find + paginate + $limit + $skip', '.find + paginate + $limit 0', '.find + paginate + params' ]) const TYPE = process.env.TEST_DB || 'sqlite' const db = knex(connection(TYPE) as any) // Create a public database to mimic a "schema" const schemaName = 'public' const clean = async () => { await db.schema.dropTableIfExists('todos') await db.schema.dropTableIfExists(people.fullName) await db.schema.createTable(people.fullName, (table) => { table.increments('id') table.string('name').notNullable() table.integer('age') table.integer('time') table.boolean('created') return table }) await db.schema.createTable('todos', (table) => { table.increments('id') table.string('text') table.integer('personId') return table }) await db.schema.dropTableIfExists(peopleId.fullName) await db.schema.createTable(peopleId.fullName, (table) => { table.increments('customid') table.string('name') table.integer('age') table.integer('time') table.boolean('created') return table }) await db.schema.dropTableIfExists(peopleExtendedOps.fullName) await db.schema.createTable(peopleExtendedOps.fullName, (table) => { table.increments('id') table.string('name') table.integer('age') table.integer('time') table.boolean('created') return table }) await db.schema.dropTableIfExists(users.fullName) await db.schema.createTable(users.fullName, (table) => { table.increments('id') table.string('name') table.integer('age') table.integer('time') table.boolean('created') return table }) } const personSchema = { $id: 'Person', type: 'object', additionalProperties: false, required: ['_id', 'name', 'age'], properties: { id: { type: 'number' }, name: { type: 'string' }, age: { type: ['number', 'null'] }, time: { type: 'string' }, create: { type: 'boolean' } } } as const const personQuery = { $id: 'PersonQuery', type: 'object', additionalProperties: false, properties: { ...querySyntax(personSchema.properties, { name: { $like: { type: 'string' }, $ilike: { type: 'string' }, $notlike: { type: 'string' } } }) } } as const const validator = new Ajv({ coerceTypes: true }) const personQueryValidator = getValidator(personQuery, validator) type Person = { id: number name: string age: number | null time: string create: boolean } type Todo = { id: number text: string personId: number personName: string } type ServiceTypes = { people: KnexService 'people-customid': KnexService users: KnexService todos: KnexService 'people-extended-ops': KnexService } class TodoService extends KnexService { createQuery(params: KnexAdapterParams) { const query = super.createQuery(params) query.join('people as person', 'todos.personId', 'person.id').select('person.name as personName') return query } } const people = new KnexService({ Model: db, name: 'people', events: ['testing'] }) const peopleId = new KnexService({ Model: db, id: 'customid', name: 'people-customid', events: ['testing'] }) const users = new KnexService({ Model: db, name: 'users', events: ['testing'] }) const todos = new TodoService({ Model: db, name: 'todos' }) const peopleExtendedOps = new KnexService({ Model: db, name: 'people-extended-ops', events: ['testing'], extendedOperators: { $neq: '<>', // Not equal (alternative syntax) $startsWith: 'like' // Same as $like but with a different name } }) describe('Feathers Knex Service', () => { const app = feathers() .hooks({ before: [transaction.start()], after: [transaction.end()], error: [transaction.rollback()] }) .use('people', people) .use('people-customid', peopleId) .use('users', users) .use('todos', todos) .use('people-extended-ops', peopleExtendedOps) const peopleService = app.service('people') peopleService.hooks({ before: { find: [hooks.validateQuery(personQueryValidator)] } }) before(() => { if (TYPE === 'sqlite') { // Attach the public database to mimic a "schema" db.schema.raw(`attach database '${schemaName}.sqlite' as ${schemaName}`) } }) before(clean) after(clean) describe('$like method', () => { let charlie: Person beforeEach(async () => { charlie = await peopleService.create({ name: 'Charlie Brown', age: 10 }) }) afterEach(() => peopleService.remove(charlie.id)) it('$like in query', async () => { const data = await peopleService.find({ paginate: false, query: { name: { $like: '%lie%' } } }) assert.strictEqual(data[0].name, 'Charlie Brown') }) }) describe('$notlike method', () => { let hasMatch: Person let hasNoMatch: Person beforeEach(async () => { hasMatch = await peopleService.create({ name: 'XYZabcZYX' }) hasNoMatch = await peopleService.create({ name: 'XYZZYX' }) }) afterEach(() => { peopleService.remove(hasMatch.id) peopleService.remove(hasNoMatch.id) }) it('$notlike in query', async () => { const data = await peopleService.find({ paginate: false, query: { name: { $notlike: '%abc%' } } }) assert.strictEqual(data.length, 1) assert.strictEqual(data[0].name, 'XYZZYX') }) }) describe('adapter specifics', () => { let daves: Person[] beforeEach(async () => { daves = await Promise.all([ peopleService.create({ name: 'Ageless', age: null }), peopleService.create({ name: 'Dave', age: 32 }), peopleService.create({ name: 'Dada', age: 1 }) ]) }) afterEach(async () => { try { await peopleService.remove(daves[0].id) await peopleService.remove(daves[1].id) await peopleService.remove(daves[2].id) } catch (error: unknown) {} }) it('$or works properly (#120)', async () => { const data = await peopleService.find({ paginate: false, query: { name: 'Dave', $or: [ { age: 1 }, { age: 32 } ] } }) assert.strictEqual(data.length, 1) assert.strictEqual(data[0].name, 'Dave') assert.strictEqual(data[0].age, 32) }) it('$and works properly', async () => { const data = await peopleService.find({ paginate: false, query: { $and: [ { $or: [{ name: 'Dave' }, { name: 'Dada' }] }, { age: { $lt: 23 } } ] } }) assert.strictEqual(data.length, 1) assert.strictEqual(data[0].name, 'Dada') assert.strictEqual(data[0].age, 1) }) it('where conditions support NULL values properly', async () => { const data = await peopleService.find({ paginate: false, query: { age: null } }) assert.strictEqual(data.length, 1) assert.strictEqual(data[0].name, 'Ageless') assert.strictEqual(data[0].age, null) }) it('where conditions support NOT NULL case properly', async () => { const data = await peopleService.find({ paginate: false, query: { age: { $ne: null } } }) assert.strictEqual(data.length, 2) assert.notStrictEqual(data[0].name, 'Ageless') assert.notStrictEqual(data[0].age, null) assert.notStrictEqual(data[1].name, 'Ageless') assert.notStrictEqual(data[1].age, null) }) it('where conditions support NULL values within AND conditions', async () => { const data = await peopleService.find({ paginate: false, query: { age: null, name: 'Ageless' } }) assert.strictEqual(data.length, 1) assert.strictEqual(data[0].name, 'Ageless') assert.strictEqual(data[0].age, null) }) it('where conditions support NULL values within OR conditions', async () => { const data = await peopleService.find({ paginate: false, query: { $or: [ { age: null }, { name: 'Dada' } ] } }) assert.strictEqual(data.length, 2) assert.notStrictEqual(data[0].name, 'Dave') assert.notStrictEqual(data[0].age, 32) assert.notStrictEqual(data[1].name, 'Dave') assert.notStrictEqual(data[1].age, 32) }) it('attaches the SQL error', async () => { await assert.rejects( () => peopleService.create({}), (error: any) => { assert.ok(error[ERROR]) return true } ) }) it('get by id works with `createQuery` as params.knex', async () => { const knex = peopleService.createQuery() const dave = await peopleService.get(daves[0].id, { knex }) assert.deepStrictEqual(dave, daves[0]) }) }) describe('hooks', () => { type ModelStub = { getModel: () => Knex } afterEach(async () => { await db('people').truncate() }) it('does reject on problem with commit', async () => { const app = feathers() app.hooks({ before: transaction.start(), after: [ (context: HookContext) => { const client = context.params.transaction.trx.client const query = client.query client.query = (conn: any, sql: any) => { let result = query.call(client, conn, sql) if (sql === 'COMMIT;') { result = result.then(() => { throw new TypeError('Deliberate') }) } return result } }, transaction.end() ], error: transaction.rollback() }) app.use('/people', people) await assert.rejects(() => app.service('/people').create({ name: 'Foo' }), { message: 'Deliberate' }) }) it('does commit, rollback, nesting', async () => { const app = feathers<{ people: typeof people test: Pick & ModelStub }>() app.hooks({ before: transaction.start(), after: transaction.end(), error: transaction.rollback() }) app.use('people', people) app.use('test', { getModel: () => db, create: async (data: any, params) => { const created = await app.service('people').create({ name: 'Foo' }, { ...params }) if (data.throw) { throw new TypeError('Deliberate') } return created } }) await assert.rejects(() => app.service('test').create({ throw: true }), { message: 'Deliberate' }) assert.strictEqual((await app.service('people').find({ paginate: false })).length, 0) await app.service('test').create({}) assert.strictEqual((await app.service('people').find({ paginate: false })).length, 1) }) it('does use savepoints for nested calls', async () => { const app = feathers<{ people: typeof people success: Pick & ModelStub fail: Pick & ModelStub test: Pick & ModelStub }>() app.hooks({ before: transaction.start(), after: transaction.end(), error: transaction.rollback() }) app.use('people', people) app.use('success', { getModel: () => db, create: async (_data, params) => { return app.service('people').create({ name: 'Success' }, { ...params }) } }) app.use('fail', { getModel: () => db, create: async (_data, params) => { await app.service('people').create({ name: 'Fail' }, { ...params }) throw new TypeError('Deliberate') } }) app.use('test', { getModel: () => db, create: async (_data, params) => { await app.service('success').create({}, { ...params }) await app .service('fail') .create({}, { ...params }) // eslint-disable-next-line @typescript-eslint/no-empty-function .catch(() => {}) return [] } }) await app.service('test').create({}) const created = await app.service('people').find({ paginate: false }) assert.strictEqual(created.length, 1) assert.ok(created[0].name) }) it('allows waiting for transaction to complete', async () => { const app = feathers<{ people: typeof people test: Pick & ModelStub }>() let seq: string[] = [] app.hooks({ before: [ transaction.start(), (context: HookContext) => { seq.push(`${context.path}: waiting for trx to be committed`) context.params.transaction.committed.then((success: any) => { seq.push(`${context.path}: committed ${success}`) }) }, async (context: HookContext) => { seq.push(`${context.path}: another hook`) } ], after: [ transaction.end(), (context: HookContext) => { seq.push(`${context.path}: trx ended`) } ], error: [ transaction.rollback(), (context: HookContext) => { seq.push(`${context.path}: trx rolled back`) } ] }) app.use('people', people) app.use('test', { getModel: () => db, create: async (data: any, params) => { const peeps = await app.service('people').create({ name: 'Foo' }, { ...params }) if (data.throw) { throw new TypeError('Deliberate') } return peeps } }) assert.deepStrictEqual(seq, []) await assert.rejects(() => app.service('test').create({ throw: true }), { message: 'Deliberate' }) assert.deepStrictEqual(seq, [ 'test: waiting for trx to be committed', 'test: another hook', 'people: waiting for trx to be committed', 'people: another hook', 'people: trx ended', 'test: committed false', 'people: committed false', 'test: trx rolled back' ]) seq = [] assert.strictEqual((await app.service('people').find({ paginate: false })).length, 0) assert.deepStrictEqual(seq, [ 'people: waiting for trx to be committed', 'people: another hook', 'people: committed true', 'people: trx ended' ]) seq = [] await app.service('test').create({}) assert.deepStrictEqual(seq, [ 'test: waiting for trx to be committed', 'test: another hook', 'people: waiting for trx to be committed', 'people: another hook', 'people: trx ended', 'test: committed true', 'people: committed true', 'test: trx ended' ]) seq = [] assert.strictEqual((await app.service('people').find({ paginate: false })).length, 1) assert.deepStrictEqual(seq, [ 'people: waiting for trx to be committed', 'people: another hook', 'people: committed true', 'people: trx ended' ]) }) }) describe('associations', () => { const todoService = app.service('todos') it('create, query and get with associations, can unambigiously $select', async () => { const dave = await peopleService.create({ name: 'Dave', age: 133 }) const todo = await todoService.create({ text: 'Do dishes', personId: dave.id }) const [found] = await todoService.find({ paginate: false, query: { 'person.age': { $gt: 100 } } }) const got = await todoService.get(todo.id) assert.deepStrictEqual( await todoService.get(todo.id, { query: { $select: ['id', 'text'] } }), { id: todo.id, text: todo.text, personName: 'Dave' } ) assert.strictEqual(got.personName, dave.name) assert.deepStrictEqual(got, todo) assert.deepStrictEqual(found, todo) peopleService.remove(dave.id) todoService.remove(todo.id) }) }) describe('extendedOperators', () => { const extendedService = app.service('people-extended-ops') let testData: Person[] beforeEach(async () => { testData = await Promise.all([ extendedService.create({ name: 'StartWithA', age: 25 }), extendedService.create({ name: 'MiddleAMiddle', age: 30 }), extendedService.create({ name: 'EndWithA', age: 35 }) ]) }) afterEach(async () => { try { for (const item of testData) { await extendedService.remove(item.id) } } catch (error: unknown) {} }) it('supports custom operators through extendedOperators option', async () => { // Test the $startsWith custom operator const startsWithResults = await extendedService.find({ paginate: false, query: { name: { $startsWith: 'Start%' // LIKE operator with % wildcard } } }) assert.strictEqual(startsWithResults.length, 1) assert.strictEqual(startsWithResults[0].name, 'StartWithA') // Test that regular operators still work alongside extended ones const combinedResults = await extendedService.find({ paginate: false, query: { $and: [{ name: { $neq: 'EndWithA' } }, { age: { $gt: 26 } }] } }) assert.strictEqual(combinedResults.length, 1) assert.strictEqual(combinedResults[0].name, 'MiddleAMiddle') }) }) testSuite(app, errors, 'users') testSuite(app, errors, 'people') testSuite(app, errors, 'people-customid', 'customid') testSuite(app, errors, 'people-extended-ops') }) ================================================ FILE: packages/knex/test/overrides.test.ts ================================================ import knex from 'knex' import assert from 'assert' import { feathers, Paginated } from '@feathersjs/feathers' import { KnexAdapterParams, KnexService, transaction } from '../src' import { PaginationOptions } from '@feathersjs/adapter-commons' // const { transaction } = service.hooks const db = knex({ client: 'sqlite3', connection: { filename: './db.sqlite' } }) const schemaName = 'overrides' knex({ client: 'sqlite3', connection: { filename: `./${schemaName}.sqlite` } }) type Animal = { id: number ancestor_id: number ancestor_name: string name: string } /** * Override the _find() method to manipulate the knex query, and * introduce ambiguity by the table to itself. */ class AnimalService extends KnexService { async _find(params?: P & { paginate?: PaginationOptions }): Promise> async _find(params?: P & { paginate: false }): Promise async _find(params?: P): Promise | T[]> async _find(params: P = {} as P): Promise | T[]> { const knexQuery = this.createQuery(params) knexQuery .select('ancestors.name as ancestor_name') .leftJoin('animals as ancestors', 'ancestors.id', '=', 'animals.ancestor_id') params.knex = knexQuery return super._find(params) } } const animals = new AnimalService({ Model: db, name: 'animals', events: ['testing'] }) function clean() { return db.schema.dropTableIfExists(animals.fullName).then(() => { return db.schema.createTable(animals.fullName, (table) => { table.increments('id') table.integer('ancestor_id') table.string('name').notNullable() return table }) }) } describe('Feathers Knex Overridden Method With Self-Join', () => { let ancestor: Animal let animal: Animal const app = feathers<{ animals: AnimalService }>() .hooks({ before: [transaction.start()], after: [transaction.end()], error: [transaction.rollback()] }) .use('animals', animals) const animalService = app.service('animals') before(() => { return db.schema.raw(`attach database '${schemaName}.sqlite' as ${schemaName}`) }) before(clean) after(clean) beforeEach(async () => { ancestor = await animalService.create({ name: 'Ape' }) animal = await animalService.create({ ancestor_id: ancestor.id, name: 'Human' }) }) it('finds properly', async () => { const foundAnimals = await animalService.find({ paginate: false, query: { $limit: 1, ancestor_name: 'Ape' } }) assert.strictEqual(foundAnimals[0].id, animal.id) assert.strictEqual(foundAnimals[0].name, 'Human') assert.strictEqual(foundAnimals[0].ancestor_name, 'Ape') }) /** * Previously, any query modified to include joins with ambiguous primary keys * would yield an ambiguous column errors: * BadRequest: select `animals`.* * from `animals` * left join `animals` as `ancestors` on `ancestors`.`id` = `animals`.`ancestor_id` * where `id` in (2) - SQLITE_ERROR: ambiguous column name: id * * The fix involves explicitly specifying the table to query in the _patch() method */ it('patches without ambiguous query', async () => { const newName = 'Homo Sapiens' const patchedAnimal = await animalService.patch(animal.id, { name: newName }) assert.strictEqual(patchedAnimal.name, newName) }) it('get the service model (getModel)', async () => { const model = animalService.Model const options = animalService.options assert.strictEqual(model, options.Model) }) }) ================================================ FILE: packages/knex/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/koa/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/koa ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/koa ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/koa ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/koa ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/koa ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/koa ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/koa ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/koa ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/koa ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/koa ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/koa ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/koa ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/koa ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/koa ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/koa ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/koa ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/koa ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/koa ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/koa ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/koa ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/koa ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/koa ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/koa ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/koa ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/koa ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/koa ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/koa ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) ### Bug Fixes - **koa:** Ensure .teardown works without a server ([#3234](https://github.com/feathersjs/feathers/issues/3234)) ([818572d](https://github.com/feathersjs/feathers/commit/818572df98456bc3e1a300e879329aa8f849be64)) ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/koa ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/koa ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) ### Bug Fixes - **koa:** Replace koa-bodyparser with koa-body ([#3093](https://github.com/feathersjs/feathers/issues/3093)) ([2456bf8](https://github.com/feathersjs/feathers/commit/2456bf882c99ae2cddd1a39bffba7e61217fc055)) # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) ### Bug Fixes - **koa:** Make Koa app inspectable ([#3069](https://github.com/feathersjs/feathers/issues/3069)) ([4fbbfff](https://github.com/feathersjs/feathers/commit/4fbbfff2a3c625f8e6929e5a09e2cf7b739ffe11)) # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) ### Bug Fixes - **koa:** Fix missing dependency on feathers ([#3061](https://github.com/feathersjs/feathers/issues/3061)) ([80dc95f](https://github.com/feathersjs/feathers/commit/80dc95ff85c9074b8f70e3ff71562f18863ef2be)) # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) ### Bug Fixes - **transports:** Add remaining middleware for generated apps to Koa and Express ([#2796](https://github.com/feathersjs/feathers/issues/2796)) ([0d5781a](https://github.com/feathersjs/feathers/commit/0d5781a5c72a0cbb2ec8211bfa099f0aefe115a2)) # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) ### Bug Fixes - **koa:** Only set error code for Feathers errors ([#2793](https://github.com/feathersjs/feathers/issues/2793)) ([d3ee41e](https://github.com/feathersjs/feathers/commit/d3ee41e27b0ea5d29b344d6584ab03e48d16e2b4)) ### Features - **cli:** Generate full client test suite and improve typed client ([#2788](https://github.com/feathersjs/feathers/issues/2788)) ([57119b6](https://github.com/feathersjs/feathers/commit/57119b6bb2797f7297cf054268a248c093ecd538)) # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Bug Fixes - **core:** Ensure setup and teardown can be overriden and maintain hook functionality ([#2779](https://github.com/feathersjs/feathers/issues/2779)) ([ab580cb](https://github.com/feathersjs/feathers/commit/ab580cbcaa68d19144d86798c13bf564f9d424a6)) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) ### Features - Add CORS support to oAuth, Express, Koa and generated application ([#2744](https://github.com/feathersjs/feathers/issues/2744)) ([fd218f2](https://github.com/feathersjs/feathers/commit/fd218f289f8ca4c101e9938e8683e2efef6e8131)) # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Features - **cli:** Add support for JavaScript to the new CLI ([#2668](https://github.com/feathersjs/feathers/issues/2668)) ([ebac587](https://github.com/feathersjs/feathers/commit/ebac587f7d00dc7607c3f546352d79f79b89a5d4)) - **cli:** Initial Feathers v5 CLI and Pinion generator ([#2578](https://github.com/feathersjs/feathers/issues/2578)) ([7f59ae7](https://github.com/feathersjs/feathers/commit/7f59ae7f1471895ba8a82aa4702f1a23f71b7682)) # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) ### Features - **core:** Add app.teardown functionality ([#2570](https://github.com/feathersjs/feathers/issues/2570)) ([fcdf524](https://github.com/feathersjs/feathers/commit/fcdf524ae1995bb59265d39f12e98b7794bed023)) - **core:** Finalize app.teardown() functionality ([#2584](https://github.com/feathersjs/feathers/issues/2584)) ([1a166f3](https://github.com/feathersjs/feathers/commit/1a166f3ded811ecacf0ae8cb67880bc9fa2eeafa)) - **transport-commons:** add `context.http.response` ([#2524](https://github.com/feathersjs/feathers/issues/2524)) ([5bc9d44](https://github.com/feathersjs/feathers/commit/5bc9d447043c2e2b742c73ed28ecf3b3264dd9e5)) # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) ### Features - **express, koa:** make transports similar ([#2486](https://github.com/feathersjs/feathers/issues/2486)) ([26aa937](https://github.com/feathersjs/feathers/commit/26aa937c114fb8596dfefc599b1f53cead69c159)) # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Bug Fixes - **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110)) ### Features - **core:** add `context.http` and move `statusCode` there ([#2496](https://github.com/feathersjs/feathers/issues/2496)) ([b701bf7](https://github.com/feathersjs/feathers/commit/b701bf77fb83048aa1dffa492b3d77dd53f7b72b)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/koa # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) ### Bug Fixes - **koa:** Throw a NotFound Feathers error on missing paths ([#2415](https://github.com/feathersjs/feathers/issues/2415)) ([e013f98](https://github.com/feathersjs/feathers/commit/e013f98315d550ced6eacffd615c61bb0912b4ba)) # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Bug Fixes - **koa:** Use extended query parser for compatibility ([#2397](https://github.com/feathersjs/feathers/issues/2397)) ([b2944ba](https://github.com/feathersjs/feathers/commit/b2944bac3ec6d5ecc80dc518cd4e58093692db74)) ### Features - **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) ### Features - **koa:** KoaJS transport adapter ([#2315](https://github.com/feathersjs/feathers/issues/2315)) ([2554b57](https://github.com/feathersjs/feathers/commit/2554b57cf05731df58feeba9c12faab18e442107)) ================================================ FILE: packages/koa/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2018 Feathers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/koa/README.md ================================================ # @feathersjs/koa [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/koa.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/koa) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > Feathers KoaJS framework bindings and REST provider ## Installation ``` npm install @feathersjs/koa --save ``` ## Documentation Refer to the [Feathers Koa API documentation](https://feathersjs.com/api/koa.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/koa/package.json ================================================ { "name": "@feathersjs/koa", "description": "Feathers KoaJS framework bindings and REST provider", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "koajs" ], "license": "MIT", "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/koa" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 14" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/authentication": "^5.0.42", "@feathersjs/commons": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/feathers": "^5.0.42", "@feathersjs/transport-commons": "^5.0.42", "@koa/cors": "^5.0.0", "@types/koa": "^3.0.1", "@types/koa-qs": "^2.0.5", "@types/koa-static": "^4.0.4", "@types/koa__cors": "^5.0.1", "koa": "^3.1.2", "koa-body": "^7.0.1", "koa-compose": "^4.1.0", "koa-qs": "^3.0.0", "koa-static": "^5.0.0" }, "devDependencies": { "@feathersjs/authentication-local": "^5.0.42", "@feathersjs/memory": "^5.0.42", "@feathersjs/tests": "^5.0.42", "@types/koa-compose": "^3.2.9", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "axios": "^1.13.6", "mocha": "^11.7.5", "shx": "^0.4.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/koa/src/authentication.ts ================================================ import { Application, HookContext } from '@feathersjs/feathers' import { createDebug } from '@feathersjs/commons' import { authenticate as AuthenticateHook } from '@feathersjs/authentication' import { Middleware } from './declarations' const debug = createDebug('@feathersjs/koa/authentication') export type AuthenticationSettings = { service?: string strategies?: string[] } export function parseAuthentication(settings: AuthenticationSettings = {}): Middleware { return async (ctx, next) => { const app = ctx.app const service = app.defaultAuthentication?.(settings.service) if (!service) { return next() } const config = service.configuration const authStrategies = settings.strategies || config.parseStrategies || config.authStrategies || [] if (authStrategies.length === 0) { debug('No `authStrategies` or `parseStrategies` found in authentication configuration') return next() } const authentication = await service.parse(ctx.req, ctx.res, ...authStrategies) if (authentication) { debug('Parsed authentication from HTTP header', authentication) ctx.feathers = { ...ctx.feathers, authentication } } return next() } } export function authenticate(settings: string | AuthenticationSettings, ...strategies: string[]): Middleware { const hook = AuthenticateHook(settings, ...strategies) return async (ctx, next) => { const app = ctx.app as Application const params = ctx.feathers const context = { app, params } as HookContext await hook(context) ctx.feathers = context.params return next() } } ================================================ FILE: packages/koa/src/declarations.ts ================================================ import Koa, { Next } from 'koa' import { Server } from 'http' import { Application as FeathersApplication, HookContext, Params, RouteLookup } from '@feathersjs/feathers' import '@feathersjs/authentication' export type ApplicationAddons = { server: Server listen(port?: number, ...args: any[]): Promise } export type Application = Omit & FeathersApplication & ApplicationAddons export type FeathersKoaContext = Koa.Context & { app: A } export type Middleware = (context: FeathersKoaContext, next: Next) => any declare module '@feathersjs/feathers/lib/declarations' { interface ServiceOptions { koa?: { before?: Middleware[] after?: Middleware[] composed?: Middleware } } } declare module 'koa' { interface ExtendableContext { feathers?: Partial lookup?: RouteLookup hook?: HookContext } } ================================================ FILE: packages/koa/src/handlers.ts ================================================ import { FeathersError, NotFound } from '@feathersjs/errors' import { FeathersKoaContext } from './declarations' export const errorHandler = () => async (ctx: FeathersKoaContext, next: () => Promise) => { try { await next() if (ctx.body === undefined) { throw new NotFound(`Path ${ctx.path} not found`) } } catch (error: any) { ctx.response.status = error instanceof FeathersError ? error.code : 500 ctx.body = typeof error.toJSON === 'function' ? error.toJSON() : { message: error.message } } } ================================================ FILE: packages/koa/src/index.ts ================================================ import Koa from 'koa' import koaQs from 'koa-qs' import { Application as FeathersApplication } from '@feathersjs/feathers' import { routing } from '@feathersjs/transport-commons' import { createDebug } from '@feathersjs/commons' import { koaBody as bodyParser } from 'koa-body' import cors from '@koa/cors' import serveStatic from 'koa-static' import { Application } from './declarations' export { Koa, bodyParser, cors, serveStatic } export * from './authentication' export * from './declarations' export * from './handlers' export * from './rest' const debug = createDebug('@feathersjs/koa') export function koa( feathersApp?: FeathersApplication, koaApp: Koa = new Koa() ): Application { if (!feathersApp) { return koaApp as any } if (typeof feathersApp.setup !== 'function') { throw new Error('@feathersjs/koa requires a valid Feathers application instance') } const app = feathersApp as any as Application const { listen: koaListen, use: koaUse } = koaApp const { use: feathersUse, teardown: feathersTeardown } = feathersApp Object.assign(app, { use(location: string | Koa.Middleware, ...args: any[]) { if (typeof location === 'string') { return (feathersUse as any).call(this, location, ...args) } return koaUse.call(this, location) }, async listen(port?: number, ...args: any[]) { const server = koaListen.call(this, port, ...args) this.server = server await this.setup(server) debug('Feathers application listening') return server }, async teardown(server?: any) { return feathersTeardown.call(this, server).then( () => new Promise((resolve, reject) => { if (this.server) { this.server.close((e) => (e ? reject(e) : resolve(this))) } else { resolve(this) } }) ) } } as Application) const appDescriptors = { ...Object.getOwnPropertyDescriptors(Object.getPrototypeOf(app)), ...Object.getOwnPropertyDescriptors(app) } const newDescriptors = { ...Object.getOwnPropertyDescriptors(Object.getPrototypeOf(koaApp)), ...Object.getOwnPropertyDescriptors(koaApp) } // Copy all non-existing properties (including non-enumerables) // that don't already exist on the Express app Object.keys(newDescriptors).forEach((prop) => { const appProp = appDescriptors[prop] const newProp = newDescriptors[prop] if (appProp === undefined && newProp !== undefined) { Object.defineProperty(app, prop, newProp) } }) koaQs(app as any) Object.getOwnPropertySymbols(koaApp).forEach((symbol) => { const target = app as any const source = koaApp as any target[symbol] = source[symbol] }) // This reinitializes hooks app.setup = feathersApp.setup as any app.teardown = feathersApp.teardown as any app.configure(routing() as any) app.use((ctx, next) => { ctx.feathers = { ...ctx.feathers, provider: 'rest' } return next() }) return app } ================================================ FILE: packages/koa/src/rest.ts ================================================ import compose from 'koa-compose' import { http } from '@feathersjs/transport-commons' import { createDebug } from '@feathersjs/commons' import { getServiceOptions, defaultServiceMethods, createContext } from '@feathersjs/feathers' import { MethodNotAllowed } from '@feathersjs/errors' import { Application, Middleware } from './declarations' import { AuthenticationSettings, parseAuthentication } from './authentication' const debug = createDebug('@feathersjs/koa/rest') const serviceMiddleware = (): Middleware => { return async (ctx, next) => { const { query, headers, path, body: data, method: httpMethod } = ctx.request as any const methodOverride = ctx.request.headers[http.METHOD_HEADER] as string | undefined // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const { service, params: { __id: id = null, ...route } = {} } = ctx.lookup! const method = http.getServiceMethod(httpMethod, id, methodOverride) const { methods } = getServiceOptions(service) debug(`Found service for path ${path}, attempting to run '${method}' service method`) if (!methods.includes(method) || defaultServiceMethods.includes(methodOverride)) { const error = new MethodNotAllowed(`Method \`${method}\` is not supported by this endpoint.`) ctx.response.status = error.code throw error } const createArguments = http.argumentsFor[method as 'get'] || http.argumentsFor.default const params = { query, headers, route, ...ctx.feathers } const args = createArguments({ id, data, params }) const contextBase = createContext(service, method, { http: {} }) ctx.hook = contextBase const context = await (service as any)[method](...args, contextBase) ctx.hook = context const response = http.getResponse(context) ctx.status = response.status ctx.set(response.headers) ctx.body = response.body return next() } } const servicesMiddleware = (): Middleware => { return async (ctx, next) => { const app = ctx.app const lookup = app.lookup(ctx.request.path) if (!lookup) { return next() } ctx.lookup = lookup const options = getServiceOptions(lookup.service) const middleware = options.koa.composed return middleware(ctx, next) } } // eslint-disable-next-line @typescript-eslint/no-empty-function export const formatter: Middleware = (_ctx, _next) => {} export type RestOptions = { formatter?: Middleware authentication?: AuthenticationSettings } export const rest = (options?: RestOptions | Middleware) => { options = typeof options === 'function' ? { formatter: options } : options || {} const formatterMiddleware = options.formatter || formatter const authenticationOptions = options.authentication return (app: Application) => { app.use(parseAuthentication(authenticationOptions)) app.use(servicesMiddleware()) app.mixins.push((_service, _path, options) => { const { koa: { before = [], after = [] } = {} } = options const middlewares = [].concat(before, serviceMiddleware(), after, formatterMiddleware) const middleware = compose(middlewares) options.koa ||= {} options.koa.composed = middleware }) } } ================================================ FILE: packages/koa/test/app.fixture.ts ================================================ import { memory } from '@feathersjs/memory' import { feathers, Params, HookContext } from '@feathersjs/feathers' import { authenticate, AuthenticationService, JWTStrategy } from '@feathersjs/authentication' import { LocalStrategy, hooks } from '@feathersjs/authentication-local' import { koa, rest, bodyParser, errorHandler, cors } from '../src' const { protect, hashPassword } = hooks const app = koa(feathers()) const authService = new AuthenticationService(app) app.use(errorHandler()) app.use(cors()) app.use(bodyParser()) app.configure(rest()) app.set('authentication', { entity: 'user', service: 'users', secret: 'supersecret', authStrategies: ['local', 'jwt'], parseStrategies: ['jwt'], local: { usernameField: 'email', passwordField: 'password' } }) authService.register('jwt', new JWTStrategy()) authService.register('local', new LocalStrategy()) app.use('/authentication', authService) app.use( '/users', memory({ paginate: { default: 10, max: 20 } }) ) app.service('users').hooks({ before: { create: [hashPassword('password')] }, after: { all: [protect('password')], get: [ (context: HookContext) => { if (context.params.provider) { context.result.fromGet = true } return context } ] } }) app.use('/dummy', { async get(id: string, params: Params) { return { id, params } } }) app.service('dummy').hooks({ before: [authenticate('jwt')] }) export default app ================================================ FILE: packages/koa/test/authentication.test.ts ================================================ import { strict as assert } from 'assert' import _axios from 'axios' import { AuthenticationResult } from '@feathersjs/authentication' import app from './app.fixture' const axios = _axios.create({ baseURL: 'http://localhost:9776/' }) describe('@feathersjs/koa/authentication', () => { const email = 'koatest@authentication.com' const password = 'superkoa' let authResult: AuthenticationResult let user: any before(async () => { await app.listen(9776) user = await app.service('users').create({ email, password }) authResult = ( await axios.post('/authentication', { strategy: 'local', password, email }) ).data }) after(() => app.teardown()) describe('service authentication', () => { it('successful local authentication', () => { assert.ok(authResult.accessToken) assert.strictEqual(authResult.user.email, email) assert.strictEqual(authResult.user.password, undefined) }) it('local authentication with wrong password fails', async () => { try { await axios.post('/authentication', { strategy: 'local', password: 'wrong', email }) assert.fail('Should never get here') } catch (error: any) { const { data } = error.response assert.strictEqual(data.name, 'NotAuthenticated') assert.strictEqual(data.message, 'Invalid login') } }) it('authenticating with JWT works but returns same accessToken', async () => { const { accessToken } = authResult const { data } = await axios.post('/authentication', { strategy: 'jwt', accessToken }) assert.strictEqual(data.accessToken, accessToken) assert.strictEqual(data.authentication.strategy, 'jwt') assert.strictEqual(data.authentication.payload.sub, user.id.toString()) assert.strictEqual(data.user.email, email) }) it('can make a protected request with Authorization header', async () => { const { accessToken } = authResult const { data } = await axios.get('/dummy/dave?user[name]=thing&user[message]=hi', { headers: { Authorization: accessToken } }) assert.strictEqual(data.id, 'dave') assert.deepStrictEqual(data.params.query, { user: { name: 'thing', message: 'hi' } }) assert.deepStrictEqual(data.params.user, user) assert.strictEqual(data.params.authentication.accessToken, accessToken) }) it('errors when there are no authStrategies and parseStrategies', async () => { const { accessToken } = authResult app.get('authentication').authStrategies = [] delete app.get('authentication').parseStrategies try { await axios.get('/dummy/dave', { headers: { Authorization: accessToken } }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.response.data.name, 'NotAuthenticated') app.get('authentication').authStrategies = ['jwt', 'local'] } }) it('can make a protected request with Authorization header and bearer scheme', () => { const { accessToken } = authResult return axios .get('/dummy/dave', { headers: { Authorization: ` Bearer: ${accessToken}` } }) .then((res) => { const { data, data: { params } } = res assert.strictEqual(data.id, 'dave') assert.deepStrictEqual(params.user, user) assert.strictEqual(params.authentication.accessToken, accessToken) }) }) }) }) ================================================ FILE: packages/koa/test/index.test.ts ================================================ import { strict as assert } from 'assert' import Koa from 'koa' import axios from 'axios' import { ApplicationHookMap, feathers, Id } from '@feathersjs/feathers' import { Service, restTests } from '@feathersjs/tests' import { koa, rest, Application, bodyParser, errorHandler } from '../src' describe('@feathersjs/koa', () => { let app: Application before(async () => { app = koa(feathers()) app.use(errorHandler()) app.use(bodyParser()) app.use(async (ctx, next) => { if (ctx.request.path === '/middleware') { ctx.body = { feathers: ctx.feathers, message: 'Hello from middleware' } } else { await next() } }) app.configure(rest()) app.use('/', new Service()) app.use('todo', new Service(), { koa: { after: [ async (ctx, next) => { const body = ctx.body as any if (body.id === 'custom-middleware') { body.description = 'Description from custom middleware' } await next() } ] }, methods: ['get', 'find', 'create', 'update', 'patch', 'remove', 'customMethod'] }) app.hooks({ setup: [ async (context, next) => { assert.ok(context.app) await next() } ], teardown: [ async (context, next) => { assert.ok(context.app) await next() } ] } as ApplicationHookMap) await app.listen(8465) }) after(() => app.teardown()) it('throws an error when initialized with invalid application', () => { try { koa({} as Application) assert.fail('Should never get here') } catch (error: any) { assert.equal(error.message, '@feathersjs/koa requires a valid Feathers application instance') } }) it('returns Koa instance when no Feathers app is passed', () => { assert.ok(koa() instanceof Koa) }) it('Koa wrapped and context.app are the same', async () => { const app = koa(feathers()) app.use('/test', { async get(id: Id) { return { id } } }) app.service('test').hooks({ before: { get: [ (context) => { assert.ok(context.app === app) } ] } }) assert.deepStrictEqual(await app.service('test').get('testing'), { id: 'testing' }) }) it('starts as a Koa and Feathers application', async () => { const { data } = await axios.get('http://localhost:8465/middleware') const todo = await app.service('todo').get('dishes', { query: {} }) assert.deepEqual(data, { message: 'Hello from middleware', feathers: { provider: 'rest' } }) assert.deepEqual(todo, { id: 'dishes', description: 'You have to do dishes!' }) }) it('supports custom service middleware', async () => { const { data } = await axios.get('http://localhost:8465/todo/custom-middleware') assert.deepStrictEqual(data, { id: 'custom-middleware', description: 'Description from custom middleware' }) }) it('works with custom methods that are allowed', async () => { const { data } = await axios.post( 'http://localhost:8465/todo', { message: 'Custom hello' }, { headers: { 'X-Service-Method': 'customMethod' } } ) assert.deepStrictEqual(data, { data: { message: 'Custom hello' }, method: 'customMethod', provider: 'rest' }) await assert.rejects( () => axios.post( 'http://localhost:8465/todo', {}, { headers: { 'X-Service-Method': 'internalMethod' } } ), (error: any) => { const { data } = error.response assert.strictEqual(data.code, 405) assert.strictEqual(data.message, 'Method `internalMethod` is not supported by this endpoint.') return true } ) }) it('throws a 404 NotFound JSON error', async () => { await assert.rejects( () => axios.post( 'http://localhost:8465/no/where', {}, { headers: { 'X-Service-Method': 'internalMethod', Accept: 'application/json' } } ), (error: any) => { const { data } = error.response assert.deepStrictEqual(data, { name: 'NotFound', message: 'Path /no/where not found', code: 404, className: 'not-found' }) return true } ) }) it('.teardown closes http server', async () => { const app = koa(feathers()) let called = false const server = await app.listen(8787) server.on('close', () => { called = true }) await app.teardown() assert.ok(called) }) it('.teardown works without server (#3224)', async () => { const app = koa(feathers()) await app.teardown() }) restTests('Services', 'todo', 8465) restTests('Root service', '/', 8465) }) ================================================ FILE: packages/koa/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/memory/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/memory ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/memory ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/memory ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/memory ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/memory ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - @feathersjs/memory update with query ([#3617](https://github.com/feathersjs/feathers/issues/3617)) ([4c6caa2](https://github.com/feathersjs/feathers/commit/4c6caa27e9af1312718d0c233a0c35f7739ac553)) - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/memory ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/memory ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/memory ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/memory ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/memory ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/memory ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/memory ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/memory ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/memory ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/memory ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/memory ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/memory ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/memory ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/memory ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/memory ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/memory ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/memory ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/memory ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) ### Bug Fixes - allow \_patch to modify the entire base schema ([#3300](https://github.com/feathersjs/feathers/issues/3300)) ([0f41622](https://github.com/feathersjs/feathers/commit/0f41622307589b3a0b62ac411a73e6a601bda171)) ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) - **memory:** Ensure correct pagination totals ([#3307](https://github.com/feathersjs/feathers/issues/3307)) ([c59e1b8](https://github.com/feathersjs/feathers/commit/c59e1b80cb43571077b035ab2bf0b44f9daa5ab8)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/memory ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/memory ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/memory ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/memory ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/memory ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/memory ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) - **memory:** Fix memory adapter readme ([#3153](https://github.com/feathersjs/feathers/issues/3153)) ([a9d826a](https://github.com/feathersjs/feathers/commit/a9d826a7dbe7df4501fbf82a47d2c3a77ca9e0c0)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) ### Bug Fixes - **memory/mongodb:** $select as only property & force 'id' in '$select' ([#3081](https://github.com/feathersjs/feathers/issues/3081)) ([fbe3cf5](https://github.com/feathersjs/feathers/commit/fbe3cf5199e102b5aeda2ae33828d5034df3d105)) # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Features - **adapter:** Add patch data type to adapters and refactor AdapterBase usage ([#2906](https://github.com/feathersjs/feathers/issues/2906)) ([9ddc2e6](https://github.com/feathersjs/feathers/commit/9ddc2e6b028f026f939d6af68125847e5c6734b4)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) ### Bug Fixes - **memory:** Use for loop in \_find() for better performance ([#2844](https://github.com/feathersjs/feathers/issues/2844)) ([d6ee5f1](https://github.com/feathersjs/feathers/commit/d6ee5f1c869f0c65cb470130f35956a52356e5c3)) # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) ### Features - **cli:** Generate full client test suite and improve typed client ([#2788](https://github.com/feathersjs/feathers/issues/2788)) ([57119b6](https://github.com/feathersjs/feathers/commit/57119b6bb2797f7297cf054268a248c093ecd538)) # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Features - **cli:** Initial Feathers v5 CLI and Pinion generator ([#2578](https://github.com/feathersjs/feathers/issues/2578)) ([7f59ae7](https://github.com/feathersjs/feathers/commit/7f59ae7f1471895ba8a82aa4702f1a23f71b7682)) # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Bug Fixes - **adapter-commons:** Clarify adapter query filtering ([#2607](https://github.com/feathersjs/feathers/issues/2607)) ([2dac771](https://github.com/feathersjs/feathers/commit/2dac771b0a3298d6dd25994d05186701b0617718)) ### Features - **mongodb:** Add feathers-mongodb adapter as @feathersjs/mongodb ([#2610](https://github.com/feathersjs/feathers/issues/2610)) ([6d43734](https://github.com/feathersjs/feathers/commit/6d43734a53db02c435cafc52a22dca414e5d0940)) - **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5)) - **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28)) ### BREAKING CHANGES - **adapter-commons:** Changes the common adapter base class to use `sanitizeQuery` and `sanitizeData` # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) ### Bug Fixes - **adapter-tests:** Add tests for pagination in multi updates ([#2472](https://github.com/feathersjs/feathers/issues/2472)) ([98a811a](https://github.com/feathersjs/feathers/commit/98a811ac605575ff812a08d0504729a5efe7a69c)) # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) ### Features - **schema:** Initial version of schema definitions and resolvers ([#2441](https://github.com/feathersjs/feathers/issues/2441)) ([c57a5cd](https://github.com/feathersjs/feathers/commit/c57a5cd56699a121647be4506d8f967e6d72ecae)) # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Bug Fixes - Update database adapter common repository urls ([#2380](https://github.com/feathersjs/feathers/issues/2380)) ([3f4db68](https://github.com/feathersjs/feathers/commit/3f4db68d6700c7d9023ecd17d0d39893f75a19fd)) ### Features - **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f)) - **typescript:** Allow to pass generic service options to adapter services ([#2392](https://github.com/feathersjs/feathers/issues/2392)) ([f9431f2](https://github.com/feathersjs/feathers/commit/f9431f242354f804cafb835519f98dd405ac4f0b)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) ### Features - **koa:** KoaJS transport adapter ([#2315](https://github.com/feathersjs/feathers/issues/2315)) ([2554b57](https://github.com/feathersjs/feathers/commit/2554b57cf05731df58feeba9c12faab18e442107)) # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) **Note:** Version bump only for package @feathersjs/memory # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) ### Features - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) ### Features - **memory:** Move feathers-memory into @feathersjs/memory ([#2153](https://github.com/feathersjs/feathers/issues/2153)) ([dd61fe3](https://github.com/feathersjs/feathers/commit/dd61fe371fb0502f78b8ccbe1f45a030e31ecff6)) # Change Log ## [v4.1.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v4.1.0) (2019-10-07) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v4.0.1...v4.1.0) **Merged pull requests:** - Update all dependencies [\#104](https://github.com/feathersjs-ecosystem/feathers-memory/pull/104) ([daffl](https://github.com/daffl)) ## [v4.0.1](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v4.0.1) (2019-09-29) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v4.0.0...v4.0.1) **Closed issues:** - An in-range update of @types/node is breaking the build 🚨 [\#101](https://github.com/feathersjs-ecosystem/feathers-memory/issues/101) - An in-range update of webpack is breaking the build 🚨 [\#98](https://github.com/feathersjs-ecosystem/feathers-memory/issues/98) **Merged pull requests:** - Pass entity type to AdapterService\ [\#103](https://github.com/feathersjs-ecosystem/feathers-memory/pull/103) ([daffl](https://github.com/daffl)) - Update semistandard to the latest version 🚀 [\#102](https://github.com/feathersjs-ecosystem/feathers-memory/pull/102) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update dtslint to the latest version 🚀 [\#100](https://github.com/feathersjs-ecosystem/feathers-memory/pull/100) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Greenkeeper/webpack 4.36.1 [\#99](https://github.com/feathersjs-ecosystem/feathers-memory/pull/99) ([daffl](https://github.com/daffl)) ## [v4.0.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v4.0.0) (2019-07-05) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v3.0.2...v4.0.0) **Merged pull requests:** - Add TypeScript definitions and upgrade to Feathers 4 [\#97](https://github.com/feathersjs-ecosystem/feathers-memory/pull/97) ([daffl](https://github.com/daffl)) - Update mocha to the latest version 🚀 [\#94](https://github.com/feathersjs-ecosystem/feathers-memory/pull/94) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v3.0.2](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v3.0.2) (2019-01-24) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v3.0.1...v3.0.2) **Closed issues:** - Multiple patch records [\#92](https://github.com/feathersjs-ecosystem/feathers-memory/issues/92) **Merged pull requests:** - Allow patch to update prop that is within the query [\#93](https://github.com/feathersjs-ecosystem/feathers-memory/pull/93) ([Mattchewone](https://github.com/Mattchewone)) - Add new tests [\#91](https://github.com/feathersjs-ecosystem/feathers-memory/pull/91) ([daffl](https://github.com/daffl)) - Update @feathersjs/adapter-commons to the latest version 🚀 [\#90](https://github.com/feathersjs-ecosystem/feathers-memory/pull/90) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v3.0.1](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v3.0.1) (2018-12-29) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v3.0.0...v3.0.1) **Merged pull requests:** - Add default params to hook-less methods [\#89](https://github.com/feathersjs-ecosystem/feathers-memory/pull/89) ([daffl](https://github.com/daffl)) ## [v3.0.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v3.0.0) (2018-12-17) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v2.2.0...v3.0.0) **Closed issues:** - An in-range update of webpack is breaking the build 🚨 [\#84](https://github.com/feathersjs-ecosystem/feathers-memory/issues/84) - An in-range update of @feathersjs/errors is breaking the build 🚨 [\#83](https://github.com/feathersjs-ecosystem/feathers-memory/issues/83) **Merged pull requests:** - Update to @feathersjs/adapter-commons and drop Node 6 [\#88](https://github.com/feathersjs-ecosystem/feathers-memory/pull/88) ([daffl](https://github.com/daffl)) - Update semistandard to the latest version 🚀 [\#87](https://github.com/feathersjs-ecosystem/feathers-memory/pull/87) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update all dependencies and Webpack build [\#85](https://github.com/feathersjs-ecosystem/feathers-memory/pull/85) ([daffl](https://github.com/daffl)) - Update babel-loader to the latest version 🚀 [\#81](https://github.com/feathersjs-ecosystem/feathers-memory/pull/81) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.2.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v2.2.0) (2018-08-26) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v2.1.3...v2.2.0) **Closed issues:** - Previously functional batch service no longer works when creating in-memory service [\#77](https://github.com/feathersjs-ecosystem/feathers-memory/issues/77) **Merged pull requests:** - Remove cloneDeep dependency [\#80](https://github.com/feathersjs-ecosystem/feathers-memory/pull/80) ([daffl](https://github.com/daffl)) - Fix cloning of instances [\#79](https://github.com/feathersjs-ecosystem/feathers-memory/pull/79) ([homerjam](https://github.com/homerjam)) - Update sift to the latest version 🚀 [\#76](https://github.com/feathersjs-ecosystem/feathers-memory/pull/76) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.1.3](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v2.1.3) (2018-06-11) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v2.1.2...v2.1.3) **Closed issues:** - Use with create-react-app [\#74](https://github.com/feathersjs-ecosystem/feathers-memory/issues/74) **Merged pull requests:** - Transpile all Feathers modules for distributable [\#75](https://github.com/feathersjs-ecosystem/feathers-memory/pull/75) ([saiichihashimoto](https://github.com/saiichihashimoto)) - Update shx to the latest version 🚀 [\#73](https://github.com/feathersjs-ecosystem/feathers-memory/pull/73) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.1.2](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v2.1.2) (2018-06-03) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v2.1.1...v2.1.2) **Merged pull requests:** - Update uberproto to the latest version 🚀 [\#72](https://github.com/feathersjs-ecosystem/feathers-memory/pull/72) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update clone-deep to the latest version 🚀 [\#70](https://github.com/feathersjs-ecosystem/feathers-memory/pull/70) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.1.1](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v2.1.1) (2018-03-07) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v2.1.0...v2.1.1) **Closed issues:** - Why are all the data deleted after the server is rebooted? [\#68](https://github.com/feathersjs-ecosystem/feathers-memory/issues/68) **Merged pull requests:** - Update webpack to the latest version 🚀 [\#69](https://github.com/feathersjs-ecosystem/feathers-memory/pull/69) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update clone-deep to the latest version 🚀 [\#67](https://github.com/feathersjs-ecosystem/feathers-memory/pull/67) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update mocha to the latest version 🚀 [\#66](https://github.com/feathersjs-ecosystem/feathers-memory/pull/66) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update semistandard to the latest version 🚀 [\#65](https://github.com/feathersjs-ecosystem/feathers-memory/pull/65) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.1.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v2.1.0) (2017-12-03) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v2.0.0...v2.1.0) **Merged pull requests:** - Use namespaced module name for exporting [\#64](https://github.com/feathersjs-ecosystem/feathers-memory/pull/64) ([daffl](https://github.com/daffl)) ## [v2.0.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v2.0.0) (2017-12-03) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v1.3.1...v2.0.0) **Merged pull requests:** - Client build [\#63](https://github.com/feathersjs-ecosystem/feathers-memory/pull/63) ([daffl](https://github.com/daffl)) - Upgrade to Feathers Buzzard \(v3\) [\#62](https://github.com/feathersjs-ecosystem/feathers-memory/pull/62) ([daffl](https://github.com/daffl)) - Update to new plugin infrastructure [\#61](https://github.com/feathersjs-ecosystem/feathers-memory/pull/61) ([daffl](https://github.com/daffl)) - Update clone-deep to the latest version 🚀 [\#60](https://github.com/feathersjs-ecosystem/feathers-memory/pull/60) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.3.1](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v1.3.1) (2017-10-20) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v1.3.0...v1.3.1) **Closed issues:** - Custom $select returning `id` [\#58](https://github.com/feathersjs-ecosystem/feathers-memory/issues/58) - Best practice for $search [\#51](https://github.com/feathersjs-ecosystem/feathers-memory/issues/51) **Merged pull requests:** - Do not select the id by default [\#59](https://github.com/feathersjs-ecosystem/feathers-memory/pull/59) ([daffl](https://github.com/daffl)) ## [v1.3.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v1.3.0) (2017-10-19) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v1.2.1...v1.3.0) **Merged pull requests:** - Modified matcher to use new sift package [\#57](https://github.com/feathersjs-ecosystem/feathers-memory/pull/57) ([Mattchewone](https://github.com/Mattchewone)) - Update mocha to the latest version 🚀 [\#56](https://github.com/feathersjs-ecosystem/feathers-memory/pull/56) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.2.1](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v1.2.1) (2017-09-13) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v1.2.0...v1.2.1) ## [v1.2.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v1.2.0) (2017-09-13) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v1.1.0...v1.2.0) **Closed issues:** - \[RFE\] An option to set the type of the id field to String [\#54](https://github.com/feathersjs-ecosystem/feathers-memory/issues/54) **Merged pull requests:** - Deep clone objects before returning [\#55](https://github.com/feathersjs-ecosystem/feathers-memory/pull/55) ([daffl](https://github.com/daffl)) - Update feathers-socketio to the latest version 🚀 [\#52](https://github.com/feathersjs-ecosystem/feathers-memory/pull/52) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update feathers-service-tests to the latest version 🚀 [\#50](https://github.com/feathersjs-ecosystem/feathers-memory/pull/50) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update semistandard to the latest version 🚀 [\#49](https://github.com/feathersjs-ecosystem/feathers-memory/pull/49) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update dependencies to enable Greenkeeper 🌴 [\#48](https://github.com/feathersjs-ecosystem/feathers-memory/pull/48) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.1.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v1.1.0) (2017-01-31) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v1.0.1...v1.1.0) **Merged pull requests:** - Allow to pass a custom matcher and sorter in the options [\#47](https://github.com/feathersjs-ecosystem/feathers-memory/pull/47) ([daffl](https://github.com/daffl)) - Change `var` to `const`, fix a mistake with `feathers-memory` requiring [\#46](https://github.com/feathersjs-ecosystem/feathers-memory/pull/46) ([osenvosem](https://github.com/osenvosem)) ## [v1.0.1](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v1.0.1) (2016-11-15) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v1.0.0...v1.0.1) **Merged pull requests:** - feathers-service-tests@0.9.1 breaks build 🚨 [\#45](https://github.com/feathersjs-ecosystem/feathers-memory/pull/45) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.0.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v1.0.0) (2016-11-11) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.8.1...v1.0.0) **Closed issues:** - Support $select for gets [\#35](https://github.com/feathersjs-ecosystem/feathers-memory/issues/35) **Merged pull requests:** - Update feathers-service-tests to version 0.9.0 🚀 [\#44](https://github.com/feathersjs-ecosystem/feathers-memory/pull/44) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-commons to version 0.8.0 🚀 [\#43](https://github.com/feathersjs-ecosystem/feathers-memory/pull/43) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v0.8.1](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.8.1) (2016-11-02) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.8.0...v0.8.1) **Merged pull requests:** - fix $select with more than one field [\#42](https://github.com/feathersjs-ecosystem/feathers-memory/pull/42) ([t2t2](https://github.com/t2t2)) - babel-preset-es2015@6.18.0 breaks build 🚨 [\#41](https://github.com/feathersjs-ecosystem/feathers-memory/pull/41) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Two tweaks for clean build and tests on Windows [\#38](https://github.com/feathersjs-ecosystem/feathers-memory/pull/38) ([ghost](https://github.com/ghost)) - jshint —\> semistandard [\#37](https://github.com/feathersjs-ecosystem/feathers-memory/pull/37) ([marshallswain](https://github.com/marshallswain)) - adding code coverage reporting [\#36](https://github.com/feathersjs-ecosystem/feathers-memory/pull/36) ([ekryski](https://github.com/ekryski)) - Update feathers-service-tests to version 0.8.0 🚀 [\#32](https://github.com/feathersjs-ecosystem/feathers-memory/pull/32) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v0.8.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.8.0) (2016-09-08) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.7.5...v0.8.0) **Closed issues:** - Remove object from memory once sent? [\#30](https://github.com/feathersjs-ecosystem/feathers-memory/issues/30) **Merged pull requests:** - Update service tests, id and events option [\#31](https://github.com/feathersjs-ecosystem/feathers-memory/pull/31) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update mocha to version 3.0.0 🚀 [\#29](https://github.com/feathersjs-ecosystem/feathers-memory/pull/29) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v0.7.5](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.7.5) (2016-07-25) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.7.4...v0.7.5) ## [v0.7.4](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.7.4) (2016-07-21) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.7.3...v0.7.4) **Merged pull requests:** - Update feathers-query-filters to version 2.0.0 🚀 [\#28](https://github.com/feathersjs-ecosystem/feathers-memory/pull/28) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v0.7.3](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.7.3) (2016-06-16) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.7.2...v0.7.3) **Merged pull requests:** - Update feathers-service-tests to version 0.6.0 🚀 [\#27](https://github.com/feathersjs-ecosystem/feathers-memory/pull/27) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v0.7.2](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.7.2) (2016-06-14) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.7.1...v0.7.2) **Closed issues:** - Support $search [\#14](https://github.com/feathersjs-ecosystem/feathers-memory/issues/14) **Merged pull requests:** - Use the original id if it can be coerced [\#26](https://github.com/feathersjs-ecosystem/feathers-memory/pull/26) ([daffl](https://github.com/daffl)) - mocha@2.5.0 breaks build 🚨 [\#25](https://github.com/feathersjs-ecosystem/feathers-memory/pull/25) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update babel-plugin-add-module-exports to version 0.2.0 🚀 [\#24](https://github.com/feathersjs-ecosystem/feathers-memory/pull/24) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v0.7.1](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.7.1) (2016-04-05) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.7.0...v0.7.1) ## [v0.7.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.7.0) (2016-04-04) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.6.3...v0.7.0) **Merged pull requests:** - Move to feathers-commons utilities [\#20](https://github.com/feathersjs-ecosystem/feathers-memory/pull/20) ([daffl](https://github.com/daffl)) ## [v0.6.3](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.6.3) (2016-02-25) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.6.2...v0.6.3) **Closed issues:** - Upgrade to lodash 4 [\#17](https://github.com/feathersjs-ecosystem/feathers-memory/issues/17) **Merged pull requests:** - Use individual Lodash methods [\#19](https://github.com/feathersjs-ecosystem/feathers-memory/pull/19) ([daffl](https://github.com/daffl)) ## [v0.6.2](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.6.2) (2016-02-24) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.6.1...v0.6.2) **Merged pull requests:** - bumping feathers-errors version [\#16](https://github.com/feathersjs-ecosystem/feathers-memory/pull/16) ([ekryski](https://github.com/ekryski)) ## [v0.6.1](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.6.1) (2016-02-22) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.6.0...v0.6.1) **Merged pull requests:** - Exmaple update [\#15](https://github.com/feathersjs-ecosystem/feathers-memory/pull/15) ([ekryski](https://github.com/ekryski)) ## [v0.6.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.6.0) (2016-01-30) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.5.3...v0.6.0) **Merged pull requests:** - Use internal methods instead of service methods directly [\#13](https://github.com/feathersjs-ecosystem/feathers-memory/pull/13) ([daffl](https://github.com/daffl)) ## [v0.5.3](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.5.3) (2016-01-23) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.5.2...v0.5.3) ## [v0.5.2](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.5.2) (2016-01-23) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.5.1...v0.5.2) **Merged pull requests:** - Adding nsp check [\#12](https://github.com/feathersjs-ecosystem/feathers-memory/pull/12) ([marshallswain](https://github.com/marshallswain)) ## [v0.5.1](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.5.1) (2015-12-19) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.5.0...v0.5.1) ## [v0.5.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.5.0) (2015-12-03) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.4.1...v0.5.0) ## [v0.4.1](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.4.1) (2015-12-03) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/v0.4.0...v0.4.1) **Merged pull requests:** - Use ES6 classes, Promises and support pagination [\#11](https://github.com/feathersjs-ecosystem/feathers-memory/pull/11) ([daffl](https://github.com/daffl)) ## [v0.4.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/v0.4.0) (2015-11-07) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/0.3.4...v0.4.0) **Closed issues:** - How properly append values to an existing memory element [\#9](https://github.com/feathersjs-ecosystem/feathers-memory/issues/9) - how to initialize memory on app startup [\#8](https://github.com/feathersjs-ecosystem/feathers-memory/issues/8) - Add query-filter support [\#7](https://github.com/feathersjs-ecosystem/feathers-memory/issues/7) - Remove sorting and other processing from core service [\#4](https://github.com/feathersjs-ecosystem/feathers-memory/issues/4) **Merged pull requests:** - Migrate to ES6 plugin infrastructure and shared feathers-service-tests [\#10](https://github.com/feathersjs-ecosystem/feathers-memory/pull/10) ([daffl](https://github.com/daffl)) - Added support for simple query in find [\#6](https://github.com/feathersjs-ecosystem/feathers-memory/pull/6) ([ruimgoncalves](https://github.com/ruimgoncalves)) ## [0.3.4](https://github.com/feathersjs-ecosystem/feathers-memory/tree/0.3.4) (2014-09-25) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/0.3.3...0.3.4) **Closed issues:** - Query and persisting Data [\#5](https://github.com/feathersjs-ecosystem/feathers-memory/issues/5) ## [0.3.3](https://github.com/feathersjs-ecosystem/feathers-memory/tree/0.3.3) (2014-06-13) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/0.3.2...0.3.3) ## [0.3.2](https://github.com/feathersjs-ecosystem/feathers-memory/tree/0.3.2) (2014-06-13) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/0.3.1...0.3.2) ## [0.3.1](https://github.com/feathersjs-ecosystem/feathers-memory/tree/0.3.1) (2014-06-13) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/0.3.0...0.3.1) **Closed issues:** - Fix peer dependency [\#3](https://github.com/feathersjs-ecosystem/feathers-memory/issues/3) - Should support `patch` service method [\#2](https://github.com/feathersjs-ecosystem/feathers-memory/issues/2) - Need to return proper errors [\#1](https://github.com/feathersjs-ecosystem/feathers-memory/issues/1) ## [0.3.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/0.3.0) (2014-06-05) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/0.2.1...0.3.0) ## [0.2.1](https://github.com/feathersjs-ecosystem/feathers-memory/tree/0.2.1) (2014-06-04) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/0.2.0...0.2.1) ## [0.2.0](https://github.com/feathersjs-ecosystem/feathers-memory/tree/0.2.0) (2014-04-22) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/0.1.2...0.2.0) ## [0.1.2](https://github.com/feathersjs-ecosystem/feathers-memory/tree/0.1.2) (2014-04-11) [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-memory/compare/0.1.1...0.1.2) ## [0.1.1](https://github.com/feathersjs-ecosystem/feathers-memory/tree/0.1.1) (2014-04-11) \* _This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)_ ================================================ FILE: packages/memory/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/memory/README.md ================================================ # @feathersjs/memory [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/memory.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/memory) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > A Feathers service adapter for in-memory data storage that works on all platforms. ## Installation ```bash $ npm install --save @feathersjs/memory ``` ## Documentation See [FeathersJS Memory Adapter API documentation](https://feathersjs.com/api/databases/memory.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/memory/package.json ================================================ { "name": "@feathersjs/memory", "description": "An in memory service store", "version": "5.0.42", "homepage": "https://github.com/feathersjs/feathers", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/memory" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "_templates/**", "src/**", "lib/**", "*.js" ], "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**/*.test.ts" }, "publishConfig": { "access": "public" }, "directories": { "lib": "lib" }, "dependencies": { "@feathersjs/adapter-commons": "^5.0.42", "@feathersjs/errors": "^5.0.42", "sift": "^17.1.3" }, "devDependencies": { "@feathersjs/adapter-tests": "^5.0.42", "@feathersjs/feathers": "^5.0.42", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "mocha": "^11.7.5", "shx": "^0.4.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/memory/src/index.ts ================================================ import { BadRequest, MethodNotAllowed, NotFound } from '@feathersjs/errors' import { sorter, select, AdapterBase, AdapterServiceOptions, PaginationOptions, AdapterParams } from '@feathersjs/adapter-commons' import sift from 'sift' import { NullableId, Id, Params, Paginated } from '@feathersjs/feathers' export interface MemoryServiceStore { [key: string]: T } export interface MemoryServiceOptions extends AdapterServiceOptions { store?: MemoryServiceStore startId?: number matcher?: (query: any) => any sorter?: (sort: any) => any } const _select = (data: any, params: any, ...args: string[]) => { const base = select(params, ...args) return base(JSON.parse(JSON.stringify(data))) } export class MemoryAdapter< Result = any, Data = Partial, ServiceParams extends Params = Params, PatchData = Partial > extends AdapterBase> { store: MemoryServiceStore _uId: number constructor(options: MemoryServiceOptions = {}) { super({ id: 'id', matcher: sift, sorter, store: {}, startId: 0, ...options }) this._uId = this.options.startId this.store = { ...this.options.store } } async getEntries(_params?: ServiceParams) { const params = _params || ({} as ServiceParams) return this._find({ ...params, paginate: false }) } getQuery(params: ServiceParams) { const { $skip, $sort, $limit, $select, ...query } = params.query || {} return { query, filters: { $skip, $sort, $limit, $select } } } async _find(_params?: ServiceParams & { paginate?: PaginationOptions }): Promise> async _find(_params?: ServiceParams & { paginate: false }): Promise async _find(_params?: ServiceParams): Promise | Result[]> async _find(params: ServiceParams = {} as ServiceParams): Promise | Result[]> { const { paginate } = this.getOptions(params) const { query, filters } = this.getQuery(params) let values = Object.values(this.store) const hasSkip = filters.$skip !== undefined const hasSort = filters.$sort !== undefined const hasLimit = filters.$limit !== undefined const hasQuery = Object.keys(query).length > 0 if (hasSort) { values.sort(this.options.sorter(filters.$sort)) } if (paginate) { if (hasQuery) { values = values.filter(this.options.matcher(query)) } const total = values.length if (hasSkip) { values = values.slice(filters.$skip) } if (hasLimit) { values = values.slice(0, filters.$limit) } const result: Paginated = { total, limit: filters.$limit, skip: filters.$skip || 0, data: values.map((value) => _select(value, params, this.id)) } return result } /* Without pagination, we don't have to match every result and gain considerable performance improvements with a breaking for loop. */ if (hasQuery || hasLimit || hasSkip) { let skipped = 0 const matcher = this.options.matcher(query) const matched = [] if (hasLimit && filters.$limit === 0) { return [] } for (let index = 0, length = values.length; index < length; index++) { const value = values[index] if (hasQuery && !matcher(value, index, values)) { continue } if (hasSkip && filters.$skip > skipped) { skipped++ continue } matched.push(_select(value, params, this.id)) if (hasLimit && filters.$limit === matched.length) { break } } return matched } return values.map((value) => _select(value, params, this.id)) } async _get(id: Id, params: ServiceParams = {} as ServiceParams): Promise { const { query } = this.getQuery(params) if (id in this.store) { const value = this.store[id] if (this.options.matcher(query)(value)) { return _select(value, params, this.id) } } throw new NotFound(`No record found for id '${id}'`) } async _create(data: Partial, params?: ServiceParams): Promise async _create(data: Partial[], params?: ServiceParams): Promise async _create(data: Partial | Partial[], _params?: ServiceParams): Promise async _create( data: Partial | Partial[], params: ServiceParams = {} as ServiceParams ): Promise { if (Array.isArray(data)) { return Promise.all(data.map((current) => this._create(current, params))) } const id = (data as any)[this.id] || this._uId++ const current = { ...data, [this.id]: id } const result = (this.store[id] = current as any) return _select(result, params, this.id) as Result } async _update(id: Id, data: Data, params: ServiceParams = {} as ServiceParams): Promise { if (id === null || Array.isArray(data)) { throw new BadRequest("You can not replace multiple instances. Did you mean 'patch'?") } const oldEntry = await this._get(id, params) this.store[id] = { ...data, [this.id]: (oldEntry as any)[this.id] } as Result return this._get(id, params) } async _patch(id: null, data: PatchData | Partial, params?: ServiceParams): Promise async _patch(id: Id, data: PatchData | Partial, params?: ServiceParams): Promise async _patch( id: NullableId, data: PatchData | Partial, _params?: ServiceParams ): Promise async _patch( id: NullableId, data: PatchData | Partial, params: ServiceParams = {} as ServiceParams ): Promise { if (id === null && !this.allowsMulti('patch', params)) { throw new MethodNotAllowed('Can not patch multiple entries') } const { query } = this.getQuery(params) const patchEntry = (entry: Result) => { const currentId = (entry as any)[this.id] this.store[currentId] = { ...this.store[currentId], ...data, [this.id]: (entry as any)[this.id] } return _select(this.store[currentId], params, this.id) } if (id === null) { const entries = await this.getEntries({ ...params, query }) return entries.map(patchEntry) } return patchEntry(await this._get(id, params)) // Will throw an error if not found } async _remove(id: null, params?: ServiceParams): Promise async _remove(id: Id, params?: ServiceParams): Promise async _remove(id: NullableId, _params?: ServiceParams): Promise async _remove(id: NullableId, params: ServiceParams = {} as ServiceParams): Promise { if (id === null && !this.allowsMulti('remove', params)) { throw new MethodNotAllowed('Can not remove multiple entries') } const { query } = this.getQuery(params) if (id === null) { const entries = await this.getEntries({ ...params, query }) return Promise.all(entries.map((current: any) => this._remove(current[this.id] as Id, params))) } const entry = await this._get(id, params) delete this.store[id] return entry } } export class MemoryService< Result = any, Data = Partial, ServiceParams extends AdapterParams = AdapterParams, PatchData = Partial > extends MemoryAdapter { async find(params?: ServiceParams & { paginate?: PaginationOptions }): Promise> async find(params?: ServiceParams & { paginate: false }): Promise async find(params?: ServiceParams): Promise | Result[]> async find(params?: ServiceParams): Promise | Result[]> { return this._find({ ...params, query: await this.sanitizeQuery(params) }) } async get(id: Id, params?: ServiceParams): Promise { return this._get(id, { ...params, query: await this.sanitizeQuery(params) }) } async create(data: Data, params?: ServiceParams): Promise async create(data: Data[], params?: ServiceParams): Promise async create(data: Data | Data[], params?: ServiceParams): Promise { if (Array.isArray(data) && !this.allowsMulti('create', params)) { throw new MethodNotAllowed('Can not create multiple entries') } return this._create(data, params) } async update(id: Id, data: Data, params?: ServiceParams): Promise { return this._update(id, data, { ...params, query: await this.sanitizeQuery(params) }) } async patch(id: Id, data: PatchData, params?: ServiceParams): Promise async patch(id: null, data: PatchData, params?: ServiceParams): Promise async patch(id: NullableId, data: PatchData, params?: ServiceParams): Promise { const { $limit, ...query } = await this.sanitizeQuery(params) return this._patch(id, data, { ...params, query }) } async remove(id: Id, params?: ServiceParams): Promise async remove(id: null, params?: ServiceParams): Promise async remove(id: NullableId, params?: ServiceParams): Promise { const { $limit, ...query } = await this.sanitizeQuery(params) return this._remove(id, { ...params, query }) } } export function memory, P extends Params = Params>( options: Partial> = {} ) { return new MemoryService(options) } ================================================ FILE: packages/memory/test/index.test.ts ================================================ import assert from 'assert' import adapterTests from '@feathersjs/adapter-tests' import errors from '@feathersjs/errors' import { feathers } from '@feathersjs/feathers' import { MemoryService } from '../src' const testSuite = adapterTests([ '.options', '.events', '._get', '._find', '._create', '._update', '._patch', '._remove', '.get', '.get + $select', '.get + id + query', '.get + NotFound', '.get + id + query id', '.find', '.find + paginate + query', '.remove', '.remove + $select', '.remove + id + query', '.remove + multi', '.remove + multi no pagination', '.remove + id + query id', '.update', '.update + $select', '.update + id + query', '.update + NotFound', '.update + id + query id', '.update + query + NotFound', '.patch', '.patch + $select', '.patch + id + query', '.patch multiple', '.patch multiple no pagination', '.patch multi query same', '.patch multi query changed', '.patch + query + NotFound', '.patch + NotFound', '.patch + id + query id', '.create', '.create + $select', '.create multi', 'internal .find', 'internal .get', 'internal .create', 'internal .update', 'internal .patch', 'internal .remove', '.find + equal', '.find + equal multiple', '.find + $sort', '.find + $sort + string', '.find + $limit', '.find + $limit 0', '.find + $skip', '.find + $select', '.find + $or', '.find + $in', '.find + $nin', '.find + $lt', '.find + $lte', '.find + $gt', '.find + $gte', '.find + $ne', '.find + $gt + $lt + $sort', '.find + $or nested + $sort', '.find + paginate', '.find + paginate + $limit + $skip', '.find + paginate + $limit 0', '.find + paginate + params', 'params.adapter + paginate', 'params.adapter + multi' ]) describe('Feathers Memory Service', () => { type Person = { id: number name: string age: number } type Animal = { type: string age: number } const events = ['testing'] const app = feathers<{ people: MemoryService 'people-paginate': MemoryService 'people-customid': MemoryService animals: MemoryService matcher: MemoryService }>() app.use( 'people', new MemoryService({ events }) ) app.use( 'people-paginate', new MemoryService({ events, multi: true, paginate: { default: 10, max: 100 } }) ) app.use( 'people-customid', new MemoryService({ id: 'customid', events }) ) it('update with string id works', async () => { const people = app.service('people') const person = await people.create({ name: 'Tester', age: 33 }) const updatedPerson: any = await people.update(person.id.toString(), person) assert.strictEqual(typeof updatedPerson.id, 'number') await people.remove(person.id.toString()) }) it('patch record with prop also in query', async () => { app.use('animals', new MemoryService({ multi: true })) const animals = app.service('animals') await animals.create([ { type: 'cat', age: 30 }, { type: 'dog', age: 10 } ]) const [updated] = await animals.patch(null, { age: 40 }, { query: { age: 30 } }) assert.strictEqual(updated.age, 40) await animals.remove(null, {}) }) it('allows to pass custom find and sort matcher', async () => { let sorterCalled = false let matcherCalled = false app.use( 'matcher', new MemoryService({ matcher() { matcherCalled = true return function () { return true } }, sorter() { sorterCalled = true return function () { return 0 } } }) ) await app.service('matcher').find({ query: { something: 1, $sort: { something: 1 } } }) assert.ok(sorterCalled, 'sorter called') assert.ok(matcherCalled, 'matcher called') }) it('does not modify the original data', async () => { const people = app.service('people') const person = await people.create({ name: 'Delete tester', age: 33 }) delete person.age const otherPerson = await people.get(person.id) assert.strictEqual(otherPerson.age, 33) await people.remove(person.id) }) it('update with null throws error', async () => { try { await app.service('people').update(null, {}) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.message, "You can not replace multiple instances. Did you mean 'patch'?") } }) it('use $select as only query property', async () => { const people = app.service('people') const person = await people.create({ name: 'Tester', age: 42 }) const results = await people.find({ paginate: false, query: { $select: ['name'] } }) assert.deepStrictEqual(results[0], { id: person.id, name: 'Tester' }) await people.remove(person.id) }) it('using $limit still returns correct total', async () => { const service = app.service('people-paginate') for (let i = 0; i < 10; i++) { await service.create({ name: `Tester ${i}`, age: 19 }) await service.create({ name: `Tester ${i}`, age: 20 }) } try { const results = await service.find({ query: { $skip: 3, $limit: 5, age: 19 } }) assert.strictEqual(results.total, 10) assert.strictEqual(results.skip, 3) assert.strictEqual(results.limit, 5) } finally { await service.remove(null, { query: { age: { $in: [19, 20] } } }) } }) testSuite(app, errors, 'people') testSuite(app, errors, 'people-customid', 'customid') }) ================================================ FILE: packages/memory/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/mongodb/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - **mongodb:** Ensure arbitrary objects can't be passed as MongoDB ids ([#3664](https://github.com/feathersjs/feathers/issues/3664)) ([163e664](https://github.com/feathersjs/feathers/commit/163e664f231a57041034c852b80525fc5c8cf68d)) - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) - **mongodb:** Fix mongo count ([#3541](https://github.com/feathersjs/feathers/issues/3541)) ([3e95c7d](https://github.com/feathersjs/feathers/commit/3e95c7df6ae7de6a3a406dfb61dd044ea905456f)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) ### Bug Fixes - **mongodb:** Added Update Method Prototype to MongoDBService Class ([#3494](https://github.com/feathersjs/feathers/issues/3494)) ([428f23a](https://github.com/feathersjs/feathers/commit/428f23a8c622cd8bc4d06253206aadd514267846)) - **mongodb:** MongoDB Aggregation improvements ([#3366](https://github.com/feathersjs/feathers/issues/3366)) ([f2829b1](https://github.com/feathersjs/feathers/commit/f2829b1f8e33d13caae3557d37225d990467fb39)) ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) ### Bug Fixes - allow \_patch to modify the entire base schema ([#3300](https://github.com/feathersjs/feathers/issues/3300)) ([0f41622](https://github.com/feathersjs/feathers/commit/0f41622307589b3a0b62ac411a73e6a601bda171)) ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/mongodb ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) ### Bug Fixes - **mongodb:** Speed up multi create ([#3171](https://github.com/feathersjs/feathers/issues/3171)) ([e34f728](https://github.com/feathersjs/feathers/commit/e34f728139a1008503aa440f1b7cf6395719417b)) ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) - **mongodb:** Add MongoDB as peerDependency ([#3148](https://github.com/feathersjs/feathers/issues/3148)) ([0137b40](https://github.com/feathersjs/feathers/commit/0137b40fb694fa95e3b7b7ad41504831b894d977)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) ### Bug Fixes - **memory/mongodb:** $select as only property & force 'id' in '$select' ([#3081](https://github.com/feathersjs/feathers/issues/3081)) ([fbe3cf5](https://github.com/feathersjs/feathers/commit/fbe3cf5199e102b5aeda2ae33828d5034df3d105)) # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/mongodb # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/mongodb # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) ### Features - **mongodb:** Add Object ID keyword converter and update MongoDB CLI & docs ([#3041](https://github.com/feathersjs/feathers/issues/3041)) ([ca0994e](https://github.com/feathersjs/feathers/commit/ca0994eaecb5a31f310bc980d106834e11f24f41)) # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - **databases:** Ensure that query sanitization is not necessary when using query schemas ([#3022](https://github.com/feathersjs/feathers/issues/3022)) ([dbf514e](https://github.com/feathersjs/feathers/commit/dbf514e85d1508b95c007462a39b3cadd4ff391d)) - **databases:** Improve documentation for adapters and allow dynamic Knex adapter options ([#3019](https://github.com/feathersjs/feathers/issues/3019)) ([66c4b5e](https://github.com/feathersjs/feathers/commit/66c4b5e72000dd03acb57fca1cad4737c85c9c9e)) - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) ### Features - **database:** Add and to the query syntax ([#3021](https://github.com/feathersjs/feathers/issues/3021)) ([00cb0d9](https://github.com/feathersjs/feathers/commit/00cb0d9c302ae951ae007d3d6ceba33e254edd9c)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Bug Fixes - **databases:** Make sure adapter method signatures are exported properly ([#2943](https://github.com/feathersjs/feathers/issues/2943)) ([458d668](https://github.com/feathersjs/feathers/commit/458d66859e256c5854e7590f0b4a11b233fe0374)) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Bug Fixes - **schema:** Check for undefined value in resolveQueryObjectId resolver ([#2914](https://github.com/feathersjs/feathers/issues/2914)) ([d9449fa](https://github.com/feathersjs/feathers/commit/d9449fa835f58fc9cec5f7254c50219494129140)) ### Features - **adapter:** Add patch data type to adapters and refactor AdapterBase usage ([#2906](https://github.com/feathersjs/feathers/issues/2906)) ([9ddc2e6](https://github.com/feathersjs/feathers/commit/9ddc2e6b028f026f939d6af68125847e5c6734b4)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) ### Features - **mongodb:** Add ObjectId resolvers and MongoDB option in the guide ([#2847](https://github.com/feathersjs/feathers/issues/2847)) ([c5c1fba](https://github.com/feathersjs/feathers/commit/c5c1fba5718a63412075cd3838b86b889eb0bd48)) # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/mongodb # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) ### Features - **cli:** Generate full client test suite and improve typed client ([#2788](https://github.com/feathersjs/feathers/issues/2788)) ([57119b6](https://github.com/feathersjs/feathers/commit/57119b6bb2797f7297cf054268a248c093ecd538)) - **cli:** Improve generated schema definitions ([#2783](https://github.com/feathersjs/feathers/issues/2783)) ([474a9fd](https://github.com/feathersjs/feathers/commit/474a9fda2107e9bcf357746320a8e00cda8182b6)) # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) **Note:** Version bump only for package @feathersjs/mongodb # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) - **mongodb:** Ensure transactions are used properly in create ([#2699](https://github.com/feathersjs/feathers/issues/2699)) ([fe22615](https://github.com/feathersjs/feathers/commit/fe22615b7fa17d3c20ac26d6f82097917c9b63f6)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/mongodb # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/mongodb # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/mongodb # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Features - **authentication-local:** Add passwordHash property resolver ([#2660](https://github.com/feathersjs/feathers/issues/2660)) ([b41279b](https://github.com/feathersjs/feathers/commit/b41279b55eea3771a6fa4983a37be2413287bbc6)) - **knex:** Add KnexJS SQL database adapter to core ([#2671](https://github.com/feathersjs/feathers/issues/2671)) ([9380fff](https://github.com/feathersjs/feathers/commit/9380fff58596e8bb90b8bb098d2795b7eadfec20)) # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/mongodb # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/mongodb # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) ### Bug Fixes - **typescript:** Make additional types generic to work with extended types ([#2625](https://github.com/feathersjs/feathers/issues/2625)) ([269fdec](https://github.com/feathersjs/feathers/commit/269fdecc5961092dc8608b3cbe16f433c80bfa96)) # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Features - **mongodb:** Add feathers-mongodb adapter as @feathersjs/mongodb ([#2610](https://github.com/feathersjs/feathers/issues/2610)) ([6d43734](https://github.com/feathersjs/feathers/commit/6d43734a53db02c435cafc52a22dca414e5d0940)) ================================================ FILE: packages/mongodb/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/mongodb/README.md ================================================ # @feathersjs/mongodb [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/mongodb.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/mongodb) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > Feathers MongoDB service adapter ## Installation ``` npm install @feathersjs/mongodb --save ``` ## Documentation Refer to the [Feathers MongoDB adapter documentation](https://feathersjs.com/api/databases/mongodb.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/mongodb/package.json ================================================ { "name": "@feathersjs/mongodb", "description": "Feathers MongoDB service adapter", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 14" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/adapter-commons": "^5.0.42", "@feathersjs/commons": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/feathers": "^5.0.42" }, "peerDependencies": { "mongodb": "^6.19.0" }, "devDependencies": { "@feathersjs/adapter-tests": "^5.0.42", "@feathersjs/schema": "^5.0.42", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "mocha": "^11.7.5", "mongodb-memory-server": "^11.0.1", "shx": "^0.4.0", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/mongodb/src/adapter.ts ================================================ import { ObjectId, Collection, FindOptions, BulkWriteOptions, InsertOneOptions, DeleteOptions, CountDocumentsOptions, ReplaceOptions, FindOneAndReplaceOptions, FindOneAndUpdateOptions, Document, FindOneAndDeleteOptions } from 'mongodb' import { BadRequest, MethodNotAllowed, NotFound } from '@feathersjs/errors' import { _ } from '@feathersjs/commons' import { AdapterBase, AdapterParams, AdapterServiceOptions, PaginationOptions, AdapterQuery, getLimit } from '@feathersjs/adapter-commons' import { Id, Paginated } from '@feathersjs/feathers' import { errorHandler } from './error-handler' export interface MongoDBAdapterOptions extends AdapterServiceOptions { Model: Collection | Promise disableObjectify?: boolean useEstimatedDocumentCount?: boolean /** * A list of MongoDB update operators to block in `patch` data. * Defaults to `['$rename']`. Any `$`-prefixed key in this list will be * silently dropped from the update. */ disabledOperators?: string[] } export interface MongoDBAdapterParams extends AdapterParams< Q, Partial > { pipeline?: Document[] mongodb?: | BulkWriteOptions | FindOptions | InsertOneOptions | DeleteOptions | CountDocumentsOptions | ReplaceOptions | FindOneAndReplaceOptions | FindOneAndDeleteOptions } export type AdapterId = Id | ObjectId export type NullableAdapterId = AdapterId | null // Create the service. export class MongoDbAdapter< Result, Data = Partial, ServiceParams extends MongoDBAdapterParams = MongoDBAdapterParams, PatchData = Partial > extends AdapterBase { constructor(options: MongoDBAdapterOptions) { if (!options) { throw new Error('MongoDB options have to be provided') } super({ id: '_id', ...options }) } getObjectId(id: AdapterId) { if (this.options.disableObjectify) { return id } if (this.id === '_id' && ObjectId.isValid(id as string)) { id = new ObjectId(id.toString()) } return id } filterQuery(id: NullableAdapterId, params: ServiceParams) { const options = this.getOptions(params) const { $select, $sort, $limit: _limit, $skip = 0, ...query } = (params.query || {}) as AdapterQuery const $limit = getLimit(_limit, options.paginate) if (id !== null) { if (typeof id !== 'string' && typeof id !== 'number' && !(id instanceof ObjectId)) { throw new BadRequest(`Invalid id '${JSON.stringify(id)}'`) } query.$and = (query.$and || []).concat({ [this.id]: this.getObjectId(id) }) } if (query[this.id]) { query[this.id] = this.getObjectId(query[this.id]) } return { filters: { $select, $sort, $limit, $skip }, query } } getModel(params: ServiceParams = {} as ServiceParams) { const { Model } = this.getOptions(params) return Promise.resolve(Model) } async findRaw(params: ServiceParams) { const { filters, query } = this.filterQuery(null, params) const model = await this.getModel(params) const q = model.find(query, params.mongodb) if (filters.$sort !== undefined) { q.sort(filters.$sort) } if (filters.$select !== undefined) { q.project(this.getProjection(filters.$select)) } if (filters.$skip !== undefined) { q.skip(filters.$skip) } if (filters.$limit !== undefined) { q.limit(filters.$limit) } return q } /* TODO: Remove $out and $merge stages, else it returns an empty cursor. I think its safe to assume this is primarily for querying. */ async aggregateRaw(params: ServiceParams) { const model = await this.getModel(params) const pipeline = params.pipeline || [] const index = pipeline.findIndex((stage: Document) => stage.$feathers) const before = index >= 0 ? pipeline.slice(0, index) : [] const feathersPipeline = this.makeFeathersPipeline(params) const after = index >= 0 ? pipeline.slice(index + 1) : pipeline return model.aggregate([...before, ...feathersPipeline, ...after], params.mongodb) } makeFeathersPipeline(params: ServiceParams) { const { filters, query } = this.filterQuery(null, params) const pipeline: Document[] = [{ $match: query }] if (filters.$sort !== undefined) { pipeline.push({ $sort: filters.$sort }) } if (filters.$skip !== undefined) { pipeline.push({ $skip: filters.$skip }) } if (filters.$limit !== undefined) { pipeline.push({ $limit: filters.$limit }) } if (filters.$select !== undefined) { pipeline.push({ $project: this.getProjection(filters.$select) }) } return pipeline } getProjection(select?: string[] | { [key: string]: number }) { if (!select) { return undefined } if (Array.isArray(select)) { if (!select.includes(this.id)) { select = [this.id, ...select] } return select.reduce<{ [key: string]: number }>( (value, name) => ({ ...value, [name]: 1 }), {} ) } if (!select[this.id]) { return { ...select, [this.id]: 1 } } return select } normalizeId(id: NullableAdapterId, data: D): D { if (this.id === '_id') { // Default Mongo IDs cannot be updated. The Mongo library handles // this automatically. return _.omit(data, this.id) } else if (id !== null) { // If not using the default Mongo _id field set the ID to its // previous value. This prevents orphaned documents. return { ...data, [this.id]: id } } return data } async countDocuments(params: ServiceParams) { const { useEstimatedDocumentCount } = this.getOptions(params) const { query } = this.filterQuery(null, params) if (params.pipeline) { const aggregateParams = { ...params, paginate: false, pipeline: [...params.pipeline, { $count: 'total' }], query: { ...params.query, $select: [this.id], $sort: undefined, $skip: undefined, $limit: undefined } } const [result] = await this.aggregateRaw(aggregateParams).then((result) => result.toArray()) if (!result) { return 0 } return result.total } const model = await this.getModel(params) if (useEstimatedDocumentCount && typeof model.estimatedDocumentCount === 'function') { return model.estimatedDocumentCount() } return model.countDocuments(query, params.mongodb) } async _get(id: AdapterId, params: ServiceParams = {} as ServiceParams): Promise { const { query, filters: { $select } } = this.filterQuery(id, params) if (params.pipeline) { const aggregateParams = { ...params, query: { ...params.query, $limit: 1, $and: (params.query.$and || []).concat({ [this.id]: this.getObjectId(id) }) } } return this.aggregateRaw(aggregateParams) .then((result) => result.toArray()) .then(([result]) => { if (!result) { throw new NotFound(`No record found for id '${id}'`) } return result }) .catch(errorHandler) } const findOptions: FindOptions = { projection: this.getProjection($select), ...params.mongodb } return this.getModel(params) .then((model) => model.findOne(query, findOptions)) .then((result) => { if (!result) { throw new NotFound(`No record found for id '${id}'`) } return result }) .catch(errorHandler) } async _find(params?: ServiceParams & { paginate?: PaginationOptions }): Promise> async _find(params?: ServiceParams & { paginate: false }): Promise async _find(params?: ServiceParams): Promise | Result[]> async _find(params: ServiceParams = {} as ServiceParams): Promise | Result[]> { const { paginate } = this.getOptions(params) const { filters } = this.filterQuery(null, params) const paginationDisabled = params.paginate === false || !paginate || !paginate.default const getData = () => { const result = params.pipeline ? this.aggregateRaw(params) : this.findRaw(params) return result.then((result) => result.toArray()) } if (paginationDisabled) { if (filters.$limit === 0) { return [] as Result[] } const data = await getData() return data as Result[] } if (filters.$limit === 0) { return { total: await this.countDocuments(params), data: [] as Result[], limit: filters.$limit, skip: filters.$skip || 0 } } const [data, total] = await Promise.all([getData(), this.countDocuments(params)]) return { total, data: data as Result[], limit: filters.$limit, skip: filters.$skip || 0 } } async _create(data: Data, params?: ServiceParams): Promise async _create(data: Data[], params?: ServiceParams): Promise async _create(data: Data | Data[], _params?: ServiceParams): Promise async _create( data: Data | Data[], params: ServiceParams = {} as ServiceParams ): Promise { if (Array.isArray(data) && !this.allowsMulti('create', params)) { throw new MethodNotAllowed('Can not create multiple entries') } const model = await this.getModel(params) const setId = (item: any) => { const entry = Object.assign({}, item) if (this.id !== '_id' && typeof entry[this.id] === 'undefined') { return { [this.id]: new ObjectId().toHexString(), ...entry } } return entry } if (Array.isArray(data)) { const created = await model.insertMany(data.map(setId), params.mongodb).catch(errorHandler) return this._find({ ...params, paginate: false, query: { _id: { $in: Object.values(created.insertedIds) }, $select: params.query?.$select } }) } const created = await model.insertOne(setId(data), params.mongodb).catch(errorHandler) const result = await this._find({ ...params, paginate: false, query: { _id: created.insertedId, $select: params.query?.$select, $limit: 1 } }) return result[0] } async _patch(id: null, data: PatchData | Partial, params?: ServiceParams): Promise async _patch(id: AdapterId, data: PatchData | Partial, params?: ServiceParams): Promise async _patch( id: NullableAdapterId, data: PatchData | Partial, _params?: ServiceParams ): Promise async _patch( id: NullableAdapterId, _data: PatchData | Partial, params: ServiceParams = {} as ServiceParams ): Promise { if (id === null && !this.allowsMulti('patch', params)) { throw new MethodNotAllowed('Can not patch multiple entries') } const data = this.normalizeId(id, _data) const model = await this.getModel(params) const { query, filters: { $sort, $select } } = this.filterQuery(id, params) const disabledOperators = this.getOptions(params).disabledOperators || ['$rename'] const replacement = Object.keys(data).reduce( (current, key) => { const value = (data as any)[key] if (key.charAt(0) !== '$') { current.$set[key] = value } else if (key === '$set') { current.$set = { ...current.$set, ...value } } else if (!disabledOperators.includes(key)) { current[key] = value } return current }, { $set: {} } as any ) if (id === null) { const findParams = { ...params, paginate: false, query: { ...params.query, $select: [this.id] } } return this._find(findParams) .then(async (result) => { const idList = (result as Result[]).map((item: any) => item[this.id]) await model.updateMany({ [this.id]: { $in: idList } }, replacement, params.mongodb) return this._find({ ...params, paginate: false, query: { [this.id]: { $in: idList }, $sort, $select } }) }) .catch(errorHandler) } if (params.pipeline) { const getParams = { ...params, query: { ...params.query, $select: [this.id] } } return this._get(id, getParams) .then(async () => { await model.updateOne({ [this.id]: id }, replacement, params.mongodb) return this._get(id, { ...params, query: { $select } }) }) .catch(errorHandler) } const updateOptions: FindOneAndUpdateOptions = { projection: this.getProjection($select), ...(params.mongodb as FindOneAndUpdateOptions), returnDocument: 'after' } return model .findOneAndUpdate(query, replacement, updateOptions) .then((result) => { if (!result) { throw new NotFound(`No record found for id '${id}'`) } return result as Result }) .catch(errorHandler) } async _update(id: AdapterId, data: Data, params: ServiceParams = {} as ServiceParams): Promise { if (id === null || Array.isArray(data)) { throw new BadRequest("You can not replace multiple instances. Did you mean 'patch'?") } const { query, filters: { $select } } = this.filterQuery(id, params) const model = await this.getModel(params) const replacement = this.normalizeId(id, data) if (params.pipeline) { const getParams = { ...params, query: { ...params.query, $select: [this.id] } } return this._get(id, getParams) .then(async () => { await model.replaceOne({ [this.id]: id }, replacement, params.mongodb) return this._get(id, { ...params, query: { $select } }) }) .catch(errorHandler) } const replaceOptions: FindOneAndReplaceOptions = { projection: this.getProjection($select), ...(params.mongodb as FindOneAndReplaceOptions), returnDocument: 'after' } return model .findOneAndReplace(query, replacement, replaceOptions) .then((result) => { if (!result) { throw new NotFound(`No record found for id '${id}'`) } return result as Result }) .catch(errorHandler) } async _remove(id: null, params?: ServiceParams): Promise async _remove(id: AdapterId, params?: ServiceParams): Promise async _remove(id: NullableAdapterId, _params?: ServiceParams): Promise async _remove( id: NullableAdapterId | ObjectId, params: ServiceParams = {} as ServiceParams ): Promise { if (id === null && !this.allowsMulti('remove', params)) { throw new MethodNotAllowed('Can not remove multiple entries') } const model = await this.getModel(params) const { query } = this.filterQuery(id, params) const findParams = { ...params, paginate: false } if (id === null) { return this._find(findParams) .then(async (result) => { const idList = (result as Result[]).map((item: any) => item[this.id]) await model.deleteMany({ [this.id]: { $in: idList } }, params.mongodb) return result }) .catch(errorHandler) } if (params.pipeline) { return this._get(id, params) .then(async (result) => { await model.deleteOne({ [this.id]: id }, params.mongodb) return result }) .catch(errorHandler) } const deleteOptions: FindOneAndDeleteOptions = { ...(params.mongodb as FindOneAndDeleteOptions), projection: this.getProjection(params.query?.$select) } return model .findOneAndDelete(query, deleteOptions) .then((result) => { if (!result) { throw new NotFound(`No record found for id '${id}'`) } return result as Result }) .catch(errorHandler) } } ================================================ FILE: packages/mongodb/src/converters.ts ================================================ import { ObjectId } from 'mongodb' export type ObjectIdParam = string | number | ObjectId export type IdQueryObject = { $in?: T[] $nin?: T[] $ne?: T } const toObjectId = (value: ObjectIdParam) => new ObjectId(value as string) export async function resolveObjectId(value: ObjectIdParam) { return toObjectId(value) } export async function resolveQueryObjectId( value: IdQueryObject ): Promise> export async function resolveQueryObjectId(value: ObjectIdParam): Promise export async function resolveQueryObjectId(value: ObjectIdParam | IdQueryObject) { if (!value) { return undefined } if (typeof value === 'string' || typeof value === 'number' || value instanceof ObjectId) { return toObjectId(value) } const convertedObject: IdQueryObject = {} if (Array.isArray(value.$in)) { convertedObject.$in = value.$in.map(toObjectId) } if (Array.isArray(value.$nin)) { convertedObject.$nin = value.$nin.map(toObjectId) } if (value.$ne !== undefined) { convertedObject.$ne = toObjectId(value.$ne) } return convertedObject } export const keywordObjectId = { keyword: 'objectid', type: 'string', modifying: true, compile(schemaVal: boolean) { if (!schemaVal) return () => true return function (value: string, obj: any) { const { parentData, parentDataProperty } = obj try { parentData[parentDataProperty] = new ObjectId(value) return true } catch (error) { throw new Error(`invalid objectid for property "${parentDataProperty}"`) } } } } as const ================================================ FILE: packages/mongodb/src/error-handler.ts ================================================ import { GeneralError } from '@feathersjs/errors' import { MongoError } from 'mongodb' export function errorHandler(error: MongoError): any { // See https://github.com/mongodb/mongo/blob/master/docs/errors.md if (error && error.name && error.name.startsWith('Mongo')) { throw new GeneralError(error, { name: error.name, code: error.code }) } throw error } ================================================ FILE: packages/mongodb/src/index.ts ================================================ import { PaginationOptions } from '@feathersjs/adapter-commons' import { MethodNotAllowed } from '@feathersjs/errors/lib' import { Paginated, Params } from '@feathersjs/feathers' import { AdapterId, MongoDbAdapter, MongoDBAdapterParams, NullableAdapterId } from './adapter' export * from './adapter' export * from './error-handler' export * from './converters' export class MongoDBService< Result = any, Data = Partial, ServiceParams extends Params = MongoDBAdapterParams, PatchData = Partial > extends MongoDbAdapter { async find(params?: ServiceParams & { paginate?: PaginationOptions }): Promise> async find(params?: ServiceParams & { paginate: false }): Promise async find(params?: ServiceParams): Promise | Result[]> async find(params?: ServiceParams): Promise | Result[]> { return this._find({ ...params, query: await this.sanitizeQuery(params) }) } async get(id: AdapterId, params?: ServiceParams): Promise { return this._get(id, { ...params, query: await this.sanitizeQuery(params) }) } async create(data: Data, params?: ServiceParams): Promise async create(data: Data[], params?: ServiceParams): Promise async create(data: Data | Data[], params?: ServiceParams): Promise async create(data: Data | Data[], params?: ServiceParams): Promise { if (Array.isArray(data) && !this.allowsMulti('create', params)) { throw new MethodNotAllowed('Can not create multiple entries') } return this._create(data, params) } async update(id: NullableAdapterId, data: Data, params?: ServiceParams): Promise async update(id: AdapterId, data: Data, params?: ServiceParams): Promise { return this._update(id, data, { ...params, query: await this.sanitizeQuery(params) }) } async patch(id: null, data: PatchData, params?: ServiceParams): Promise async patch(id: AdapterId, data: PatchData, params?: ServiceParams): Promise async patch(id: NullableAdapterId, data: PatchData, params?: ServiceParams): Promise async patch(id: NullableAdapterId, data: PatchData, params?: ServiceParams): Promise { const { $limit, ...query } = await this.sanitizeQuery(params) return this._patch(id, data, { ...params, query }) } async remove(id: AdapterId, params?: ServiceParams): Promise async remove(id: null, params?: ServiceParams): Promise async remove(id: NullableAdapterId, params?: ServiceParams): Promise async remove(id: NullableAdapterId, params?: ServiceParams): Promise { const { $limit, ...query } = await this.sanitizeQuery(params) return this._remove(id, { ...params, query }) } } ================================================ FILE: packages/mongodb/test/converters.test.ts ================================================ import { Ajv } from '@feathersjs/schema' import assert from 'assert' import { ObjectId } from 'mongodb' import { keywordObjectId, resolveObjectId, resolveQueryObjectId } from '../src' describe('ObjectId resolvers', () => { it('resolveObjectId', async () => { const oid = await resolveObjectId('5f9e3c1b9b9b9b9b9b9b9b9b') assert.ok(oid instanceof ObjectId) }) it('resolveQueryObjectId', async () => { const oid = await resolveQueryObjectId('5f9e3c1b9b9b9b9b9b9b9b9b') assert.ok(oid instanceof ObjectId) }) it('resolveQueryObjectId with object', async () => { const oids = await resolveQueryObjectId({ $in: ['5f9e3c1b9b9b9b9b9b9b9b9b'], $ne: '5f9e3c1b9b9b9b9b9b9b9b9a' }) assert.ok(oids.$in && oids.$in[0] instanceof ObjectId) assert.ok(oids.$ne instanceof ObjectId) }) it('resolveQueryObjectId with falsey value', async () => { await resolveQueryObjectId(undefined) await resolveQueryObjectId(null) await resolveQueryObjectId(0) assert.ok('Falsey value does not throw exception') }) }) const validator = new Ajv({ coerceTypes: true }) validator.addKeyword(keywordObjectId) describe('objectid keyword', () => { it('converts objectid strings when keyword is used', async () => { const schema = { type: 'object', properties: { _id: { type: 'string', objectid: true }, otherId: { type: 'string', objectid: true } }, additionalProperties: false } const validate = validator.compile(schema) const data = { _id: '622585621f3996763f1e4444', otherId: '622585621f3996763f1e5555' } assert.equal(typeof data._id, 'string') assert.equal(typeof data.otherId, 'string') // runs converters validate(data) assert.ok((data._id as any) instanceof ObjectId) assert.equal(typeof data.otherId, 'object') }) it('does not convert objectid strings without keyword', async () => { const schema = { type: 'object', properties: { _id: { type: 'string' }, otherId: { type: 'string' } }, additionalProperties: false } const validate = validator.compile(schema) const data = { _id: '622585621f3996763f1e4444', otherId: '622585621f3996763f1e5555' } assert.equal(typeof data._id, 'string') assert.equal(typeof data.otherId, 'string') // runs converters validate(data) assert.equal(typeof data._id, 'string') assert.equal(typeof data.otherId, 'string') }) it('fails on invalid objectids', async () => { const schema = { type: 'object', properties: { _id: { type: 'string', objectid: true } }, additionalProperties: false } const validate = validator.compile(schema) const data = { _id: '622585621f3996763f1e444' } assert.equal(typeof data._id, 'string') assert.throws(() => validate(data), /invalid objectid for property "_id"/) }) }) ================================================ FILE: packages/mongodb/test/index.test.ts ================================================ import { Db, MongoClient, ObjectId } from 'mongodb' import adapterTests from '@feathersjs/adapter-tests' import assert from 'assert' import { MongoMemoryServer } from 'mongodb-memory-server' import { Ajv, FromSchema, getValidator, hooks, querySyntax } from '@feathersjs/schema' import { feathers } from '@feathersjs/feathers' import errors from '@feathersjs/errors' import { MongoDBService, AdapterId } from '../src' const testSuite = adapterTests([ '.options', '.events', '._get', '._find', '._create', '._update', '._patch', '._remove', '.get', '.get + $select', '.get + id + query', '.get + NotFound', '.get + id + query id', '.find', '.find + paginate + query', '.remove', '.remove + $select', '.remove + id + query', '.remove + multi', '.remove + multi no pagination', '.remove + id + query id', '.remove + NotFound', '.update', '.update + $select', '.update + id + query', '.update + NotFound', '.update + id + query id', '.update + query + NotFound', '.patch', '.patch + $select', '.patch + id + query', '.patch multiple', '.patch multiple no pagination', '.patch multi query same', '.patch multi query changed', '.patch + query + NotFound', '.patch + NotFound', '.patch + id + query id', '.create', '.create ignores query', '.create + $select', '.create multi', 'internal .find', 'internal .get', 'internal .create', 'internal .update', 'internal .patch', 'internal .remove', '.find + equal', '.find + equal multiple', '.find + $sort', '.find + $sort + string', '.find + $limit', '.find + $limit 0', '.find + $skip', '.find + $select', '.find + $or', '.find + $and', '.find + $in', '.find + $nin', '.find + $lt', '.find + $lte', '.find + $gt', '.find + $gte', '.find + $ne', '.find + $gt + $lt + $sort', '.find + $or nested + $sort', '.find + $and + $or', '.find + paginate', '.find + paginate + $limit + $skip', '.find + paginate + $limit 0', '.find + paginate + params', 'params.adapter + paginate', 'params.adapter + multi' ]) describe('Feathers MongoDB Service', () => { const personSchema = { $id: 'Person', type: 'object', additionalProperties: false, required: ['_id', 'name', 'age'], properties: { _id: { oneOf: [{ type: 'string' }, { type: 'object' }] }, name: { type: 'string' }, age: { type: 'number' }, friends: { type: 'array', items: { type: 'string' } }, team: { type: 'string' }, $push: { type: 'object', properties: { friends: { type: 'string' } } } } } as const const personQuery = { $id: 'PersonQuery', type: 'object', additionalProperties: false, properties: { ...querySyntax(personSchema.properties, { name: { $regex: { type: 'string' } } }) } } as const const validator = new Ajv({ coerceTypes: true }) const personQueryValidator = getValidator(personQuery, validator) type Person = Omit, '_id'> & { _id: AdapterId } type Todo = { _id: string name: string userId: string person?: Person } type ServiceTypes = { people: MongoDBService 'people-customid': MongoDBService todos: MongoDBService } const app = feathers() let db: Db let mongoClient: MongoClient let mongod: MongoMemoryServer before(async () => { mongod = await MongoMemoryServer.create() const client = await MongoClient.connect(mongod.getUri()) mongoClient = client db = client.db('feathers-test') app.use( 'people', new MongoDBService({ Model: db.collection('people'), events: ['testing'] }) ) app.use( 'people-customid', new MongoDBService({ Model: db.collection('people-customid'), id: 'customid', events: ['testing'] }) ) app.service('people').hooks({ before: { find: [hooks.validateQuery(personQueryValidator)] } }) db.collection('people-customid').deleteMany({}) db.collection('people').deleteMany({}) db.collection('todos').deleteMany({}) db.collection('people').createIndex({ name: 1 }, { partialFilterExpression: { team: 'blue' } }) }) after(async () => { await db.dropDatabase() await mongoClient.close() await mongod.stop() }) describe('Service utility functions', () => { describe('getObjectId', () => { it('returns an ObjectID instance for a valid ID', () => { const id = new ObjectId() const objectify = app.service('people').getObjectId(id.toString()) assert.ok(objectify instanceof ObjectId) assert.strictEqual(objectify.toString(), id.toString()) }) it('returns an ObjectID instance for a valid ID', () => { const id = 'non-valid object id' const objectify = app.service('people').getObjectId(id.toString()) assert.ok(!(objectify instanceof ObjectId)) assert.strictEqual(objectify, id) }) }) }) // For some bizarre reason this test is flaky describe.skip('works with ObjectIds', () => { it('can call methods with ObjectId instance', async () => { const person = await app.service('people').create({ name: 'David' }) const withId = await app.service('people').get(person._id.toString()) assert.strictEqual(withId.name, 'David') await app.service('people').remove(new ObjectId(person._id.toString())) }) }) describe('Special collation param', () => { let peopleService: MongoDBService let people: Person[] function indexOfName(results: Person[], name: string) { let index = 0 for (const person of results) { if (person.name === name) { return index } index++ } return -1 } beforeEach(async () => { peopleService = app.service('people') peopleService.options.multi = true peopleService.options.disableObjectify = true people = await peopleService.create([{ name: 'AAA' }, { name: 'aaa' }, { name: 'ccc' }]) }) afterEach(async () => { peopleService.options.multi = false try { await Promise.all([ peopleService.remove(people[0]._id), peopleService.remove(people[1]._id), peopleService.remove(people[2]._id) ]) } catch (error: unknown) {} }) it('queries for ObjectId in find', async () => { const person = await peopleService.create({ name: 'Coerce' }) const results = await peopleService.find({ paginate: false, query: { _id: new ObjectId(person._id) } }) assert.strictEqual(results.length, 1) await peopleService.remove(person._id) }) it('works with normal string _id', async () => { const person = await peopleService.create({ _id: 'lessonKTDA08', name: 'Coerce' }) const result = await peopleService.get(person._id) assert.strictEqual(result.name, 'Coerce') await peopleService.remove(person._id) }) it('sorts with default behavior without collation param', async () => { const results = await peopleService.find({ paginate: false, query: { $sort: { name: -1 } } }) assert.ok(indexOfName(results, 'aaa') < indexOfName(results, 'AAA')) }) it('sorts using collation param if present', async () => { const results = await peopleService.find({ paginate: false, query: { $sort: { name: -1 } }, mongodb: { collation: { locale: 'en', strength: 1 } } }) assert.ok(indexOfName(results, 'aaa') > indexOfName(results, 'AAA')) }) it('removes with default behavior without collation param', async () => { await peopleService.remove(null, { query: { name: { $gt: 'AAA' } } }) const results = await peopleService.find({ paginate: false }) assert.strictEqual(results.length, 1) assert.strictEqual(results[0].name, 'AAA') }) it('removes using collation param if present', async () => { const removed = await peopleService.remove(null, { query: { name: 'AAA' }, mongodb: { collation: { locale: 'en', strength: 1 } } }) const results = await peopleService.find({ paginate: false }) assert.strictEqual(removed.length, 2) assert.strictEqual(results[0].name, 'ccc') assert.strictEqual(results.length, 1) }) it('handles errors', async () => { await assert.rejects( () => peopleService.create( { name: 'Dave' }, { mongodb: { collation: { locale: 'fdsfdsfds', strength: 1 } } } ), { name: 'GeneralError' } ) }) it('updates with default behavior without collation param', async () => { const query = { name: { $gt: 'AAA' } } const result = await peopleService.patch(null, { age: 99 }, { query }) assert.strictEqual(result.length, 2) result.forEach((person) => { assert.strictEqual(person.age, 99) }) }) it('updates using collation param if present', async () => { const result = await peopleService.patch( null, { age: 110 }, { query: { name: { $gt: 'AAA' } }, mongodb: { collation: { locale: 'en', strength: 1 } } } ) assert.strictEqual(result.length, 1) assert.strictEqual(result[0].name, 'ccc') }) it('pushes to an array using patch', async () => { const result = await peopleService.patch( null, { $push: { friends: 'Adam' } }, { query: { name: { $gt: 'AAA' } } } ) assert.strictEqual(result[0].friends?.length, 1) const patched = await peopleService.patch( null, { $push: { friends: 'Bell' } }, { query: { name: { $gt: 'AAA' } } } ) assert.strictEqual(patched[0].friends?.length, 2) }) it('can use $limit in patch', async () => { const data = { name: 'ddd' } const query = { $limit: 1 } const result = await peopleService._patch(null, data, { query }) assert.strictEqual(result.length, 1) assert.strictEqual(result[0].name, 'ddd') const pipelineResult = await peopleService._patch(null, data, { pipeline: [], query }) assert.strictEqual(pipelineResult.length, 1) assert.strictEqual(pipelineResult[0].name, 'ddd') }) it('can use $limit in remove', async () => { const query = { $limit: 1 } const result = await peopleService._remove(null, { query }) assert.strictEqual(result.length, 1) const pipelineResult = await peopleService._remove(null, { pipeline: [], query }) assert.strictEqual(pipelineResult.length, 1) }) it('can use $sort in patch', async () => { const updated = await peopleService._patch( null, { name: 'ddd' }, { query: { $limit: 1, $sort: { name: -1 } } } ) const result = await peopleService.find({ paginate: false, query: { $limit: 1, $sort: { name: -1 } } }) assert.strictEqual(updated.length, 1) assert.strictEqual(result[0].name, 'ddd') const pipelineUpdated = await peopleService._patch( null, { name: 'eee' }, { pipeline: [], query: { $limit: 1, $sort: { name: -1 } } } ) const pipelineResult = await peopleService.find({ paginate: false, pipeline: [], query: { $limit: 1, $sort: { name: -1 } } }) assert.strictEqual(pipelineUpdated.length, 1) assert.strictEqual(pipelineResult[0].name, 'eee') }) it('can use $sort in remove', async () => { const removed = await peopleService._remove(null, { query: { $limit: 1, $sort: { name: -1 } } }) assert.strictEqual(removed.length, 1) assert.strictEqual(removed[0].name, 'ccc') const pipelineRemoved = await peopleService._remove(null, { pipeline: [], query: { $limit: 1, $sort: { name: -1 } } }) assert.strictEqual(pipelineRemoved.length, 1) assert.strictEqual(pipelineRemoved[0].name, 'aaa') }) it('overrides default index selection using hint param if present', async () => { const indexed = await peopleService.create({ name: 'Indexed', team: 'blue' }) const result = await peopleService.find({ paginate: false, query: {}, mongodb: { hint: { name: 1 } } }) assert.strictEqual(result[0].name, 'Indexed') assert.strictEqual(result.length, 1) await peopleService.remove(indexed._id) }) }) describe('Aggregation', () => { let bob: any let alice: any let doug: any before(async () => { app.use( 'todos', new MongoDBService({ Model: db.collection('todos'), events: ['testing'] }) ) bob = await app.service('people').create({ name: 'Bob', age: 25 }) alice = await app.service('people').create({ name: 'Alice', age: 19 }) doug = await app.service('people').create({ name: 'Doug', age: 32 }) // Create a task for each person await app.service('todos').create({ name: 'Bob do dishes', userId: bob._id }) await app.service('todos').create({ name: 'Bob do laundry', userId: bob._id }) await app.service('todos').create({ name: 'Alice do dishes', userId: alice._id }) await app.service('todos').create({ name: 'Doug do dishes', userId: doug._id }) }) after(async () => { db.collection('people').deleteMany({}) db.collection('todos').deleteMany({}) }) it('assumes the feathers stage runs before all if it is not explicitly provided in pipeline', async () => { const result = await app.service('todos').find({ query: { name: /dishes/, $sort: { name: 1 } }, pipeline: [ { $lookup: { from: 'people', localField: 'userId', foreignField: '_id', as: 'person' } }, { $unwind: { path: '$person' } } ], paginate: false }) assert.deepEqual(result[0].person, alice) assert.deepEqual(result[1].person, bob) assert.deepEqual(result[2].person, doug) }) it('can prepend stages by explicitly placing the feathers stage', async () => { const result = await app.service('todos').find({ query: { $sort: { name: 1 } }, pipeline: [ { $match: { name: 'Bob do dishes' } }, { $feathers: {} }, { $lookup: { from: 'people', localField: 'userId', foreignField: '_id', as: 'person' } }, { $unwind: { path: '$person' } } ], paginate: false }) assert.deepEqual(result[0].person, bob) assert.equal(result.length, 1) }) it('can count documents with aggregation', async () => { const service = app.service('people') const paginateBefore = service.options.paginate const test = async (paginate: any) => { service.options.paginate = paginate const query = { age: { $gte: 25 } } const findResult = await app.service('people').find({ query }) const aggregationResult = await app.service('people').find({ query, pipeline: [] }) assert.deepStrictEqual(findResult.total, aggregationResult.total) } await test({ default: 10, max: 50 }) // There are 2 people with age >= 25. // Test that aggregation works when results are less than default await test({ default: 1, max: 50 }) service.options.paginate = paginateBefore }) it('can use aggregation in _get', async () => { const dave = await app.service('people').create({ name: 'Dave', age: 25 }) const result = await app.service('people').get(dave._id, { pipeline: [{ $addFields: { aggregation: true } }] }) assert.deepStrictEqual(result, { ...dave, aggregation: true }) app.service('people').remove(dave._id) }) it('can use aggregation in _create', async () => { const dave = (await app.service('people').create( { name: 'Dave' }, { pipeline: [{ $addFields: { aggregation: true } }] } )) as any assert.deepStrictEqual(dave.aggregation, true) app.service('people').remove(dave._id) }) it('can use aggregation in multi _create', async () => { app.service('people').options.multi = true const dave = (await app.service('people').create([{ name: 'Dave' }], { pipeline: [{ $addFields: { aggregation: true } }] })) as any assert.deepStrictEqual(dave[0].aggregation, true) app.service('people').options.multi = false app.service('people').remove(dave[0]._id) }) it('can use aggregation in _update', async () => { const dave = await app.service('people').create({ name: 'Dave' }) const result = await app.service('people').update( dave._id, { name: 'Marshal' }, { pipeline: [{ $addFields: { aggregation: true } }] } ) assert.deepStrictEqual(result, { ...dave, name: 'Marshal', aggregation: true }) app.service('people').remove(dave._id) }) it('can use aggregation in _patch', async () => { const dave = await app.service('people').create({ name: 'Dave' }) const result = await app.service('people').patch( dave._id, { name: 'Marshal' }, { pipeline: [{ $addFields: { aggregation: true } }] } ) assert.deepStrictEqual(result, { ...dave, name: 'Marshal', aggregation: true }) app.service('people').remove(dave._id) }) it('can use aggregation in multi _patch', async () => { app.service('people').options.multi = true const dave = await app.service('people').create({ name: 'Dave' }) const result = await app.service('people').patch( null, { name: 'Marshal' }, { query: { _id: dave._id }, pipeline: [{ $addFields: { aggregation: true } }] } ) assert.deepStrictEqual(result[0], { ...dave, name: 'Marshal', aggregation: true }) app.service('people').options.multi = false app.service('people').remove(dave._id) }) it('can use aggregation and query in _update', async () => { const dave = await app.service('people').create({ name: 'Dave' }) const result = await app.service('people').update( dave._id, { name: 'Marshal' }, { query: { name: 'Dave' }, pipeline: [{ $addFields: { aggregation: true } }] } ) assert.deepStrictEqual(result, { ...dave, name: 'Marshal', aggregation: true }) app.service('people').remove(dave._id) }) it('can use aggregation and query in _patch', async () => { const dave = await app.service('people').create({ name: 'Dave' }) const result = await app.service('people').patch( dave._id, { name: 'Marshal' }, { query: { name: 'Dave' }, pipeline: [{ $addFields: { aggregation: true } }] } ) assert.deepStrictEqual(result, { ...dave, name: 'Marshal', aggregation: true }) app.service('people').remove(dave._id) }) it('can use aggregation in _remove', async () => { const dave = await app.service('people').create({ name: 'Dave' }) const result = await app.service('people').remove(dave._id, { pipeline: [{ $addFields: { aggregation: true } }] }) assert.deepStrictEqual(result, { ...dave, aggregation: true }) try { await await app.service('people').get(dave._id) throw new Error('Should never get here') } catch (error: any) { assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error') } }) it('can use aggregation in multi _remove', async () => { app.service('people').options.multi = true const dave = await app.service('people').create({ name: 'Dave' }) const result = await app.service('people').remove(null, { query: { _id: dave._id }, pipeline: [{ $addFields: { aggregation: true } }] }) assert.deepStrictEqual(result[0], { ...dave, aggregation: true }) app.service('people').options.multi = false // app.service('people').remove(dave._id) }) }) describe('query validation', () => { it('validated queries are not sanitized', async () => { const dave = await app.service('people').create({ name: 'Dave' }) const result = await app.service('people').find({ query: { name: { $regex: 'Da.*' } } }) assert.deepStrictEqual(result, [dave]) app.service('people').remove(dave._id) }) }) // TODO: Should this test be part of the adapterTests? describe('Updates mutated query', () => { it('Can re-query mutated data', async () => { const dave = await app.service('people').create({ name: 'Dave' }) const dave2 = await app.service('people').create({ name: 'Dave' }) app.service('people').options.multi = true const updated = await app .service('people') .update(dave._id, { name: 'Marshal' }, { query: { name: 'Dave' } }) assert.deepStrictEqual(updated, { ...dave, name: 'Marshal' }) const patched = await app .service('people') .patch(dave._id, { name: 'Dave' }, { query: { name: 'Marshal' } }) assert.deepStrictEqual(patched, { ...dave, name: 'Dave' }) const updatedPipeline = await app .service('people') .update(dave._id, { name: 'Marshal' }, { query: { name: 'Dave' }, pipeline: [] }) assert.deepStrictEqual(updatedPipeline, { ...dave, name: 'Marshal' }) const patchedPipeline = await app .service('people') .patch(dave._id, { name: 'Dave' }, { query: { name: 'Marshal' }, pipeline: [] }) assert.deepStrictEqual(patchedPipeline, { ...dave, name: 'Dave' }) const multiPatch = await app .service('people') .patch(null, { name: 'Marshal' }, { query: { name: 'Dave' } }) assert.deepStrictEqual(multiPatch, [ { ...dave, name: 'Marshal' }, { ...dave2, name: 'Marshal' } ]) const multiPatchPipeline = await app .service('people') .patch(null, { name: 'Dave' }, { query: { name: 'Marshal' }, pipeline: [] }) assert.deepStrictEqual(multiPatchPipeline, [ { ...dave, name: 'Dave' }, { ...dave2, name: 'Dave' } ]) app.service('people').options.multi = false app.service('people').remove(dave._id) app.service('people').remove(dave2._id) }) }) describe('disabledOperators in _patch', () => { it('drops $rename by default', async () => { const person = await app.service('people').create({ name: 'Secure', age: 30 }) const result = await app.service('people').patch(person._id, { name: 'Updated', $rename: { age: 'exposed' } } as any) assert.strictEqual(result.name, 'Updated') assert.strictEqual(result.age, 30) await app.service('people').remove(person._id) }) it('allows $push and other operators not in the denylist', async () => { const person = await app.service('people').create({ name: 'PushTest', age: 20 }) const result = await app.service('people').patch(person._id, { $push: { friends: 'Alice' } } as any) assert.strictEqual(result.friends?.length, 1) assert.strictEqual(result.friends[0], 'Alice') await app.service('people').remove(person._id) }) it('drops operators added to disabledOperators', async () => { const person = await app.service('people').create({ name: 'IncTest', age: 25 }) const result = await app.service('people').patch( person._id, { $inc: { age: 100 } } as any, { adapter: { disabledOperators: ['$rename', '$inc'] } } ) assert.strictEqual(result.age, 25) await app.service('people').remove(person._id) }) }) describe('NoSQL injection via object id', () => { let target: Person beforeEach(async () => { target = await app.service('people').create({ name: 'Target' }) }) afterEach(async () => { try { await app.service('people').remove(target._id) } catch (e: unknown) {} }) it('rejects object as id in get', async () => { await assert.rejects(() => app.service('people').get({ $ne: null } as any), { name: 'BadRequest' }) }) it('rejects object as id in remove', async () => { await assert.rejects(() => app.service('people').remove({ $ne: null } as any), { name: 'BadRequest' }) }) it('rejects object as id in update', async () => { await assert.rejects(() => app.service('people').update({ $ne: null } as any, { name: 'Hacked' }), { name: 'BadRequest' }) }) it('rejects object as id in patch', async () => { await assert.rejects(() => app.service('people').patch({ $ne: null } as any, { name: 'Hacked' }), { name: 'BadRequest' }) }) it('rejects regex operator as id', async () => { await assert.rejects(() => app.service('people').get({ $regex: '^' } as any), { name: 'BadRequest' }) }) }) testSuite(app, errors, 'people', '_id') testSuite(app, errors, 'people-customid', 'customid') }) ================================================ FILE: packages/mongodb/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/rest-client/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) ### Bug Fixes - **client:** Ensure all client methods require valid ids ([#3661](https://github.com/feathersjs/feathers/issues/3661)) ([bc754d3](https://github.com/feathersjs/feathers/commit/bc754d3666b059b9d93799602dac427cb419ddc6)) ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **client:** Replace placeholders in URL with route params ([#3270](https://github.com/feathersjs/feathers/issues/3270)) ([a0624eb](https://github.com/feathersjs/feathers/commit/a0624eb5a7919aa1b179a71beb1c1b9cab574525)) - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) ### Bug Fixes - **client:** Add underscored methods to clients ([#3176](https://github.com/feathersjs/feathers/issues/3176)) ([f3c01f7](https://github.com/feathersjs/feathers/commit/f3c01f7b8266bfc642c55b77ba8e5bb333542630)) ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/rest-client ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Features - **cli:** Add typed client to a generated app ([#2669](https://github.com/feathersjs/feathers/issues/2669)) ([5b801b5](https://github.com/feathersjs/feathers/commit/5b801b5017ddc3eaa95622b539f51d605916bc86)) # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) ### Bug Fixes - **express:** Ensure Express options can be set before configuring REST transport ([#2655](https://github.com/feathersjs/feathers/issues/2655)) ([c9b8f74](https://github.com/feathersjs/feathers/commit/c9b8f74a0196acb99be44ac5e0fff3f1128288cd)) ### Features - **client:** Improve client side custom method support ([#2654](https://github.com/feathersjs/feathers/issues/2654)) ([c138acf](https://github.com/feathersjs/feathers/commit/c138acf50affbe6b66177d084d3c7a3e9220f09f)) # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Features - **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5)) - **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28)) # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) ### Features - **express, koa:** make transports similar ([#2486](https://github.com/feathersjs/feathers/issues/2486)) ([26aa937](https://github.com/feathersjs/feathers/commit/26aa937c114fb8596dfefc599b1f53cead69c159)) # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Bug Fixes - **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Features - **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) ### Bug Fixes - **dependencies:** Fix transport-commons dependency and update other dependencies ([#2284](https://github.com/feathersjs/feathers/issues/2284)) ([05b03b2](https://github.com/feathersjs/feathers/commit/05b03b27b40604d956047e3021d8053c3a137616)) # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) ### Features - **core:** Public custom service methods ([#2270](https://github.com/feathersjs/feathers/issues/2270)) ([e65abfb](https://github.com/feathersjs/feathers/commit/e65abfb5388df6c19a11c565cf1076a29f32668d)) - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) **Note:** Version bump only for package @feathersjs/rest-client # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) **Note:** Version bump only for package @feathersjs/rest-client ## [4.5.10](https://github.com/feathersjs/feathers/compare/v4.5.9...v4.5.10) (2020-11-08) **Note:** Version bump only for package @feathersjs/rest-client ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) ### Bug Fixes - **rest-client:** Handle non-JSON errors with fetch adapter ([#2086](https://github.com/feathersjs/feathers/issues/2086)) ([e24217a](https://github.com/feathersjs/feathers/commit/e24217ad1e784ad71cd9d64fe1727dd02f039991)) ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) **Note:** Version bump only for package @feathersjs/rest-client ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) **Note:** Version bump only for package @feathersjs/rest-client ## [4.5.6](https://github.com/feathersjs/feathers/compare/v4.5.5...v4.5.6) (2020-07-12) **Note:** Version bump only for package @feathersjs/rest-client ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) **Note:** Version bump only for package @feathersjs/rest-client ## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-04-29) **Note:** Version bump only for package @feathersjs/rest-client ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) **Note:** Version bump only for package @feathersjs/rest-client ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) **Note:** Version bump only for package @feathersjs/rest-client ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/rest-client # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) ### Features - **rest-client:** Allow for customising rest clients ([#1780](https://github.com/feathersjs/feathers/issues/1780)) ([c5cfec7](https://github.com/feathersjs/feathers/commit/c5cfec7a4aafcaffaab0cdacb9b5d297ff20320f)) ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/rest-client ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/rest-client # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) ### Bug Fixes - **core:** Improve hook missing parameter message by adding the service name ([#1703](https://github.com/feathersjs/feathers/issues/1703)) ([2331c2a](https://github.com/feathersjs/feathers/commit/2331c2a3dd70d432db7d62a76ed805d359cbbba5)) - **rest-client:** Allow to customize getting the query ([#1594](https://github.com/feathersjs/feathers/issues/1594)) ([5f21272](https://github.com/feathersjs/feathers/commit/5f212729849414c4da6f0d51edd1986feca992ee)) ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) **Note:** Version bump only for package @feathersjs/rest-client ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/rest-client ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) **Note:** Version bump only for package @feathersjs/rest-client ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) **Note:** Version bump only for package @feathersjs/rest-client ## [4.3.5](https://github.com/feathersjs/feathers/compare/v4.3.4...v4.3.5) (2019-10-07) ### Bug Fixes - Change this reference in client libraries to explicitly passed app ([#1597](https://github.com/feathersjs/feathers/issues/1597)) ([4e4d10a](https://github.com/feathersjs/feathers/commit/4e4d10a)) ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) **Note:** Version bump only for package @feathersjs/rest-client ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) **Note:** Version bump only for package @feathersjs/rest-client ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) **Note:** Version bump only for package @feathersjs/rest-client ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) **Note:** Version bump only for package @feathersjs/rest-client # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/rest-client # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/rest-client # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) ### Bug Fixes - Update all dependencies ([7d53a00](https://github.com/feathersjs/feathers/commit/7d53a00)) # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) **Note:** Version bump only for package @feathersjs/rest-client # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/rest-client # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) **Note:** Version bump only for package @feathersjs/rest-client # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) **Note:** Version bump only for package @feathersjs/rest-client # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) ### Bug Fixes - Use `export =` in TypeScript definitions ([#1285](https://github.com/feathersjs/feathers/issues/1285)) ([12d0f4b](https://github.com/feathersjs/feathers/commit/12d0f4b)) # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) **Note:** Version bump only for package @feathersjs/rest-client # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) ### Features - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - Authentication v3 core server implementation ([#1205](https://github.com/feathersjs/feathers/issues/1205)) ([1bd7591](https://github.com/feathersjs/feathers/commit/1bd7591)) ## [1.4.7](https://github.com/feathersjs/feathers/compare/@feathersjs/rest-client@1.4.6...@feathersjs/rest-client@1.4.7) (2019-01-02) ### Bug Fixes - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) ## [1.4.6](https://github.com/feathersjs/feathers/compare/@feathersjs/rest-client@1.4.5...@feathersjs/rest-client@1.4.6) (2018-12-16) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) ## [1.4.5](https://github.com/feathersjs/feathers/compare/@feathersjs/rest-client@1.4.4...@feathersjs/rest-client@1.4.5) (2018-09-21) **Note:** Version bump only for package @feathersjs/rest-client ## [1.4.4](https://github.com/feathersjs/feathers/compare/@feathersjs/rest-client@1.4.3...@feathersjs/rest-client@1.4.4) (2018-09-17) **Note:** Version bump only for package @feathersjs/rest-client ## [1.4.3](https://github.com/feathersjs/feathers/compare/@feathersjs/rest-client@1.4.2...@feathersjs/rest-client@1.4.3) (2018-09-02) **Note:** Version bump only for package @feathersjs/rest-client ## 1.4.2 - Migrate to Monorepo ([feathers#462](https://github.com/feathersjs/feathers/issues/462)) ## [v1.4.1](https://github.com/feathersjs/rest-client/tree/v1.4.1) (2018-06-27) [Full Changelog](https://github.com/feathersjs/rest-client/compare/v1.4.0...v1.4.1) **Merged pull requests:** - URL encode ID. [\#33](https://github.com/feathersjs/rest-client/pull/33) ([SteffenLanger](https://github.com/SteffenLanger)) - Update shx to the latest version 🚀 [\#31](https://github.com/feathersjs/rest-client/pull/31) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.4.0](https://github.com/feathersjs/rest-client/tree/v1.4.0) (2018-05-17) [Full Changelog](https://github.com/feathersjs/rest-client/compare/v1.3.4...v1.4.0) **Closed issues:** - Need a way to abort requests [\#29](https://github.com/feathersjs/rest-client/issues/29) - Pass request options to transport \(request\) [\#26](https://github.com/feathersjs/rest-client/issues/26) **Merged pull requests:** - Add support for passing library options in params.connection [\#30](https://github.com/feathersjs/rest-client/pull/30) ([daffl](https://github.com/daffl)) - Update dependencies to enable Greenkeeper 🌴 [\#28](https://github.com/feathersjs/rest-client/pull/28) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.3.4](https://github.com/feathersjs/rest-client/tree/v1.3.4) (2018-03-17) [Full Changelog](https://github.com/feathersjs/rest-client/compare/v1.3.3...v1.3.4) **Closed issues:** - Window.fetch on macOS [\#24](https://github.com/feathersjs/rest-client/issues/24) - Error on server side rendering [\#23](https://github.com/feathersjs/rest-client/issues/23) **Merged pull requests:** - Properly serialize ECONNREFUSED errors [\#27](https://github.com/feathersjs/rest-client/pull/27) ([daffl](https://github.com/daffl)) - Update axios to the latest version 🚀 [\#25](https://github.com/feathersjs/rest-client/pull/25) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update node-fetch to the latest version 🚀 [\#22](https://github.com/feathersjs/rest-client/pull/22) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update mocha to the latest version 🚀 [\#21](https://github.com/feathersjs/rest-client/pull/21) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.3.3](https://github.com/feathersjs/rest-client/tree/v1.3.3) (2018-01-03) [Full Changelog](https://github.com/feathersjs/rest-client/compare/v1.3.2...v1.3.3) **Closed issues:** - Conditions, like { name: null } , to query resources can't be used. [\#18](https://github.com/feathersjs/rest-client/issues/18) - Failed to minify the code from /lib/base.js [\#14](https://github.com/feathersjs/rest-client/issues/14) **Merged pull requests:** - Update documentation to correspond with latest release [\#20](https://github.com/feathersjs/rest-client/pull/20) ([daffl](https://github.com/daffl)) - Update semistandard to the latest version 🚀 [\#19](https://github.com/feathersjs/rest-client/pull/19) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update feathers-memory to the latest version 🚀 [\#17](https://github.com/feathersjs/rest-client/pull/17) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.3.2](https://github.com/feathersjs/rest-client/tree/v1.3.2) (2017-11-16) [Full Changelog](https://github.com/feathersjs/rest-client/compare/v1.3.1...v1.3.2) **Merged pull requests:** - Add default export for better ES module \(TypeScript\) compatibility [\#16](https://github.com/feathersjs/rest-client/pull/16) ([daffl](https://github.com/daffl)) - Update package.json [\#15](https://github.com/feathersjs/rest-client/pull/15) ([frank-dspeed](https://github.com/frank-dspeed)) - Update @angular/platform-browser to the latest version 🚀 [\#13](https://github.com/feathersjs/rest-client/pull/13) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update @angular/http to the latest version 🚀 [\#12](https://github.com/feathersjs/rest-client/pull/12) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update @angular/core to the latest version 🚀 [\#11](https://github.com/feathersjs/rest-client/pull/11) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update @angular/common to the latest version 🚀 [\#10](https://github.com/feathersjs/rest-client/pull/10) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.3.1](https://github.com/feathersjs/rest-client/tree/v1.3.1) (2017-11-01) [Full Changelog](https://github.com/feathersjs/rest-client/compare/v1.3.0...v1.3.1) **Merged pull requests:** - Update dependencies [\#9](https://github.com/feathersjs/rest-client/pull/9) ([daffl](https://github.com/daffl)) - Update babelify to the latest version 🚀 [\#8](https://github.com/feathersjs/rest-client/pull/8) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.3.0](https://github.com/feathersjs/rest-client/tree/v1.3.0) (2017-10-23) [Full Changelog](https://github.com/feathersjs/rest-client/compare/v1.2.0...v1.3.0) **Merged pull requests:** - Update all dependencies to use npm scope [\#7](https://github.com/feathersjs/rest-client/pull/7) ([daffl](https://github.com/daffl)) - Update axios to the latest version 🚀 [\#6](https://github.com/feathersjs/rest-client/pull/6) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.2.0](https://github.com/feathersjs/rest-client/tree/v1.2.0) (2017-10-19) [Full Changelog](https://github.com/feathersjs/rest-client/compare/v1.1.1-0...v1.2.0) ## [v1.1.1-0](https://github.com/feathersjs/rest-client/tree/v1.1.1-0) (2017-10-19) [Full Changelog](https://github.com/feathersjs/rest-client/compare/v1.1.0...v1.1.1-0) **Merged pull requests:** - Rename repository to publish in npm namespace [\#5](https://github.com/feathersjs/rest-client/pull/5) ([daffl](https://github.com/daffl)) - Upgrade to use Feathers v3 [\#4](https://github.com/feathersjs/rest-client/pull/4) ([daffl](https://github.com/daffl)) - Update mocha to the latest version 🚀 [\#3](https://github.com/feathersjs/rest-client/pull/3) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.1.0](https://github.com/feathersjs/rest-client/tree/v1.1.0) (2017-07-20) [Full Changelog](https://github.com/feathersjs/rest-client/compare/v1.0.0...v1.1.0) **Merged pull requests:** - add support for @angular/common/http \(HttpClient\) [\#2](https://github.com/feathersjs/rest-client/pull/2) ([j2L4e](https://github.com/j2L4e)) ## [v1.0.0](https://github.com/feathersjs/rest-client/tree/v1.0.0) (2017-07-16) **Merged pull requests:** - Update dependencies to enable Greenkeeper 🌴 [\#1](https://github.com/feathersjs/rest-client/pull/1) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) \* _This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)_ ================================================ FILE: packages/rest-client/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/rest-client/README.md ================================================ # @feathersjs/rest-client [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/rest-client.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/rest-client) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > REST client services for different HTTP libraries ## Installation ``` npm install @feathersjs/rest-client --save ``` ## Documentation Refer to the [Feathers REST client API documentation](https://feathersjs.com/api/client/rest.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/rest-client/package.json ================================================ { "name": "@feathersjs/rest-client", "description": "REST client services for different Ajax libraries", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/rest-client" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/commons": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/feathers": "^5.0.42", "@types/superagent": "^8.1.9", "qs": "^6.15.0" }, "devDependencies": { "@feathersjs/express": "^5.0.42", "@feathersjs/memory": "^5.0.42", "@feathersjs/tests": "^5.0.42", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "@types/node-fetch": "^2.6.13", "@types/qs": "^6.14.0", "axios": "^1.13.6", "mocha": "^11.7.5", "node-fetch": "^2.6.1", "rxjs": "^7.8.2", "shx": "^0.4.0", "superagent": "^10.3.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/rest-client/src/axios.ts ================================================ import { Params } from '@feathersjs/feathers' import { Base, RestClientParams } from './base' export class AxiosClient, P extends Params = RestClientParams> extends Base { request(options: any, params: RestClientParams) { const config = Object.assign( { url: options.url, method: options.method, data: options.body, headers: Object.assign( { Accept: 'application/json' }, this.options.headers, options.headers ) }, params.connection ) return this.connection .request(config) .then((res: any) => res.data) .catch((error: any) => { const response = error.response || error throw response instanceof Error ? response : response.data || response }) } } ================================================ FILE: packages/rest-client/src/base.ts ================================================ import qs from 'qs' import { Params, Id, Query, NullableId, ServiceInterface } from '@feathersjs/feathers' import { BadRequest, Unavailable, convert } from '@feathersjs/errors' import { _, stripSlashes } from '@feathersjs/commons' function toError(error: Error & { code: string }) { if (error.code === 'ECONNREFUSED') { throw new Unavailable(error.message, _.pick(error, 'address', 'port', 'config')) } throw convert(error) } export interface RestClientParams extends Params { connection?: any } interface RestClientSettings { name: string base: string connection: any options: any } export abstract class Base< T = any, D = Partial, P extends Params = RestClientParams > implements ServiceInterface { name: string base: string connection: any options: any constructor(settings: RestClientSettings) { this.name = stripSlashes(settings.name) this.options = settings.options this.connection = settings.connection this.base = `${settings.base}/${this.name}` } makeUrl(query: Query, id?: string | number | null, route?: { [key: string]: string }) { let url = this.base if (route) { Object.keys(route).forEach((key) => { url = url.replace(`:${key}`, route[key]) }) } query = query || {} if (typeof id !== 'undefined' && id !== null) { url += `/${encodeURIComponent(id)}` } return url + this.getQuery(query) } getQuery(query: Query) { if (Object.keys(query).length !== 0) { const queryString = qs.stringify(query) return `?${queryString}` } return '' } abstract request(options: any, params: P): any methods(this: any, ...names: string[]) { names.forEach((method) => { const _method = `_${method}` this[_method] = function (data: any, params: Params = {}) { return this.request( { body: data, url: this.makeUrl(params.query, null, params.route), method: 'POST', headers: Object.assign( { 'Content-Type': 'application/json', 'X-Service-Method': method }, params.headers ) }, params ).catch(toError) } this[method] = function (data: any, params: Params = {}) { return this[_method](data, params) } }) return this } _find(params?: P) { return this.request( { url: this.makeUrl(params.query, null, params.route), method: 'GET', headers: Object.assign({}, params.headers) }, params ).catch(toError) } find(params?: P) { return this._find(params) } _get(id: Id, params?: P) { if (id === undefined || id === '') { return Promise.reject(new BadRequest('id for .get is required')) } return this.request( { url: this.makeUrl(params.query, id, params.route), method: 'GET', headers: Object.assign({}, params.headers) }, params ).catch(toError) } get(id: Id, params?: P) { return this._get(id, params) } _create(data: D, params?: P) { return this.request( { url: this.makeUrl(params.query, null, params.route), body: data, method: 'POST', headers: Object.assign({ 'Content-Type': 'application/json' }, params.headers) }, params ).catch(toError) } create(data: D, params?: P) { return this._create(data, params) } _update(id: NullableId, data: D, params?: P) { if (id === undefined || id === '') { return Promise.reject(new BadRequest('id for .update is required')) } return this.request( { url: this.makeUrl(params.query, id, params.route), body: data, method: 'PUT', headers: Object.assign({ 'Content-Type': 'application/json' }, params.headers) }, params ).catch(toError) } update(id: NullableId, data: D, params?: P) { return this._update(id, data, params) } _patch(id: NullableId, data: D, params?: P) { if (id === undefined || id === '') { return Promise.reject(new BadRequest('id for .patch is required')) } return this.request( { url: this.makeUrl(params.query, id, params.route), body: data, method: 'PATCH', headers: Object.assign({ 'Content-Type': 'application/json' }, params.headers) }, params ).catch(toError) } patch(id: NullableId, data: D, params?: P) { return this._patch(id, data, params) } _remove(id: NullableId, params?: P) { if (id === undefined || id === '') { return Promise.reject(new BadRequest('id for .remove is required')) } return this.request( { url: this.makeUrl(params.query, id, params.route), method: 'DELETE', headers: Object.assign({}, params.headers) }, params ).catch(toError) } remove(id: NullableId, params?: P) { return this._remove(id, params) } } ================================================ FILE: packages/rest-client/src/fetch.ts ================================================ import { errors } from '@feathersjs/errors' import { Params } from '@feathersjs/feathers' import { Base, RestClientParams } from './base' export class FetchClient, P extends Params = RestClientParams> extends Base { request(options: any, params: RestClientParams) { const fetchOptions = Object.assign({}, options, params.connection) fetchOptions.headers = Object.assign( { Accept: 'application/json' }, this.options.headers, fetchOptions.headers ) if (options.body) { fetchOptions.body = JSON.stringify(options.body) } return this.connection(options.url, fetchOptions) .then(this.checkStatus) .then((response: any) => { if (response.status === 204) { return null } return response.json() }) } checkStatus(response: any) { if (response.ok) { return response } return response .json() .catch(() => { const ErrorClass = (errors as any)[response.status] || Error return new ErrorClass('JSON parsing error') }) .then((error: any) => { error.response = response throw error }) } } ================================================ FILE: packages/rest-client/src/index.ts ================================================ import { Application, TransportConnection, defaultServiceMethods } from '@feathersjs/feathers' import { Base } from './base' import { AxiosClient } from './axios' import { FetchClient } from './fetch' import { SuperagentClient } from './superagent' export { AxiosClient, FetchClient, SuperagentClient } const transports = { superagent: SuperagentClient, fetch: FetchClient, axios: AxiosClient } export type Handler = ( connection: any, options?: any, Service?: any ) => TransportConnection export interface Transport { superagent: Handler fetch: Handler axios: Handler } export type RestService> = Base export default function restClient(base = '') { const result: any = { Base } Object.keys(transports).forEach((key) => { result[key] = function (connection: any, options: any = {}, Service: Base = (transports as any)[key]) { if (!connection) { throw new Error(`${key} has to be provided to feathers-rest`) } if (typeof options === 'function') { Service = options options = {} } const defaultService = function (name: string) { return new (Service as any)({ base, name, connection, options }) } const initialize = (app: Application & { rest: any }) => { if (app.rest !== undefined) { throw new Error('Only one default client provider can be configured') } app.rest = connection app.defaultService = defaultService app.mixins.unshift((service, _location, options) => { if (options && options.methods && service instanceof Base) { const customMethods = options.methods.filter((name) => !defaultServiceMethods.includes(name)) service.methods(...customMethods) } }) } initialize.Service = Service initialize.service = defaultService return initialize } }) return result as Transport } if (typeof module !== 'undefined') { module.exports = Object.assign(restClient, module.exports) } ================================================ FILE: packages/rest-client/src/superagent.ts ================================================ import { Params } from '@feathersjs/feathers' import { Base, RestClientParams } from './base' export class SuperagentClient, P extends Params = RestClientParams> extends Base< T, D, P > { request(options: any, params: RestClientParams) { const superagent = this.connection(options.method, options.url) .set(this.options.headers || {}) .set('Accept', 'application/json') .set(params.connection || {}) .set(options.headers || {}) .type(options.type || 'json') return new Promise((resolve, reject) => { superagent.set(options.headers) if (options.body) { superagent.send(options.body) } superagent.end(function (error: any, res: any) { if (error) { try { const response = error.response error = JSON.parse(error.response.text) error.response = response } catch (e: any) {} return reject(error) } resolve(res && res.body) }) }) } } ================================================ FILE: packages/rest-client/test/axios.test.ts ================================================ import { strict as assert } from 'assert' import axios from 'axios' import { Server } from 'http' import { feathers } from '@feathersjs/feathers' import { clientTests } from '@feathersjs/tests' import { NotAcceptable } from '@feathersjs/errors' import createServer from './server' import rest from '../src' import { ServiceTypes } from './declarations' describe('Axios REST connector', function () { const url = 'http://localhost:8889' const connection = rest(url).axios(axios) const app = feathers() .configure(connection) .use('todos', connection.service('todos'), { methods: ['get', 'find', 'create', 'patch', 'customMethod'] }) const service = app.service('todos') let server: Server before(async () => { server = await createServer().listen(8889) }) after((done) => server.close(done)) it('supports custom headers', async () => { const headers = { Authorization: 'let-me-in' } const todo = await service.get(0, { headers }) assert.deepStrictEqual(todo, { id: 0, authorization: 'let-me-in', text: 'some todo', complete: false, query: {} }) }) it('uses params.connection for additional options', async () => { const connection = { headers: { Authorization: 'let-me-in' } } const todo = await service.get(0, { connection }) assert.deepStrictEqual(todo, { id: 0, authorization: 'let-me-in', text: 'some todo', complete: false, query: {} }) }) it('can initialize a client instance', async () => { const init = rest(url).axios(axios) const todoService = init.service('todos') assert.ok(todoService instanceof init.Service, 'Returned service is a client') const todos = await todoService.find({}) assert.deepStrictEqual(todos, [ { text: 'some todo', complete: false, id: 0 } ]) }) it('supports nested arrays in queries', async () => { const query = { test: { $in: ['0', '1', '2'] } } const data = await service.get(0, { query }) assert.deepStrictEqual(data.query, query) }) it('remove many', async () => { const todo: any = await service.remove(null) assert.strictEqual(todo.id, null) assert.strictEqual(todo.text, 'deleted many') }) it('converts feathers errors (#50)', async () => { try { await service.get(0, { query: { feathersError: true } }) assert.fail('Should never get here') } catch (error: any) { assert.ok(error instanceof NotAcceptable) assert.strictEqual(error.message, 'This is a Feathers error') assert.strictEqual(error.code, 406) } }) it('ECONNREFUSED errors are serializable', async () => { const url = 'http://localhost:60000' const setup = rest(url).axios(axios) const app = feathers().configure(setup) try { await app.service('something').find() assert.fail('Should never get here') } catch (e: any) { const err = JSON.parse(JSON.stringify(e)) assert.strictEqual(err.name, 'Unavailable') assert.ok(e.data.config) } }) it('works with custom method .customMethod', async () => { const result = await service.customMethod({ message: 'hi' }) assert.deepEqual(result, { data: { message: 'hi' }, provider: 'rest', type: 'customMethod' }) }) clientTests(service, 'todos') }) ================================================ FILE: packages/rest-client/test/declarations.ts ================================================ import { CustomMethod } from '@feathersjs/feathers' import { RestService } from '../src' type Data = { message: string } type Result = { data: Data provider: string type: string } export type ServiceTypes = { todos: RestService & { customMethod: CustomMethod } } ================================================ FILE: packages/rest-client/test/fetch.test.ts ================================================ import { strict as assert } from 'assert' import fetch from 'node-fetch' import { feathers } from '@feathersjs/feathers' import { clientTests } from '@feathersjs/tests' import { NotAcceptable } from '@feathersjs/errors' import { Server } from 'http' import rest from '../src' import createServer from './server' import { ServiceTypes } from './declarations' describe('fetch REST connector', function () { const url = 'http://localhost:8889' const connection = rest(url).fetch(fetch) const app = feathers() .configure(connection) .use('todos', connection.service('todos'), { methods: ['get', 'find', 'create', 'patch', 'customMethod'] }) const service = app.service('todos') let server: Server service.hooks({ after: { customMethod: [ (context) => { context.result.data.message += '!' } ] } }) before(async () => { server = await createServer().listen(8889) }) after((done) => server.close(done)) it('supports custom headers', async () => { const headers = { Authorization: 'let-me-in' } const todo = await service.get(0, { headers }) assert.deepStrictEqual(todo, { id: 0, text: 'some todo', authorization: 'let-me-in', complete: false, query: {} }) }) it('supports params.connection', async () => { const connection = { headers: { Authorization: 'let-me-in' } } const todo = await service.get(0, { connection }) assert.deepStrictEqual(todo, { id: 0, text: 'some todo', authorization: 'let-me-in', complete: false, query: {} }) }) it('handles errors properly', async () => { try { await service.get(-1, {}) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.code, 404) } }) it('supports nested arrays in queries', async () => { const query = { test: { $in: ['0', '1', '2'] } } const data = await service.get(0, { query }) assert.deepStrictEqual(data.query, query) }) it('can initialize a client instance', async () => { const init = rest(url).fetch(fetch) const todoService = init.service('todos') assert.ok(todoService instanceof init.Service, 'Returned service is a client') const todos = await todoService.find({}) assert.deepStrictEqual(todos, [ { text: 'some todo', complete: false, id: 0 } ]) }) it('remove many', async () => { const todo: any = await service.remove(null) assert.strictEqual(todo.id, null) assert.strictEqual(todo.text, 'deleted many') }) it('converts feathers errors (#50)', async () => { try { await service.get(0, { query: { feathersError: true } }) assert.fail('Should never get here') } catch (error: any) { assert.ok(error.response) assert.ok(error instanceof NotAcceptable) assert.strictEqual(error.message, 'This is a Feathers error') assert.strictEqual(error.code, 406) assert.deepStrictEqual(error.data, { data: true }) } }) it('returns null for 204 responses', async () => { const response = await service.remove(0, { query: { noContent: true } }) assert.strictEqual(response, null) }) it('works with custom method .customMethod', async () => { const result = await service.customMethod({ message: 'hi' }) assert.deepEqual(result, { data: { message: 'hi!' }, provider: 'rest', type: 'customMethod' }) }) clientTests(service, 'todos') }) ================================================ FILE: packages/rest-client/test/index.test.ts ================================================ /* eslint-disable @typescript-eslint/ban-ts-comment */ import fetch from 'node-fetch' import { strict as assert } from 'assert' import { feathers } from '@feathersjs/feathers' import { default as init, FetchClient } from '../src' describe('REST client tests', function () { it('is built correctly', () => { const transports = init() assert.strictEqual(typeof init, 'function') assert.strictEqual(typeof transports.superagent, 'function') assert.strictEqual(typeof transports.fetch, 'function') assert.strictEqual(typeof transports.axios, 'function') }) it('throw errors when no connection is provided', () => { const transports = init() try { // @ts-ignore transports.fetch() } catch (e: any) { assert.strictEqual(e.message, 'fetch has to be provided to feathers-rest') } }) it('app has the rest attribute', () => { const app = feathers() app.configure(init('http://localhost:8889').fetch(fetch)) assert.ok((app as any).rest) }) it('throws an error when configured twice', () => { const app = feathers() app.configure(init('http://localhost:8889').fetch(fetch)) try { app.configure(init('http://localhost:8889').fetch(fetch)) assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, 'Only one default client provider can be configured') } }) it('errors when id property for get, patch, update or remove is undefined or empty string', async () => { const app = feathers().configure(init('http://localhost:8889').fetch(fetch)) const service = app.service('todos') await assert.rejects(() => service.get(undefined), { message: 'id for .get is required' }) await assert.rejects(() => service.get(''), { message: 'id for .get is required' }) await assert.rejects(() => service.remove(undefined), { message: 'id for .remove is required' }) await assert.rejects(() => service.remove(''), { message: 'id for .remove is required' }) await assert.rejects(() => service.update(undefined, {}), { message: 'id for .update is required' }) await assert.rejects(() => service.update('', {}), { message: 'id for .update is required' }) await assert.rejects(() => service.patch(undefined, {}), { message: 'id for .patch is required' }) await assert.rejects(() => service.patch('', {}), { message: 'id for .patch is required' }) }) it('uses a custom client', async () => { const app = feathers() class MyFetchClient extends FetchClient { find() { return Promise.resolve({ connection: this.connection, base: this.base, message: 'Custom fetch client' }) } } app.configure(init('http://localhost:8889').fetch(fetch, {}, MyFetchClient)) const data = await app.service('messages').find() assert.deepStrictEqual(data, { connection: fetch, base: 'http://localhost:8889/messages', message: 'Custom fetch client' }) }) it('uses a custom client as second arg', async () => { const app = feathers() class MyFetchClient extends FetchClient { find() { return Promise.resolve({ connection: this.connection, base: this.base, message: 'Custom fetch client' }) } } app.configure(init('http://localhost:8889').fetch(fetch, MyFetchClient)) const data = await app.service('messages').find() assert.deepStrictEqual(data, { connection: fetch, base: 'http://localhost:8889/messages', message: 'Custom fetch client' }) }) it('replace placeholder in route URLs', async () => { const app = feathers() let expectedValue: string | null = null class MyFetchClient extends FetchClient { request(options: any, _params: any) { assert.equal(options.url, expectedValue) return Promise.resolve() } } app.configure(init('http://localhost:8889').fetch(fetch, {}, MyFetchClient)) expectedValue = 'http://localhost:8889/admin/todos' await app.service(':slug/todos').find({ route: { slug: 'admin' } }) await app.service(':slug/todos').create( {}, { route: { slug: 'admin' } } ) expectedValue = 'http://localhost:8889/admin/todos/0' await app.service(':slug/todos').get(0, { route: { slug: 'admin' } }) expectedValue = 'http://localhost:8889/admin/todos/0' await app.service(':slug/todos').patch( 0, {}, { route: { slug: 'admin' } } ) expectedValue = 'http://localhost:8889/admin/todos/0' await app.service(':slug/todos').update( 0, {}, { route: { slug: 'admin' } } ) expectedValue = 'http://localhost:8889/admin/todos/0' await app.service(':slug/todos').remove(0, { route: { slug: 'admin' } }) }) }) ================================================ FILE: packages/rest-client/test/server.ts ================================================ import { feathers, Id, NullableId, Params } from '@feathersjs/feathers' import expressify, { rest, urlencoded, json } from '@feathersjs/express' import { MemoryService } from '@feathersjs/memory' import { FeathersError, NotAcceptable } from '@feathersjs/errors' // eslint-disable-next-line no-extend-native Object.defineProperty(Error.prototype, 'toJSON', { value() { const alt: any = {} Object.getOwnPropertyNames(this).forEach((key: string) => { alt[key] = this[key] }, this) return alt }, configurable: true, writable: true }) const errorHandler = function (error: FeathersError, _req: any, res: any, _next: any) { // eslint-disable-line @typescript-eslint/no-unused-vars const code = !isNaN(parseInt(error.code as any, 10)) ? parseInt(error.code as any, 10) : 500 res.status(code) res.format({ 'application/json'() { res.json(Object.assign({}, error.toJSON())) } }) } interface TodoServiceParams extends Params { authorization: any } // Create an in-memory CRUD service for our Todos class TodoService extends MemoryService { get(id: Id, params: TodoServiceParams) { if (params.query.error) { throw new Error('Something went wrong') } if (params.query.feathersError) { throw new NotAcceptable('This is a Feathers error', { data: true }) } return super.get(id).then((data) => { console.log('!', params.query) const result = Object.assign({ query: params.query }, data) if (params.authorization) { result.authorization = params.authorization } return result }) } remove(id: NullableId, params: Params) { if (id === null) { return Promise.resolve({ id, text: 'deleted many' }) } if (params.query.noContent) { return Promise.resolve() } return super.remove(id, params) } async customMethod(data: any, { provider }: Params) { return { data, provider, type: 'customMethod' } } } export default (configurer?: any) => { const app = expressify(feathers()) .use(function (req, res, next) { res.header('Access-Control-Allow-Origin', '*') res.header('Access-Control-Allow-Headers', 'Authorization') req.feathers = { ...req.feathers, authorization: req.headers.authorization } next() }) // Parse HTTP bodies .use(json()) .use(urlencoded({ extended: true })) .configure( rest(function formatter(_req, res, next) { if (!res.data) { next() } res.format({ html() { res.end('

    This is HTML content. You should not see it.

    ') }, json() { res.json(res.data) } }) }) ) // Host our Todos service on the /todos path .use('todos', new TodoService(), { methods: ['find', 'get', 'create', 'patch', 'update', 'remove', 'customMethod'] }) .use(errorHandler) if (typeof configurer === 'function') { configurer.call(app) } app.service('todos').create({ text: 'some todo', complete: false }) return app } ================================================ FILE: packages/rest-client/test/superagent.test.ts ================================================ import { strict as assert } from 'assert' import superagent from 'superagent' import { Server } from 'http' import { feathers } from '@feathersjs/feathers' import { clientTests } from '@feathersjs/tests' import { NotAcceptable } from '@feathersjs/errors' import rest from '../src' import createServer from './server' import { ServiceTypes } from './declarations' describe('Superagent REST connector', function () { let server: Server const url = 'http://localhost:8889' const setup = rest(url).superagent(superagent) const app = feathers().configure(setup) const service = app.service('todos') service.methods('customMethod') before(async () => { server = await createServer().listen(8889) }) after((done) => server.close(done)) it('supports custom headers', async () => { const headers = { Authorization: 'let-me-in' } const todo = await service.get(0, { headers }) assert.deepStrictEqual(todo, { id: 0, authorization: 'let-me-in', text: 'some todo', complete: false, query: {} }) }) it('supports params.connection', async () => { const connection = { Authorization: 'let-me-in' } const todo = await service.get(0, { connection }) assert.deepStrictEqual(todo, { id: 0, authorization: 'let-me-in', text: 'some todo', complete: false, query: {} }) }) it('can initialize a client instance', async () => { const init = rest(url).superagent(superagent) const todoService = init.service('todos') assert.ok(todoService instanceof init.Service, 'Returned service is a client') const todos = await todoService.find({}) assert.deepStrictEqual(todos, [ { text: 'some todo', complete: false, id: 0 } ]) }) it('supports nested arrays in queries', async () => { const query = { test: { $in: ['0', '1', '2'] } } const data = await service.get(0, { query }) assert.deepStrictEqual(data.query, query) }) it('remove many', async () => { const todo: any = await service.remove(null) assert.strictEqual(todo.id, null) assert.strictEqual(todo.text, 'deleted many') }) it('converts feathers errors (#50)', async () => { try { await service.get(0, { query: { feathersError: true } }) assert.fail('Should never get here') } catch (error: any) { assert.ok(error.response) assert.ok(error instanceof NotAcceptable) assert.strictEqual(error.message, 'This is a Feathers error') assert.strictEqual(error.code, 406) } }) it('works with custom method .customMethod', async () => { const result = await service.customMethod({ message: 'hi' }) assert.deepEqual(result, { data: { message: 'hi' }, provider: 'rest', type: 'customMethod' }) }) clientTests(service, 'todos') }) ================================================ FILE: packages/rest-client/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/schema/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/schema ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/schema ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/schema ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/schema ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/schema ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/schema ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/schema ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/schema ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/schema ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/schema ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) ### Bug Fixes - **schema:** Allow regular functions in resolvers ([#3487](https://github.com/feathersjs/feathers/issues/3487)) ([187868e](https://github.com/feathersjs/feathers/commit/187868edd9c0c9d885c482b85be7a90655c86ca2)) ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/schema ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/schema ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/schema ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/schema ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/schema ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/schema ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/schema ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/schema ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/schema ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/schema ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) ### Bug Fixes - **schema:** Fix setting dispatch on existing nested objects ([#3380](https://github.com/feathersjs/feathers/issues/3380)) ([04efd5a](https://github.com/feathersjs/feathers/commit/04efd5ab3339beafa0e1a9ef851483a387c6ec96)) ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/schema ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) ### Bug Fixes - **schema:** Allow $in and $nin queries to work for arrays ([#3352](https://github.com/feathersjs/feathers/issues/3352)) ([677c214](https://github.com/feathersjs/feathers/commit/677c214a353a7f9a1f90649b9bbec4d0d6517a6f)) - **schema:** Remove undefined $select when using resolveResult hook ([#3354](https://github.com/feathersjs/feathers/issues/3354)) ([c43e009](https://github.com/feathersjs/feathers/commit/c43e009188eb84f98e3f5f29ac4444e6967afc1f)) ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) ### Bug Fixes - **schema:** Add typescript as peerDependency ([#3287](https://github.com/feathersjs/feathers/issues/3287)) ([cb562ee](https://github.com/feathersjs/feathers/commit/cb562eeddfa88e34fe5727d4000fa037746b0249)) ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/schema ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/schema ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/schema ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/schema ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) ### Bug Fixes - **schema:** Exclude json-schema-to-ts@2.8.0 ([#3180](https://github.com/feathersjs/feathers/issues/3180)) ([aee8531](https://github.com/feathersjs/feathers/commit/aee8531b5f0578f11e43b19a469b96e6f4b170ce)) ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) ### Bug Fixes - **core:** Use Symbol.for to instantiate shared symbols ([#3087](https://github.com/feathersjs/feathers/issues/3087)) ([7f3fc21](https://github.com/feathersjs/feathers/commit/7f3fc2167576f228f8183568eb52b077160e8d65)) - **memory/mongodb:** $select as only property & force 'id' in '$select' ([#3081](https://github.com/feathersjs/feathers/issues/3081)) ([fbe3cf5](https://github.com/feathersjs/feathers/commit/fbe3cf5199e102b5aeda2ae33828d5034df3d105)) # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/schema # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) ### Bug Fixes - **schema:** validateQuery - move next function outside of try-catch ([#3053](https://github.com/feathersjs/feathers/issues/3053)) ([37fe5c4](https://github.com/feathersjs/feathers/commit/37fe5c4a4d813867f6d02098b7c77d08786248c7)) ### Features - **schema:** Add schema helper for handling Object ids ([#3058](https://github.com/feathersjs/feathers/issues/3058)) ([1393bed](https://github.com/feathersjs/feathers/commit/1393bed81a9ee814de6aab0e537af83e667591a2)) # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) ### Bug Fixes - **schema:** Do not change the hook context in resolvers ([#3048](https://github.com/feathersjs/feathers/issues/3048)) ([bfd8c04](https://github.com/feathersjs/feathers/commit/bfd8c04c15279063a0d4b70771715c656dda5f7c)) - **schema:** Ensure that resolveResult and resolveExternal are run as around hooks ([#3032](https://github.com/feathersjs/feathers/issues/3032)) ([71942f4](https://github.com/feathersjs/feathers/commit/71942f418e3afe167aef4f98b1a97356dae7625c)) # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - **configuration:** Add pool and connection object to SQL database default configuration ([#3023](https://github.com/feathersjs/feathers/issues/3023)) ([092c749](https://github.com/feathersjs/feathers/commit/092c749d43f7da4d019576d1210fe7d3719a44a2)) - **databases:** Ensure that query sanitization is not necessary when using query schemas ([#3022](https://github.com/feathersjs/feathers/issues/3022)) ([dbf514e](https://github.com/feathersjs/feathers/commit/dbf514e85d1508b95c007462a39b3cadd4ff391d)) - **schema:** Allow any type in resolver hooks ([#3006](https://github.com/feathersjs/feathers/issues/3006)) ([f01281f](https://github.com/feathersjs/feathers/commit/f01281f7d83262738459585fc3f53f56c0a0deb8)) - **schema:** Ensure all types of nested data are securely dispatched ([#3005](https://github.com/feathersjs/feathers/issues/3005)) ([e4a9da5](https://github.com/feathersjs/feathers/commit/e4a9da5f3288e8e9f02087754473c7a9dfda6cb1)) - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) - **schema:** Allow to add additional operators to the query syntax ([#2941](https://github.com/feathersjs/feathers/issues/2941)) ([f324940](https://github.com/feathersjs/feathers/commit/f324940d5795b41e8c6fc113defb0beb7ab03a0a)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Bug Fixes - **core:** `context.type` for around hooks ([#2890](https://github.com/feathersjs/feathers/issues/2890)) ([d606ac6](https://github.com/feathersjs/feathers/commit/d606ac660fd5335c95206784fea36530dd2e851a)) - **core:** Improve service option usage and method option typings ([#2902](https://github.com/feathersjs/feathers/issues/2902)) ([164d75c](https://github.com/feathersjs/feathers/commit/164d75c0f11139a316baa91f1762de8f8eb7da2d)) - **schema:** Allow query schemas with no properties, error on unsupported types ([#2904](https://github.com/feathersjs/feathers/issues/2904)) ([b66c734](https://github.com/feathersjs/feathers/commit/b66c734357478f51b2d38fa7f3eee08640cea26e)) ### Features - **adapter:** Add patch data type to adapters and refactor AdapterBase usage ([#2906](https://github.com/feathersjs/feathers/issues/2906)) ([9ddc2e6](https://github.com/feathersjs/feathers/commit/9ddc2e6b028f026f939d6af68125847e5c6734b4)) - **cli:** Use separate patch schema and types ([#2916](https://github.com/feathersjs/feathers/issues/2916)) ([7088af6](https://github.com/feathersjs/feathers/commit/7088af64a539dc7f1a016d832b77b98aaaf92603)) - **schema:** Split resolver options and property resolvers ([#2889](https://github.com/feathersjs/feathers/issues/2889)) ([4822c94](https://github.com/feathersjs/feathers/commit/4822c949812e5a1dceff3c62b2f9de4781b4d601)) - **schema:** Virtual property resolvers ([#2900](https://github.com/feathersjs/feathers/issues/2900)) ([7d03b57](https://github.com/feathersjs/feathers/commit/7d03b57ae2f633bdd4a368e0d5955011fbd6c329)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/schema # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) ### Bug Fixes - **schema:** Improve resolver performance ([#2822](https://github.com/feathersjs/feathers/issues/2822)) ([5fa900f](https://github.com/feathersjs/feathers/commit/5fa900f90d55859332c90283dddddab26ae3759c)) - **schema:** Use the same options for resolveData hook ([#2833](https://github.com/feathersjs/feathers/issues/2833)) ([ed3b050](https://github.com/feathersjs/feathers/commit/ed3b05051db6886729d4824825ca8f00c2459af7)) # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) ### Features - **cli:** Generate full client test suite and improve typed client ([#2788](https://github.com/feathersjs/feathers/issues/2788)) ([57119b6](https://github.com/feathersjs/feathers/commit/57119b6bb2797f7297cf054268a248c093ecd538)) - **cli:** Improve generated schema definitions ([#2783](https://github.com/feathersjs/feathers/issues/2783)) ([474a9fd](https://github.com/feathersjs/feathers/commit/474a9fda2107e9bcf357746320a8e00cda8182b6)) # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) - **schema:** Make schemas validation library independent and add TypeBox support ([#2772](https://github.com/feathersjs/feathers/issues/2772)) ([44172d9](https://github.com/feathersjs/feathers/commit/44172d99b566d11d9ceda04f1d0bf72b6d05ce76)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) ### Bug Fixes - **schema:** Fix for Ajv global collision bug [#2681](https://github.com/feathersjs/feathers/issues/2681) ([#2702](https://github.com/feathersjs/feathers/issues/2702)) ([0b2def6](https://github.com/feathersjs/feathers/commit/0b2def6ca483fad6ca22fcc4ea9873bc027925d8)) ### Features - **authentication-oauth:** Koa and transport independent oAuth authentication ([#2737](https://github.com/feathersjs/feathers/issues/2737)) ([9231525](https://github.com/feathersjs/feathers/commit/9231525a24bb790ba9c5d940f2867a9c727691c9)) # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) ### Bug Fixes - Freeze the resolver context ([#2685](https://github.com/feathersjs/feathers/issues/2685)) ([247dccb](https://github.com/feathersjs/feathers/commit/247dccb2eb72551962030321cb1c0ecb11b0181e)) # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/schema # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/schema # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Bug Fixes - **schema:** Fix dispatch resovler hook to convert actually resolved data ([#2663](https://github.com/feathersjs/feathers/issues/2663)) ([f7e87db](https://github.com/feathersjs/feathers/commit/f7e87dbb9a0bc8d89aee47318dddbaa4d6ba5b91)) ### Features - **cli:** Add typed client to a generated app ([#2669](https://github.com/feathersjs/feathers/issues/2669)) ([5b801b5](https://github.com/feathersjs/feathers/commit/5b801b5017ddc3eaa95622b539f51d605916bc86)) # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) ### Bug Fixes - **schema:** Always resolve dispatch in resolveAll and add getDispatch method ([#2645](https://github.com/feathersjs/feathers/issues/2645)) ([145b366](https://github.com/feathersjs/feathers/commit/145b366435695438fbc8db9fdb161162ca9049ad)) - **schema:** remove `default` from queryProperty schemas ([#2646](https://github.com/feathersjs/feathers/issues/2646)) ([940a2b6](https://github.com/feathersjs/feathers/commit/940a2b6868d2f77f81edb1661f6417ec2ea6e372)) ### Features - **core:** Rename async hooks to around hooks, allow usual registration format ([#2652](https://github.com/feathersjs/feathers/issues/2652)) ([2a485a0](https://github.com/feathersjs/feathers/commit/2a485a07929184261f27437fc0fdfe5a44694834)) # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) ### Bug Fixes - **schema:** Allows resolveData with different resolvers based on method ([#2644](https://github.com/feathersjs/feathers/issues/2644)) ([be71fa2](https://github.com/feathersjs/feathers/commit/be71fa2fe260e05b7dcc0d5f439e33f2e9ec2434)) # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) ### Bug Fixes - **schema:** Add Combine helper to allow merging schema types that use ([#2637](https://github.com/feathersjs/feathers/issues/2637)) ([06d03e9](https://github.com/feathersjs/feathers/commit/06d03e91abb1347576c2351c12322d01c58473e5)) - **typescript:** Make additional types generic to work with extended types ([#2625](https://github.com/feathersjs/feathers/issues/2625)) ([269fdec](https://github.com/feathersjs/feathers/commit/269fdecc5961092dc8608b3cbe16f433c80bfa96)) ### Features - **schema:** Add resolveAll hook ([#2643](https://github.com/feathersjs/feathers/issues/2643)) ([85527d7](https://github.com/feathersjs/feathers/commit/85527d71cb78852880696e5d96abdcdf24593934)) - **schema:** Add resolver for safe external data dispatching ([#2641](https://github.com/feathersjs/feathers/issues/2641)) ([72b980e](https://github.com/feathersjs/feathers/commit/72b980e05631136d30c8f1468dee45ec6a8d2503)) - **schema:** Add schema resolver converter functionality ([#2640](https://github.com/feathersjs/feathers/issues/2640)) ([26d9e05](https://github.com/feathersjs/feathers/commit/26d9e05327d6e0144466cd57d6fcc11ac7ecb06a)) # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) ### Features - **schema:** Add querySyntax helper to create full query schemas ([#2621](https://github.com/feathersjs/feathers/issues/2621)) ([2bbb103](https://github.com/feathersjs/feathers/commit/2bbb103b2f3e30fb0fff935f92ad3276a1a67e41)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Features - **schema:** Allow hooks to run resolvers in sequence ([#2609](https://github.com/feathersjs/feathers/issues/2609)) ([d85c507](https://github.com/feathersjs/feathers/commit/d85c507c76d07e48fc8e7e28ff7de0ef435e0ef8)) - **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5)) - **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28)) # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) ### Bug Fixes - **schema:** result resolver correctly resolves paginated find result ([#2594](https://github.com/feathersjs/feathers/issues/2594)) ([6511e45](https://github.com/feathersjs/feathers/commit/6511e45bd0624f1a629530719709f4b27fecbe0b)) ### Features - **configuration:** Allow app configuration to be validated against a schema ([#2590](https://github.com/feathersjs/feathers/issues/2590)) ([a268f86](https://github.com/feathersjs/feathers/commit/a268f86da92a8ada14ed11ab456aac0a4bba5bb0)) # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) ### Bug Fixes - **hooks:** Allow all built-in hooks to be used the async and regular way ([#2559](https://github.com/feathersjs/feathers/issues/2559)) ([8f9f631](https://github.com/feathersjs/feathers/commit/8f9f631e0ce89de349207db72def84e7ab496a4a)) - **queryProperty:** allow compound oneOf ([#2545](https://github.com/feathersjs/feathers/issues/2545)) ([3077d2d](https://github.com/feathersjs/feathers/commit/3077d2d896a38d579ce4d5b530e21ad332bcf221)) - **schema:** Properly handle resolver errors ([#2540](https://github.com/feathersjs/feathers/issues/2540)) ([31fbdff](https://github.com/feathersjs/feathers/commit/31fbdff8bd848ac7e0eda56e307ac34b1bfcf17f)) # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) ### Bug Fixes - **schema:** Do not error for schemas without properties ([#2519](https://github.com/feathersjs/feathers/issues/2519)) ([96fdb47](https://github.com/feathersjs/feathers/commit/96fdb47d45fd88a8039aa9cc9ec8aebd98672b95)) - **schema:** Fix resolver data type and use new validation feature in test fixture ([#2523](https://github.com/feathersjs/feathers/issues/2523)) ([1093f12](https://github.com/feathersjs/feathers/commit/1093f124b60524cbd9050fcf07ddaf1d558973da)) ### Features - **schema:** Allow to use custom AJV and test with ajv-formats ([#2513](https://github.com/feathersjs/feathers/issues/2513)) ([ecfa4df](https://github.com/feathersjs/feathers/commit/ecfa4df29f029f6ca8517cacf518c14b46ffeb4e)) - **schema:** Improve schema typing, validation and extensibility ([#2521](https://github.com/feathersjs/feathers/issues/2521)) ([8c1b350](https://github.com/feathersjs/feathers/commit/8c1b35052792e82d13be03c06583534284fbae82)) # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Bug Fixes - **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/schema # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/schema # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/schema # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) ### Features - **schema:** Allow resolvers to validate a schema ([#2465](https://github.com/feathersjs/feathers/issues/2465)) ([7d9590b](https://github.com/feathersjs/feathers/commit/7d9590bbe12b94b8b5a7987684f5d4968e426481)) # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) ### Features - **schema:** Initial version of schema definitions and resolvers ([#2441](https://github.com/feathersjs/feathers/issues/2441)) ([c57a5cd](https://github.com/feathersjs/feathers/commit/c57a5cd56699a121647be4506d8f967e6d72ecae)) ================================================ FILE: packages/schema/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/schema/README.md ================================================ # @feathersjs/schema [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/schema.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/schema) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > A common data schema definition format ## Installation ``` npm install @feathersjs/schema --save ``` ## Documentation Refer to the [Feathers schema API documentation](https://feathersjs.com/api/schema/) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/schema/package.json ================================================ { "name": "@feathersjs/schema", "description": "A common data schema definition format", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/schema" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts", "test": "npm run compile && npm run mocha" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/adapter-commons": "^5.0.42", "@feathersjs/commons": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/feathers": "^5.0.42", "@feathersjs/hooks": "^0.9.0", "@types/json-schema": "^7.0.15", "ajv": "^8.18.0", "ajv-formats": "^3.0.1", "json-schema-to-ts": "^3.1.1" }, "devDependencies": { "@feathersjs/memory": "^5.0.42", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "ajv-formats": "^3.0.1", "mocha": "^11.7.5", "shx": "^0.4.0", "typescript": "^5.9.2" }, "peerDependencies": { "typescript": ">=5.9" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/schema/src/default-schemas.ts ================================================ import { FromSchema } from 'json-schema-to-ts' export const authenticationSettingsSchema = { type: 'object', required: ['secret', 'entity', 'authStrategies'], properties: { secret: { type: 'string', description: 'The JWT signing secret' }, entity: { oneOf: [ { type: 'null' }, { type: 'string' } ], description: 'The name of the authentication entity (e.g. user)' }, entityId: { type: 'string', description: 'The name of the authentication entity id property' }, service: { type: 'string', description: 'The path of the entity service' }, authStrategies: { type: 'array', items: { type: 'string' }, description: 'A list of authentication strategy names that are allowed to create JWT access tokens' }, parseStrategies: { type: 'array', items: { type: 'string' }, description: 'A list of authentication strategy names that should parse HTTP headers for authentication information (defaults to `authStrategies`)' }, jwtOptions: { type: 'object' }, jwt: { type: 'object', properties: { header: { type: 'string', default: 'Authorization', description: 'The HTTP header containing the JWT' }, schemes: { type: 'array', items: { type: 'string' }, description: 'An array of schemes to support' } } }, local: { type: 'object', required: ['usernameField', 'passwordField'], properties: { usernameField: { type: 'string', description: 'Name of the username field (e.g. `email`)' }, passwordField: { type: 'string', description: 'Name of the password field (e.g. `password`)' }, hashSize: { type: 'number', description: 'The BCrypt salt length' }, errorMessage: { type: 'string', default: 'Invalid login', description: 'The error message to return on errors' }, entityUsernameField: { type: 'string', description: 'Name of the username field on the entity if authentication request data and entity field names are different' }, entityPasswordField: { type: 'string', description: 'Name of the password field on the entity if authentication request data and entity field names are different' } } }, oauth: { type: 'object', properties: { redirect: { type: 'string' }, origins: { type: 'array', items: { type: 'string' } }, defaults: { type: 'object', properties: { key: { type: 'string' }, secret: { type: 'string' } } } } } } } as const export type AuthenticationConfiguration = FromSchema export const sqlSettingsSchema = { type: 'object', properties: { client: { type: 'string' }, pool: { type: 'object', properties: { min: { type: 'number' }, max: { type: 'number' } } }, connection: { oneOf: [ { type: 'string' }, { type: 'object', properties: { host: { type: 'string' }, port: { type: 'number' }, user: { type: 'string' }, password: { type: 'string' }, database: { type: 'string' } } } ] } } } as const /** * Schema for properties that are available in a standard Feathers application. */ export const defaultAppSettings = { authentication: authenticationSettingsSchema, origins: { type: 'array', items: { type: 'string' } }, paginate: { type: 'object', additionalProperties: false, required: ['default', 'max'], properties: { default: { type: 'number' }, max: { type: 'number' } } }, mongodb: { type: 'string' }, mysql: sqlSettingsSchema, postgresql: sqlSettingsSchema, sqlite: sqlSettingsSchema, mssql: sqlSettingsSchema } as const export const defaultAppConfiguration = { type: 'object', additionalProperties: false, properties: defaultAppSettings } as const export type DefaultAppConfiguration = FromSchema ================================================ FILE: packages/schema/src/hooks/index.ts ================================================ export * from './resolve' export * from './validate' ================================================ FILE: packages/schema/src/hooks/resolve.ts ================================================ import { HookContext, NextFunction } from '@feathersjs/feathers' import { compose } from '@feathersjs/hooks' import { Resolver, ResolverStatus } from '../resolver' const getResult = (context: H) => { const isPaginated = context.method === 'find' && context.result.data const data = isPaginated ? context.result.data : context.result return { isPaginated, data } } const runResolvers = async ( resolvers: Resolver[], data: any, ctx: H, status?: Partial> ) => { let current: any = data for (const resolver of resolvers) { if (resolver && typeof resolver.resolve === 'function') { current = await resolver.resolve(current, ctx, status) } } return current as T } export type ResolverSetting = Resolver | Resolver[] export const resolveQuery = (...resolvers: Resolver[]) => async (context: H, next?: NextFunction) => { const data = context?.params?.query || {} const query = await runResolvers(resolvers, data, context) context.params = { ...context.params, query } if (typeof next === 'function') { return next() } } export const resolveData = (...resolvers: Resolver[]) => async (context: H, next?: NextFunction) => { if (context.data !== undefined) { const data = context.data const status = { originalContext: context } if (Array.isArray(data)) { context.data = await Promise.all( data.map((current) => runResolvers(resolvers, current, context, status)) ) } else { context.data = await runResolvers(resolvers, data, context, status) } } if (typeof next === 'function') { return next() } } export const resolveResult = (...resolvers: Resolver[]) => { const virtualProperties = new Set(resolvers.reduce((acc, current) => acc.concat(current.virtualNames), [])) return async (context: H, next: NextFunction) => { if (typeof next !== 'function') { throw new Error('The resolveResult hook must be used as an around hook') } const { $resolve, $select, ...query } = context.params?.query || {} const hasVirtualSelects = Array.isArray($select) && $select.some((name) => virtualProperties.has(name)) const resolve = { originalContext: context, ...context.params.resolve, properties: $resolve || $select } context.params = { ...context.params, resolve, query: { ...query, ...(!!$select && !hasVirtualSelects ? { $select } : {}) } } await next() const status = context.params.resolve const { isPaginated, data } = getResult(context) const result = Array.isArray(data) ? await Promise.all(data.map(async (current) => runResolvers(resolvers, current, context, status))) : await runResolvers(resolvers, data, context, status) if (isPaginated) { context.result.data = result } else { context.result = result } } } export const DISPATCH = Symbol.for('@feathersjs/schema/dispatch') export const getDispatchValue = (value: any): any => { if (typeof value === 'object' && value !== null) { if (value[DISPATCH] !== undefined) { return value[DISPATCH] } if (Array.isArray(value)) { return value.map((item) => getDispatchValue(item)) } } return value } export const getDispatch = (value: any): any => typeof value === 'object' && value !== null && value[DISPATCH] ? value[DISPATCH] : null export const setDispatch = (current: any, dispatch: any) => { Object.defineProperty(current, DISPATCH, { value: dispatch, enumerable: false, configurable: false }) return dispatch } export const resolveExternal = (...resolvers: Resolver[]) => async (context: H, next: NextFunction) => { if (typeof next !== 'function') { throw new Error('The resolveExternal hook must be used as an around hook') } await next() const existingDispatch = getDispatch(context.result) if (existingDispatch !== null) { context.dispatch = existingDispatch } else { const status = context.params.resolve const { isPaginated, data } = getResult(context) const resolveAndGetDispatch = async (current: any) => { const currentExistingDispatch = getDispatch(current) if (currentExistingDispatch !== null) { return currentExistingDispatch } const resolved = await runResolvers(resolvers, current, context, status) const currentDispatch = Object.keys(resolved).reduce( (res, key) => { res[key] = getDispatchValue(resolved[key]) return res }, {} as Record ) return setDispatch(current, currentDispatch) } const result = await (Array.isArray(data) ? Promise.all(data.map(resolveAndGetDispatch)) : resolveAndGetDispatch(data)) const dispatch = isPaginated ? { ...context.result, data: result } : result context.dispatch = setDispatch(context.result, dispatch) } } export const resolveDispatch = resolveExternal type ResolveAllSettings = { data?: { create: Resolver patch: Resolver update: Resolver } query?: Resolver result?: Resolver dispatch?: Resolver } const dataMethods = ['create', 'update', 'patch'] as const /** * Resolve all resolvers at once. * * @param map The individual resolvers * @returns A combined resolver middleware * @deprecated Use individual data, query and external resolvers and hooks instead. * @see https://dove.feathersjs.com/guides/cli/service.schemas.html */ export const resolveAll = (map: ResolveAllSettings) => { const middleware = [] middleware.push(resolveDispatch(map.dispatch)) if (map.result) { middleware.push(resolveResult(map.result)) } if (map.query) { middleware.push(resolveQuery(map.query)) } if (map.data) { dataMethods.forEach((name) => { if (map.data[name]) { const resolver = resolveData(map.data[name]) middleware.push(async (context: H, next: NextFunction) => context.method === name ? resolver(context, next) : next() ) } }) } return compose(middleware) } ================================================ FILE: packages/schema/src/hooks/validate.ts ================================================ import { HookContext, NextFunction } from '@feathersjs/feathers' import { BadRequest } from '@feathersjs/errors' import { VALIDATED } from '@feathersjs/adapter-commons' import { Schema, Validator } from '../schema' import { DataValidatorMap } from '../json-schema' export const validateQuery = (schema: Schema | Validator) => { const validator: Validator = typeof schema === 'function' ? schema : schema.validate.bind(schema) return async (context: H, next?: NextFunction) => { const data = context?.params?.query || {} try { const query = await validator(data) Object.defineProperty(query, VALIDATED, { value: true }) context.params = { ...context.params, query } } catch (error: any) { throw error.ajv ? new BadRequest(error.message, error.errors) : error } if (typeof next === 'function') { return next() } } } export const validateData = (schema: Schema | DataValidatorMap | Validator) => { return async (context: H, next?: NextFunction) => { const data = context.data const validator = typeof (schema as Schema).validate === 'function' ? (schema as Schema).validate.bind(schema) : typeof schema === 'function' ? schema : (schema as any)[context.method] if (validator) { try { if (Array.isArray(data)) { context.data = await Promise.all(data.map((current) => validator(current))) } else { context.data = await validator(data) } Object.defineProperty(context.data, VALIDATED, { value: true }) } catch (error: any) { throw error.ajv ? new BadRequest(error.message, error.errors) : error } } if (typeof next === 'function') { return next() } } } ================================================ FILE: packages/schema/src/index.ts ================================================ import addFormats, { FormatName, FormatOptions, FormatsPluginOptions } from 'ajv-formats' import { ResolverStatus } from './resolver' export type { FromSchema } from 'json-schema-to-ts' export { addFormats, FormatName, FormatOptions, FormatsPluginOptions } export * from './schema' export * from './resolver' export * from './hooks' export * from './json-schema' export * from './default-schemas' export * as hooks from './hooks' export * as jsonSchema from './json-schema' export type Infer = S['_type'] export type Combine = Pick, Exclude, keyof U>> & U declare module '@feathersjs/feathers/lib/declarations' { interface Params { resolve?: ResolverStatus } } ================================================ FILE: packages/schema/src/json-schema.ts ================================================ import { _ } from '@feathersjs/commons' import { JSONSchema } from 'json-schema-to-ts' import { JSONSchemaDefinition, Ajv, Validator } from './schema' export type DataSchemaMap = { create: JSONSchemaDefinition update?: JSONSchemaDefinition patch?: JSONSchemaDefinition } export type DataValidatorMap = { create: Validator update: Validator patch: Validator } /** * Returns a compiled validation function for a schema and AJV validator instance. * * @param schema The JSON schema definition * @param validator The AJV validation instance * @returns A compiled validation function */ export const getValidator = (schema: JSONSchemaDefinition, validator: Ajv): Validator => validator.compile({ $async: true, ...(schema as any) }) as any as Validator /** * Returns compiled validation functions to validate data for the `create`, `update` and `patch` * service methods. If not passed explicitly, the `update` validator will be the same as the `create` * and `patch` will be the `create` validator with no required fields. * * @param def Either general JSON schema definition or a mapping of `create`, `update` and `patch` * to their respecitve JSON schema * @param validator The Ajv instance to use as the validator * @returns A map of validator functions */ export const getDataValidator = ( def: JSONSchemaDefinition | DataSchemaMap, validator: Ajv ): DataValidatorMap => { const schema = ((def as any).create ? def : { create: def }) as DataSchemaMap return { create: getValidator(schema.create, validator), update: getValidator( schema.update || { ...(schema.create as any), $id: `${schema.create.$id}Update` }, validator ), patch: getValidator( schema.patch || { ...(schema.create as any), $id: `${schema.create.$id}Patch`, required: [] }, validator ) } } export type PropertyQuery = { anyOf: [ D, { type: 'object' additionalProperties: false properties: { $gt: D $gte: D $lt: D $lte: D $ne: D $in: { type: 'array' items: D } $nin: { type: 'array' items: D } } & X } ] } /** * Create a Feathers query syntax compatible JSON schema definition for a property definition. * * @param def The property definition (e.g. `{ type: 'string' }`) * @param extensions Additional properties to add to the query property schema * @returns A JSON schema definition for the Feathers query syntax for this property. */ export const queryProperty = ( def: T, extensions: X = {} as X ) => { const definition = _.omit(def, 'default') return { anyOf: [ definition, { type: 'object', additionalProperties: false, properties: { $gt: definition, $gte: definition, $lt: definition, $lte: definition, $ne: definition, $in: definition.type === 'array' ? definition : { type: 'array', items: definition }, $nin: definition.type === 'array' ? definition : { type: 'array', items: definition }, ...extensions } } ] } as const } /** * Creates Feathers a query syntax compatible JSON schema for multiple properties. * * @param definitions A map of property definitions * @param extensions Additional properties to add to the query property schema * @returns The JSON schema definition for the Feathers query syntax for multiple properties */ export const queryProperties = < T extends { [key: string]: JSONSchema }, X extends { [K in keyof T]?: { [key: string]: JSONSchema } } >( definitions: T, extensions: X = {} as X ) => Object.keys(definitions).reduce( (res, key) => { const result = res as any const definition = definitions[key] result[key] = queryProperty(definition as JSONSchemaDefinition, extensions[key as keyof T]) return result }, {} as { [K in keyof T]: PropertyQuery } ) /** * Creates a JSON schema for the complete Feathers query syntax including `$limit`, $skip` * and `$sort` and `$select` for the allowed properties. * * @param definition The property definitions to create the query syntax schema for * @param extensions Additional properties to add to the query property schema * @returns A JSON schema for the complete query syntax */ export const querySyntax = < T extends { [key: string]: JSONSchema }, X extends { [K in keyof T]?: { [key: string]: JSONSchema } } >( definition: T, extensions: X = {} as X ) => { const keys = Object.keys(definition) const props = queryProperties(definition, extensions) const $or = { type: 'array', items: { type: 'object', additionalProperties: false, properties: props } } as const const $and = { type: 'array', items: { type: 'object', additionalProperties: false, properties: { ...props, $or } } } as const return { $limit: { type: 'number', minimum: 0 }, $skip: { type: 'number', minimum: 0 }, $sort: { type: 'object', properties: keys.reduce( (res, key) => { const result = res as any result[key] = { type: 'number', enum: [1, -1] } return result }, {} as { [K in keyof T]: { readonly type: 'number'; readonly enum: [1, -1] } } ) }, $select: { type: 'array', maxItems: keys.length, items: { type: 'string', ...(keys.length > 0 ? { enum: keys as any as (keyof T)[] } : {}) } }, $or, $and, ...props } as const } export const ObjectIdSchema = () => ({ anyOf: [ { type: 'string', objectid: true }, { type: 'object', properties: {}, additionalProperties: true } ] }) as const ================================================ FILE: packages/schema/src/resolver.ts ================================================ import { BadRequest } from '@feathersjs/errors' import { Schema } from './schema' type PromiseOrLiteral = Promise | V export type PropertyResolver = (( value: V | undefined, obj: T, context: C, status: ResolverStatus ) => PromiseOrLiteral) & { [IS_VIRTUAL]?: boolean } export type VirtualResolver = ( obj: T, context: C, status: ResolverStatus ) => PromiseOrLiteral export const IS_VIRTUAL = Symbol.for('@feathersjs/schema/virtual') /** * Create a resolver for a virtual property. A virtual property is a property that * is computed and never has an initial value. * * @param virtualResolver The virtual resolver function * @returns The property resolver function */ export const virtual = (virtualResolver: VirtualResolver) => { const propertyResolver: PropertyResolver = async (_value, obj, context, status) => virtualResolver(obj, context, status) propertyResolver[IS_VIRTUAL] = true return propertyResolver } export type PropertyResolverMap = { [key in keyof T]?: PropertyResolver | ReturnType> } export type ResolverConverter = ( obj: any, context: C, status: ResolverStatus ) => PromiseOrLiteral export interface ResolverOptions { schema?: Schema /** * A converter function that is run before property resolvers * to transform the initial data into a different format. */ converter?: ResolverConverter } export interface ResolverConfig extends ResolverOptions { /** * @deprecated Use the `validateData` and `validateQuery` hooks explicitly instead */ validate?: 'before' | 'after' | false /** * The properties to resolve */ properties: PropertyResolverMap } export interface ResolverStatus { path: string[] originalContext?: C properties?: (keyof T)[] stack: PropertyResolver[] } export class Resolver { readonly _type!: T public propertyNames: (keyof T)[] public virtualNames: (keyof T)[] constructor(public readonly options: ResolverConfig) { this.propertyNames = Object.keys(options.properties) as any as (keyof T)[] this.virtualNames = this.propertyNames.filter((name) => options.properties[name][IS_VIRTUAL]) } /** * Resolve a single property * * @param name The name of the property * @param data The current data * @param context The current resolver context * @param status The current resolver status * @returns The resolver property */ async resolveProperty( name: K, data: D, context: C, status: Partial> = {} ): Promise { const resolver = this.options.properties[name] const value = (data as any)[name] const { path = [], stack = [] } = status || {} // This prevents circular dependencies if (stack.includes(resolver)) { return undefined } const resolverStatus = { ...status, path: [...path, name as string], stack: [...stack, resolver] } return resolver(value, data as any, context, resolverStatus) } async convert(data: D, context: C, status?: Partial>) { if (this.options.converter) { const { path = [], stack = [] } = status || {} return this.options.converter(data, context, { ...status, path, stack }) } return data } async resolve(_data: D, context: C, status?: Partial>): Promise { const { properties: resolvers, schema, validate } = this.options const payload = await this.convert(_data, context, status) if (!Array.isArray(status?.properties) && this.propertyNames.length === 0) { return payload as T } const data = schema && validate === 'before' ? await schema.validate(payload) : payload const propertyList = ( Array.isArray(status?.properties) ? status?.properties : // By default get all data and resolver keys but remove duplicates [...new Set(Object.keys(data).concat(this.propertyNames as string[]))] ) as (keyof T)[] const result: any = {} const errors: any = {} let hasErrors = false // Not the most elegant but better performance await Promise.all( propertyList.map(async (name) => { const value = (data as any)[name] if (resolvers[name]) { try { const resolved = await this.resolveProperty(name, data, context, status) if (resolved !== undefined) { result[name] = resolved } } catch (error: any) { // TODO add error stacks const convertedError = typeof error.toJSON === 'function' ? error.toJSON() : { message: error.message || error } errors[name] = convertedError hasErrors = true } } else if (value !== undefined) { result[name] = value } }) ) if (hasErrors) { const propertyName = status?.properties ? ` ${status.properties.join('.')}` : '' throw new BadRequest('Error resolving data' + (propertyName ? ` ${propertyName}` : ''), errors) } return schema && validate === 'after' ? await schema.validate(result) : result } } /** * Create a new resolver with ``. * * @param options The configuration for the returned resolver * @returns A new resolver instance */ export function resolve( properties: PropertyResolverMap, options?: ResolverOptions ): Resolver export function resolve(options: ResolverConfig): Resolver export function resolve( properties: PropertyResolverMap | ResolverConfig, options?: ResolverOptions ) { const settings = ( (properties as ResolverConfig).properties ? properties : { properties, ...options } ) as ResolverConfig return new Resolver(settings) } ================================================ FILE: packages/schema/src/schema.ts ================================================ import Ajv, { AsyncValidateFunction, ValidateFunction } from 'ajv' import { FromSchema, JSONSchema } from 'json-schema-to-ts' import { BadRequest } from '@feathersjs/errors' export const DEFAULT_AJV = new Ajv({ coerceTypes: true, addUsedSchema: false }) export { Ajv } /** * A validation function that takes data and returns the (possibly coerced) * data or throws a validation error. */ export type Validator = (data: T) => Promise export type JSONSchemaDefinition = JSONSchema & { $id: string $async?: true properties?: { [key: string]: JSONSchema } required?: readonly string[] } export interface Schema { validate(...args: Parameters>): Promise } export class SchemaWrapper implements Schema> { ajv: Ajv validator: AsyncValidateFunction readonly _type!: FromSchema constructor( public definition: S, ajv: Ajv = DEFAULT_AJV ) { this.ajv = ajv this.validator = this.ajv.compile({ $async: true, ...(this.definition as any) }) as AsyncValidateFunction } get properties() { return this.definition.properties as S['properties'] } get required() { return this.definition.required as S['required'] } async validate>(...args: Parameters>) { try { const validated = (await this.validator(...args)) as T return validated } catch (error: any) { throw new BadRequest(error.message, error.errors) } } toJSON() { return this.definition } } export function schema(definition: S, ajv: Ajv = DEFAULT_AJV) { return new SchemaWrapper(definition, ajv) } ================================================ FILE: packages/schema/test/fixture.ts ================================================ import { feathers, HookContext, Application as FeathersApplication } from '@feathersjs/feathers' import { memory, MemoryService } from '@feathersjs/memory' import { GeneralError } from '@feathersjs/errors' import { AdapterParams } from '@feathersjs/adapter-commons' import { resolve, resolveResult, resolveQuery, resolveData, validateData, validateQuery, querySyntax, resolveDispatch, resolveAll, Ajv, FromSchema, getValidator, getDataValidator, virtual, resolveExternal } from '../src' const fixtureAjv = new Ajv({ coerceTypes: true, addUsedSchema: false }) export const userDataSchema = { $id: 'UserData', type: 'object', additionalProperties: false, required: ['email'], properties: { email: { type: 'string' }, password: { type: 'string' } } } as const export const userDataValidator = getValidator(userDataSchema, fixtureAjv) export const userDataValidatorMap = getDataValidator(userDataSchema, fixtureAjv) export type UserData = FromSchema export const userDataResolver = resolve>({ properties: { password: async () => { return 'hashed' } } }) export const userSchema = { $id: 'User', type: 'object', additionalProperties: false, required: ['id', ...userDataSchema.required], properties: { ...userDataSchema.properties, id: { type: 'number' }, name: { type: 'string' } } } as const export type User = FromSchema export const userResolver = resolve>({ name: async (_value, user) => user.email.split('@')[0] }) export const userExternalResolver = resolve>({ properties: { password: async (): Promise => undefined, email: async () => '[redacted]' } }) export const secondUserResolver = resolve>({ name: async (value, user) => `${value} (${user.email})` }) export const messageDataSchema = { $id: 'MessageData', type: 'object', additionalProperties: false, required: ['text', 'userId'], properties: { text: { type: 'string' }, userId: { type: 'number' } } } as const export type MessageData = FromSchema export const messageSchema = { $id: 'MessageResult', type: 'object', additionalProperties: false, required: ['id', ...messageDataSchema.required], properties: { ...messageDataSchema.properties, id: { type: 'number' }, user: { $ref: 'User' }, userList: { type: 'array', items: { $ref: 'User' } }, userPage: { type: 'object' } } } as const export type Message = FromSchema< typeof messageSchema, { references: [typeof userSchema] } > export const messageResolver = resolve>({ user: virtual(async (message, context) => { const { userId } = message if (context.params.error === true) { throw new GeneralError('This is an error') } const { data: [user] } = (await context.app.service('users').find({ ...context.params, paginate: { default: 2 }, query: { id: userId } })) as any return user as Message['user'] }), userList: virtual(async (_message, context) => { const users = await context.app.service('users').find({ paginate: false }) return users.map((user) => user) as any }), userPage: virtual(async (_message, context) => { const users = await context.app.service('users').find({ adapter: { paginate: { default: 2 } } }) return users as any }) }) export const otherMessageResolver = resolve<{ text: string }, HookContext>({}) export const messageQuerySchema = { $id: 'MessageQuery', type: 'object', additionalProperties: false, required: [], properties: { ...querySyntax(messageDataSchema.properties), $select: { type: 'array', items: { type: 'string' } }, $resolve: { type: 'array', items: { type: 'string' } } } } as const export type MessageQuery = FromSchema export const messageQueryValidator = getValidator(messageQuerySchema, fixtureAjv) export const messageQueryResolver = resolve>({ userId: async (value, _query, context) => { if (context.params?.user) { return context.params.user.id } return value } }) interface ServiceParams extends AdapterParams { user?: User error?: boolean } class MessageService extends MemoryService { async customMethod(data: any) { return data } } const findResult = { message: 'Hello' } class CustomService { async find() { return [findResult] } } const customMethodDataResolver = resolve>({ properties: { userId: async () => 0, additionalData: async () => 'additional data' } }) type ServiceTypes = { users: MemoryService messages: MessageService paginatedMessages: MemoryService custom: CustomService } type Application = FeathersApplication const app = feathers() app.use( 'users', memory({ multi: ['create'] }) ) app.use('messages', new MessageService(), { methods: ['find', 'get', 'create', 'update', 'patch', 'remove', 'customMethod'] }) app.use('custom', new CustomService()) app.service('custom').hooks({ around: { all: [resolveExternal(resolve>({}))] } }) app.use('paginatedMessages', memory({ paginate: { default: 10 } })) app.service('messages').hooks({ around: { all: [ resolveAll({ result: messageResolver, query: messageQueryResolver }), validateQuery(messageQueryValidator) ], customMethod: [resolveData(customMethodDataResolver)], find: [ async (context, next) => { // A hook that makes sure that virtual properties are not passed to the adapter as `$select` // An SQL adapter would throw an error if it received a query like this if (context.params?.query?.$select && context.params?.query?.$select.includes('user')) { throw new Error('Invalid $select') } await next() } ] } }) app .service('paginatedMessages') .hooks([ resolveDispatch(), resolveResult(messageResolver, otherMessageResolver), validateQuery(messageQueryValidator), resolveQuery(messageQueryResolver) ]) app .service('users') .hooks([resolveDispatch(userExternalResolver), resolveResult(userResolver, secondUserResolver)]) app.service('users').hooks({ create: [validateData(userDataValidator), validateData(userDataValidatorMap), resolveData(userDataResolver)] }) export { app } ================================================ FILE: packages/schema/test/hooks.test.ts ================================================ import { createContext } from '@feathersjs/feathers' import assert from 'assert' import { app, Message, User } from './fixture' describe('@feathersjs/schema/hooks', () => { const text = 'Hi there' let message: Message let messageOnPaginatedService: Message let user: User const userProps = (user: User) => ({ user, userList: [user], userPage: { limit: 2, skip: 0, total: 1, data: [user] } }) before(async () => { user = ( await app.service('users').create([ { email: 'hello@feathersjs.com', password: 'supersecret' } ]) )[0] message = await app.service('messages').create({ text, userId: user.id }) messageOnPaginatedService = await app.service('paginatedMessages').create({ text, userId: user.id }) }) it('ran resolvers in sequence', async () => { assert.strictEqual(user.name, 'hello (hello@feathersjs.com)') }) it('validates data', async () => { assert.rejects(() => app.service('users').create({ password: 'failing' } as any), { name: 'BadRequest' }) }) it('resolves results and handles resolver errors (#2534)', async () => { const payload = { userId: user.id, text } assert.ok(user) assert.strictEqual(user.password, 'hashed', 'Resolved data') assert.deepStrictEqual(message, { id: 0, ...userProps(user), ...payload }) const messages = await app.service('messages').find({ provider: 'external' }) assert.deepStrictEqual(messages, [ { id: 0, ...userProps(user), ...payload } ]) await assert.rejects( () => app.service('messages').find({ provider: 'external', error: true }), { name: 'BadRequest', message: 'Error resolving data', code: 400, className: 'bad-request', data: { user: { name: 'GeneralError', message: 'This is an error', code: 500, className: 'general-error' } } } ) }) it('resolves get result with the object on result', async () => { const payload = { userId: user.id, text } assert.ok(user) assert.strictEqual(user.password, 'hashed', 'Resolved data') assert.deepStrictEqual(message, { id: 0, ...userProps(user), ...payload }) const result = await app.service('messages').get(0, { provider: 'external' }) assert.deepStrictEqual(result, { id: 0, ...userProps(user), ...payload }) }) it('resolves with $select and virtual properties', async () => { const messages = await app.service('messages').find({ paginate: false, query: { $select: ['user', 'text'] } }) assert.deepStrictEqual(Object.keys(messages[0]), ['text', 'user']) }) it('resolves find results with paginated result object', async () => { const payload = { userId: user.id, text } assert.ok(user) assert.strictEqual(user.password, 'hashed', 'Resolved data') assert.deepStrictEqual(messageOnPaginatedService, { id: 0, ...userProps(user), ...payload }) const messages = await app.service('paginatedMessages').find({ provider: 'external', query: { $limit: 1, $skip: 0 } }) assert.deepStrictEqual(messages, { limit: 1, skip: 0, total: 1, data: [ { id: 0, ...userProps(user), ...payload } ] }) }) it('resolves safe dispatch data recursively and with arrays and pages', async () => { const service = app.service('messages') const context = await service.get(0, {}, createContext(service as any, 'get')) const user = { id: 0, email: '[redacted]', name: 'hello (hello@feathersjs.com)' } assert.strictEqual(context.result.user.password, 'hashed') assert.deepStrictEqual(context.dispatch, { text: 'Hi there', userId: 0, id: 0, ...userProps(user) }) }) it('resolves safe dispatch with static data', async () => { const service = app.service('custom') await service.find() assert.deepStrictEqual(await service.find(), [{ message: 'Hello' }]) }) it('resolves data for custom methods', async () => { const result = await app.service('messages').customMethod({ message: 'Hello' }) const user = { email: 'hello@feathersjs.com', password: 'hashed', id: 0, name: 'hello (hello@feathersjs.com)' } assert.deepStrictEqual(result, { message: 'Hello', userId: 0, additionalData: 'additional data', ...userProps(user) }) }) it('validates and converts the query', async () => { const otherUser = await app.service('users').create({ email: 'helloagain@feathersjs.com', password: 'supersecret' }) await app.service('messages').create({ text, userId: otherUser.id }) const messages = await app.service('messages').find({ paginate: false, query: { userId: `${user.id}` } }) assert.strictEqual(messages.length, 1) const userMessages = await app.service('messages').find({ paginate: false, user }) assert.strictEqual(userMessages.length, 1) assert.strictEqual(userMessages[0].userId, user.id) const msg = await app.service('messages').get(userMessages[0].id, { query: { $resolve: ['user'] } }) assert.deepStrictEqual(msg, { user }) assert.rejects( () => app.service('messages').find({ query: { thing: 'me' } }), { name: 'BadRequest', message: 'validation failed', code: 400, className: 'bad-request', data: [ { instancePath: '', schemaPath: '#/additionalProperties', keyword: 'additionalProperties', params: { additionalProperty: 'thing' }, message: 'must NOT have additional properties' } ] } ) }) }) ================================================ FILE: packages/schema/test/json-schema.test.ts ================================================ import Ajv from 'ajv' import assert from 'assert' import { ObjectId as MongoObjectId } from 'mongodb' import { FromSchema } from '../src/' import { querySyntax, ObjectIdSchema } from '../src/json-schema' describe('@feathersjs/schema/json-schema', () => { it('querySyntax works with no properties', async () => { const schema = { type: 'object', properties: querySyntax({}) } new Ajv().compile(schema) }) it('querySyntax with extensions', async () => { const schema = { name: { type: 'string' }, age: { type: 'number' } } as const const querySchema = { type: 'object', properties: querySyntax(schema, { name: { $ilike: { type: 'string' } }, age: { $value: { type: 'null' } } } as const) } as const type Query = FromSchema const q: Query = { name: { $ilike: 'hello' }, age: { $value: null, $gte: 42 } } const validator = new Ajv({ strict: false }).compile(querySchema) assert.ok(validator(q)) }) it('$in and $nin works with array definitions', async () => { const schema = { things: { type: 'array', items: { type: 'number' } } } as const const querySchema = { type: 'object', properties: querySyntax(schema) } as const type Query = FromSchema const q: Query = { things: { $in: [10, 20], $nin: [30] } } const validator = new Ajv({ strict: false }).compile(querySchema) assert.ok(validator(q)) }) // Test ObjectId validation it('ObjectId', async () => { const schema = { type: 'object', properties: { _id: ObjectIdSchema() } } const validator = new Ajv({ strict: false }).compile(schema) const validated = await validator({ _id: '507f191e810c19729de860ea' }) assert.ok(validated) const validated2 = await validator({ _id: new MongoObjectId() }) assert.ok(validated2) }) }) ================================================ FILE: packages/schema/test/resolver.test.ts ================================================ import assert from 'assert' import { BadRequest } from '@feathersjs/errors' import { FromSchema, schema, resolve, virtual } from '../src' describe('@feathersjs/schema/resolver', () => { const userSchema = { $id: 'simple-user', type: 'object', required: ['firstName', 'lastName'], additionalProperties: false, properties: { firstName: { type: 'string' }, lastName: { type: 'string' }, password: { type: 'string' } } } as const const context = { isContext: true } type User = FromSchema & { name: string } it('simple resolver', async () => { const userResolver = resolve({ password: async (): Promise => undefined, name: async (_value, user, ctx, status) => { assert.deepStrictEqual(ctx, context) assert.deepStrictEqual(status.path, ['name']) assert.strictEqual(typeof status.stack[0], 'function') return `${user.firstName} ${user.lastName}` } }) const u = await userResolver.resolve( { firstName: 'Dave', lastName: 'L.' }, context ) assert.deepStrictEqual(u, { firstName: 'Dave', lastName: 'L.', name: 'Dave L.' }) const withProps = await userResolver.resolve( { firstName: 'David', lastName: 'L' }, context, { properties: ['name', 'lastName'] } ) assert.deepStrictEqual(withProps, { name: 'David L', lastName: 'L' }) }) it('simple resolver with virtual', async () => { const userResolver = resolve({ password: async (): Promise => undefined, name: virtual(async (user, ctx, status) => { assert.deepStrictEqual(ctx, context) assert.deepStrictEqual(status.path, ['name']) assert.strictEqual(typeof status.stack[0], 'function') return `${user.firstName} ${user.lastName}` }) }) const u = await userResolver.resolve( { firstName: 'Dave', lastName: 'L.' }, context ) assert.deepStrictEqual(u, { firstName: 'Dave', lastName: 'L.', name: 'Dave L.' }) }) it('simple resolver with schema and validation', async () => { const userFeathersSchema = schema(userSchema) const userBeforeResolver = resolve({ schema: userFeathersSchema, validate: 'before', properties: { name: async (_name, user) => `${user.firstName} ${user.lastName}` } }) const userAfterResolver = resolve({ schema: userFeathersSchema, validate: 'after', properties: { firstName: async (): Promise => undefined } }) await assert.rejects(() => userBeforeResolver.resolve({}, context), { message: 'validation failed' }) await assert.rejects( () => userAfterResolver.resolve( { firstName: 'Test', lastName: 'Me' }, context ), { message: 'validation failed' } ) }) it('simple resolver with converter', async () => { const userConverterResolver = resolve({ converter: async (data) => ({ firstName: 'Default', lastName: 'Name', ...data }), properties: { name: async (_name, user) => `${user.firstName} ${user.lastName}` } }) const u = await userConverterResolver.resolve({}, context) assert.deepStrictEqual(u, { firstName: 'Default', lastName: 'Name', name: 'Default Name' }) }) it('resolving with errors', async () => { const dummyResolver = resolve<{ name: string; age: number }, Record>({ properties: { name: async (value) => { if (value === 'Dave') { throw new Error(`No ${value}s allowed`) } return value }, age: async (value) => { if (value && value < 18) { throw new BadRequest('Invalid age') } return value } } }) assert.rejects( () => dummyResolver.resolve( { name: 'Dave', age: 16 }, {} ), { name: 'BadRequest', message: 'Error resolving data', code: 400, className: 'bad-request', data: { name: { message: 'No Daves allowed' }, age: { name: 'BadRequest', message: 'Invalid age', code: 400, className: 'bad-request' } } } ) }) it('empty resolver returns original data', async () => { const resolver = resolve({ properties: {} }) const data = { message: 'Hello' } const resolved = await resolver.resolve(data, {}) assert.strictEqual(data, resolved) }) it('empty resolver still allows to select properties', async () => { const data = { message: 'Hello', name: 'David' } const resolver = resolve({ properties: {} }) const resolved = await resolver.resolve(data, {}, { properties: ['message'] }) assert.deepStrictEqual(resolved, { message: 'Hello' }) }) }) ================================================ FILE: packages/schema/test/schema.test.ts ================================================ import assert from 'assert' import { schema, Infer, queryProperty } from '../src/' import Ajv, { AnySchemaObject } from 'ajv' import addFormats from 'ajv-formats' const customAjv = new Ajv({ coerceTypes: true }) addFormats(customAjv) // Utility for converting "date" and "date-time" string formats into Dates. customAjv.addKeyword({ keyword: 'convert', type: 'string', compile(schemaVal: boolean, parentSchema: AnySchemaObject) { return ['date-time', 'date'].includes(parentSchema.format) && schemaVal ? function (value: string, obj: any) { const { parentData, parentDataProperty } = obj // Update date-time string to Date object parentData[parentDataProperty] = new Date(value) return true } : () => true } }) describe('@feathersjs/schema/schema', () => { it('type inference and validation', async () => { const messageSchema = schema({ $id: 'message-test', type: 'object', required: ['text', 'read'], additionalProperties: false, properties: { text: { type: 'string' }, read: { type: 'boolean' }, upvotes: { type: 'number' } } } as const) type Message = Infer const message = await messageSchema.validate({ text: 'hi', read: 0, upvotes: '10' }) assert.deepStrictEqual(messageSchema.toJSON(), messageSchema.definition) assert.deepStrictEqual(message, { text: 'hi', read: false, upvotes: 10 }) await assert.rejects(() => messageSchema.validate({ text: 'failing' }), { name: 'BadRequest', data: [ { instancePath: '', keyword: 'required', message: "must have required property 'read'", params: { missingProperty: 'read' }, schemaPath: '#/required' } ] }) }) it('uses custom AJV with format validation', async () => { const formatsSchema = schema( { $id: 'formats-test', type: 'object', required: [], additionalProperties: false, properties: { dobString: { type: 'string', format: 'date' }, createdAt: { type: 'string', format: 'date-time' } } } as const, customAjv ) await formatsSchema.validate({ createdAt: '2021-12-22T23:59:59.999Z' }) try { await formatsSchema.validate({ createdAt: '2021-12-22T23:59:59.bbb' }) } catch (error: any) { assert.equal(error.data[0].message, 'must match format "date-time"') } }) it('custom AJV can convert dates', async () => { const definition = { $id: 'converts-formats-test', type: 'object', required: [], additionalProperties: false, properties: { dobString: queryProperty({ type: 'string', format: 'date', convert: true }), createdAt: { type: 'string', format: 'date-time', convert: true } } } as const const formatsSchema = schema(definition, customAjv) const validated: any = await formatsSchema.validate({ dobString: { $gt: '2025-04-25' }, createdAt: '2021-12-22T23:59:59.999Z' }) assert.ok(validated.dobString.$gt instanceof Date) assert.ok(validated.createdAt instanceof Date) }) it('schema extension and type inference', async () => { const messageSchema = schema({ $id: 'message-ext', type: 'object', required: ['text', 'read'], additionalProperties: false, properties: { text: { type: 'string' }, read: { type: 'boolean' } } } as const) const messageResultSchema = schema({ $id: 'message-ext-vote', type: 'object', required: ['upvotes', ...messageSchema.definition.required], additionalProperties: false, properties: { ...messageSchema.definition.properties, upvotes: { type: 'number' } } } as const) type MessageResult = Infer const m = await messageResultSchema.validate({ text: 'Hi', read: 'false', upvotes: '23' }) assert.deepStrictEqual(m, { text: 'Hi', read: false, upvotes: 23 }) }) it('with references', async () => { const userSchema = schema( { $id: 'ref-user', type: 'object', required: ['email'], additionalProperties: false, properties: { email: { type: 'string' }, age: { type: 'number' } } } as const, customAjv ) const messageSchema = schema( { $id: 'ref-message', type: 'object', required: ['text', 'user'], additionalProperties: false, properties: { text: { type: 'string' }, user: { $ref: 'ref-user' } } } as const, customAjv ) type User = Infer type Message = Infer & { user: User } const res = await messageSchema.validate({ text: 'Hello', user: { email: 'hello@feathersjs.com', age: '42' } }) assert.ok(userSchema) assert.deepStrictEqual(res, { text: 'Hello', user: { email: 'hello@feathersjs.com', age: 42 } }) }) it('works with oneOf properties (#2508)', async () => { const oneOfSchema = schema({ $id: 'schemaA', oneOf: [ { type: 'object', additionalProperties: false, required: ['x'], properties: { x: { type: 'number' } } }, { type: 'object', additionalProperties: false, required: ['y'], properties: { y: { type: 'number' } } } ] } as const) const res = await oneOfSchema.validate({ x: '3' }) assert.deepStrictEqual(res, { x: 3 }) }) it('can handle compound queryProperty', async () => { const formatsSchema = schema( { $id: 'compoundQueryProperty', type: 'object', required: [], additionalProperties: false, properties: { dobString: queryProperty({ oneOf: [ { type: 'string', format: 'date', convert: true }, { type: 'string', format: 'date-time', convert: true }, { type: 'object' } ] }) } } as const, customAjv ) const validated = await formatsSchema.validate({ dobString: { $gt: '2025-04-25', $lte: new Date('2027-04-25') } }) assert.ok(validated) }) it('can still fail queryProperty validation', async () => { const formatsSchema = schema( { $id: 'compoundQueryPropertyFail', type: 'object', required: [], additionalProperties: false, properties: { dobString: queryProperty({ type: 'string' }) } } as const, customAjv ) try { const validated = await formatsSchema.validate({ dobString: { $moose: 'test' } }) assert(!validated, 'should not have gotten here') } catch (error: any) { assert.ok(error.data?.length > 0) } }) it('removes default from queryProperty schemas like $gt', async () => { const validator = schema( { $id: 'noDefault$gt', type: 'object', required: [], additionalProperties: false, properties: { someDate: queryProperty({ default: '0000-00-00', type: 'string' }) } } as const, customAjv ) assert.equal( validator.definition.properties.someDate.anyOf[1].properties.$gt.type, 'string', 'type is found under $gt' ) assert(!validator.definition.properties.someDate.anyOf[1].properties.$gt.default, 'no default under $gt') }) }) ================================================ FILE: packages/schema/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/socketio/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) ### Bug Fixes - Reduce usage of lodash ([#3455](https://github.com/feathersjs/feathers/issues/3455)) ([8ce807a](https://github.com/feathersjs/feathers/commit/8ce807a5ca53ff5b8d5107a0656c6329404e6e6c)) ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/socketio ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Bug Fixes - **socketio:** Disconnect socket on app disconnect event ([#2896](https://github.com/feathersjs/feathers/issues/2896)) ([4ba0039](https://github.com/feathersjs/feathers/commit/4ba003907843cfc2655798a568b16f07ff8adb1b)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) ### Bug Fixes - **authentication:** Improve logout and disconnect connection handling ([#2813](https://github.com/feathersjs/feathers/issues/2813)) ([dd77379](https://github.com/feathersjs/feathers/commit/dd77379d8bdcd32d529bef912e672639e4899823)) - **docs:** Review transport API docs and update Express middleware setup ([#2811](https://github.com/feathersjs/feathers/issues/2811)) ([1b97f14](https://github.com/feathersjs/feathers/commit/1b97f14d474f5613482f259eeaa585c24fcfab43)) ### Features - **cli:** Add authentication client to generated client ([#2801](https://github.com/feathersjs/feathers/issues/2801)) ([bd59f91](https://github.com/feathersjs/feathers/commit/bd59f91b45a01c2eea0c4386e567f4de5aa6ad99)) # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Bug Fixes - **core:** Ensure setup and teardown can be overriden and maintain hook functionality ([#2779](https://github.com/feathersjs/feathers/issues/2779)) ([ab580cb](https://github.com/feathersjs/feathers/commit/ab580cbcaa68d19144d86798c13bf564f9d424a6)) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) ### Bug Fixes - **socketio:** Reinitialize hooks on overriden setup method ([#2722](https://github.com/feathersjs/feathers/issues/2722)) ([5e8e7c4](https://github.com/feathersjs/feathers/commit/5e8e7c442238fdc929a0a36b8b8ca2b230ce761f)) # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Features - **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28)) # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Bug Fixes - **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Features - **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) ### Features - **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/socketio # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) ### Bug Fixes - **dependencies:** Fix transport-commons dependency and update other dependencies ([#2284](https://github.com/feathersjs/feathers/issues/2284)) ([05b03b2](https://github.com/feathersjs/feathers/commit/05b03b27b40604d956047e3021d8053c3a137616)) # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) ### Features - **core:** Public custom service methods ([#2270](https://github.com/feathersjs/feathers/issues/2270)) ([e65abfb](https://github.com/feathersjs/feathers/commit/e65abfb5388df6c19a11c565cf1076a29f32668d)) - Application service types default to any ([#1566](https://github.com/feathersjs/feathers/issues/1566)) ([d93ba9a](https://github.com/feathersjs/feathers/commit/d93ba9a17edd20d3397bb00f4f6e82e804e42ed6)) - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) - **core:** Remove Uberproto ([#2178](https://github.com/feathersjs/feathers/issues/2178)) ([ddf8821](https://github.com/feathersjs/feathers/commit/ddf8821f53317e6a378657f7d66acb03a037ee47)) ### BREAKING CHANGES - **core:** Services no longer extend Uberproto objects and `service.mixin()` is no longer available. # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### Features - **transport-commons:** Remove legacy message format and unnecessary client timeouts ([#1939](https://github.com/feathersjs/feathers/issues/1939)) ([5538881](https://github.com/feathersjs/feathers/commit/5538881a08bc130de42c5984055729d8336f8615)) ### BREAKING CHANGES - **transport-commons:** Removes the old message format and client service timeout # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### Features - **transport-commons:** Remove legacy message format and unnecessary client timeouts ([#1939](https://github.com/feathersjs/feathers/issues/1939)) ([5538881](https://github.com/feathersjs/feathers/commit/5538881a08bc130de42c5984055729d8336f8615)) ### BREAKING CHANGES - **transport-commons:** Removes the old message format and client service timeout ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) **Note:** Version bump only for package @feathersjs/socketio ## [4.5.10](https://github.com/feathersjs/feathers/compare/v4.5.9...v4.5.10) (2020-11-08) **Note:** Version bump only for package @feathersjs/socketio ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) **Note:** Version bump only for package @feathersjs/socketio ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) **Note:** Version bump only for package @feathersjs/socketio ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) **Note:** Version bump only for package @feathersjs/socketio ## [4.5.6](https://github.com/feathersjs/feathers/compare/v4.5.5...v4.5.6) (2020-07-12) **Note:** Version bump only for package @feathersjs/socketio ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) **Note:** Version bump only for package @feathersjs/socketio ## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-04-29) **Note:** Version bump only for package @feathersjs/socketio ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) **Note:** Version bump only for package @feathersjs/socketio ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) **Note:** Version bump only for package @feathersjs/socketio ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/socketio # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) **Note:** Version bump only for package @feathersjs/socketio ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/socketio ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/socketio # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) ### Features - **authentication:** Add parseStrategies to allow separate strategies for creating JWTs and parsing headers ([#1708](https://github.com/feathersjs/feathers/issues/1708)) ([5e65629](https://github.com/feathersjs/feathers/commit/5e65629b924724c3e81d7c81df047e123d1c8bd7)) ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) **Note:** Version bump only for package @feathersjs/socketio ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/socketio ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) **Note:** Version bump only for package @feathersjs/socketio ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) **Note:** Version bump only for package @feathersjs/socketio ## [4.3.5](https://github.com/feathersjs/feathers/compare/v4.3.4...v4.3.5) (2019-10-07) **Note:** Version bump only for package @feathersjs/socketio ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) ### Bug Fixes - Typing improvements ([#1580](https://github.com/feathersjs/feathers/issues/1580)) ([7818aec](https://github.com/feathersjs/feathers/commit/7818aec)) ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) **Note:** Version bump only for package @feathersjs/socketio ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) **Note:** Version bump only for package @feathersjs/socketio ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) **Note:** Version bump only for package @feathersjs/socketio # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/socketio # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/socketio # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) ### Bug Fixes - Expire and remove authenticated real-time connections ([#1512](https://github.com/feathersjs/feathers/issues/1512)) ([2707c33](https://github.com/feathersjs/feathers/commit/2707c33)) - Use WeakMap to connect socket to connection ([#1509](https://github.com/feathersjs/feathers/issues/1509)) ([64807e3](https://github.com/feathersjs/feathers/commit/64807e3)) # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) **Note:** Version bump only for package @feathersjs/socketio # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/socketio # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) **Note:** Version bump only for package @feathersjs/socketio # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) **Note:** Version bump only for package @feathersjs/socketio # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) ### Bug Fixes - Use `export =` in TypeScript definitions ([#1285](https://github.com/feathersjs/feathers/issues/1285)) ([12d0f4b](https://github.com/feathersjs/feathers/commit/12d0f4b)) ### Features - Add global disconnect event ([#1355](https://github.com/feathersjs/feathers/issues/1355)) ([85afcca](https://github.com/feathersjs/feathers/commit/85afcca)) # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) ### Features - Add params.headers to all transports when available ([#1303](https://github.com/feathersjs/feathers/issues/1303)) ([ebce79b](https://github.com/feathersjs/feathers/commit/ebce79b)) # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) - **package:** update debug to version 3.0.0 ([#83](https://github.com/feathersjs/feathers/issues/83)) ([49f1de9](https://github.com/feathersjs/feathers/commit/49f1de9)) - **package:** update socket.io to version 2.0.0 ([#75](https://github.com/feathersjs/feathers/issues/75)) ([d4a4b71](https://github.com/feathersjs/feathers/commit/d4a4b71)) ### chore - drop support for Node.js 0.10 ([#48](https://github.com/feathersjs/feathers/issues/48)) ([3f7555a](https://github.com/feathersjs/feathers/commit/3f7555a)) ### Features - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) ### BREAKING CHANGES - This module no longer supports Node.js 0.10 ## [3.2.9](https://github.com/feathersjs/feathers/compare/@feathersjs/socketio@3.2.8...@feathersjs/socketio@3.2.9) (2019-01-02) **Note:** Version bump only for package @feathersjs/socketio ## [3.2.8](https://github.com/feathersjs/feathers/compare/@feathersjs/socketio@3.2.7...@feathersjs/socketio@3.2.8) (2018-12-16) **Note:** Version bump only for package @feathersjs/socketio ## [3.2.7](https://github.com/feathersjs/feathers/compare/@feathersjs/socketio@3.2.6...@feathersjs/socketio@3.2.7) (2018-10-25) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) ## [3.2.6](https://github.com/feathersjs/feathers/compare/@feathersjs/socketio@3.2.5...@feathersjs/socketio@3.2.6) (2018-09-21) **Note:** Version bump only for package @feathersjs/socketio ## [3.2.5](https://github.com/feathersjs/feathers/compare/@feathersjs/socketio@3.2.4...@feathersjs/socketio@3.2.5) (2018-09-17) **Note:** Version bump only for package @feathersjs/socketio ## [3.2.4](https://github.com/feathersjs/feathers/compare/@feathersjs/socketio@3.2.3...@feathersjs/socketio@3.2.4) (2018-09-02) **Note:** Version bump only for package @feathersjs/socketio ## 3.2.3 - Migrate to Monorepo ([feathers#462](https://github.com/feathersjs/feathers/issues/462)) ## [v3.2.2](https://github.com/feathersjs/socketio/tree/v3.2.2) (2018-06-03) [Full Changelog](https://github.com/feathersjs/socketio/compare/v3.2.1...v3.2.2) **Merged pull requests:** - Update uberproto to the latest version 🚀 [\#117](https://github.com/feathersjs/socketio/pull/117) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v3.2.1](https://github.com/feathersjs/socketio/tree/v3.2.1) (2018-04-04) [Full Changelog](https://github.com/feathersjs/socketio/compare/v3.2.0...v3.2.1) **Closed issues:** - Connection closed before receiving a handshake response [\#113](https://github.com/feathersjs/socketio/issues/113) - `yarn add @feathersjs/socketio` gets stuck [\#112](https://github.com/feathersjs/socketio/issues/112) **Merged pull requests:** - Use latest version of Socket.io \(2.1.0\) [\#115](https://github.com/feathersjs/socketio/pull/115) ([daffl](https://github.com/daffl)) ## [v3.2.0](https://github.com/feathersjs/socketio/tree/v3.2.0) (2018-02-09) [Full Changelog](https://github.com/feathersjs/socketio/compare/v3.1.0...v3.2.0) **Closed issues:** - My chat room sometimes the user's text has become????? [\#109](https://github.com/feathersjs/socketio/issues/109) **Merged pull requests:** - Update @feathersjs/transport-commons to the latest version 🚀 [\#111](https://github.com/feathersjs/socketio/pull/111) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v3.1.0](https://github.com/feathersjs/socketio/tree/v3.1.0) (2018-01-30) [Full Changelog](https://github.com/feathersjs/socketio/compare/v3.0.2...v3.1.0) **Closed issues:** - How to change 5000ms timeout? [\#107](https://github.com/feathersjs/socketio/issues/107) **Merged pull requests:** - Change dependency to @feathersjs/transport-commons [\#110](https://github.com/feathersjs/socketio/pull/110) ([daffl](https://github.com/daffl)) - Update mocha to the latest version 🚀 [\#108](https://github.com/feathersjs/socketio/pull/108) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v3.0.2](https://github.com/feathersjs/socketio/tree/v3.0.2) (2018-01-03) [Full Changelog](https://github.com/feathersjs/socketio/compare/v3.0.1...v3.0.2) **Closed issues:** - Updated from feathers-socketio to @feathersjs/socketio; error message [\#104](https://github.com/feathersjs/socketio/issues/104) - How to stop listening to socket server from client service [\#103](https://github.com/feathersjs/socketio/issues/103) - Options are not passed to socket-io [\#101](https://github.com/feathersjs/socketio/issues/101) - feathers / graphql using REST / Sockets [\#97](https://github.com/feathersjs/socketio/issues/97) **Merged pull requests:** - Update Readme to correspond with latest release [\#106](https://github.com/feathersjs/socketio/pull/106) ([daffl](https://github.com/daffl)) - Update semistandard to the latest version 🚀 [\#105](https://github.com/feathersjs/socketio/pull/105) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update feathers-memory to the latest version 🚀 [\#102](https://github.com/feathersjs/socketio/pull/102) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v3.0.1](https://github.com/feathersjs/socketio/tree/v3.0.1) (2017-11-16) [Full Changelog](https://github.com/feathersjs/socketio/compare/v3.0.0...v3.0.1) **Closed issues:** - Remote address IP is always undefined [\#96](https://github.com/feathersjs/socketio/issues/96) **Merged pull requests:** - Add default export for better ES module \(TypeScript\) compatibility [\#100](https://github.com/feathersjs/socketio/pull/100) ([daffl](https://github.com/daffl)) - Updating client use example to fix imports [\#99](https://github.com/feathersjs/socketio/pull/99) ([corymsmith](https://github.com/corymsmith)) ## [v3.0.0](https://github.com/feathersjs/socketio/tree/v3.0.0) (2017-11-01) [Full Changelog](https://github.com/feathersjs/socketio/compare/v2.0.1...v3.0.0) **Merged pull requests:** - Update dependencies for release [\#95](https://github.com/feathersjs/socketio/pull/95) ([daffl](https://github.com/daffl)) - Throw an error when using an incompatible version of Feathers [\#94](https://github.com/feathersjs/socketio/pull/94) ([daffl](https://github.com/daffl)) ## [v2.0.1](https://github.com/feathersjs/socketio/tree/v2.0.1) (2017-10-31) [Full Changelog](https://github.com/feathersjs/socketio/compare/v3.0.0-pre.4...v2.0.1) **Merged pull requests:** - Add an error when trying to use earlier versions with Feathers v3 [\#93](https://github.com/feathersjs/socketio/pull/93) ([daffl](https://github.com/daffl)) ## [v3.0.0-pre.4](https://github.com/feathersjs/socketio/tree/v3.0.0-pre.4) (2017-10-25) [Full Changelog](https://github.com/feathersjs/socketio/compare/v3.0.0-pre.3...v3.0.0-pre.4) ## [v3.0.0-pre.3](https://github.com/feathersjs/socketio/tree/v3.0.0-pre.3) (2017-10-22) [Full Changelog](https://github.com/feathersjs/socketio/compare/v3.0.0-pre.2...v3.0.0-pre.3) **Merged pull requests:** - Rename repository and update to using npm scopes [\#92](https://github.com/feathersjs/socketio/pull/92) ([daffl](https://github.com/daffl)) - Updates for Feathers v3 \(Buzzard\) [\#91](https://github.com/feathersjs/socketio/pull/91) ([daffl](https://github.com/daffl)) ## [v3.0.0-pre.2](https://github.com/feathersjs/socketio/tree/v3.0.0-pre.2) (2017-10-18) [Full Changelog](https://github.com/feathersjs/socketio/compare/v3.0.0-pre.1...v3.0.0-pre.2) **Merged pull requests:** - Some finishing touches for v3 [\#90](https://github.com/feathersjs/socketio/pull/90) ([daffl](https://github.com/daffl)) ## [v3.0.0-pre.1](https://github.com/feathersjs/socketio/tree/v3.0.0-pre.1) (2017-10-17) [Full Changelog](https://github.com/feathersjs/socketio/compare/v2.0.0...v3.0.0-pre.1) **Closed issues:** - Filter service updates by ID [\#87](https://github.com/feathersjs/socketio/issues/87) - An in-range update of mocha is breaking the build 🚨 [\#86](https://github.com/feathersjs/socketio/issues/86) - An in-range update of babel-cli is breaking the build 🚨 [\#85](https://github.com/feathersjs/socketio/issues/85) - Connection closed before receiving a handshake response [\#84](https://github.com/feathersjs/socketio/issues/84) - Maybe acting wrong please look into my test app [\#81](https://github.com/feathersjs/socketio/issues/81) - Connecting to sockets on a path [\#80](https://github.com/feathersjs/socketio/issues/80) - An in-range update of babel-core is breaking the build 🚨 [\#79](https://github.com/feathersjs/socketio/issues/79) - An in-range update of mocha is breaking the build 🚨 [\#78](https://github.com/feathersjs/socketio/issues/78) - Add Socket.io v2 support [\#77](https://github.com/feathersjs/socketio/issues/77) - Any chance for socket.io-p2p support? [\#37](https://github.com/feathersjs/socketio/issues/37) **Merged pull requests:** - Finalizing updates for Feathers v3 [\#89](https://github.com/feathersjs/socketio/pull/89) ([daffl](https://github.com/daffl)) - Update mocha to the latest version 🚀 [\#88](https://github.com/feathersjs/socketio/pull/88) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update debug to the latest version 🚀 [\#83](https://github.com/feathersjs/socketio/pull/83) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update to latest plugin infrastructure [\#82](https://github.com/feathersjs/socketio/pull/82) ([daffl](https://github.com/daffl)) ## [v2.0.0](https://github.com/feathersjs/socketio/tree/v2.0.0) (2017-05-10) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.6.0...v2.0.0) **Closed issues:** - An in-range update of feathers-hooks is breaking the build 🚨 [\#74](https://github.com/feathersjs/socketio/issues/74) - An in-range update of debug is breaking the build 🚨 [\#73](https://github.com/feathersjs/socketio/issues/73) - An in-range update of debug is breaking the build 🚨 [\#71](https://github.com/feathersjs/socketio/issues/71) **Merged pull requests:** - Update socket.io-client to the latest version 🚀 [\#76](https://github.com/feathersjs/socketio/pull/76) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update socket.io to the latest version 🚀 [\#75](https://github.com/feathersjs/socketio/pull/75) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update semistandard to the latest version 🚀 [\#72](https://github.com/feathersjs/socketio/pull/72) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.6.0](https://github.com/feathersjs/socketio/tree/v1.6.0) (2017-04-18) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.5.2...v1.6.0) **Closed issues:** - Add headers and remote ip address to socket.feathers [\#67](https://github.com/feathersjs/socketio/issues/67) **Merged pull requests:** - Update feathers-hooks to the latest version 🚀 [\#70](https://github.com/feathersjs/socketio/pull/70) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Add port argument [\#69](https://github.com/feathersjs/socketio/pull/69) ([kozzztya](https://github.com/kozzztya)) - Update dependencies to enable Greenkeeper 🌴 [\#68](https://github.com/feathersjs/socketio/pull/68) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.5.2](https://github.com/feathersjs/socketio/tree/v1.5.2) (2017-03-03) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.5.1...v1.5.2) **Merged pull requests:** - Server-side socketio typedef to allow `import \* as` syntax when importing [\#65](https://github.com/feathersjs/socketio/pull/65) ([myknbani](https://github.com/myknbani)) ## [v1.5.1](https://github.com/feathersjs/socketio/tree/v1.5.1) (2017-03-02) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.5.0...v1.5.1) **Closed issues:** - Typescript definition bug [\#63](https://github.com/feathersjs/socketio/issues/63) **Merged pull requests:** - fix Typescript issue \(\#63\) [\#64](https://github.com/feathersjs/socketio/pull/64) ([superbarne](https://github.com/superbarne)) - feathers-hooks@1.8.0 breaks build 🚨 [\#62](https://github.com/feathersjs/socketio/pull/62) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.5.0](https://github.com/feathersjs/socketio/tree/v1.5.0) (2017-03-01) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.4.3...v1.5.0) **Merged pull requests:** - Typescript Definitions [\#60](https://github.com/feathersjs/socketio/pull/60) ([AbraaoAlves](https://github.com/AbraaoAlves)) ## [v1.4.3](https://github.com/feathersjs/socketio/tree/v1.4.3) (2017-02-24) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.4.2...v1.4.3) **Closed issues:** - Get data after connection established [\#59](https://github.com/feathersjs/socketio/issues/59) - Unable to use feathers from within React \(Feathers vs SocketIO implementation setup issue\) [\#51](https://github.com/feathersjs/socketio/issues/51) **Merged pull requests:** - Add option to set the maxListeners [\#61](https://github.com/feathersjs/socketio/pull/61) ([Faianca](https://github.com/Faianca)) - Create .codeclimate.yml [\#56](https://github.com/feathersjs/socketio/pull/56) ([larkinscott](https://github.com/larkinscott)) - socket.io@1.7.1 breaks build 🚨 [\#54](https://github.com/feathersjs/socketio/pull/54) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-memory to version 1.0.0 🚀 [\#50](https://github.com/feathersjs/socketio/pull/50) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-commons to version 0.8.0 🚀 [\#49](https://github.com/feathersjs/socketio/pull/49) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.4.2](https://github.com/feathersjs/socketio/tree/v1.4.2) (2016-11-02) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.4.1...v1.4.2) **Closed issues:** - Upgrade to socket.io 1.4 [\#39](https://github.com/feathersjs/socketio/issues/39) - Disable/restrict failed request queue? [\#38](https://github.com/feathersjs/socketio/issues/38) - Uncaught \(in promise\) Error: Timeout of 5000ms exceeded calling sites::find\(…\) [\#36](https://github.com/feathersjs/socketio/issues/36) - Regarding plain websockets [\#34](https://github.com/feathersjs/socketio/issues/34) - Clean way to subscribe to a filtered set of events [\#32](https://github.com/feathersjs/socketio/issues/32) - "Can't find variable: Reflect" on bad requests/authentication token missing; react-native [\#31](https://github.com/feathersjs/socketio/issues/31) - Client should convert error objects to feathers-errors [\#30](https://github.com/feathersjs/socketio/issues/30) **Merged pull requests:** - 👻😱 Node.js 0.10 is unmaintained 😱👻 [\#48](https://github.com/feathersjs/socketio/pull/48) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Swapping rm to rifraf and using relative path to \_mocha for windows support [\#47](https://github.com/feathersjs/socketio/pull/47) ([corymsmith](https://github.com/corymsmith)) - jshint —\> semistandard [\#46](https://github.com/feathersjs/socketio/pull/46) ([corymsmith](https://github.com/corymsmith)) - update feathers dev dependency [\#45](https://github.com/feathersjs/socketio/pull/45) ([ekryski](https://github.com/ekryski)) - adding code coverage [\#44](https://github.com/feathersjs/socketio/pull/44) ([ekryski](https://github.com/ekryski)) - socket.io-client@1.5.0 breaks build 🚨 [\#43](https://github.com/feathersjs/socketio/pull/43) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-memory to version 0.8.0 🚀 [\#35](https://github.com/feathersjs/socketio/pull/35) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update mocha to version 3.0.0 🚀 [\#33](https://github.com/feathersjs/socketio/pull/33) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.4.1](https://github.com/feathersjs/socketio/tree/v1.4.1) (2016-05-23) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.4.0...v1.4.1) **Closed issues:** - README.md broken link to provider documentation [\#23](https://github.com/feathersjs/socketio/issues/23) - Insecure Defaults Allow MITM Over TLS [\#22](https://github.com/feathersjs/socketio/issues/22) **Merged pull requests:** - mocha@2.5.0 breaks build 🚨 [\#28](https://github.com/feathersjs/socketio/pull/28) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update feathers-socket-commons to version 2.0.0 🚀 [\#27](https://github.com/feathersjs/socketio/pull/27) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update babel-plugin-add-module-exports to version 0.2.0 🚀 [\#26](https://github.com/feathersjs/socketio/pull/26) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - fix link in README.md to feathers-socketio API docs [\#24](https://github.com/feathersjs/socketio/pull/24) ([ElliotPsyIT](https://github.com/ElliotPsyIT)) ## [v1.4.0](https://github.com/feathersjs/socketio/tree/v1.4.0) (2016-04-28) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.3.4...v1.4.0) **Merged pull requests:** - Client timeout [\#21](https://github.com/feathersjs/socketio/pull/21) ([daffl](https://github.com/daffl)) - Update feathers-socket-commons to version 1.0.0 🚀 [\#20](https://github.com/feathersjs/socketio/pull/20) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - nsp@2.3.2 breaks build 🚨 [\#18](https://github.com/feathersjs/socketio/pull/18) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - More tests for error cases [\#16](https://github.com/feathersjs/socketio/pull/16) ([daffl](https://github.com/daffl)) ## [v1.3.4](https://github.com/feathersjs/socketio/tree/v1.3.4) (2016-04-16) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.3.3...v1.3.4) **Merged pull requests:** - Increase the default number of maximum event listeners [\#15](https://github.com/feathersjs/socketio/pull/15) ([daffl](https://github.com/daffl)) - Update feathers-memory to version 0.7.0 🚀 [\#14](https://github.com/feathersjs/socketio/pull/14) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.3.3](https://github.com/feathersjs/socketio/tree/v1.3.3) (2016-02-18) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.3.2...v1.3.3) **Closed issues:** - Needs possibility to pass options to io.listen\(\) [\#12](https://github.com/feathersjs/socketio/issues/12) **Merged pull requests:** - Allow to pass Socket.io options [\#13](https://github.com/feathersjs/socketio/pull/13) ([daffl](https://github.com/daffl)) ## [v1.3.2](https://github.com/feathersjs/socketio/tree/v1.3.2) (2016-02-11) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.3.1...v1.3.2) **Merged pull requests:** - Allow to instantiate a client instance [\#11](https://github.com/feathersjs/socketio/pull/11) ([daffl](https://github.com/daffl)) ## [v1.3.1](https://github.com/feathersjs/socketio/tree/v1.3.1) (2016-02-09) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.3.0...v1.3.1) ## [v1.3.0](https://github.com/feathersjs/socketio/tree/v1.3.0) (2016-02-09) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.2.0...v1.3.0) **Merged pull requests:** - Update feathers-memory to version 0.6.0 🚀 [\#8](https://github.com/feathersjs/socketio/pull/8) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Update lodash to version 4.0.1 🚀 [\#7](https://github.com/feathersjs/socketio/pull/7) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - Adding nsp check [\#6](https://github.com/feathersjs/socketio/pull/6) ([marshallswain](https://github.com/marshallswain)) ## [v1.2.0](https://github.com/feathersjs/socketio/tree/v1.2.0) (2016-01-21) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.1.0...v1.2.0) **Closed issues:** - Better event filtering [\#2](https://github.com/feathersjs/socketio/issues/2) **Merged pull requests:** - Refactoring to use feathers-socket-commons that support event filtering [\#5](https://github.com/feathersjs/socketio/pull/5) ([daffl](https://github.com/daffl)) - Fixing .npmignore entries [\#3](https://github.com/feathersjs/socketio/pull/3) ([corymsmith](https://github.com/corymsmith)) ## [v1.1.0](https://github.com/feathersjs/socketio/tree/v1.1.0) (2016-01-10) [Full Changelog](https://github.com/feathersjs/socketio/compare/v1.0.0...v1.1.0) **Merged pull requests:** - feathers-socketio/client service and tests [\#1](https://github.com/feathersjs/socketio/pull/1) ([daffl](https://github.com/daffl)) ## [v1.0.0](https://github.com/feathersjs/socketio/tree/v1.0.0) (2016-01-03) \* _This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)_ ================================================ FILE: packages/socketio/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/socketio/README.md ================================================ # @feathersjs/socketio [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/socketio.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/socketio) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > The Feathers Socket.io real-time API provider ## Installation ``` npm install @feathersjs/socketio --save ``` ## Documentation Refer to the [Feathers SocketIO API documentation](https://feathersjs.com/api/socketio.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/socketio/package.json ================================================ { "name": "@feathersjs/socketio", "description": "The Feathers Socket.io real-time API provider", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/socketio" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/commons": "^5.0.42", "@feathersjs/feathers": "^5.0.42", "@feathersjs/transport-commons": "^5.0.42", "socket.io": "^4.8.3" }, "devDependencies": { "@feathersjs/express": "^5.0.42", "@feathersjs/memory": "^5.0.42", "@feathersjs/tests": "^5.0.42", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "lodash": "^4.17.23", "mocha": "^11.7.5", "shx": "^0.4.0", "socket.io-client": "^4.8.3", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/socketio/src/index.ts ================================================ import http from 'http' import { Server, ServerOptions } from 'socket.io' import { createDebug } from '@feathersjs/commons' import { Application, RealTimeConnection } from '@feathersjs/feathers' import { socket } from '@feathersjs/transport-commons' import { disconnect, params, authentication, FeathersSocket } from './middleware' const debug = createDebug('@feathersjs/socketio') declare module '@feathersjs/feathers/lib/declarations' { // eslint-disable-next-line @typescript-eslint/no-unused-vars interface Application { io: any listen(options: any): Promise } } function configureSocketio(callback?: (io: Server) => void): (app: Application) => void function configureSocketio( options: number | Partial, callback?: (io: Server) => void ): (app: Application) => void function configureSocketio( port: number, options?: Partial, callback?: (io: Server) => void ): (app: Application) => void function configureSocketio(port?: any, options?: any, config?: any) { if (typeof port !== 'number') { config = options options = port port = null } if (typeof options !== 'object') { config = options options = {} } return (app: Application) => { // Function that gets the connection const getParams = (socket: FeathersSocket) => socket.feathers // A mapping from connection to socket instance const socketMap = new WeakMap() // Promise that resolves with the Socket.io `io` instance // when `setup` has been called (with a server) const done = new Promise((resolve) => { const { listen, setup } = app as any Object.assign(app, { async listen(this: any, ...args: any[]) { if (typeof listen === 'function') { // If `listen` already exists // usually the case when the app has been expressified return listen.call(this, ...args) } const server = http.createServer() await this.setup(server) return server.listen(...args) }, async setup(this: any, server: http.Server, ...rest: any[]) { if (!this.io) { const io = (this.io = new Server(port || server, options)) io.use(disconnect(app, getParams, socketMap)) io.use(params(app, socketMap)) io.use(authentication(app, getParams)) // In Feathers it is easy to hit the standard Node warning limit // of event listeners (e.g. by registering 10 services). // So we set it to a higher number. 64 should be enough for everyone. io.sockets.setMaxListeners(64) } if (typeof config === 'function') { debug('Calling SocketIO configuration function') config.call(this, this.io) } resolve(this.io) return setup.call(this, server, ...rest) } }) }) app.configure( socket({ done, socketMap, getParams, emit: 'emit' }) ) } } export = configureSocketio ================================================ FILE: packages/socketio/src/middleware.ts ================================================ import { Application, Params, RealTimeConnection } from '@feathersjs/feathers' import { createDebug } from '@feathersjs/commons' import { Socket } from 'socket.io' const debug = createDebug('@feathersjs/socketio/middleware') export type ParamsGetter = (socket: Socket) => any export type NextFunction = (err?: any) => void export interface FeathersSocket extends Socket { feathers?: Params & { [key: string]: any } } export const disconnect = ( app: Application, getParams: ParamsGetter, socketMap: WeakMap ) => { app.on('disconnect', (connection: RealTimeConnection) => { const socket = socketMap.get(connection) if (socket && socket.connected) { socket.disconnect() } }) return (socket: FeathersSocket, next: NextFunction) => { socket.on('disconnect', () => app.emit('disconnect', getParams(socket))) next() } } export const params = (_app: Application, socketMap: WeakMap) => (socket: FeathersSocket, next: NextFunction) => { socket.feathers = { provider: 'socketio', headers: socket.handshake.headers } socketMap.set(socket.feathers, socket) next() } export const authentication = (app: Application, getParams: ParamsGetter, settings: any = {}) => (socket: FeathersSocket, next: NextFunction) => { const service = (app as any).defaultAuthentication ? (app as any).defaultAuthentication(settings.service) : null if (service === null) { return next() } const config = service.configuration const authStrategies = config.parseStrategies || config.authStrategies || [] if (authStrategies.length === 0) { return next() } service .parse(socket.handshake, null, ...authStrategies) .then(async (authentication: any) => { if (authentication) { debug('Parsed authentication from HTTP header', authentication) socket.feathers.authentication = authentication await service.create(authentication, { provider: 'socketio', connection: getParams(socket) }) } next() }) .catch(next) } ================================================ FILE: packages/socketio/test/events.ts ================================================ import { strict as assert } from 'assert' import { io, Socket } from 'socket.io-client' import { verify } from '@feathersjs/tests' import { RealTimeConnection } from '@feathersjs/feathers' export default (name: string, options: any) => { const call = (method: string, ...args: any[]) => { return new Promise((resolve, reject) => { const { socket } = options const emitArgs = [method, name].concat(args) socket.emit(...emitArgs, (error: any, result: any) => (error ? reject(error) : resolve(result))) }) } const verifyEvent = (done: (err?: any) => void, callback: (data: any) => void) => { return function (data: any) { try { callback(data) done() } catch (error: any) { done(error) } } } describe('Basic service events', () => { let socket: Socket let connection: RealTimeConnection before((done) => { options.app.once('connection', (conn: RealTimeConnection) => { connection = conn options.app.channel('default').join(connection) options.app.publish(() => options.app.channel('default')) done() }) socket = io('http://localhost:7886') }) after((done) => { socket.once('disconnect', () => done()) socket.disconnect() }) it(`${name} created`, (done) => { const original = { name: 'created event' } socket.once( `${name} created`, verifyEvent(done, (data) => verify.create(original, data)) ) call('create', original) }) it(`${name} updated`, (done) => { const original = { name: 'updated event' } socket.once( `${name} updated`, verifyEvent(done, (data: any) => verify.update(10, original, data)) ) call('update', 10, original) }) it(`${name} patched`, (done) => { const original = { name: 'patched event' } socket.once( `${name} patched`, verifyEvent(done, (data: any) => verify.patch(12, original, data)) ) call('patch', 12, original) }) it(`${name} removed`, (done) => { socket.once( `${name} removed`, verifyEvent(done, (data: any) => verify.remove(333, data)) ) call('remove', 333) }) it(`${name} custom events`, (done) => { const service = options.app.service(name) const original = { name: 'created event' } socket.once( `${name} log`, verifyEvent(done, (data: any) => { assert.deepStrictEqual(data, { message: 'Custom log event', data: original }) }) ) service.emit('log', { data: original, message: 'Custom log event' }) }) }) describe('Event channels', () => { const eventName = `${name} created` let connections: RealTimeConnection[] let sockets: any[] before((done) => { let counter = 0 const handler = (connection: RealTimeConnection) => { counter++ options.app.channel(connection.channel).join(connection) connections.push(connection) if (counter === 3) { done() options.app.removeListener('connection', handler) } } connections = [] sockets = [] options.app.on('connection', handler) sockets.push( io('http://localhost:7886', { query: { channel: 'first' } }), io('http://localhost:7886', { query: { channel: 'second' } }), io('http://localhost:7886', { query: { channel: 'second' } }) ) }) after(() => { sockets.forEach((socket) => socket.disconnect()) }) it(`filters '${eventName}' event for a single channel`, (done) => { const service = options.app.service(name) const [socket, otherSocket] = sockets const onError = () => { done(new Error('Should not get this event')) } service.publish('created', (data: any) => options.app.channel(data.room)) socket.once(eventName, (data: any) => { assert.strictEqual(data.room, 'first') otherSocket.removeEventListener(eventName, onError) done() }) otherSocket.once(eventName, onError) service.create({ text: 'Event dispatching test', room: 'first' }) }) it(`filters '${name} created' event for a channel with multiple connections`, (done) => { let counter = 0 const service = options.app.service(name) const [otherSocket, socketOne, socketTwo] = sockets const onError = () => { done(new Error('Should not get this event')) } const onEvent = (data: any) => { counter++ assert.strictEqual(data.room, 'second') if (++counter === 2) { otherSocket.removeEventListener(eventName, onError) done() } } service.publish('created', (data: any) => options.app.channel(data.room)) socketOne.once(eventName, onEvent) socketTwo.once(eventName, onEvent) otherSocket.once(eventName, onError) service.create({ text: 'Event dispatching test', room: 'second' }) }) }) } ================================================ FILE: packages/socketio/test/index.test.ts ================================================ import { strict as assert } from 'assert' import { feathers, Application, HookContext, NullableId, Params, ApplicationHookContext } from '@feathersjs/feathers' import express from '@feathersjs/express' import { Request, Response } from 'express' import omit from 'lodash/omit' import extend from 'lodash/extend' import { io } from 'socket.io-client' import axios from 'axios' import { Server } from 'http' import { Service } from '@feathersjs/tests' import { Socket } from 'socket.io-client' import methodTests from './methods' import eventTests from './events' import socketio from '../src' import { FeathersSocket, NextFunction } from '../src/middleware.js' class VerifierService { async find(params: Params) { return { params } } async create(data: any, params: Params) { return { data, params } } async update(id: NullableId, data: any, params: Params) { return { id, data, params } } } describe('@feathersjs/socketio', () => { let app: Application let server: Server let socket: Socket const socketParams: any = { user: { name: 'David' }, provider: 'socketio' } const options = { get app() { return app }, get socket() { return socket } } before((done) => { const errorHook = (hook: HookContext) => { if (hook.params.query.hookError) { throw new Error(`Error from ${hook.method}, ${hook.type} hook`) } } app = feathers() .configure( socketio((io) => { io.use(function (socket: FeathersSocket, next: NextFunction) { socket.feathers!.user = { name: 'David' } socketParams.headers = socket.feathers!.headers const { channel } = socket.handshake.query as any if (channel) { socket.feathers!.channel = channel } next() }) }) ) .use('/todo', new Service()) .use('/verify', new VerifierService()) app.service('todo').hooks({ before: { get: errorHook } }) app.hooks({ setup: [ async (context: ApplicationHookContext, next: NextFunction) => { assert.notStrictEqual(context.app, undefined) await next() } ] }) app .listen(7886) .then((srv) => { server = srv server.once('listening', () => { app.use('/tasks', new Service()) app.service('tasks').hooks({ before: { get: errorHook } }) }) }) .catch(done) socket = io('http://localhost:7886') socket.on('connect', () => done()) }) after((done) => { socket.disconnect() server.close(done) }) it('runs io before setup (#131)', (done) => { let counter = 0 const app = feathers().configure( socketio(() => { assert.strictEqual(counter, 0) counter++ }) ) app.listen(8887).then((srv) => { srv.on('listening', () => srv.close(done)) }) }) it('can set MaxListeners', (done) => { const app = feathers().configure(socketio((io) => io.sockets.setMaxListeners(100))) app.listen(8987).then((srv) => { srv.on('listening', () => { assert.strictEqual(app.io.sockets.getMaxListeners(), 100) srv.close(done) }) }) }) it('expressified app works', async () => { const data = { message: 'Hello world' } const app = express(feathers()) .configure(socketio()) .use('/test', (_req: Request, res: Response) => res.json(data)) const srv = await app.listen(8992) const response = await axios({ url: 'http://localhost:8992/socket.io/socket.io.js' }) assert.strictEqual(response.status, 200) const res = await axios({ url: 'http://localhost:8992/test' }) assert.deepStrictEqual(res.data, data) await new Promise((resolve) => srv.close(() => resolve(srv))) }) it('can set options (#12)', (done) => { const application = feathers().configure( socketio( { path: '/test/' }, (ioInstance) => assert.ok(ioInstance) ) ) application.listen(8987).then((srv) => { srv.on('listening', async () => { const { status } = await axios('http://localhost:8987/test/socket.io.js') assert.strictEqual(status, 200) srv.close(done) }) }) }) it('passes handshake as service parameters', (done) => { socket.emit('create', 'verify', {}, (error: any, data: any) => { assert.ok(!error) assert.deepStrictEqual( omit(data.params, 'query', 'route', 'connection'), socketParams, 'Passed handshake parameters' ) socket.emit( 'update', 'verify', 1, {}, { test: 'param' }, (error: any, data: any) => { assert.ok(!error) assert.deepStrictEqual( data.params, extend( { route: {}, connection: socketParams, query: { test: 'param' } }, socketParams ), 'Passed handshake parameters as query' ) done() } ) }) }) it('connection and disconnect events (#1243, #1238)', (done) => { const mySocket = io('http://localhost:7886?channel=dctest') app.once('connection', (connection) => { assert.strictEqual(connection.channel, 'dctest') app.once('disconnect', (disconnection) => { assert.strictEqual(disconnection.channel, 'dctest') done() }) setTimeout(() => mySocket.close(), 100) }) assert.ok(mySocket) }) it('app `disconnect` event disconnects socket (#2754)', (done) => { const mySocket = io('http://localhost:7886?channel=dctest') app.once('connection', (connection) => { assert.strictEqual(connection.channel, 'dctest') mySocket.once('disconnect', () => done()) app.emit('disconnect', connection) }) assert.ok(mySocket) }) it('missing parameters in socket call works (#88)', (done) => { socket.emit('find', 'verify', (error: any, data: any) => { assert.ok(!error) assert.deepStrictEqual( omit(data.params, 'query', 'route', 'connection'), socketParams, 'Handshake parameters passed on proper position' ) done() }) }) describe('Service method calls', () => { describe("('method', 'service') event format", () => { describe('Service', () => methodTests('todo', options)) describe('Dynamic Service', () => methodTests('todo', options)) }) }) describe('Service events', () => { describe('Service', () => eventTests('todo', options)) describe('Dynamic Service', () => eventTests('tasks', options)) }) }) ================================================ FILE: packages/socketio/test/methods.ts ================================================ import { strict as assert } from 'assert' import { verify } from '@feathersjs/tests' export default (name: string, options: any) => { const call = (method: string, ...args: any[]) => new Promise((resolve, reject) => { const { socket } = options const prefix = [method, name] const emitArgs = prefix.concat(args) socket.emit(...emitArgs, (error: any, result: any) => (error ? reject(error) : resolve(result))) }) it('invalid arguments cause an error', async () => { await assert.rejects(() => call('find', 1, {}), { message: "Too many arguments for 'find' method" }) }) it('.find', () => async () => { await call('find', {}).then((data) => verify.find(data)) }) it('.get', () => async () => { await call('get', 'laundry').then((data) => verify.get('laundry', data)) }) it('.get with error', () => async () => { try { await call('get', 'laundry', { error: true }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'Something for laundry went wrong') } }) it('.get with runtime error', () => async () => { try { await call('get', 'laundry', { runtimeError: true }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'thingThatDoesNotExist is not defined') } }) it('.get with error in hook', () => async () => { try { await call('get', 'laundry', { hookError: true }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'Error from get, before hook') } }) it('.create', async () => { const original = { name: 'creating' } const data = await call('create', original, {}) verify.create(original, data) }) it('.create without parameters', async () => { const original = { name: 'creating again' } const data = await call('create', original) verify.create(original, data) }) it('.update', async () => { const original = { name: 'updating' } const data = await call('update', 23, original, {}) verify.update(23, original, data) }) it('.update many', async () => { const original = { name: 'updating', many: true } const data = await call('update', null, original) verify.update(null, original, data) }) it('.patch', async () => { const original = { name: 'patching' } const data = await call('patch', 25, original) verify.patch(25, original, data) }) it('.patch many', async () => { const original = { name: 'patching', many: true } const data = await call('patch', null, original) verify.patch(null, original, data) }) it('.remove', () => async () => { const data = await call('remove', 11) verify.remove(11, data) }) it('.remove many', async () => { const data = await call('remove', null) verify.remove(null, data) }) } ================================================ FILE: packages/socketio/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/socketio-client/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/socketio-client ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.2](https://github.com/feathersjs/feathers/compare/v5.0.1...v5.0.2) (2023-03-23) ### Bug Fixes - **socketio-client:** Move core dependency to the right spot ([#3117](https://github.com/feathersjs/feathers/issues/3117)) ([6cd66f1](https://github.com/feathersjs/feathers/commit/6cd66f13e4e668defb57074413846550b147a51d)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) ### Bug Fixes - **socketio-client:** Make Socket.io client event target compatible ([#2686](https://github.com/feathersjs/feathers/issues/2686)) ([716c49a](https://github.com/feathersjs/feathers/commit/716c49a270e4be5e5276192092c292f72ffcfa19)) # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) ### Features - **cli:** Add typed client to a generated app ([#2669](https://github.com/feathersjs/feathers/issues/2669)) ([5b801b5](https://github.com/feathersjs/feathers/commit/5b801b5017ddc3eaa95622b539f51d605916bc86)) # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) ### Features - **client:** Improve client side custom method support ([#2654](https://github.com/feathersjs/feathers/issues/2654)) ([c138acf](https://github.com/feathersjs/feathers/commit/c138acf50affbe6b66177d084d3c7a3e9220f09f)) # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Features - **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5)) # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Bug Fixes - **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Features - **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) ### Bug Fixes - **dependencies:** Fix transport-commons dependency and update other dependencies ([#2284](https://github.com/feathersjs/feathers/issues/2284)) ([05b03b2](https://github.com/feathersjs/feathers/commit/05b03b27b40604d956047e3021d8053c3a137616)) # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) - **socketio-client:** Fix client transport-commons reference ([#2164](https://github.com/feathersjs/feathers/issues/2164)) ([3a42c54](https://github.com/feathersjs/feathers/commit/3a42c544058456b19c7e21827226541bfa6ad621)) ### Features - **core:** Public custom service methods ([#2270](https://github.com/feathersjs/feathers/issues/2270)) ([e65abfb](https://github.com/feathersjs/feathers/commit/e65abfb5388df6c19a11c565cf1076a29f32668d)) - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) - **transport-commons:** New built-in high performance radix router ([#2177](https://github.com/feathersjs/feathers/issues/2177)) ([6d18065](https://github.com/feathersjs/feathers/commit/6d180651b4eb40289ecea3df3575f207aa6c5d1f)) # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) **Note:** Version bump only for package @feathersjs/socketio-client # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) ### Bug Fixes - **socketio-client:** Throw an error and show a warning if someone tries to use socket.io-client v3 ([#2135](https://github.com/feathersjs/feathers/issues/2135)) ([cc3521c](https://github.com/feathersjs/feathers/commit/cc3521c935a1cbd690e29b7057998e3898f282db)) ## [4.5.10](https://github.com/feathersjs/feathers/compare/v4.5.9...v4.5.10) (2020-11-08) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.5.6](https://github.com/feathersjs/feathers/compare/v4.5.5...v4.5.6) (2020-07-12) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.5.4](https://github.com/feathersjs/feathers/compare/v4.5.3...v4.5.4) (2020-04-29) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/socketio-client # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/socketio-client # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.3.5](https://github.com/feathersjs/feathers/compare/v4.3.4...v4.3.5) (2019-10-07) ### Bug Fixes - Change this reference in client libraries to explicitly passed app ([#1597](https://github.com/feathersjs/feathers/issues/1597)) ([4e4d10a](https://github.com/feathersjs/feathers/commit/4e4d10a)) ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) **Note:** Version bump only for package @feathersjs/socketio-client ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) **Note:** Version bump only for package @feathersjs/socketio-client # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/socketio-client # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/socketio-client # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) **Note:** Version bump only for package @feathersjs/socketio-client # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) **Note:** Version bump only for package @feathersjs/socketio-client # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/socketio-client # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) **Note:** Version bump only for package @feathersjs/socketio-client # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) **Note:** Version bump only for package @feathersjs/socketio-client # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) ### Bug Fixes - Use `export =` in TypeScript definitions ([#1285](https://github.com/feathersjs/feathers/issues/1285)) ([12d0f4b](https://github.com/feathersjs/feathers/commit/12d0f4b)) # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) **Note:** Version bump only for package @feathersjs/socketio-client # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) ### Features - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - Allow registering a service at the root level ([#1115](https://github.com/feathersjs/feathers/issues/1115)) ([c73d322](https://github.com/feathersjs/feathers/commit/c73d322)) - Authentication v3 core server implementation ([#1205](https://github.com/feathersjs/feathers/issues/1205)) ([1bd7591](https://github.com/feathersjs/feathers/commit/1bd7591)) ## [1.2.1](https://github.com/feathersjs/feathers/compare/@feathersjs/socketio-client@1.2.0...@feathersjs/socketio-client@1.2.1) (2019-01-02) ### Bug Fixes - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) # [1.2.0](https://github.com/feathersjs/feathers/compare/@feathersjs/socketio-client@1.1.5...@feathersjs/socketio-client@1.2.0) (2018-12-16) ### Features - Allow registering a service at the root level ([#1115](https://github.com/feathersjs/feathers/issues/1115)) ([c73d322](https://github.com/feathersjs/feathers/commit/c73d322)) ## [1.1.5](https://github.com/feathersjs/feathers/compare/@feathersjs/socketio-client@1.1.4...@feathersjs/socketio-client@1.1.5) (2018-10-25) ### Bug Fixes - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) ## [1.1.4](https://github.com/feathersjs/feathers/compare/@feathersjs/socketio-client@1.1.3...@feathersjs/socketio-client@1.1.4) (2018-09-21) **Note:** Version bump only for package @feathersjs/socketio-client ## [1.1.3](https://github.com/feathersjs/feathers/compare/@feathersjs/socketio-client@1.1.2...@feathersjs/socketio-client@1.1.3) (2018-09-17) **Note:** Version bump only for package @feathersjs/socketio-client ## [1.1.2](https://github.com/feathersjs/feathers/compare/@feathersjs/socketio-client@1.1.1...@feathersjs/socketio-client@1.1.2) (2018-09-02) **Note:** Version bump only for package @feathersjs/socketio-client ## 1.1.1 - Migrate to Monorepo ([feathers#462](https://github.com/feathersjs/feathers/issues/462)) ## [v1.1.0](https://github.com/feathersjs/socketio-client/tree/v1.1.0) (2018-02-09) [Full Changelog](https://github.com/feathersjs/socketio-client/compare/v1.0.3...v1.1.0) **Closed issues:** - Non compatible with SSR [\#11](https://github.com/feathersjs/socketio-client/issues/11) - Timeout error, why? [\#9](https://github.com/feathersjs/socketio-client/issues/9) **Merged pull requests:** - Update @feathersjs/transport-commons to the latest version 🚀 [\#12](https://github.com/feathersjs/socketio-client/pull/12) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.3](https://github.com/feathersjs/socketio-client/tree/v1.0.3) (2018-02-05) [Full Changelog](https://github.com/feathersjs/socketio-client/compare/v1.0.2...v1.0.3) **Merged pull requests:** - Move to use transport-commons [\#10](https://github.com/feathersjs/socketio-client/pull/10) ([daffl](https://github.com/daffl)) - Update mocha to the latest version 🚀 [\#8](https://github.com/feathersjs/socketio-client/pull/8) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.2](https://github.com/feathersjs/socketio-client/tree/v1.0.2) (2018-01-03) [Full Changelog](https://github.com/feathersjs/socketio-client/compare/v1.0.1...v1.0.2) **Merged pull requests:** - Update documentation to correspond with latest release [\#7](https://github.com/feathersjs/socketio-client/pull/7) ([daffl](https://github.com/daffl)) - Update semistandard to the latest version 🚀 [\#6](https://github.com/feathersjs/socketio-client/pull/6) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update feathers-memory to the latest version 🚀 [\#5](https://github.com/feathersjs/socketio-client/pull/5) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.1](https://github.com/feathersjs/socketio-client/tree/v1.0.1) (2017-11-16) [Full Changelog](https://github.com/feathersjs/socketio-client/compare/v1.0.0...v1.0.1) **Merged pull requests:** - Add default export for better ES module \(TypeScript\) compatibility [\#4](https://github.com/feathersjs/socketio-client/pull/4) ([daffl](https://github.com/daffl)) ## [v1.0.0](https://github.com/feathersjs/socketio-client/tree/v1.0.0) (2017-11-01) [Full Changelog](https://github.com/feathersjs/socketio-client/compare/v1.0.0-pre.3...v1.0.0) **Merged pull requests:** - Update dependencies for release [\#3](https://github.com/feathersjs/socketio-client/pull/3) ([daffl](https://github.com/daffl)) ## [v1.0.0-pre.3](https://github.com/feathersjs/socketio-client/tree/v1.0.0-pre.3) (2017-10-23) [Full Changelog](https://github.com/feathersjs/socketio-client/compare/v1.0.0-pre.2...v1.0.0-pre.3) **Merged pull requests:** - Use scoped npm packages [\#2](https://github.com/feathersjs/socketio-client/pull/2) ([daffl](https://github.com/daffl)) ## [v1.0.0-pre.2](https://github.com/feathersjs/socketio-client/tree/v1.0.0-pre.2) (2017-10-19) [Full Changelog](https://github.com/feathersjs/socketio-client/compare/v1.0.0-pre.1...v1.0.0-pre.2) **Merged pull requests:** - Update dependencies to enable Greenkeeper 🌴 [\#1](https://github.com/feathersjs/socketio-client/pull/1) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v1.0.0-pre.1](https://github.com/feathersjs/socketio-client/tree/v1.0.0-pre.1) (2017-10-18) \* _This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)_ ================================================ FILE: packages/socketio-client/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/socketio-client/README.md ================================================ # @feathersjs/socketio-client [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/socketio-client.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/socketio-client) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > Client for Socket.io Feathers connections ## Installation ``` npm install @feathersjs/socketio-client --save ``` ## Documentation Refer to the [Feathers SocketIO API documentation](https://feathersjs.com/api/client/socketio.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/socketio-client/package.json ================================================ { "name": "@feathersjs/socketio-client", "description": "The client for Socket.io through feathers-socketio", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/socketio-client" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts", "test": "npm run mocha" }, "directories": { "lib": "lib" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/feathers": "^5.0.42", "@feathersjs/transport-commons": "^5.0.42" }, "devDependencies": { "@feathersjs/commons": "^5.0.42", "@feathersjs/memory": "^5.0.42", "@feathersjs/socketio": "^5.0.42", "@feathersjs/tests": "^5.0.42", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "mocha": "^11.7.5", "shx": "^0.4.0", "socket.io-client": "^4.8.3", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/socketio-client/src/index.ts ================================================ import { Service, SocketService } from '@feathersjs/transport-commons/client' import { Socket } from 'socket.io-client' import { Application, TransportConnection, defaultEventMap, defaultServiceMethods } from '@feathersjs/feathers' export { SocketService } declare module '@feathersjs/feathers/lib/declarations' { // eslint-disable-next-line @typescript-eslint/no-unused-vars interface FeathersApplication { /** * The Socket.io client instance. Usually does not need * to be accessed directly. */ io?: Socket } } export default function socketioClient(connection: Socket, options?: any) { if (!connection) { throw new Error('Socket.io connection needs to be provided') } const defaultService = function (this: any, name: string) { const events = Object.values(defaultEventMap) const settings = Object.assign({}, options, { events, name, connection, method: 'emit' }) return new Service(settings) as any } const initialize = function (app: Application) { if (app.io !== undefined) { throw new Error('Only one default client provider can be configured') } app.io = connection as any app.defaultService = defaultService app.mixins.unshift((service, _location, options) => { if (options && options.methods && service instanceof Service) { const customMethods = options.methods.filter((name) => !defaultServiceMethods.includes(name)) service.methods(...customMethods) } }) } initialize.Service = Service initialize.service = defaultService return initialize as TransportConnection } if (typeof module !== 'undefined') { module.exports = Object.assign(socketioClient, module.exports) } ================================================ FILE: packages/socketio-client/test/index.test.ts ================================================ /* eslint-disable @typescript-eslint/ban-ts-comment */ import { strict as assert } from 'assert' import { Server } from 'http' import { CustomMethod, feathers } from '@feathersjs/feathers' import { io, Socket } from 'socket.io-client' import { clientTests } from '@feathersjs/tests' import { createServer } from './server' import socketio, { SocketService } from '../src' type ServiceTypes = { '/': SocketService todos: SocketService & { customMethod: CustomMethod<{ message: string }> } [key: string]: any } describe('@feathersjs/socketio-client', () => { const app = feathers() let socket: Socket let server: Server before(async () => { server = await createServer().listen(9988) socket = io('http://localhost:9988') const connection = socketio(socket) app.configure(connection) app.use('todos', connection.service('todos'), { methods: ['find', 'get', 'create', 'patch', 'customMethod'] }) }) after((done) => { socket.disconnect() server.close(done) }) it('throws an error with no connection', () => { try { // @ts-ignore feathers().configure(socketio()) assert.ok(false) } catch (e: any) { assert.strictEqual(e.message, 'Socket.io connection needs to be provided') } }) it('app has the io attribute', () => { assert.ok((app as any).io) }) it('throws an error when configured twice', () => { try { app.configure(socketio(socket)) assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, 'Only one default client provider can be configured') } }) it('can initialize a client instance', async () => { const init = socketio(socket) const totoService = init.service('todos') assert.ok(totoService instanceof init.Service, 'Returned service is a client') const todos = await totoService.find() assert.deepEqual(todos, [ { text: 'some todo', complete: false, id: 0 } ]) }) it('return 404 for non-existent service', async () => { try { await app.service('not/me').create({}) assert.fail('Should never get here') } catch (e: any) { assert.strictEqual(e.message, "Service 'not/me' not found") } }) it('is event target compatible', async () => { app.service('todo').addEventListener('created', (data: any) => assert.ok(data)) }) it('calls .customMethod', async () => { const service = app.service('todos') const result = await service.customMethod({ message: 'hi' }) assert.deepStrictEqual(result, { data: { message: 'hi' }, provider: 'socketio', type: 'customMethod' }) }) clientTests(app, 'todos') clientTests(app, '/') }) ================================================ FILE: packages/socketio-client/test/server.ts ================================================ import { feathers, Id, Params } from '@feathersjs/feathers' import socketio from '@feathersjs/socketio' import '@feathersjs/transport-commons' import { MemoryService } from '@feathersjs/memory' // eslint-disable-next-line no-extend-native Object.defineProperty(Error.prototype, 'toJSON', { value() { const alt: any = {} Object.getOwnPropertyNames(this).forEach((key: string) => { alt[key] = this[key] }, this) return alt }, configurable: true, writable: true }) // Create an in-memory CRUD service for our Todos class TodoService extends MemoryService { async get(id: Id, params: Params) { if (params.query.error) { throw new Error('Something went wrong') } const data = await super.get(id) return Object.assign({ query: params.query }, data) } async customMethod(data: any, { provider }: Params) { return { data, provider, type: 'customMethod' } } } export function createServer() { const app = feathers() .configure(socketio()) .use('/', new TodoService()) .use('/todos', new TodoService(), { methods: ['find', 'get', 'create', 'update', 'patch', 'remove', 'customMethod'] }) const service = app.service('todos') const rootService = app.service('/') const publisher = () => app.channel('general') const data = { text: 'some todo', complete: false } app.on('connection', (connection) => app.channel('general').join(connection)) rootService.create(data) rootService.publish(publisher) service.create(data) service.publish(publisher) return app } ================================================ FILE: packages/socketio-client/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/tests/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/tests ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/tests ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/tests ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/tests ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/tests ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/tests ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/tests ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/tests ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/tests ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/tests ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/tests ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/tests ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/tests ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/tests ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/tests ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/tests ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/tests ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/tests ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/tests ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/tests ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/tests ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/tests ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/tests ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) **Note:** Version bump only for package @feathersjs/tests ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/tests ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) **Note:** Version bump only for package @feathersjs/tests ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/tests ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/tests ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/tests ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/tests ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) **Note:** Version bump only for package @feathersjs/tests ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package @feathersjs/tests # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) ### Features - **express, koa:** make transports similar ([#2486](https://github.com/feathersjs/feathers/issues/2486)) ([26aa937](https://github.com/feathersjs/feathers/commit/26aa937c114fb8596dfefc599b1f53cead69c159)) # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Bug Fixes - **koa:** Use extended query parser for compatibility ([#2397](https://github.com/feathersjs/feathers/issues/2397)) ([b2944ba](https://github.com/feathersjs/feathers/commit/b2944bac3ec6d5ecc80dc518cd4e58093692db74)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) ### Features - **core:** Public custom service methods ([#2270](https://github.com/feathersjs/feathers/issues/2270)) ([e65abfb](https://github.com/feathersjs/feathers/commit/e65abfb5388df6c19a11c565cf1076a29f32668d)) - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) **Note:** Version bump only for package @feathersjs/tests # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) **Note:** Version bump only for package @feathersjs/tests ## [4.5.10](https://github.com/feathersjs/feathers/compare/v4.5.9...v4.5.10) (2020-11-08) **Note:** Version bump only for package @feathersjs/tests ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) **Note:** Version bump only for package @feathersjs/tests ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) **Note:** Version bump only for package @feathersjs/tests ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) **Note:** Version bump only for package @feathersjs/tests ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) **Note:** Version bump only for package @feathersjs/tests ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) **Note:** Version bump only for package @feathersjs/tests ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) **Note:** Version bump only for package @feathersjs/tests ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/tests # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) **Note:** Version bump only for package @feathersjs/tests ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/tests ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) **Note:** Version bump only for package @feathersjs/tests # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) **Note:** Version bump only for package @feathersjs/tests ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) **Note:** Version bump only for package @feathersjs/tests ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/tests ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) **Note:** Version bump only for package @feathersjs/tests ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) **Note:** Version bump only for package @feathersjs/tests ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) **Note:** Version bump only for package @feathersjs/tests ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) **Note:** Version bump only for package @feathersjs/tests ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) **Note:** Version bump only for package @feathersjs/tests ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) **Note:** Version bump only for package @feathersjs/tests # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/tests # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/tests # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) ### Bug Fixes - Update all dependencies ([7d53a00](https://github.com/feathersjs/feathers/commit/7d53a00)) # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) **Note:** Version bump only for package @feathersjs/tests # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/tests # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) **Note:** Version bump only for package @feathersjs/tests # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) **Note:** Version bump only for package @feathersjs/tests # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) **Note:** Version bump only for package @feathersjs/tests # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) ### Bug Fixes - Improve authentication parameter handling ([#1333](https://github.com/feathersjs/feathers/issues/1333)) ([6e77204](https://github.com/feathersjs/feathers/commit/6e77204)) ================================================ FILE: packages/tests/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/tests/README.md ================================================ # @feathersjs/tests [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/tests.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/tests) > Common tests for Feathers core modules ================================================ FILE: packages/tests/package.json ================================================ { "name": "@feathersjs/tests", "private": true, "description": "Feathers core module common tests", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/tests" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "scripts": { "prepublish": "npm run compile", "pack": "echo \"not necessary\"", "test": "echo \"not necessary\"", "compile": "shx rm -rf lib/ && tsc" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@types/lodash": "^4.17.24", "axios": "^1.13.6", "lodash": "^4.17.23" }, "devDependencies": { "@feathersjs/feathers": "^5.0.42", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "mocha": "^11.7.5", "shx": "^0.4.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" } } ================================================ FILE: packages/tests/resources/certificate.pem ================================================ -----BEGIN CERTIFICATE----- MIIEBTCCAu2gAwIBAgIUD49sq2fjXZWMlFOp5lCNqVIorZkwDQYJKoZIhvcNAQEL BQAwgZExCzAJBgNVBAYTAkNBMRAwDgYDVQQIDAdBbGJlcnRhMRAwDgYDVQQHDAdD YWxnYXJ5MREwDwYDVQQKDAhGZWF0aGVyczERMA8GA1UECwwIRmVhdGhlcnMxEzAR BgNVBAMMCkZlYXRoZXJzSlMxIzAhBgkqhkiG9w0BCQEWFGhlbGxvQGZlYXRoZXJz anMuY29tMB4XDTI2MDIxOTIwNTgwNVoXDTM2MDIxNzIwNTgwNVowgZExCzAJBgNV BAYTAkNBMRAwDgYDVQQIDAdBbGJlcnRhMRAwDgYDVQQHDAdDYWxnYXJ5MREwDwYD VQQKDAhGZWF0aGVyczERMA8GA1UECwwIRmVhdGhlcnMxEzARBgNVBAMMCkZlYXRo ZXJzSlMxIzAhBgkqhkiG9w0BCQEWFGhlbGxvQGZlYXRoZXJzanMuY29tMIIBIjAN BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA43FIMR2DBk2HQIrx00boWnqjXJP7 fSOKmDd+YekmhTjnIhgdErthtnuOrR+sv64a6sslKc7OFC40ooCjhdrDQVOoXaOU lrLZQ/C/0UqzuzE+zD9Z3nMxopsUQPUtI/BAb30xGNm4VltkxNkjL0g/0wu2jWQQ fQY5I/RVX8iKfkFzTDshLxo18bTDAhfeAebNYDWoUCLKbQCf0YF3wUNGuGR2/XCk AEedBPXoU7x5VvmPR5M4Xk7V3viXVkgqjchn3REvinTTltfOJZRXqyfsKFKm+z8P dDCm1yXgx1omUhmpZ5P7qRWf0rFNh6v63e+62PurrAWuPvpk/tLqishsAQIDAQAB o1MwUTAdBgNVHQ4EFgQUfMSETLqaqpNhZ4Wg33q0sZ5dqOcwHwYDVR0jBBgwFoAU fMSETLqaqpNhZ4Wg33q0sZ5dqOcwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0B AQsFAAOCAQEAwy5DbsrduML5mpXbyleCBIlRiaNtrl4fpHoZmGstok3kvq1RonAY L8/5XDn/aKBc7P0ELBWxC/EjrFNrQp+FFY2o8OQzFEtojB4LXV9Iph8IWErnwPcK vxVIV543xZu8dAvSPm+/bAdeOba2WyMkJyMgYFwLAOzzDUG3MBP8plGdXZ05N5zA hWde/ntHVqW0E5wkaEveQwzJDAIXMhEDYEbQ8WOKiYty8Zso68HSAsl+iMICxrqQ rJoPCW5Eo+S+3K3K1CTDQuozO7HG1uyeFrcR8Dw9EI1875sjj0yQPlf6SlTYYDot wDzhAkPkoqhBp6hbAd1Hf6nvJWn+LH5osg== -----END CERTIFICATE----- ================================================ FILE: packages/tests/resources/privatekey.pem ================================================ -----BEGIN PRIVATE KEY----- MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDjcUgxHYMGTYdA ivHTRuhaeqNck/t9I4qYN35h6SaFOOciGB0Su2G2e46tH6y/rhrqyyUpzs4ULjSi gKOF2sNBU6hdo5SWstlD8L/RSrO7MT7MP1neczGimxRA9S0j8EBvfTEY2bhWW2TE 2SMvSD/TC7aNZBB9Bjkj9FVfyIp+QXNMOyEvGjXxtMMCF94B5s1gNahQIsptAJ/R gXfBQ0a4ZHb9cKQAR50E9ehTvHlW+Y9HkzheTtXe+JdWSCqNyGfdES+KdNOW184l lFerJ+woUqb7Pw90MKbXJeDHWiZSGalnk/upFZ/SsU2Hq/rd77rY+6usBa4++mT+ 0uqKyGwBAgMBAAECggEAVKnJCTtmmBSI+c4e6Zo2COQo5l/RmEoAH9xcZ779z06Y vzjBrcThwSdqO2iUif+Z1nfLPC5WyO1QO4NuG3gNAcbN4BlxyM0HkkJObO6FS/Ov YCFe5y7zNYfLuMhrRrr6iWXNPmZhN4gq0RnQ/ptC4uEz0ZsDhj6oS4l6tD52yzsH KtT83fVWdSIgL9qHLtL9EPHgw/erFB5bdxu+Fzo7eQQeOiwh1ITvpFgeJ1nxIc35 fCCCYD7EA/p0ZPn337It40UQGnoKiZrM96nzBqkdjnJpYcsdvCLUhXAbzHRmi2kr IsBKhY99+KG8zVznwNaSmqjmEwabhRkma/7NwK2wrwKBgQD20bZjghJwUcHMroGX szi6O4zik7CHPZbSAL/EcycoEaTgmdkAQrH3hKC7cVw8KBdJjs+CN131669o81vS 9fBFH2fkE4fctzFmwDz9UBL9WU7ysKnmpkP1k8pAwc4Cs+KKdZR2XgXRCeNiXIjE UrjsnKLTjWMaHMtzF8hq8vRtLwKBgQDr5w8SkiCknJ8mjlLOBOg+IwHQl/B3BBnf TbrJxxwYvaO4Agc9kRKT9/QPoMioONCpK3oTsiTlED+3mRfkixatcUBtS8Nsu4bq quu7gBuBQNyDDszCmm0GIjeiYyjzy3eiyhtg8cfngZ+GyMsV3nZ2E0z+jGyFCT+b 2NniMUNNzwKBgD022eNoGSaeQFCBX0a+fm1B47k2I+wGzGcdJHKWlLmNVrUVswor gHQBAtQ6U0PgNZZawwBqtvUNFR4UbUuvD341QdEBPwrwrGHtf7LbrzoCcmAijKDV z7kShHD3IB7veloYu094Fj04FJsKlCkM0yxr1L5fLJsHVTYgSeashw6lAoGAGR/u 1weBOocD3FNkNlUHdza7RsAn+EUTjFj2/+6Y63mnKj3tD32YAPJzqAZz2JbUgnAC /H4It+zXHHLNvKWjsK1TM1DSa449fFjf6oRmaYnC8qJs5H0WB4U1b7In9m9BOrFT 4StfIyUHHI/eMWIUM9cyaBoEpNarU6nw6spcZLkCgYEAkIUZrQhsHyin4YvRPrrN pbn/ZIuIIFvghPiUucqdt3h1pdCsgebN8Z5DOYGf27EkT41oV24rKvTUXnb8fV6F NWbniV6d2YPOqnJ0rCtfou1gQ1fWWQBnAQDK7wn/rPedtxXDWr74raNByppc0P9r qBfYqpXj88GVYhhwUR+WVSI= -----END PRIVATE KEY----- ================================================ FILE: packages/tests/src/client.ts ================================================ import { strict as assert } from 'assert' export interface Todo { text: string complete?: boolean id?: number } export function clientTests(app: any, name: string) { const getService = () => (name && typeof app.service === 'function' ? app.service(name) : app) describe('Service base tests', () => { it('.find', async () => { const todos = await getService().find() assert.deepEqual(todos, [ { // eslint-disable-line text: 'some todo', complete: false, id: 0 } ]) }) it('.get and params passing', async () => { const query = { some: 'thing', other: ['one', 'two'], nested: { a: { b: 'object' } } } const todo = await getService().get(0, { query }) assert.deepEqual(todo, { // eslint-disable-line id: 0, text: 'some todo', complete: false, query }) }) it('.create', async () => { const todo = await getService().create({ text: 'created todo', complete: true }) assert.deepEqual(todo, { // eslint-disable-line id: 1, text: 'created todo', complete: true }) }) it('.create and created event', (done) => { getService().once('created', (data: Todo) => { assert.strictEqual(data.text, 'created todo') assert.ok(data.complete) done() }) getService().create({ text: 'created todo', complete: true }) }) it('.update and updated event', (done) => { getService().once('updated', (data: Todo) => { assert.strictEqual(data.text, 'updated todo') assert.ok(data.complete) done() }) getService() .create({ text: 'todo to update', complete: false }) .then((todo: Todo) => { getService().update(todo.id, { text: 'updated todo', complete: true }) }) }) it('.patch and patched event', (done) => { getService().once('patched', (data: Todo) => { assert.strictEqual(data.text, 'todo to patch') assert.ok(data.complete) done() }) getService() .create({ text: 'todo to patch', complete: false }) .then((todo: Todo) => getService().patch(todo.id, { complete: true })) }) it('.remove and removed event', (done) => { getService().once('removed', (data: Todo) => { assert.strictEqual(data.text, 'todo to remove') assert.strictEqual(data.complete, false) done() }) getService() .create({ text: 'todo to remove', complete: false }) .then((todo: Todo) => getService().remove(todo.id)) .catch(done) }) it('.get with error', async () => { const query = { error: true } try { await getService().get(0, { query }) assert.fail('Should never get here') } catch (error: any) { assert.strictEqual(error.message, 'Something went wrong') } }) }) } ================================================ FILE: packages/tests/src/fixture.ts ================================================ import assert from 'assert' const clone = (data: any) => JSON.parse(JSON.stringify(data)) const findAllData = [ { id: 0, description: 'You have to do something' }, { id: 1, description: 'You have to do laundry' } ] export class Service { events = ['log'] async find() { return findAllData } async get(name: string, params: any) { if (params.query.error) { throw new Error(`Something for ${name} went wrong`) } if (params.query.runtimeError) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore thingThatDoesNotExist() // eslint-disable-line } return Promise.resolve({ id: name, description: `You have to do ${name}!` }) } async create(data: any) { const result = Object.assign({}, clone(data), { id: 42, status: 'created' }) if (Array.isArray(data)) { result.many = true } return result } async update(id: any, data: any) { const result = Object.assign({}, clone(data), { id, status: 'updated' }) if (id === null) { result.many = true } return result } async patch(id: any, data: any) { const result = Object.assign({}, clone(data), { id, status: 'patched' }) if (id === null) { result.many = true } return result } async remove(id: any) { return { id } } async customMethod(data: any, params: any) { return { data, method: 'customMethod', provider: params.provider } } async internalMethod() { throw new Error('Should never get here') } } export const verify = { find(data: any) { assert.deepStrictEqual(findAllData, clone(data), 'Data as expected') }, get(id: any, data: any) { assert.strictEqual(data.id, id, 'Got id in data') assert.strictEqual(data.description, `You have to do ${id}!`, 'Got description') }, create(original: any, current: any) { const expected = Object.assign({}, clone(original), { id: 42, status: 'created' }) assert.deepStrictEqual(expected, clone(current), 'Data ran through .create as expected') }, update(id: any, original: any, current: any) { const expected = Object.assign({}, clone(original), { id, status: 'updated' }) assert.deepStrictEqual(expected, clone(current), 'Data ran through .update as expected') }, patch(id: any, original: any, current: any) { const expected = Object.assign({}, clone(original), { id, status: 'patched' }) assert.deepStrictEqual(expected, clone(current), 'Data ran through .patch as expected') }, remove(id: any, data: any) { assert.deepStrictEqual({ id }, clone(data), '.remove called') } } ================================================ FILE: packages/tests/src/index.ts ================================================ export * from './client' export * from './rest' export * from './fixture' ================================================ FILE: packages/tests/src/rest.ts ================================================ import assert from 'assert' import axios from 'axios' import { verify } from './fixture' export function restTests(description: string, name: string, port: number) { describe(description, () => { it('GET .find', async () => { const res = await axios.get(`http://localhost:${port}/${name}`) assert.ok(res.status === 200, 'Got OK status code') verify.find(res.data) }) it('GET .get', async () => { const res = await axios.get(`http://localhost:${port}/${name}/dishes`) assert.ok(res.status === 200, 'Got OK status code') verify.get('dishes', res.data) }) it('POST .create', async () => { const original = { description: 'POST .create' } const res = await axios.post(`http://localhost:${port}/${name}`, original) assert.ok(res.status === 201, 'Got CREATED status code') verify.create(original, res.data) }) it('PUT .update', async () => { const original = { description: 'PUT .update' } const res = await axios.put(`http://localhost:${port}/${name}/544`, original) assert.ok(res.status === 200, 'Got OK status code') verify.update('544', original, res.data) }) it('PUT .update many', async () => { const original = { description: 'PUT .update', many: true } const res = await axios.put(`http://localhost:${port}/${name}`, original) const { data } = res assert.ok(res.status === 200, 'Got OK status code') verify.update(null, original, data) }) it('PATCH .patch', async () => { const original = { description: 'PATCH .patch' } const res = await axios.patch(`http://localhost:${port}/${name}/544`, original) assert.ok(res.status === 200, 'Got OK status code') verify.patch('544', original, res.data) }) it('PATCH .patch many', async () => { const original = { description: 'PATCH .patch', many: true } const res = await axios.patch(`http://localhost:${port}/${name}`, original) assert.ok(res.status === 200, 'Got OK status code') verify.patch(null, original, res.data) }) it('DELETE .remove', async () => { const res = await axios.delete(`http://localhost:${port}/${name}/233`) assert.ok(res.status === 200, 'Got OK status code') verify.remove('233', res.data) }) it('DELETE .remove many', async () => { const res = await axios.delete(`http://localhost:${port}/${name}`) assert.ok(res.status === 200, 'Got OK status code') verify.remove(null, res.data) }) }) } ================================================ FILE: packages/tests/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/transport-commons/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) ### Bug Fixes - **client:** Ensure all client methods require valid ids ([#3661](https://github.com/feathersjs/feathers/issues/3661)) ([bc754d3](https://github.com/feathersjs/feathers/commit/bc754d3666b059b9d93799602dac427cb419ddc6)) ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) ### Bug Fixes - **transport-commons:** Fix HTTP status precedence ([#3511](https://github.com/feathersjs/feathers/issues/3511)) ([5d999a0](https://github.com/feathersjs/feathers/commit/5d999a0acddc0cb7692058209dfbc62673ab5a69)) ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) ### Bug Fixes - Reduce usage of lodash ([#3455](https://github.com/feathersjs/feathers/issues/3455)) ([8ce807a](https://github.com/feathersjs/feathers/commit/8ce807a5ca53ff5b8d5107a0656c6329404e6e6c)) ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) ### Bug Fixes - **socketio:** Handle ackTimeout of socket.io ([#3437](https://github.com/feathersjs/feathers/issues/3437)) ([2642072](https://github.com/feathersjs/feathers/commit/26420721f3eb16f716a9e68ab3ed9f415bab7a9c)) ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) - **transport-commons:** Properly delete route data ([#3433](https://github.com/feathersjs/feathers/issues/3433)) ([af01bdb](https://github.com/feathersjs/feathers/commit/af01bdbe050dd428d6fffefa1874e9a6e4182bad)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) ### Bug Fixes - **transport-commons:** Allow case insensitive route lookups ([#3353](https://github.com/feathersjs/feathers/issues/3353)) ([a4a5ab6](https://github.com/feathersjs/feathers/commit/a4a5ab6cb59048176292cd71c04a32aa71ac4642)) ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **client:** Replace placeholders in URL with route params ([#3270](https://github.com/feathersjs/feathers/issues/3270)) ([a0624eb](https://github.com/feathersjs/feathers/commit/a0624eb5a7919aa1b179a71beb1c1b9cab574525)) - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) ### Bug Fixes - **client:** Add underscored methods to clients ([#3176](https://github.com/feathersjs/feathers/issues/3176)) ([f3c01f7](https://github.com/feathersjs/feathers/commit/f3c01f7b8266bfc642c55b77ba8e5bb333542630)) ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) ### Bug Fixes - **transport-commons:** Handle invalid service paths on socket lookups ([#3241](https://github.com/feathersjs/feathers/issues/3241)) ([c397ab3](https://github.com/feathersjs/feathers/commit/c397ab3a0cd184044ae4f73540549b30a396821c)) ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) **Note:** Version bump only for package @feathersjs/transport-commons ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) ### Bug Fixes - **core:** Use Symbol.for to instantiate shared symbols ([#3087](https://github.com/feathersjs/feathers/issues/3087)) ([7f3fc21](https://github.com/feathersjs/feathers/commit/7f3fc2167576f228f8183568eb52b077160e8d65)) - **transport-commons:** Fix dispatching of arrays ([#3075](https://github.com/feathersjs/feathers/issues/3075)) ([98fdda5](https://github.com/feathersjs/feathers/commit/98fdda53187acee88137b39662c766cc62cd7b55)) # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Bug Fixes - **core:** Improve service option usage and method option typings ([#2902](https://github.com/feathersjs/feathers/issues/2902)) ([164d75c](https://github.com/feathersjs/feathers/commit/164d75c0f11139a316baa91f1762de8f8eb7da2d)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) ### Bug Fixes - **docs:** Review transport API docs and update Express middleware setup ([#2811](https://github.com/feathersjs/feathers/issues/2811)) ([1b97f14](https://github.com/feathersjs/feathers/commit/1b97f14d474f5613482f259eeaa585c24fcfab43)) # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) ### Features - **cli:** Generate full client test suite and improve typed client ([#2788](https://github.com/feathersjs/feathers/issues/2788)) ([57119b6](https://github.com/feathersjs/feathers/commit/57119b6bb2797f7297cf054268a248c093ecd538)) # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **core:** Allow to unregister services at runtime ([#2756](https://github.com/feathersjs/feathers/issues/2756)) ([d16601f](https://github.com/feathersjs/feathers/commit/d16601f2277dca5357866ffdefba2a611f6dc7fa)) # [5.0.0-pre.29](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.28...v5.0.0-pre.29) (2022-09-16) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.28](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.27...v5.0.0-pre.28) (2022-08-03) ### Bug Fixes - **cli:** Improve generated application and client ([#2701](https://github.com/feathersjs/feathers/issues/2701)) ([bd55ffb](https://github.com/feathersjs/feathers/commit/bd55ffb812e89bf215f4515e7f137656ea888c3f)) # [5.0.0-pre.27](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.26...v5.0.0-pre.27) (2022-07-13) ### Bug Fixes - **socketio-client:** Make Socket.io client event target compatible ([#2686](https://github.com/feathersjs/feathers/issues/2686)) ([716c49a](https://github.com/feathersjs/feathers/commit/716c49a270e4be5e5276192092c292f72ffcfa19)) # [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06) ### Features - **client:** Improve client side custom method support ([#2654](https://github.com/feathersjs/feathers/issues/2654)) ([c138acf](https://github.com/feathersjs/feathers/commit/c138acf50affbe6b66177d084d3c7a3e9220f09f)) # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04) ### Bug Fixes - **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507)) # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01) ### Bug Fixes - **transport-commons:** Ensure socket queries are always plain objects ([#2597](https://github.com/feathersjs/feathers/issues/2597)) ([97313e1](https://github.com/feathersjs/feathers/commit/97313e121cfee4199f10012e95b8507557aa507e)) # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11) ### Features - **transport-commons:** add `context.http.response` ([#2524](https://github.com/feathersjs/feathers/issues/2524)) ([5bc9d44](https://github.com/feathersjs/feathers/commit/5bc9d447043c2e2b742c73ed28ecf3b3264dd9e5)) # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12) ### Features - **express, koa:** make transports similar ([#2486](https://github.com/feathersjs/feathers/issues/2486)) ([26aa937](https://github.com/feathersjs/feathers/commit/26aa937c114fb8596dfefc599b1f53cead69c159)) # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27) ### Bug Fixes - **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110)) ### Features - **core:** add `context.http` and move `statusCode` there ([#2496](https://github.com/feathersjs/feathers/issues/2496)) ([b701bf7](https://github.com/feathersjs/feathers/commit/b701bf77fb83048aa1dffa492b3d77dd53f7b72b)) - **transport-commons:** Ability to register routes with custom params ([#2482](https://github.com/feathersjs/feathers/issues/2482)) ([497990a](https://github.com/feathersjs/feathers/commit/497990ae4a980e5a52a1f0f932db12cd0e6e254a)) # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23) ### Bug Fixes - **koa:** Use extended query parser for compatibility ([#2397](https://github.com/feathersjs/feathers/issues/2397)) ([b2944ba](https://github.com/feathersjs/feathers/commit/b2944bac3ec6d5ecc80dc518cd4e58093692db74)) # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13) ### Bug Fixes - **transport-commons:** Fix route placeholder registration and improve radix router performance ([#2336](https://github.com/feathersjs/feathers/issues/2336)) ([4d84dfd](https://github.com/feathersjs/feathers/commit/4d84dfd092ce0510312e975d5cd57e04973fb311)) ### Features - **koa:** KoaJS transport adapter ([#2315](https://github.com/feathersjs/feathers/issues/2315)) ([2554b57](https://github.com/feathersjs/feathers/commit/2554b57cf05731df58feeba9c12faab18e442107)) # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21) ### Bug Fixes - **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897)) ### Features - **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a)) # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03) **Note:** Version bump only for package @feathersjs/transport-commons # [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28) ### Bug Fixes - **transport-commons:** Do not error when adding an undefined connection to a channel ([#2268](https://github.com/feathersjs/feathers/issues/2268)) ([28114c4](https://github.com/feathersjs/feathers/commit/28114c495d6564868bb3ffbf619bf80b774dce4b)) - Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60)) - **socketio-client:** Fix client transport-commons reference ([#2164](https://github.com/feathersjs/feathers/issues/2164)) ([3a42c54](https://github.com/feathersjs/feathers/commit/3a42c544058456b19c7e21827226541bfa6ad621)) ### Features - **core:** Public custom service methods ([#2270](https://github.com/feathersjs/feathers/issues/2270)) ([e65abfb](https://github.com/feathersjs/feathers/commit/e65abfb5388df6c19a11c565cf1076a29f32668d)) - Application service types default to any ([#1566](https://github.com/feathersjs/feathers/issues/1566)) ([d93ba9a](https://github.com/feathersjs/feathers/commit/d93ba9a17edd20d3397bb00f4f6e82e804e42ed6)) - Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9)) - **transport-commons:** New built-in high performance radix router ([#2177](https://github.com/feathersjs/feathers/issues/2177)) ([6d18065](https://github.com/feathersjs/feathers/commit/6d180651b4eb40289ecea3df3575f207aa6c5d1f)) # [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17) # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### Features - **core:** use @feathers/hooks and add async type ([#1929](https://github.com/feathersjs/feathers/issues/1929)) ([a5c4756](https://github.com/feathersjs/feathers/commit/a5c47562eae8410c82fe2f6308f26f8e78b6a3e8)) - **transport-commons:** Remove legacy message format and unnecessary client timeouts ([#1939](https://github.com/feathersjs/feathers/issues/1939)) ([5538881](https://github.com/feathersjs/feathers/commit/5538881a08bc130de42c5984055729d8336f8615)) ### BREAKING CHANGES - **transport-commons:** Removes the old message format and client service timeout # [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19) ### Features - **core:** use @feathers/hooks and add async type ([#1929](https://github.com/feathersjs/feathers/issues/1929)) ([a5c4756](https://github.com/feathersjs/feathers/commit/a5c47562eae8410c82fe2f6308f26f8e78b6a3e8)) - **transport-commons:** Remove legacy message format and unnecessary client timeouts ([#1939](https://github.com/feathersjs/feathers/issues/1939)) ([5538881](https://github.com/feathersjs/feathers/commit/5538881a08bc130de42c5984055729d8336f8615)) ### BREAKING CHANGES - **transport-commons:** Removes the old message format and client service timeout ## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05) ### Bug Fixes - **socketio-client:** Throw an error and show a warning if someone tries to use socket.io-client v3 ([#2135](https://github.com/feathersjs/feathers/issues/2135)) ([cc3521c](https://github.com/feathersjs/feathers/commit/cc3521c935a1cbd690e29b7057998e3898f282db)) ## [4.5.10](https://github.com/feathersjs/feathers/compare/v4.5.9...v4.5.10) (2020-11-08) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.5.9](https://github.com/feathersjs/feathers/compare/v4.5.8...v4.5.9) (2020-10-09) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.5.8](https://github.com/feathersjs/feathers/compare/v4.5.7...v4.5.8) (2020-08-12) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.5.7](https://github.com/feathersjs/feathers/compare/v4.5.6...v4.5.7) (2020-07-24) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.5.5](https://github.com/feathersjs/feathers/compare/v4.5.4...v4.5.5) (2020-07-11) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.5.3](https://github.com/feathersjs/feathers/compare/v4.5.2...v4.5.3) (2020-04-17) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) **Note:** Version bump only for package @feathersjs/transport-commons # [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) ### Bug Fixes - Gracefully handle errors in publishers ([#1710](https://github.com/feathersjs/feathers/issues/1710)) ([0616306](https://github.com/feathersjs/feathers/commit/061630696762e9dbf1dc4e738094992ba16989fc)) # [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) ### Bug Fixes - **transport-commons:** Allow to properly chain SocketIo client.off ([#1706](https://github.com/feathersjs/feathers/issues/1706)) ([a4aecbc](https://github.com/feathersjs/feathers/commit/a4aecbcd3578c1cf4ecffb3a58fb6d26e15ee513)) ## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) ### Bug Fixes - Fix regression in transport commons ([#1551](https://github.com/feathersjs/feathers/issues/1551)) ([ed9e934](https://github.com/feathersjs/feathers/commit/ed9e934)) # [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) **Note:** Version bump only for package @feathersjs/transport-commons # [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) **Note:** Version bump only for package @feathersjs/transport-commons # [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) ### Bug Fixes - Expire and remove authenticated real-time connections ([#1512](https://github.com/feathersjs/feathers/issues/1512)) ([2707c33](https://github.com/feathersjs/feathers/commit/2707c33)) - Update all dependencies ([7d53a00](https://github.com/feathersjs/feathers/commit/7d53a00)) - Use WeakMap to connect socket to connection ([#1509](https://github.com/feathersjs/feathers/issues/1509)) ([64807e3](https://github.com/feathersjs/feathers/commit/64807e3)) # [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) ### Bug Fixes - Add getEntityId to JWT strategy and fix legacy Socket authentication ([#1488](https://github.com/feathersjs/feathers/issues/1488)) ([9a3b324](https://github.com/feathersjs/feathers/commit/9a3b324)) - Improve Params typing ([#1474](https://github.com/feathersjs/feathers/issues/1474)) ([54a3aa7](https://github.com/feathersjs/feathers/commit/54a3aa7)) # [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) **Note:** Version bump only for package @feathersjs/transport-commons # [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) **Note:** Version bump only for package @feathersjs/transport-commons # [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) ### Bug Fixes - Clean up hooks code ([#1407](https://github.com/feathersjs/feathers/issues/1407)) ([f25c88b](https://github.com/feathersjs/feathers/commit/f25c88b)) - Improve transport-commons types ([#1396](https://github.com/feathersjs/feathers/issues/1396)) ([f9d8536](https://github.com/feathersjs/feathers/commit/f9d8536)) # [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) ### Bug Fixes - Make oAuth paths more consistent and improve authentication client ([#1377](https://github.com/feathersjs/feathers/issues/1377)) ([adb2543](https://github.com/feathersjs/feathers/commit/adb2543)) - Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) # [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) ### Bug Fixes - Add fallback for legacy socket authenticate event ([#1356](https://github.com/feathersjs/feathers/issues/1356)) ([61b1056](https://github.com/feathersjs/feathers/commit/61b1056)) - Throw NotAuthenticated on token verification errors ([#1357](https://github.com/feathersjs/feathers/issues/1357)) ([e0120df](https://github.com/feathersjs/feathers/commit/e0120df)) ### Features - Add global disconnect event ([#1355](https://github.com/feathersjs/feathers/issues/1355)) ([85afcca](https://github.com/feathersjs/feathers/commit/85afcca)) # [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) ### Bug Fixes - Add registerPublisher alias for .publish ([#1302](https://github.com/feathersjs/feathers/issues/1302)) ([98fe8f8](https://github.com/feathersjs/feathers/commit/98fe8f8)) # [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) ### Bug Fixes - Compare socket event data using lodash's isEqual instead of indexOf ([#1061](https://github.com/feathersjs/feathers/issues/1061)) ([f706db3](https://github.com/feathersjs/feathers/commit/f706db3)) - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) - Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) - **package:** update debug to version 3.0.0 ([#45](https://github.com/feathersjs/feathers/issues/45)) ([9b9bde5](https://github.com/feathersjs/feathers/commit/9b9bde5)) ### Features - Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - Allow registering a service at the root level ([#1115](https://github.com/feathersjs/feathers/issues/1115)) ([c73d322](https://github.com/feathersjs/feathers/commit/c73d322)) ## [4.2.1](https://github.com/feathersjs/feathers/compare/@feathersjs/transport-commons@4.2.0...@feathersjs/transport-commons@4.2.1) (2019-01-02) ### Bug Fixes - Update adapter common tests ([#1135](https://github.com/feathersjs/feathers/issues/1135)) ([8166dda](https://github.com/feathersjs/feathers/commit/8166dda)) # [4.2.0](https://github.com/feathersjs/feathers/compare/@feathersjs/transport-commons@4.1.6...@feathersjs/transport-commons@4.2.0) (2018-12-16) ### Features - Allow registering a service at the root level ([#1115](https://github.com/feathersjs/feathers/issues/1115)) ([c73d322](https://github.com/feathersjs/feathers/commit/c73d322)) ## [4.1.6](https://github.com/feathersjs/feathers/compare/@feathersjs/transport-commons@4.1.5...@feathersjs/transport-commons@4.1.6) (2018-10-25) ### Bug Fixes - Compare socket event data using lodash's isEqual instead of indexOf ([#1061](https://github.com/feathersjs/feathers/issues/1061)) ([f706db3](https://github.com/feathersjs/feathers/commit/f706db3)) - Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) ## [4.1.5](https://github.com/feathersjs/feathers/compare/@feathersjs/transport-commons@4.1.4...@feathersjs/transport-commons@4.1.5) (2018-09-21) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.1.4](https://github.com/feathersjs/feathers/compare/@feathersjs/transport-commons@4.1.3...@feathersjs/transport-commons@4.1.4) (2018-09-17) **Note:** Version bump only for package @feathersjs/transport-commons ## [4.1.3](https://github.com/feathersjs/feathers/compare/@feathersjs/transport-commons@4.1.2...@feathersjs/transport-commons@4.1.3) (2018-09-02) **Note:** Version bump only for package @feathersjs/transport-commons ## 4.1.2 - Migrate to Monorepo ([feathers#462](https://github.com/feathersjs/feathers/issues/462)) ## [v4.1.1](https://github.com/feathersjs/transport-commons/tree/v4.1.1) (2018-07-03) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v4.1.0...v4.1.1) **Merged pull requests:** - Properly dispatch arrays that do not come from Feathers hook events [\#77](https://github.com/feathersjs/transport-commons/pull/77) ([daffl](https://github.com/daffl)) ## [v4.1.0](https://github.com/feathersjs/transport-commons/tree/v4.1.0) (2018-06-28) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v4.0.2...v4.1.0) **Merged pull requests:** - Remove empty channels [\#75](https://github.com/feathersjs/transport-commons/pull/75) ([daffl](https://github.com/daffl)) ## [v4.0.2](https://github.com/feathersjs/transport-commons/tree/v4.0.2) (2018-06-12) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v4.0.1...v4.0.2) **Merged pull requests:** - Fix looking up invalid path names through sockets [\#76](https://github.com/feathersjs/transport-commons/pull/76) ([daffl](https://github.com/daffl)) ## [v4.0.1](https://github.com/feathersjs/transport-commons/tree/v4.0.1) (2018-05-30) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v4.0.0...v4.0.1) **Merged pull requests:** - Update Codeclimate settings [\#74](https://github.com/feathersjs/transport-commons/pull/74) ([daffl](https://github.com/daffl)) ## [v4.0.0](https://github.com/feathersjs/transport-commons/tree/v4.0.0) (2018-02-09) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.2.0...v4.0.0) **Closed issues:** - Additional data for client errors [\#72](https://github.com/feathersjs/transport-commons/issues/72) **Merged pull requests:** - Throw a Timeout error on send timeout instead of Error [\#73](https://github.com/feathersjs/transport-commons/pull/73) ([TimNZ](https://github.com/TimNZ)) - Pass connection in params [\#71](https://github.com/feathersjs/transport-commons/pull/71) ([daffl](https://github.com/daffl)) - Move socket handling into its own file [\#70](https://github.com/feathersjs/transport-commons/pull/70) ([daffl](https://github.com/daffl)) ## [v3.2.0](https://github.com/feathersjs/transport-commons/tree/v3.2.0) (2018-01-30) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.1.5...v3.2.0) **Closed issues:** - Publishing to a channel fails after passing safety check [\#66](https://github.com/feathersjs/transport-commons/issues/66) - Feathers Server Ends unexpected if some arg to socket.io is a ipv6 local subnet [\#65](https://github.com/feathersjs/transport-commons/issues/65) **Merged pull requests:** - Rename to @feathersjs/transport-commons [\#69](https://github.com/feathersjs/transport-commons/pull/69) ([daffl](https://github.com/daffl)) - Switch to Radix tree based routing [\#68](https://github.com/feathersjs/transport-commons/pull/68) ([daffl](https://github.com/daffl)) - Update mocha to the latest version 🚀 [\#64](https://github.com/feathersjs/transport-commons/pull/64) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update semistandard to the latest version 🚀 [\#63](https://github.com/feathersjs/transport-commons/pull/63) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v3.1.5](https://github.com/feathersjs/transport-commons/tree/v3.1.5) (2017-12-12) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.1.4...v3.1.5) ## [v3.1.4](https://github.com/feathersjs/transport-commons/tree/v3.1.4) (2017-12-12) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.1.3...v3.1.4) **Merged pull requests:** - Fix dispatching of arrays [\#62](https://github.com/feathersjs/transport-commons/pull/62) ([daffl](https://github.com/daffl)) ## [v3.1.3](https://github.com/feathersjs/transport-commons/tree/v3.1.3) (2017-12-12) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.1.2...v3.1.3) **Merged pull requests:** - Make sure that each entry in an array is dispatched as its own even [\#61](https://github.com/feathersjs/transport-commons/pull/61) ([daffl](https://github.com/daffl)) ## [v3.1.2](https://github.com/feathersjs/transport-commons/tree/v3.1.2) (2017-12-06) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.1.1...v3.1.2) **Merged pull requests:** - Fix another error when there are no results [\#60](https://github.com/feathersjs/transport-commons/pull/60) ([daffl](https://github.com/daffl)) ## [v3.1.1](https://github.com/feathersjs/transport-commons/tree/v3.1.1) (2017-12-06) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.1.0...v3.1.1) **Merged pull requests:** - Always use a combined channel [\#59](https://github.com/feathersjs/transport-commons/pull/59) ([daffl](https://github.com/daffl)) ## [v3.1.0](https://github.com/feathersjs/transport-commons/tree/v3.1.0) (2017-12-06) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.0.1...v3.1.0) **Merged pull requests:** - Give channel dispatchers a precedence [\#58](https://github.com/feathersjs/transport-commons/pull/58) ([daffl](https://github.com/daffl)) ## [v3.0.1](https://github.com/feathersjs/transport-commons/tree/v3.0.1) (2017-11-03) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.0.0...v3.0.1) **Closed issues:** - Allow socket calls without params and callback [\#54](https://github.com/feathersjs/transport-commons/issues/54) **Merged pull requests:** - Allow socket calls without query and callback [\#55](https://github.com/feathersjs/transport-commons/pull/55) ([daffl](https://github.com/daffl)) ## [v3.0.0](https://github.com/feathersjs/transport-commons/tree/v3.0.0) (2017-11-01) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.0.0-pre.7...v3.0.0) ## [v3.0.0-pre.7](https://github.com/feathersjs/transport-commons/tree/v3.0.0-pre.7) (2017-10-25) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.0.0-pre.6...v3.0.0-pre.7) **Merged pull requests:** - Update to better returnHook handling [\#53](https://github.com/feathersjs/transport-commons/pull/53) ([daffl](https://github.com/daffl)) ## [v3.0.0-pre.6](https://github.com/feathersjs/transport-commons/tree/v3.0.0-pre.6) (2017-10-21) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.0.0-pre.5...v3.0.0-pre.6) **Closed issues:** - feathers-socket-commons produces error when it get bundled and steal-socket.io gets used as connection [\#44](https://github.com/feathersjs/transport-commons/issues/44) - Surface src/events.js lines 44-69 for feathers-hooks-common/src/filters/combine.js [\#40](https://github.com/feathersjs/transport-commons/issues/40) **Merged pull requests:** - Updates for Feathers v3 \(Buzzard\) [\#52](https://github.com/feathersjs/transport-commons/pull/52) ([daffl](https://github.com/daffl)) - Rename repository and use npm scope [\#51](https://github.com/feathersjs/transport-commons/pull/51) ([daffl](https://github.com/daffl)) ## [v3.0.0-pre.5](https://github.com/feathersjs/transport-commons/tree/v3.0.0-pre.5) (2017-10-18) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.0.0-pre.4...v3.0.0-pre.5) **Merged pull requests:** - Pass events property to the client [\#50](https://github.com/feathersjs/transport-commons/pull/50) ([daffl](https://github.com/daffl)) ## [v3.0.0-pre.4](https://github.com/feathersjs/transport-commons/tree/v3.0.0-pre.4) (2017-10-17) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.0.0-pre.3...v3.0.0-pre.4) **Merged pull requests:** - Fix the event name and add some channel debug statements [\#49](https://github.com/feathersjs/transport-commons/pull/49) ([daffl](https://github.com/daffl)) ## [v3.0.0-pre.3](https://github.com/feathersjs/transport-commons/tree/v3.0.0-pre.3) (2017-10-16) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.0.0-pre.2...v3.0.0-pre.3) **Merged pull requests:** - Update mocha to the latest version 🚀 [\#48](https://github.com/feathersjs/transport-commons/pull/48) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v3.0.0-pre.2](https://github.com/feathersjs/transport-commons/tree/v3.0.0-pre.2) (2017-09-28) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v3.0.0-pre.1...v3.0.0-pre.2) **Merged pull requests:** - Add feathers-channels [\#47](https://github.com/feathersjs/transport-commons/pull/47) ([daffl](https://github.com/daffl)) ## [v3.0.0-pre.1](https://github.com/feathersjs/transport-commons/tree/v3.0.0-pre.1) (2017-09-08) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v2.4.0...v3.0.0-pre.1) **Fixed bugs:** - Socket events don't fire for sub-apps nested more than 2 deep [\#5](https://github.com/feathersjs/transport-commons/issues/5) **Closed issues:** - more tests [\#38](https://github.com/feathersjs/transport-commons/issues/38) **Merged pull requests:** - Prepare v3.0-pre [\#46](https://github.com/feathersjs/transport-commons/pull/46) ([daffl](https://github.com/daffl)) - Update debug to the latest version 🚀 [\#45](https://github.com/feathersjs/transport-commons/pull/45) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update feathers-socketio to the latest version 🚀 [\#43](https://github.com/feathersjs/transport-commons/pull/43) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update semistandard to the latest version 🚀 [\#42](https://github.com/feathersjs/transport-commons/pull/42) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - Update dependencies to enable Greenkeeper 🌴 [\#41](https://github.com/feathersjs/transport-commons/pull/41) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) ## [v2.4.0](https://github.com/feathersjs/transport-commons/tree/v2.4.0) (2017-01-07) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v2.3.1...v2.4.0) **Implemented enhancements:** - support service.json [\#34](https://github.com/feathersjs/transport-commons/issues/34) - Socket event filters should not force returning data [\#4](https://github.com/feathersjs/transport-commons/issues/4) - bootstrap service.filters [\#37](https://github.com/feathersjs/transport-commons/pull/37) ([slajax](https://github.com/slajax)) **Closed issues:** - Sockets timed out request - retry on reconnection \[feat?\] [\#32](https://github.com/feathersjs/transport-commons/issues/32) **Merged pull requests:** - Normalize arguments when client sends packed data. [\#39](https://github.com/feathersjs/transport-commons/pull/39) ([devel-pa](https://github.com/devel-pa)) - Create .codeclimate.yml [\#33](https://github.com/feathersjs/transport-commons/pull/33) ([larkinscott](https://github.com/larkinscott)) - Update feathers-commons to version 0.8.0 🚀 [\#31](https://github.com/feathersjs/transport-commons/pull/31) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - jshint —\> semistandard [\#30](https://github.com/feathersjs/transport-commons/pull/30) ([corymsmith](https://github.com/corymsmith)) - Code coverage [\#29](https://github.com/feathersjs/transport-commons/pull/29) ([ekryski](https://github.com/ekryski)) ## [v2.3.1](https://github.com/feathersjs/transport-commons/tree/v2.3.1) (2016-09-02) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v2.3.0...v2.3.1) **Merged pull requests:** - Make service off method be namespaced [\#26](https://github.com/feathersjs/transport-commons/pull/26) ([t2t2](https://github.com/t2t2)) - Update mocha to version 3.0.0 🚀 [\#25](https://github.com/feathersjs/transport-commons/pull/25) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v2.3.0](https://github.com/feathersjs/transport-commons/tree/v2.3.0) (2016-07-24) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v2.2.1...v2.3.0) **Fixed bugs:** - Error in filter chain for 'created' event after app.authenticate\(\) [\#12](https://github.com/feathersjs/transport-commons/issues/12) **Merged pull requests:** - Skip subsequent filters instead of rejecting the promise [\#24](https://github.com/feathersjs/transport-commons/pull/24) ([daffl](https://github.com/daffl)) ## [v2.2.1](https://github.com/feathersjs/transport-commons/tree/v2.2.1) (2016-07-05) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v2.2.0...v2.2.1) ## [v2.2.0](https://github.com/feathersjs/transport-commons/tree/v2.2.0) (2016-07-05) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v2.1.0...v2.2.0) **Implemented enhancements:** - Support native websockets directly [\#8](https://github.com/feathersjs/transport-commons/issues/8) **Fixed bugs:** - Calling `off` on primus fails [\#7](https://github.com/feathersjs/transport-commons/issues/7) **Closed issues:** - Should add other eventEmitter methods [\#22](https://github.com/feathersjs/transport-commons/issues/22) - Patch event sends the whole data back [\#21](https://github.com/feathersjs/transport-commons/issues/21) **Merged pull requests:** - Pass all EventEmitter methods to the client connection [\#23](https://github.com/feathersjs/transport-commons/pull/23) ([daffl](https://github.com/daffl)) ## [v2.1.0](https://github.com/feathersjs/transport-commons/tree/v2.1.0) (2016-05-29) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v2.0.0...v2.1.0) **Closed issues:** - Client should convert error objects to feathers-errors [\#19](https://github.com/feathersjs/transport-commons/issues/19) **Merged pull requests:** - Make client convert to feathers-errors [\#20](https://github.com/feathersjs/transport-commons/pull/20) ([daffl](https://github.com/daffl)) ## [v2.0.0](https://github.com/feathersjs/transport-commons/tree/v2.0.0) (2016-05-23) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v1.0.0...v2.0.0) **Merged pull requests:** - Better handling of sub-apps and sockets [\#18](https://github.com/feathersjs/transport-commons/pull/18) ([daffl](https://github.com/daffl)) - Update babel-plugin-add-module-exports to version 0.2.0 🚀 [\#17](https://github.com/feathersjs/transport-commons/pull/17) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - babel-polyfill@6.7.4 breaks build 🚨 [\#16](https://github.com/feathersjs/transport-commons/pull/16) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) ## [v1.0.0](https://github.com/feathersjs/transport-commons/tree/v1.0.0) (2016-04-28) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v0.2.3...v1.0.0) **Implemented enhancements:** - Support acknowledgement timeouts [\#9](https://github.com/feathersjs/transport-commons/issues/9) **Closed issues:** - Feathers over sockets is totally silent when a hook has errors [\#13](https://github.com/feathersjs/transport-commons/issues/13) - Listener warning when you register your own events on the socket [\#10](https://github.com/feathersjs/transport-commons/issues/10) **Merged pull requests:** - Support timeouts for socket clients [\#15](https://github.com/feathersjs/transport-commons/pull/15) ([daffl](https://github.com/daffl)) - Convert errors in socket callbacks [\#14](https://github.com/feathersjs/transport-commons/pull/14) ([daffl](https://github.com/daffl)) ## [v0.2.3](https://github.com/feathersjs/transport-commons/tree/v0.2.3) (2016-04-16) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v0.2.2...v0.2.3) **Merged pull requests:** - Remove connection setMaxListeners [\#11](https://github.com/feathersjs/transport-commons/pull/11) ([daffl](https://github.com/daffl)) ## [v0.2.2](https://github.com/feathersjs/transport-commons/tree/v0.2.2) (2016-03-22) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v0.2.1...v0.2.2) **Merged pull requests:** - Allow chaining event listeners. [\#6](https://github.com/feathersjs/transport-commons/pull/6) ([joshuajabbour](https://github.com/joshuajabbour)) ## [v0.2.1](https://github.com/feathersjs/transport-commons/tree/v0.2.1) (2016-03-08) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v0.2.0...v0.2.1) **Merged pull requests:** - Set connection max listeners and better debug messages [\#3](https://github.com/feathersjs/transport-commons/pull/3) ([daffl](https://github.com/daffl)) ## [v0.2.0](https://github.com/feathersjs/transport-commons/tree/v0.2.0) (2016-02-08) [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v0.1.0...v0.2.0) **Merged pull requests:** - Query params [\#2](https://github.com/feathersjs/transport-commons/pull/2) ([ekryski](https://github.com/ekryski)) - Adding nsp check [\#1](https://github.com/feathersjs/transport-commons/pull/1) ([marshallswain](https://github.com/marshallswain)) ## [v0.1.0](https://github.com/feathersjs/transport-commons/tree/v0.1.0) (2016-01-21) \* _This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)_ ================================================ FILE: packages/transport-commons/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/transport-commons/README.md ================================================ # @feathersjs/transport-commons [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/transport-commons.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/transport-commons) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > Shared functionality for Feathers API transports like `@feathers/socketio` and `@feathersjs/primus`. Only intended to be used internally. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/transport-commons/client.d.ts ================================================ export * from './lib/client' ================================================ FILE: packages/transport-commons/client.js ================================================ module.exports = require('./lib/client'); ================================================ FILE: packages/transport-commons/package.json ================================================ { "name": "@feathersjs/transport-commons", "description": "Shared functionality for websocket providers", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/transport-commons" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "test": "npm run mocha", "mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "dependencies": { "@feathersjs/commons": "^5.0.42", "@feathersjs/errors": "^5.0.42", "@feathersjs/feathers": "^5.0.42", "encodeurl": "^2.0.0", "lodash": "^4.17.23" }, "devDependencies": { "@types/encodeurl": "^1.0.3", "@types/lodash": "^4.17.24", "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "mocha": "^11.7.5", "shx": "^0.4.0", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/transport-commons/src/channels/channel/base.ts ================================================ import { EventEmitter } from 'events' import { RealTimeConnection } from '@feathersjs/feathers' export class Channel extends EventEmitter { connections: RealTimeConnection[] data: any constructor(connections: RealTimeConnection[] = [], data: any = null) { super() this.connections = connections this.data = data } get length() { return this.connections.length } leave(...connections: RealTimeConnection[]) { connections.forEach((current) => { if (typeof current === 'function') { const callback = current as (connection: RealTimeConnection) => boolean this.leave(...this.connections.filter(callback)) } else { const index = this.connections.indexOf(current) if (index !== -1) { this.connections.splice(index, 1) } } }) if (this.length === 0) { this.emit('empty') } return this } join(...connections: RealTimeConnection[]) { connections.forEach((connection) => { if (connection && this.connections.indexOf(connection) === -1) { this.connections.push(connection) } }) return this } filter(fn: (connection: RealTimeConnection) => boolean) { return new Channel(this.connections.filter(fn), this.data) } send(data: any) { return new Channel(this.connections, data) } } ================================================ FILE: packages/transport-commons/src/channels/channel/combined.ts ================================================ import { RealTimeConnection } from '@feathersjs/feathers' import { Channel } from './base' function collectConnections(children: Channel[]) { const mappings = new WeakMap() const connections: RealTimeConnection[] = [] children.forEach((channel) => { channel.connections.forEach((connection) => { if (!mappings.has(connection)) { connections.push(connection) mappings.set(connection, channel.data) } }) }) return { connections, mappings } } export class CombinedChannel extends Channel { children: Channel[] mappings: WeakMap constructor(children: Channel[], data: any = null) { const { mappings, connections } = collectConnections(children) super(connections, data) this.children = children this.mappings = mappings } refresh() { const collected = collectConnections(this.children) return Object.assign(this, collected) } leave(...connections: RealTimeConnection[]) { return this.callChildren('leave', connections) } join(...connections: RealTimeConnection[]) { return this.callChildren('join', connections) } dataFor(connection: RealTimeConnection) { return this.mappings.get(connection) } private callChildren(method: string, connections: RealTimeConnection[]) { this.children.forEach((child: any) => child[method](...connections)) this.refresh() return this } } ================================================ FILE: packages/transport-commons/src/channels/index.ts ================================================ import { Application, FeathersService, RealTimeConnection, getServiceOptions } from '@feathersjs/feathers' import { createDebug } from '@feathersjs/commons' import flattenDeep from 'lodash/flattenDeep' import { Channel } from './channel/base' import { CombinedChannel } from './channel/combined' import { channelMixin, publishMixin, keys, PublishMixin, Event, Publisher } from './mixins' import EventEmitter from 'events' const debug = createDebug('@feathersjs/transport-commons/channels') const { CHANNELS } = keys declare module '@feathersjs/feathers/lib/declarations' { interface ServiceAddons extends EventEmitter { // eslint-disable-line publish(publisher: Publisher, A, this>): this publish(event: Event, publisher: Publisher, A, this>): this registerPublisher(publisher: Publisher, A, this>): this registerPublisher(event: Event, publisher: Publisher, A, this>): this } // eslint-disable-next-line @typescript-eslint/no-unused-vars interface Application { // eslint-disable-line channels: string[] channel(name: string | string[]): Channel channel(...names: string[]): Channel publish(publisher: Publisher): this publish(event: Event, publisher: Publisher): this registerPublisher(publisher: Publisher): this registerPublisher(event: Event, publisher: Publisher): this } interface Params { connection?: RealTimeConnection } } export { keys } export function channels() { return (app: Application) => { if (typeof app.channel === 'function' && typeof app.publish === 'function') { return } Object.assign(app, channelMixin(), publishMixin()) Object.defineProperty(app, 'channels', { get() { return Object.keys(this[CHANNELS]) } }) app.mixins.push((service: FeathersService, path: string) => { const { serviceEvents } = getServiceOptions(service) if (typeof service.publish === 'function') { return } Object.assign(service, publishMixin()) serviceEvents.forEach((event: string) => { service.on(event, function (data, hook) { if (!hook) { // Fake hook for custom events hook = { path, service, app, result: data } } debug('Publishing event', event, hook.path) const logError = (error: any) => debug(`Error in '${hook.path} ${event}' publisher`, error) const servicePublishers = (service as unknown as PublishMixin)[keys.PUBLISHERS] const appPublishers = (app as unknown as PublishMixin)[keys.PUBLISHERS] // This will return the first publisher list that is not empty // In the following precedence const publisher = // 1. Service publisher for a specific event servicePublishers[event] || // 2. Service publisher for all events servicePublishers[keys.ALL_EVENTS] || // 3. App publisher for a specific event appPublishers[event] || // 4. App publisher for all events appPublishers[keys.ALL_EVENTS] || // 5. No publisher (() => {}) try { Promise.resolve(publisher(data, hook)) .then((result: any) => { if (!result) { return } const results = Array.isArray(result) ? flattenDeep(result).filter(Boolean) : ([result] as Channel[]) const channel = new CombinedChannel(results) if (channel && channel.length > 0) { app.emit('publish', event, channel, hook, data) } else { debug('No connections to publish to') } }) .catch(logError) } catch (error: any) { logError(error) } }) }) }) } } export { Channel, CombinedChannel, RealTimeConnection } ================================================ FILE: packages/transport-commons/src/channels/mixins.ts ================================================ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { Application, HookContext, getServiceOptions, defaultServiceEvents } from '@feathersjs/feathers' import { createDebug } from '@feathersjs/commons' import { Channel } from './channel/base' import { CombinedChannel } from './channel/combined' const debug = createDebug('@feathersjs/transport-commons/channels/mixins') const PUBLISHERS = Symbol.for('@feathersjs/transport-commons/publishers') const CHANNELS = Symbol.for('@feathersjs/transport-commons/channels') const ALL_EVENTS = Symbol.for('@feathersjs/transport-commons/all-events') export const keys = { PUBLISHERS: PUBLISHERS as typeof PUBLISHERS, CHANNELS: CHANNELS as typeof CHANNELS, ALL_EVENTS: ALL_EVENTS as typeof ALL_EVENTS } export interface ChannelMixin { [CHANNELS]: { [key: string]: Channel } channel(...names: string[]): Channel } export function channelMixin() { const mixin: ChannelMixin = { [CHANNELS]: {}, channel(...names: string[]): Channel { debug('Returning channels', names) if (names.length === 0) { throw new Error('app.channel needs at least one channel name') } if (names.length === 1) { const [name] = names if (Array.isArray(name)) { return this.channel(...name) } if (!this[CHANNELS][name]) { const channel = new Channel() channel.once('empty', () => { channel.removeAllListeners() delete this[CHANNELS][name] }) this[CHANNELS][name] = channel } return this[CHANNELS][name] } const channels = names.map((name) => this.channel(name)) return new CombinedChannel(channels) } } return mixin } export type Event = string | typeof ALL_EVENTS export type Publisher = ( data: T, context: HookContext ) => Channel | Channel[] | void | Promise export interface PublishMixin { [PUBLISHERS]: { [ALL_EVENTS]?: Publisher; [key: string]: Publisher } publish(event: Event, publisher: Publisher): this registerPublisher(event: Event, publisher: Publisher): this } export function publishMixin() { const result: PublishMixin = { [PUBLISHERS]: {}, publish(...args) { return this.registerPublisher(...args) }, registerPublisher(event, publisher) { debug('Registering publisher', event) if (!publisher && typeof event === 'function') { publisher = event event = ALL_EVENTS } const { serviceEvents = defaultServiceEvents } = getServiceOptions(this) || {} if (event !== ALL_EVENTS && !serviceEvents.includes(event)) { throw new Error(`'${event.toString()}' is not a valid service event`) } const publishers = this[PUBLISHERS] publishers[event] = publisher return this } } return result } ================================================ FILE: packages/transport-commons/src/client.ts ================================================ /* eslint-disable @typescript-eslint/ban-ts-comment */ import { BadRequest, convert } from '@feathersjs/errors' import { createDebug } from '@feathersjs/commons' import { Id, NullableId, Params, ServiceInterface } from '@feathersjs/feathers' const debug = createDebug('@feathersjs/transport-commons/client') const namespacedEmitterMethods = [ 'addListener', 'addEventListener', 'emit', 'listenerCount', 'listeners', 'on', 'once', 'prependListener', 'prependOnceListener', 'removeAllListeners', 'removeEventListener', 'removeListener' ] const otherEmitterMethods = ['eventNames', 'getMaxListeners', 'setMaxListeners'] const addEmitterMethods = (service: any) => { otherEmitterMethods.forEach((method) => { service[method] = function (...args: any[]) { if (typeof this.connection[method] !== 'function') { throw new Error(`Can not call '${method}' on the client service connection`) } return this.connection[method](...args) } }) // Methods that should add the namespace (service path) namespacedEmitterMethods.forEach((method) => { service[method] = function (name: string, ...args: any[]) { if (typeof this.connection[method] !== 'function') { throw new Error(`Can not call '${method}' on the client service connection`) } const eventName = `${this.path} ${name}` debug(`Calling emitter method ${method} with ` + `namespaced event '${eventName}'`) const result = this.connection[method](eventName, ...args) return result === this.connection ? this : result } }) } interface ServiceOptions { name: string connection: any method: string events?: string[] } export type SocketService, P extends Params = Params> = Service export class Service, P extends Params = Params> implements ServiceInterface< T, D, P > { events: string[] path: string connection: any method: string constructor(options: ServiceOptions) { this.events = options.events this.path = options.name this.connection = options.connection this.method = options.method addEmitterMethods(this) } send(method: string, ...args: any[]) { return new Promise((resolve, reject) => { const route: Record = args.pop() let path = this.path if (route) { Object.keys(route).forEach((key) => { path = path.replace(`:${key}`, route[key]) }) } args.unshift(method, path) const socketTimeout = this.connection.flags?.timeout || this.connection._opts?.ackTimeout if (socketTimeout !== undefined) { args.push(function (timeoutError: any, error: any, data: any) { return timeoutError || error ? reject(convert(timeoutError || error)) : resolve(data) }) } else { args.push(function (error: any, data: any) { return error ? reject(convert(error)) : resolve(data) }) } debug(`Sending socket.${this.method}`, args) this.connection[this.method](...args) }) } methods(this: any, ...names: string[]) { names.forEach((method) => { const _method = `_${method}` this[_method] = function (data: any, params: Params = {}) { return this.send(method, data, params.query || {}, params.route || {}) } this[method] = function (data: any, params: Params = {}) { return this[_method](data, params, params.route || {}) } }) return this } _find(params: Params = {}) { return this.send('find', params.query || {}, params.route || {}) } find(params: Params = {}) { return this._find(params) } _get(id: Id, params: Params = {}) { if (id === undefined || id === '') { return Promise.reject(new BadRequest('id for .get is required')) } return this.send('get', id, params.query || {}, params.route || {}) } get(id: Id, params: Params = {}) { return this._get(id, params) } _create(data: D, params: Params = {}) { return this.send('create', data, params.query || {}, params.route || {}) } create(data: D, params: Params = {}) { return this._create(data, params) } _update(id: NullableId, data: D, params: Params = {}) { if (id === undefined || id === '') { return Promise.reject(new BadRequest('id for .update is required')) } return this.send('update', id, data, params.query || {}, params.route || {}) } update(id: NullableId, data: D, params: Params = {}) { if (id === undefined || id === '') { return Promise.reject(new BadRequest('id for .update is required')) } return this._update(id, data, params) } _patch(id: NullableId, data: D, params: Params = {}) { if (id === undefined || id === '') { return Promise.reject(new BadRequest('id for .patch is required')) } return this.send('patch', id, data, params.query || {}, params.route || {}) } patch(id: NullableId, data: D, params: Params = {}) { return this._patch(id, data, params) } _remove(id: NullableId, params: Params = {}) { if (id === undefined || id === '') { return Promise.reject(new BadRequest('id for .remove is required')) } return this.send('remove', id, params.query || {}, params.route || {}) } remove(id: NullableId, params: Params = {}) { return this._remove(id, params) } // `off` is actually not part of the Node event emitter spec // but we are adding it since everybody is expecting it because // of the emitter-component Socket.io is using off(name: string, ...args: any[]) { if (typeof this.connection.off === 'function') { const result = this.connection.off(`${this.path} ${name}`, ...args) return result === this.connection ? this : result } else if (args.length === 0) { // @ts-ignore return this.removeAllListeners(name) } // @ts-ignore return this.removeListener(name, ...args) } } ================================================ FILE: packages/transport-commons/src/http.ts ================================================ import { MethodNotAllowed } from '@feathersjs/errors/lib' import { HookContext, NullableId, Params } from '@feathersjs/feathers' import encodeUrl from 'encodeurl' export const METHOD_HEADER = 'x-service-method' export interface ServiceParams { id: NullableId data: any params: Params } export const statusCodes = { created: 201, noContent: 204, methodNotAllowed: 405, success: 200, seeOther: 303 } export const knownMethods: { [key: string]: string } = { post: 'create', patch: 'patch', put: 'update', delete: 'remove' } export function getServiceMethod(_httpMethod: string, id: unknown, headerOverride?: string) { const httpMethod = _httpMethod.toLowerCase() if (httpMethod === 'post' && headerOverride) { return headerOverride } const mappedMethod = knownMethods[httpMethod] if (mappedMethod) { return mappedMethod } if (httpMethod === 'get') { return id === null ? 'find' : 'get' } throw new MethodNotAllowed(`Method ${_httpMethod} not allowed`) } export const argumentsFor = { get: ({ id, params }: ServiceParams) => [id, params], find: ({ params }: ServiceParams) => [params], create: ({ data, params }: ServiceParams) => [data, params], update: ({ id, data, params }: ServiceParams) => [id, data, params], patch: ({ id, data, params }: ServiceParams) => [id, data, params], remove: ({ id, params }: ServiceParams) => [id, params], default: ({ data, params }: ServiceParams) => [data, params] } export function getStatusCode(context: HookContext, body: any, location: string | string[]) { const { http = {} } = context if (http.status) { return http.status } if (location !== undefined) { return statusCodes.seeOther } if (!body) { return statusCodes.noContent } if (context.method === 'create') { return statusCodes.created } return statusCodes.success } export function getResponse(context: HookContext) { const { http = {} } = context const body = context.dispatch !== undefined ? context.dispatch : context.result let headers = http.headers || {} let location = headers.Location if (http.location !== undefined) { location = encodeUrl(http.location) headers = { ...headers, Location: location } } const status = getStatusCode(context, body, location) return { status, headers, body } } ================================================ FILE: packages/transport-commons/src/index.ts ================================================ import { socket } from './socket' import { routing } from './routing' import { channels, Channel, CombinedChannel } from './channels' import { RealTimeConnection } from '@feathersjs/feathers' export * as http from './http' export { socket, routing, channels, Channel, CombinedChannel, RealTimeConnection } ================================================ FILE: packages/transport-commons/src/routing/index.ts ================================================ import { Application, FeathersService, ServiceOptions } from '@feathersjs/feathers' import { Router } from './router' declare module '@feathersjs/feathers/lib/declarations' { interface RouteLookup { service: Service params: { [key: string]: any } } // eslint-disable-next-line @typescript-eslint/no-unused-vars interface Application { // eslint-disable-line routes: Router<{ service: Service params?: { [key: string]: any } }> lookup(path: string): RouteLookup } } export * from './router' const lookup = function (this: Application, path: string) { const result = this.routes.lookup(path) if (result === null) { return null } const { params: colonParams, data: { service, params: dataParams } } = result const params = dataParams ? { ...dataParams, ...colonParams } : colonParams return { service, params } } export const routing = () => (app: Application) => { if (typeof app.lookup === 'function') { return } const { unuse } = app app.routes = new Router() app.lookup = lookup app.unuse = function (path: string) { app.routes.remove(path) app.routes.remove(`${path}/:__id`) return unuse.call(this, path) } // Add a mixin that registers a service on the router app.mixins.push((service: FeathersService, path: string, options: ServiceOptions) => { const { routeParams: params = {} } = options app.routes.insert(path, { service, params }) app.routes.insert(`${path}/:__id`, { service, params }) }) } ================================================ FILE: packages/transport-commons/src/routing/router.ts ================================================ import { stripSlashes } from '@feathersjs/commons' export interface LookupData { params: { [key: string]: string } } export interface LookupResult extends LookupData { data?: T } export class RouteNode { data?: T children: { [key: string]: RouteNode } = {} placeholders: RouteNode[] = [] constructor( public name: string, public depth: number ) {} get hasChildren() { return Object.keys(this.children).length !== 0 || this.placeholders.length !== 0 } insert(path: string[], data: T): RouteNode { if (this.depth === path.length) { if (this.data !== undefined) { throw new Error(`Path ${path.join('/')} already exists`) } this.data = data return this } const current = path[this.depth] const nextDepth = this.depth + 1 if (current.startsWith(':')) { // Insert a placeholder node like /messages/:id const placeholderName = current.substring(1) let placeholder = this.placeholders.find((p) => p.name === placeholderName) if (!placeholder) { placeholder = new RouteNode(placeholderName, nextDepth) this.placeholders.push(placeholder) } return placeholder.insert(path, data) } const child = this.children[current] || new RouteNode(current, nextDepth) this.children[current] = child return child.insert(path, data) } remove(path: string[]) { if (path.length === this.depth) { delete this.data return } const current = path[this.depth] if (current.startsWith(':')) { const placeholderName = current.substring(1) const placeholder = this.placeholders.find((p) => p.name === placeholderName) placeholder.remove(path) this.placeholders = this.placeholders.filter((p) => p !== placeholder) } else if (this.children[current]) { const child = this.children[current] child.remove(path) if (!child.hasChildren) { delete this.children[current] } } } lookup(path: string[], info: LookupData): LookupResult | null { if (path.length === this.depth) { return this.data === undefined ? null : { ...info, data: this.data } } const current = path[this.depth] const child = this.children[current] if (child) { const lookup = child.lookup(path, info) if (lookup !== null) { return lookup } } // This will return the first placeholder that matches early for (const placeholder of this.placeholders) { const result = placeholder.lookup(path, info) if (result !== null) { result.params[placeholder.name] = current return result } } return null } } export class Router { public caseSensitive = true constructor(public root: RouteNode = new RouteNode('', 0)) {} getPath(path: string) { const result = stripSlashes(path).split('/') if (!this.caseSensitive) { return result.map((p) => (p.startsWith(':') ? p : p.toLowerCase())) } return result } insert(path: string, data: T) { return this.root.insert(this.getPath(path), data) } remove(path: string) { return this.root.remove(this.getPath(path)) } lookup(path: string) { if (typeof path !== 'string') { return null } return this.root.lookup(this.getPath(path), { params: {} }) } } ================================================ FILE: packages/transport-commons/src/socket/index.ts ================================================ import { Application, getServiceOptions, Params, RealTimeConnection } from '@feathersjs/feathers' import { channels } from '../channels' import { routing } from '../routing' import { getDispatcher, runMethod } from './utils' export interface SocketOptions { done: Promise emit: string socketMap: WeakMap socketKey?: any getParams: (socket: any) => RealTimeConnection } export function socket({ done, emit, socketMap, socketKey, getParams }: SocketOptions) { return (app: Application) => { const leaveChannels = (connection: RealTimeConnection) => { const { channels } = app if (channels.length) { app.channel(app.channels).leave(connection) } } app.configure(channels()) app.configure(routing()) app.on('publish', getDispatcher(emit, socketMap, socketKey)) app.on('disconnect', leaveChannels) app.on('logout', (_authResult: any, params: Params) => { const { connection } = params if (connection) { leaveChannels(connection) } }) // `connection` event done.then((provider) => provider.on('connection', (connection: any) => app.emit('connection', getParams(connection))) ) // `socket.emit('methodName', 'serviceName', ...args)` handlers done.then((provider) => provider.on('connection', (connection: any) => { const methodHandlers = Object.keys(app.services).reduce((result, name) => { const { methods } = getServiceOptions(app.service(name)) methods.forEach((method) => { if (!result[method]) { result[method] = (...args: any[]) => { const [path, ...rest] = args runMethod(app, getParams(connection), path, method, rest) } } }) return result }, {} as any) Object.keys(methodHandlers).forEach((key) => connection.on(key, methodHandlers[key])) }) ) } } ================================================ FILE: packages/transport-commons/src/socket/utils.ts ================================================ import { HookContext, Application, RealTimeConnection, createContext, getServiceOptions } from '@feathersjs/feathers' import { NotFound, MethodNotAllowed, BadRequest } from '@feathersjs/errors' import { createDebug } from '@feathersjs/commons' import isEqual from 'lodash/isEqual' import { CombinedChannel } from '../channels/channel/combined' const debug = createDebug('@feathersjs/transport-commons') export const DEFAULT_PARAMS_POSITION = 1 export const paramsPositions: { [key: string]: number } = { find: 0, update: 2, patch: 2 } export function normalizeError(e: any) { const hasToJSON = typeof e.toJSON === 'function' const result = hasToJSON ? e.toJSON() : {} if (!hasToJSON) { Object.getOwnPropertyNames(e).forEach((key) => { result[key] = e[key] }) } if (process.env.NODE_ENV === 'production') { delete result.stack } delete result.hook return result } export function getDispatcher(emit: string, socketMap: WeakMap, socketKey?: any) { return function (event: string, channel: CombinedChannel, context: HookContext, data?: any) { debug(`Dispatching '${event}' to ${channel.length} connections`) channel.connections.forEach((connection) => { // The reference between connection and socket is set in `app.setup` const socket = socketKey ? connection[socketKey] : socketMap.get(connection) if (socket) { const eventName = `${context.path || ''} ${event}`.trim() let result = channel.dataFor(connection) || context.dispatch || context.result // If we are getting events from an array but try to dispatch individual data // try to get the individual item to dispatch from the correct index. if (!Array.isArray(data) && Array.isArray(context.result) && Array.isArray(result)) { result = result.find((resultData) => isEqual(resultData, data)) } debug(`Dispatching '${eventName}' to Socket ${socket.id} with`, result) socket[emit](eventName, result) } }) } } export async function runMethod( app: Application, connection: RealTimeConnection, _path: string, _method: string, args: any[] ) { const path = typeof _path === 'string' ? _path : null const method = typeof _method === 'string' ? _method : null const trace = `method '${method}' on service '${path}'` const methodArgs = args.slice(0) const callback = // eslint-disable-next-line @typescript-eslint/no-empty-function typeof methodArgs[methodArgs.length - 1] === 'function' ? methodArgs.pop() : function () {} debug(`Running ${trace}`, connection, args) const handleError = (error: any) => { debug(`Error in ${trace}`, error) callback(normalizeError(error)) } try { const lookup = app.lookup(path) // No valid service was found throw a NotFound error if (lookup === null) { throw new NotFound(path === null ? `Invalid service path` : `Service '${path}' not found`) } const { service, params: route = {} } = lookup const { methods } = getServiceOptions(service) // Only service methods are allowed if (!methods.includes(method)) { throw new MethodNotAllowed(`Method '${method}' not allowed on service '${path}'`) } const position = paramsPositions[method] !== undefined ? paramsPositions[method] : DEFAULT_PARAMS_POSITION const query = Object.assign({}, methodArgs[position]) // `params` have to be re-mapped to the query and added with the route const params = Object.assign({ query, route, connection }, connection) // `params` is always the last parameter. Error if we got more arguments. if (methodArgs.length > position + 1) { throw new BadRequest(`Too many arguments for '${method}' method`) } methodArgs[position] = params const ctx = createContext(service, method) const returnedCtx: HookContext = await (service as any)[method](...methodArgs, ctx) const result = returnedCtx.dispatch || returnedCtx.result debug(`Returned successfully ${trace}`, result) callback(null, result) } catch (error: any) { handleError(error) } } ================================================ FILE: packages/transport-commons/test/channels/channel.test.ts ================================================ /* eslint-disable @typescript-eslint/no-empty-function */ import assert from 'assert' import { feathers, Application, RealTimeConnection } from '@feathersjs/feathers' import { channels, keys } from '../../src/channels' import { Channel } from '../../src/channels/channel/base' import { CombinedChannel } from '../../src/channels/channel/combined' const { CHANNELS } = keys describe('app.channel', () => { let app: Application beforeEach(() => { app = feathers().configure(channels()) }) describe('base channels', () => { it('creates a new channel, app.channels has names', () => { assert.ok(app.channel('test') instanceof Channel) assert.deepStrictEqual(app.channels, ['test']) }) it('.join', () => { const test = app.channel('test') const c1 = { id: 1 } const c2 = { id: 2 } const c3 = { id: 3 } assert.strictEqual(test.length, 0, 'Initial channel is empty') test.join(c1) test.join(c1) assert.strictEqual(test.length, 1, 'Joining twice only runs once') test.join(c2, c3) assert.strictEqual(test.length, 3, 'New connections joined') test.join(c1, c2, c3) assert.strictEqual(test.length, 3, 'Joining multiple times does nothing') }) it('.leave', () => { const test = app.channel('test') const c1 = { id: 1 } const c2 = { id: 2 } assert.strictEqual(test.length, 0) test.join(c1, c2) assert.strictEqual(test.length, 2) test.leave(c2) test.leave(c2) assert.strictEqual(test.length, 1) assert.strictEqual(test.connections.indexOf(c2), -1) }) it('.leave conditional', () => { const test = app.channel('test') const c1 = { id: 1, leave: true } const c2 = { id: 2 } const c3 = { id: 3 } test.join(c1, c2, c3) assert.strictEqual(test.length, 3) test.leave((connection: RealTimeConnection) => connection.leave) assert.strictEqual(test.length, 2) assert.strictEqual(test.connections.indexOf(c1), -1) }) it('.filter', () => { const test = app.channel('test') const c1 = { id: 1, filter: true } const c2 = { id: 2 } const c3 = { id: 3 } test.join(c1, c2, c3) const filtered = test.filter((connection) => connection.filter) assert.ok(filtered !== test, 'Returns a new channel instance') assert.ok(filtered instanceof Channel) assert.strictEqual(filtered.length, 1) }) it('.send', () => { const data = { message: 'Hi' } const test = app.channel('test') const withData = test.send(data) assert.ok(test !== withData) assert.deepStrictEqual(withData.data, data) }) describe('empty channels', () => { it('is an EventEmitter', () => { const channel = app.channel('emitchannel') return new Promise((resolve) => { channel.once('message', (data) => { assert.strictEqual(data, 'hello') resolve() }) channel.emit('message', 'hello') }) }) it('empty', (done) => { const channel = app.channel('test') const c1 = { id: 1 } const c2 = { id: 2 } channel.once('empty', done) channel.join(c1, c2) channel.leave(c1) channel.leave(c2) }) it('removes an empty channel', () => { const channel = app.channel('test') const appChannels = (app as any)[CHANNELS] const c1 = { id: 1 } channel.join(c1) assert.ok(appChannels.test) assert.strictEqual(Object.keys(appChannels).length, 1) channel.leave(c1) assert.ok((app as any)[CHANNELS].test === undefined) assert.strictEqual(Object.keys(appChannels).length, 0) }) it('removes all event listeners from an empty channel', () => { const channel = app.channel('testing') const connection = { id: 1 } channel.on('something', () => {}) assert.strictEqual(channel.listenerCount('something'), 1) assert.strictEqual(channel.listenerCount('empty'), 1) channel.join(connection).leave(connection) assert.ok((app as any)[CHANNELS].testing === undefined) assert.strictEqual(channel.listenerCount('something'), 0) assert.strictEqual(channel.listenerCount('empty'), 0) }) }) }) describe('combined channels', () => { it('combines multiple channels', () => { const combined = app.channel('test', 'again') assert.deepStrictEqual(app.channels, ['test', 'again']) assert.ok(combined instanceof CombinedChannel) assert.strictEqual(combined.length, 0) }) it('de-dupes connections', () => { const c1 = { id: 1 } const c2 = { id: 2 } app.channel('test').join(c1, c2) app.channel('again').join(c1) const combined = app.channel('test', 'again') assert.ok(combined instanceof CombinedChannel) assert.strictEqual(combined.length, 2) }) it('does nothing when the channel is undefined (#2207)', () => { const channel = app.channel('test', 'me') channel.join(undefined) }) it('.join all child channels', () => { const c1 = { id: 1 } const c2 = { id: 2 } const combined = app.channel('test', 'again') combined.join(c1, c2) assert.strictEqual(combined.length, 2) assert.strictEqual(app.channel('test').length, 2) assert.strictEqual(app.channel('again').length, 2) }) it('.leave all child channels', () => { const c1 = { id: 1 } const c2 = { id: 2 } app.channel('test').join(c1, c2) app.channel('again').join(c1) const combined = app.channel('test', 'again') combined.leave(c1) assert.strictEqual(app.channel('test').length, 1) assert.strictEqual(app.channel('again').length, 0) }) it('.leave all child channels conditionally', () => { const c1 = { id: 1 } const c2 = { id: 2, leave: true } const combined = app.channel('test', 'again').join(c1, c2) combined.leave((connection: RealTimeConnection) => connection.leave) assert.strictEqual(app.channel('test').length, 1) assert.strictEqual(app.channel('again').length, 1) }) it('app.channel(app.channels)', () => { const c1 = { id: 1 } const c2 = { id: 2 } app.channel('test').join(c1, c2) app.channel('again').join(c1) const combined = app.channel(app.channels) assert.deepStrictEqual(combined.connections, [c1, c2]) }) }) }) ================================================ FILE: packages/transport-commons/test/channels/dispatch.test.ts ================================================ /* eslint-disable @typescript-eslint/no-empty-function */ import assert from 'assert' import { feathers, Application, HookContext } from '@feathersjs/feathers' import { channels } from '../../src/channels' import { Channel } from '../../src/channels/channel/base' import { CombinedChannel } from '../../src/channels/channel/combined' class TestService { events = ['foo'] async create(payload: any) { return payload } } describe('app.publish', () => { let app: Application beforeEach(() => { app = feathers().configure(channels()) }) it('throws an error if service does not send the event', () => { try { app.use('/test', { create(data: any) { return Promise.resolve(data) } }) app.service('test').registerPublisher('created', function () {}) app.service('test').registerPublisher('bla', function () {}) assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, "'bla' is not a valid service event") } }) describe('registration and `dispatch` event', () => { const c1 = { id: 1, test: true } const c2 = { id: 2, test: true } const data = { message: 'This is a test' } beforeEach(() => { app.use('/test', new TestService()) }) it('error in publisher is handled gracefully (#1707)', async () => { app.service('test').publish('created', () => { throw new Error('Something went wrong') }) try { await app.service('test').create({ message: 'something' }) } catch (error: any) { assert.fail('Should never get here') } }) it('simple event registration and dispatching', (done) => { app.channel('testing').join(c1) app.service('test').registerPublisher('created', () => app.channel('testing')) app.once('publish', (event: string, channel: Channel, hook: HookContext) => { try { assert.strictEqual(event, 'created') assert.strictEqual(hook.path, 'test') assert.deepStrictEqual(hook.result, data) assert.deepStrictEqual(channel.connections, [c1]) done() } catch (error: any) { done(error) } }) app.service('test').create(data).catch(done) }) it('app and global level dispatching and precedence', (done) => { app.channel('testing').join(c1) app.channel('other').join(c2) app.registerPublisher('created', () => app.channel('testing')) app.registerPublisher(() => app.channel('other')) app.once('publish', (_event: string, channel: Channel) => { assert.ok(channel.connections.indexOf(c1) !== -1) done() }) app.service('test').create(data).catch(done) }) it('promise event dispatching', (done) => { app.channel('testing').join(c1) app.channel('othertest').join(c2) app .service('test') .registerPublisher( 'created', () => new Promise((resolve) => setTimeout(() => resolve(app.channel('testing')), 50)) ) app .service('test') .registerPublisher( 'created', () => new Promise((resolve) => setTimeout(() => resolve(app.channel('testing', 'othertest')), 100)) ) app.once('publish', (_event: string, channel: Channel, hook: HookContext) => { assert.deepStrictEqual(hook.result, data) assert.deepStrictEqual(channel.connections, [c1, c2]) done() }) app.service('test').create(data).catch(done) }) it('custom event dispatching', (done) => { const eventData = { testing: true } app.channel('testing').join(c1) app.channel('othertest').join(c2) app.service('test').registerPublisher('foo', () => app.channel('testing')) app.once('publish', (event: string, channel: Channel, hook: HookContext) => { assert.strictEqual(event, 'foo') assert.deepStrictEqual(hook, { app, path: 'test', service: app.service('test'), result: eventData }) assert.deepStrictEqual(channel.connections, [c1]) done() }) app.service('test').emit('foo', eventData) }) it('does not sent `dispatch` event if there are no dispatchers', (done) => { app.once('publish', () => done(new Error('Should never get here'))) process.once('unhandledRejection', (error) => done(error)) app .service('test') .create(data) .then(() => done()) .catch(done) }) it('does not send `dispatch` event if there are no connections', (done) => { app.service('test').registerPublisher('created', () => app.channel('dummy')) app.once('publish', () => done(new Error('Should never get here'))) app .service('test') .create(data) .then(() => done()) .catch(done) }) it('dispatcher returning an array of channels', (done) => { app.channel('testing').join(c1) app.channel('othertest').join(c2) app .service('test') .registerPublisher('created', () => [app.channel('testing'), app.channel('othertest')]) app.once('publish', (_event: string, channel: Channel, hook: HookContext) => { assert.deepStrictEqual(hook.result, data) assert.deepStrictEqual(channel.connections, [c1, c2]) done() }) app.service('test').create(data).catch(done) }) it('dispatcher can send data', (done) => { const c1data = { channel: 'testing' } app.channel('testing').join(c1) app.channel('othertest').join(c2) app .service('test') .registerPublisher('created', () => [app.channel('testing').send(c1data), app.channel('othertest')]) app.once('publish', (_event: string, channel: CombinedChannel, hook: HookContext) => { assert.deepStrictEqual(hook.result, data) assert.deepStrictEqual(channel.dataFor(c1), c1data) assert.ok(channel.dataFor(c2) === null) assert.deepStrictEqual(channel.connections, [c1, c2]) done() }) app.service('test').create(data).catch(done) }) it('publisher precedence and preventing publishing', (done) => { app.channel('test').join(c1) app.registerPublisher(() => app.channel('test')) app.service('test').registerPublisher('created', (): null => null) app.once('publish', () => done(new Error('Should never get here'))) app .service('test') .create(data) .then(() => done()) .catch(done) }) it('data of first channel has precedence', (done) => { const sendData = { test: true } app.channel('testing').join(c1) app.channel('othertest').join(c1) app.service('test').registerPublisher('created', () => { return [app.channel('testing'), app.channel('othertest').send(sendData)] }) app.once('publish', (_event: string, channel: CombinedChannel) => { assert.strictEqual(channel.dataFor(c1), null) assert.deepStrictEqual(channel.connections, [c1]) done() }) app.service('test').create(data).catch(done) }) }) }) ================================================ FILE: packages/transport-commons/test/channels/index.test.ts ================================================ /* eslint-disable @typescript-eslint/no-empty-function */ import assert from 'assert' import { feathers } from '@feathersjs/feathers' import { channels, keys } from '../../src/channels' describe('feathers-channels', () => { it('has app.channel', () => { const app = feathers().configure(channels()) assert.strictEqual(typeof app.channel, 'function') assert.strictEqual(typeof (app as any)[keys.CHANNELS], 'object') assert.strictEqual(app.channels.length, 0) }) it('throws an error when called with nothing', () => { const app = feathers().configure(channels()) try { app.channel() assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, 'app.channel needs at least one channel name') } }) it('configuring twice does nothing', () => { feathers().configure(channels()).configure(channels()) }) it('does not add things to the service if `dispatch` exists', () => { const app = feathers() .configure(channels()) .use('/test', { async setup() {}, publish() { return this } } as any) const service: any = app.service('test') assert.ok(!service[keys.PUBLISHERS]) }) }) ================================================ FILE: packages/transport-commons/test/client.test.ts ================================================ /* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-empty-function */ import assert from 'assert' import { EventEmitter } from 'events' import { CustomMethods } from '@feathersjs/feathers' import { NotAuthenticated } from '@feathersjs/errors' import { Service, SocketService } from '../src/client' declare type DummyCallback = (err: any, data?: any) => void describe('client', () => { let connection: any let testData: any let service: SocketService & CustomMethods<{ customMethod: any }> & EventEmitter beforeEach(() => { connection = new EventEmitter() testData = { data: 'testing ' } service = new Service({ events: ['created'], name: 'todos', method: 'emit', connection }) as any }) it('sets `events` property on service', () => { assert.ok(service.events) }) it('throws for .get, .update, .patch and .remove with undefined or empty string id', async () => { try { await service.get(undefined) assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, 'id for .get is required') } try { await service.get('') assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, 'id for .get is required') } try { await service.update(undefined, testData) assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, 'id for .update is required') } try { await service.update('', testData) assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, 'id for .update is required') } try { await service.patch(undefined, testData) assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, 'id for .patch is required') } try { await service.patch('', testData) assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, 'id for .patch is required') } try { await service.remove(undefined) assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, 'id for .remove is required') } try { await service.remove('') assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, 'id for .remove is required') } }) it('throws an error when the emitter does not have the method', () => { const clientService = new Service({ name: 'todos', method: 'emit', connection: {} }) as Service & EventEmitter try { clientService.eventNames() assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, "Can not call 'eventNames' on the client service connection") } try { clientService.on('test', () => {}) assert.ok(false, 'Should never get here') } catch (e: any) { assert.strictEqual(e.message, "Can not call 'on' on the client service connection") } }) it('allows chaining event listeners', () => { assert.strictEqual( service, service.on('thing', () => {}) ) assert.strictEqual( service, service.once('other thing', () => {}) ) }) it('initializes and emits namespaced events', (done) => { connection.once('todos test', (data: any) => { assert.deepStrictEqual(data, testData) done() }) service.emit('test', testData) }) it('has other emitter methods', () => { assert.ok(service.eventNames()) }) it('can receive pathed events', (done) => { service.once('thing', (data) => { assert.deepStrictEqual(data, testData) done() }) connection.emit('todos thing', testData) }) it('sends all service and custom methods with acknowledgement', async () => { const idCb = (_path: any, id: any, _params: any, callback: DummyCallback) => callback(null, { id }) const idDataCb = (_path: any, _id: any, data: any, _params: any, callback: DummyCallback) => callback(null, data) const dataCb = (_path: any, data: any, _params: any, callback: DummyCallback) => { data.created = true callback(null, data) } connection.once('create', dataCb) service.methods('customMethod') let res = await service.create(testData) assert.ok(res.created) connection.once('get', idCb) res = await service.get(1) assert.deepStrictEqual(res, { id: 1 }) connection.once('remove', idCb) res = await service.remove(12) assert.deepStrictEqual(res, { id: 12 }) connection.once('update', idDataCb) res = await service.update(12, testData) assert.deepStrictEqual(res, testData) connection.once('patch', idDataCb) res = await service.patch(12, testData) assert.deepStrictEqual(res, testData) connection.once('customMethod', dataCb) res = await service.customMethod({ message: 'test' }) assert.deepStrictEqual(res, { created: true, message: 'test' }) connection.once('find', (_path: any, params: any, callback: DummyCallback) => callback(null, { params })) res = await service.find({ query: { test: true } }) assert.deepStrictEqual(res, { params: { test: true } }) }) it('replace placeholder in service paths', async () => { service = new Service({ events: ['created'], name: ':slug/todos', method: 'emit', connection }) as any const idCb = (path: any, _id: any, _params: any, callback: DummyCallback) => callback(null, path) const idDataCb = (path: any, _id: any, _data: any, _params: any, callback: DummyCallback) => callback(null, path) const dataCb = (path: any, _data: any, _params: any, callback: DummyCallback) => { callback(null, path) } connection.once('create', dataCb) service.methods('customMethod') let res = await service.create(testData, { route: { slug: 'mySlug' } }) assert.strictEqual(res, 'mySlug/todos') connection.once('get', idCb) res = await service.get(1, { route: { slug: 'mySlug' } }) assert.strictEqual(res, 'mySlug/todos') connection.once('remove', idCb) res = await service.remove(12, { route: { slug: 'mySlug' } }) assert.strictEqual(res, 'mySlug/todos') connection.once('update', idDataCb) res = await service.update(12, testData, { route: { slug: 'mySlug' } }) assert.strictEqual(res, 'mySlug/todos') connection.once('patch', idDataCb) res = await service.patch(12, testData, { route: { slug: 'mySlug' } }) assert.strictEqual(res, 'mySlug/todos') connection.once('customMethod', dataCb) res = await service.customMethod( { message: 'test' }, { route: { slug: 'mySlug' } } ) assert.strictEqual(res, 'mySlug/todos') connection.once('find', (path: any, _params: any, callback: DummyCallback) => callback(null, path)) res = await service.find({ query: { test: true }, route: { slug: 'mySlug' } }) assert.strictEqual(res, 'mySlug/todos') }) it('converts to feathers-errors (#19)', async () => { connection.once('create', (_path: any, _data: any, _params: any, callback: DummyCallback) => callback(new NotAuthenticated('Test', { hi: 'me' }).toJSON()) ) await assert.rejects(() => service.create(testData), { name: 'NotAuthenticated', message: 'Test', code: 401, data: { hi: 'me' } }) }) it('converts other errors (#19)', async () => { connection.once('create', (_path: string, _data: any, _params: any, callback: (x: string) => void) => { callback('Something went wrong') // eslint-disable-line }) await assert.rejects(() => service.create(testData), { message: 'Something went wrong' }) }) it('has all EventEmitter methods', (done) => { const testing = { hello: 'world' } const callback = (data: any) => { assert.deepStrictEqual(data, testing) assert.strictEqual(service.listenerCount('test'), 1) service.removeListener('test', callback) assert.strictEqual(service.listenerCount('test'), 0) done() } service.addListener('test', callback) connection.emit('todos test', testing) }) it('properly handles on/off methods', (done) => { const testing = { hello: 'world' } const callback1 = (data: any) => { assert.deepStrictEqual(data, testing) assert.strictEqual(service.listenerCount('test'), 3) service.off('test', callback1) assert.strictEqual(service.listenerCount('test'), 2) service.removeAllListeners('test') assert.strictEqual(service.listenerCount('test'), 0) done() } const callback2 = () => { // noop } service.on('test', callback1) service.on('test', callback2) service.on('test', callback2) connection.emit('todos test', testing) }) it('forwards namespaced call to .off, returns service instance', () => { // Use it's own connection and service so off method gets detected const conn = new EventEmitter() // @ts-ignore conn.off = function (name) { assert.strictEqual(name, 'todos test') return this } const client = new Service({ name: 'todos', method: 'emit', connection: conn }) assert.strictEqual(client.off('test'), client) }) it("handles socket.io's weird behavior with ackTimeout", async () => { connection.flags = { timeout: 10000 } const dataCb = ( _path: any, data: any, _params: any, callback: (timeoutError: any, err: any, data?: any) => void ) => { data.created = true callback(null, null, data) } const errorCb = ( _path: any, _data: any, _params: any, callback: (timeoutError: any, err: any, _data?: any) => void ) => { callback(null, new Error(), null) } const timeoutErrorCb = ( _path: any, _data: any, _params: any, callback: (timeoutError: any, err: any, _data?: any) => void ) => { callback(new Error(), null, null) } connection.once('create', dataCb) let res = await service.create(testData) assert.ok(res.created) connection.once('create', errorCb) try { res = await service.create(testData) assert.fail('should not reach') } catch (e) { assert.ok(e instanceof Error) } connection.once('create', timeoutErrorCb) try { res = await service.create(testData) assert.fail('should not reach') } catch (e) { assert.ok(e instanceof Error) } }) }) ================================================ FILE: packages/transport-commons/test/http.test.ts ================================================ import assert from 'assert' import { HookContext } from '@feathersjs/feathers' import { http } from '../src' describe('@feathersjs/transport-commons HTTP helpers', () => { it('getResponse body', () => { const plainData = { message: 'hi' } const dispatch = { message: 'from dispatch' } const resultContext = { result: plainData } const dispatchContext = { dispatch } assert.strictEqual(http.getResponse(resultContext as HookContext).body, plainData) assert.strictEqual(http.getResponse(dispatchContext as HookContext).body, dispatch) }) it('getResponse status', () => { const statusContext = { http: { status: 202 } } const createContext = { method: 'create', result: {} } const createEmptyContext = { method: 'create' } const redirectContext = { http: { location: '/' } } const redirectCreateContext = { method: 'create', http: { location: '/' } } assert.strictEqual(http.getResponse(statusContext as HookContext).status, 202) assert.strictEqual(http.getResponse(createContext as HookContext).status, http.statusCodes.created) assert.strictEqual(http.getResponse(redirectContext as HookContext).status, http.statusCodes.seeOther) assert.strictEqual( http.getResponse(redirectCreateContext as HookContext).status, http.statusCodes.seeOther ) assert.strictEqual(http.getResponse({} as HookContext).status, http.statusCodes.noContent) assert.strictEqual(http.getResponse(createEmptyContext as HookContext).status, http.statusCodes.noContent) assert.strictEqual(http.getResponse({ result: true } as HookContext).status, http.statusCodes.success) }) it('getResponse headers', () => { const headers = { key: 'value' } as any const headersContext = { http: { headers } } const locationContext = { http: { location: '/' } } assert.deepStrictEqual(http.getResponse({} as HookContext).headers, {}) assert.deepStrictEqual(http.getResponse({ http: {} } as HookContext).headers, {}) assert.strictEqual(http.getResponse(headersContext as HookContext).headers, headers) assert.deepStrictEqual(http.getResponse(locationContext as HookContext).headers, { Location: '/' }) }) it('getServiceMethod', () => { assert.strictEqual(http.getServiceMethod('GET', 2), 'get') assert.strictEqual(http.getServiceMethod('GET', null), 'find') assert.strictEqual(http.getServiceMethod('PoST', null), 'create') assert.strictEqual(http.getServiceMethod('PoST', null, 'customMethod'), 'customMethod') assert.strictEqual(http.getServiceMethod('delete', null), 'remove') assert.throws(() => http.getServiceMethod('nonsense', null)) }) }) ================================================ FILE: packages/transport-commons/test/routing/index.test.ts ================================================ /* eslint-disable @typescript-eslint/ban-ts-comment */ import assert from 'assert' import { feathers, Application } from '@feathersjs/feathers' import { routing } from '../../src/routing' describe('app.routes', () => { let app: Application beforeEach(() => { app = feathers().configure(routing()) app.use('/my/service', { get(id: string | number) { return Promise.resolve({ id }) } }) }) it('does nothing when configured twice', () => { feathers().configure(routing()).configure(routing()) }) it('has app.lookup and app.routes', () => { assert.strictEqual(typeof app.lookup, 'function') assert.ok(app.routes) }) it('returns null when nothing is found', () => { const result = app.lookup('me/service') assert.strictEqual(result, null) }) it('returns null for invalid service path', () => { assert.strictEqual(app.lookup(null), null) // @ts-ignore assert.strictEqual(app.lookup({}), null) }) it('can look up and strips slashes', () => { const result = app.lookup('my/service') assert.strictEqual(result.service, app.service('/my/service/')) }) it('can look up case insensitive', () => { app.routes.caseSensitive = false const result = app.lookup('/My/ServicE') assert.strictEqual(result.service, app.service('my/service')) }) it('can look up with id', () => { const result = app.lookup('/my/service/1234') assert.strictEqual(result.service, app.service('/my/service')) assert.deepStrictEqual(result.params, { __id: '1234' }) }) it('can look up with params, id and special characters', () => { const path = '/test/:first/my/:second' app.use(path, { async get(id: string | number) { return { id } } }) const result = app.lookup('/test/me/my/::special/testing') assert.strictEqual(result.service, app.service(path)) assert.deepStrictEqual(result.params, { __id: 'testing', first: 'me', second: '::special' }) }) it('can register routes with preset params', () => { app.routes.insert('/my/service/:__id/preset', { service: app.service('/my/service'), params: { preset: true } }) const result = app.lookup('/my/service/1234/preset') assert.strictEqual(result.service, app.service('/my/service')) assert.deepStrictEqual(result.params, { preset: true, __id: '1234' }) }) it('can pass route params during a service registration', () => { app.use( '/other/service', { async get(id: any) { return id } }, { routeParams: { used: true } } ) const result = app.lookup('/other/service/1234') assert.strictEqual(result.service, app.service('/other/service')) assert.deepStrictEqual(result.params, { used: true, __id: '1234' }) }) it('can unregister a service (#2035)', async () => { const result = app.lookup('my/service') assert.strictEqual(result.service, app.service('/my/service/')) await app.unuse('/my/service') assert.strictEqual(app.lookup('my/service'), null) }) }) ================================================ FILE: packages/transport-commons/test/routing/router.test.ts ================================================ import assert from 'assert' import { Router } from '../../src/routing' describe('router', () => { it('can lookup and insert a simple path and returns null for invalid path', () => { const r = new Router() r.insert('/hello/there/you', 'test') const result = r.lookup('hello/there/you/') assert.deepStrictEqual(result, { params: {}, data: 'test' }) assert.strictEqual(r.lookup('not/there'), null) assert.strictEqual(r.lookup('not-me'), null) }) it('can insert data at the root', () => { const r = new Router() r.insert('', 'hi') const result = r.lookup('/') assert.deepStrictEqual(result, { params: {}, data: 'hi' }) }) it('can insert with placeholder and has proper specificity', () => { const r = new Router() r.insert('/hello/:id', 'one') r.insert('/hello/:id/you', 'two') r.insert('/hello/:id/:other', 'three') const first = r.lookup('hello/there/') assert.throws(() => r.insert('/hello/:id/you', 'two'), { message: 'Path hello/:id/you already exists' }) assert.deepStrictEqual(first, { params: { id: 'there' }, data: 'one' }) const second = r.lookup('hello/yes/you') assert.deepStrictEqual(second, { params: { id: 'yes' }, data: 'two' }) const third = r.lookup('hello/yes/they') assert.deepStrictEqual(third, { params: { id: 'yes', other: 'they' }, data: 'three' }) assert.strictEqual(r.lookup('hello/yes/they/here'), null) }) it('works with different placeholders in different paths (#2327)', () => { const r = new Router() r.insert('/hello/:id', 'one') r.insert('/hello/:test/you', 'two') r.insert('/hello/:test/:two/hi/:three', 'three') r.insert('/hello/:test/:two/hi', 'four') assert.deepStrictEqual(r.lookup('/hello/there'), { params: { id: 'there' }, data: 'one' }) assert.deepStrictEqual(r.lookup('/hello/there/you'), { params: { test: 'there' }, data: 'two' }) assert.strictEqual(r.lookup('/hello/there/bla'), null) assert.deepStrictEqual(r.lookup('/hello/there/maybe/hi'), { params: { test: 'there', two: 'maybe' }, data: 'four' }) assert.deepStrictEqual(r.lookup('/hello/there/maybe/hi/test'), { params: { three: 'test', two: 'maybe', test: 'there' }, data: 'three' }) }) it('can remove paths (#2035)', () => { const r = new Router() r.insert('/hello/:id', 'one') r.insert('/hello/:test/you', 'two') r.insert('/hello/here/thing', 'else') assert.deepStrictEqual(r.lookup('hello/there'), { params: { id: 'there' }, data: 'one' }) r.remove('/hello/:id') assert.deepStrictEqual(r.lookup('hello/here/you'), { params: { test: 'here' }, data: 'two' }) assert.deepStrictEqual(r.lookup('hello/here/thing'), { params: {}, data: 'else' }) assert.strictEqual(r.lookup('hello/there'), null) r.remove('/hello/:test/you') assert.deepStrictEqual(r.lookup('hello/here/you'), null) assert.deepStrictEqual(r.lookup('hello/here/thing'), { params: {}, data: 'else' }) r.remove('/hello/here/thing') assert.ok(!r.root.hasChildren) }) it('re-initialize a service with children. (#3432)', () => { const r = new Router() r.insert('/hello', 'one') r.insert('/hello/world', 'else') assert.deepStrictEqual(r.lookup('hello'), { params: {}, data: 'one' }) r.remove('/hello') assert.deepStrictEqual(r.lookup('hello/world'), { params: {}, data: 'else' }) r.insert('/hello', 'two') assert.deepStrictEqual(r.lookup('hello'), { params: {}, data: 'two' }) assert.deepStrictEqual(r.lookup('hello/world'), { params: {}, data: 'else' }) }) }) ================================================ FILE: packages/transport-commons/test/socket/index.test.ts ================================================ import assert from 'assert' import { EventEmitter } from 'events' import { feathers, Application, Id, Params } from '@feathersjs/feathers' import { socket as commons, SocketOptions } from '../../src/socket' class DummyService { async get(id: Id, params: Params) { return { id, params } } async create(data: any, params: Params) { return { ...data, params } } async custom(data: any, params: Params) { return { ...data, params, message: 'From custom method' } } } describe('@feathersjs/transport-commons', () => { let provider: EventEmitter let options: SocketOptions let app: Application let connection: any beforeEach(() => { connection = { testing: true } provider = new EventEmitter() options = { emit: 'emit', done: Promise.resolve(provider), socketMap: new WeakMap(), getParams() { return connection } } app = feathers() .configure(commons(options)) .use('/myservice', new DummyService(), { methods: ['get', 'create', 'custom'] }) return options.done }) it('`connection` event', (done) => { const socket = new EventEmitter() app.once('connection', (data) => { assert.strictEqual(connection, data) done() }) provider.emit('connection', socket) }) describe('method name based socket events', () => { it('.get without params', (done) => { const socket = new EventEmitter() provider.emit('connection', socket) socket.emit('get', 'myservice', 10, (error: any, result: any) => { try { assert.ok(!error) assert.deepStrictEqual(result, { id: 10, params: Object.assign( { query: {}, route: {}, connection }, connection ) }) done() } catch (e: any) { done(e) } }) }) it('method with invalid service name and arguments', (done) => { const socket = new EventEmitter() provider.emit('connection', socket) socket.emit('get', null, (error: any) => { assert.strictEqual(error.name, 'NotFound') assert.strictEqual(error.message, 'Invalid service path') done() }) }) it('method with implicit toString errors properly', (done) => { const socket = new EventEmitter() provider.emit('connection', socket) socket.emit('get', { toString: '' }, (error: any) => { assert.strictEqual(error.name, 'NotFound') assert.strictEqual(error.message, 'Invalid service path') done() }) }) it('.create with params', (done) => { const socket = new EventEmitter() const data = { test: 'data' } provider.emit('connection', socket) socket.emit( 'create', 'myservice', data, { fromQuery: true }, (error: any, result: any) => { try { const params = Object.assign( { query: { fromQuery: true }, route: {}, connection }, connection ) assert.ok(!error) assert.deepStrictEqual(result, Object.assign({ params }, data)) done() } catch (e: any) { done(e) } } ) }) it('custom method with params', (done) => { const socket = new EventEmitter() const data = { test: 'data' } provider.emit('connection', socket) socket.emit( 'custom', 'myservice', data, { fromQuery: true }, (error: any, result: any) => { try { const params = Object.assign( { query: { fromQuery: true }, route: {}, connection }, connection ) assert.ok(!error) assert.deepStrictEqual(result, { ...data, params, message: 'From custom method' }) done() } catch (e: any) { done(e) } } ) }) }) }) ================================================ FILE: packages/transport-commons/test/socket/utils.test.ts ================================================ import assert from 'assert' import { EventEmitter } from 'events' import { feathers, Application, Params, RealTimeConnection } from '@feathersjs/feathers' import { NotAuthenticated } from '@feathersjs/errors' import isPlainObject from 'lodash/isPlainObject' import { routing } from '../../src/routing' import { normalizeError, getDispatcher, runMethod } from '../../src/socket/utils' describe('socket commons utils', () => { describe('.normalizeError', () => { it('simple error normalization', () => { const message = 'Something went wrong' const e = new Error(message) assert.deepStrictEqual(normalizeError(e), { message, stack: e.stack.toString() }) }) it('calls .toJSON', () => { const json = { message: 'toJSON called' } assert.deepStrictEqual( normalizeError({ toJSON() { return json } }), json ) }) it('removes `hook` property', () => { const e = { hook: true } assert.deepStrictEqual(normalizeError(e), {}) assert.ok(e.hook, 'Does not mutate the original object') }) it('hides stack in production', () => { const oldEnv = process.env.NODE_ENV process.env.NODE_ENV = 'production' const message = 'Something went wrong' const e = new Error(message) const normalized = normalizeError(e) assert.strictEqual(normalized.message, message) assert.ok(!normalized.stack) process.env.NODE_ENV = oldEnv }) }) describe('.getDispatcher', () => { it('returns a dispatcher function', () => assert.strictEqual(typeof getDispatcher('test', new WeakMap()), 'function')) it('works with backwards compatible socketKey', (done) => { const socketKey = Symbol('@feathersjs/test') const dispatcher = getDispatcher('emit', undefined, socketKey) const socket = new EventEmitter() const connection = { [socketKey]: socket } const channel: any = { connections: [connection], dataFor(): null { return null } } socket.once('testing', (data) => { assert.strictEqual(data, 'hi') done() }) dispatcher('testing', channel, { result: 'hi' } as any) }) describe('dispatcher logic', () => { let dispatcher: any let dummySocket: EventEmitter let dummyHook: any let dummyChannel: any let dummyConnection: RealTimeConnection let dummyMap: WeakMap beforeEach(() => { dummyConnection = {} dummyMap = new WeakMap() dispatcher = getDispatcher('emit', dummyMap) dummySocket = new EventEmitter() dummyHook = { result: 'hi' } dummyChannel = { connections: [dummyConnection], dataFor(): null { return null } } dummyMap.set(dummyConnection, dummySocket) }) it('dispatches a basic event', (done) => { dummySocket.once('testing', (data) => { assert.strictEqual(data, 'hi') done() }) dispatcher('testing', dummyChannel, dummyHook) }) it('dispatches event on a hooks path event', (done) => { dummyHook.path = 'myservice' dummySocket.once('myservice testing', (data) => { assert.strictEqual(data, 'hi') done() }) dispatcher('testing', dummyChannel, dummyHook) }) it('dispatches `hook.dispatch` instead', (done) => { const message = 'hi from dispatch' dummyHook.dispatch = message dummySocket.once('testing', (data) => { assert.strictEqual(data, message) done() }) dispatcher('testing', dummyChannel, dummyHook) }) it('does nothing if there is no socket', () => { dummyChannel.connections[0].test = null dispatcher('testing', dummyChannel, dummyHook) }) it('dispatches arrays properly hook events', (done) => { const data1 = { message: 'First message' } const data2 = { message: 'Second message' } dummyHook.result = [data1, data2] dummySocket.once('testing', (data) => { assert.deepStrictEqual(data, data1) dummySocket.once('testing', (result) => { assert.deepStrictEqual(result, data2) done() }) }) dispatcher('testing', dummyChannel, dummyHook, data1) dispatcher('testing', dummyChannel, dummyHook, data2) }) it('dispatches dispatch arrays properly', (done) => { const data1 = { message: 'First message' } const data2 = { message: 'Second message' } dummyHook.result = [] dummyHook.dispatch = [data1, data2] dummySocket.once('testing', (data) => { assert.deepStrictEqual(data, data1) dummySocket.once('testing', (result) => { assert.deepStrictEqual(result, data2) done() }) }) dispatcher('testing', dummyChannel, dummyHook, data1) dispatcher('testing', dummyChannel, dummyHook, data2) }) it('dispatches arrays properly for custom events', (done) => { const result = [{ message: 'First' }, { message: 'Second' }] dummyHook.result = result dummySocket.once('otherEvent', (data) => { assert.deepStrictEqual(data, result) done() }) dispatcher('otherEvent', dummyChannel, dummyHook, result) }) }) }) describe('.runMethod', () => { let app: Application beforeEach(() => { app = feathers().configure(routing()) app.use('/myservice', { async get(id: number | string, params: Params) { if (params.query.error) { throw new NotAuthenticated('None shall pass') } if (!isPlainObject(params.query)) { throw new Error('Query is not a plain object') } return { id } } }) }) describe('running methods', () => { it('basic', (done) => { const callback = (error: any, result: any) => { if (error) { return done(error) } assert.deepStrictEqual(result, { id: 10 }) done() } runMethod(app, {}, 'myservice', 'get', [10, {}, callback]) }) it('queries are always plain objects', (done) => { const callback = (error: any, result: any) => { if (error) { return done(error) } assert.deepStrictEqual(result, { id: 10 }) done() } runMethod(app, {}, 'myservice', 'get', [ 10, { __proto__: [] }, callback ]) }) it('merges params with connection and passes connection', (done) => { const connection = { testing: true } const callback = (error: any, result: any) => { if (error) { return done(error) } assert.deepStrictEqual(result, { id: 10, params: { connection, query: {}, route: {}, testing: true } }) done() } app.use('/otherservice', { get(id, params) { return Promise.resolve({ id, params }) } }) runMethod(app, connection, 'otherservice', 'get', [10, {}, callback]) }) it('with params missing', (done) => { const callback = (error: any, result: any) => { if (error) { return done(error) } assert.deepStrictEqual(result, { id: 10 }) done() } runMethod(app, {}, 'myservice', 'get', [10, callback]) }) it('with params but missing callback', (done) => { app.use('/otherservice', { get(id: number | string) { assert.strictEqual(id, 'dishes') return Promise.resolve({ id }).then((res) => { done() return res }) } }) runMethod(app, {}, 'otherservice', 'get', ['dishes', {}]) }) it('with params and callback missing', (done) => { app.use('/otherservice', { get(id: number | string) { assert.strictEqual(id, 'laundry') return Promise.resolve({ id }).then((res) => { done() return res }) } }) runMethod(app, {}, 'otherservice', 'get', ['laundry']) }) }) it('throws NotFound for invalid service', (done) => { const callback = (error: any) => { try { assert.deepStrictEqual(error, { name: 'NotFound', message: "Service 'ohmyservice' not found", code: 404, className: 'not-found' }) done() } catch (e: any) { done(e) } } runMethod(app, {}, 'ohmyservice', 'get', [10, callback]) }) it('throws MethodNotAllowed undefined method', (done) => { const callback = (error: any) => { try { assert.deepStrictEqual(error, { name: 'MethodNotAllowed', message: "Method 'create' not allowed on service 'myservice'", code: 405, className: 'method-not-allowed' }) done() } catch (e: any) { done(e) } } runMethod(app, {}, 'myservice', 'create', [{}, callback]) }) it('throws MethodNotAllowed for invalid service method', (done) => { const callback = (error: any) => { try { assert.deepStrictEqual(error, { name: 'MethodNotAllowed', message: "Method 'blabla' not allowed on service 'myservice'", code: 405, className: 'method-not-allowed' }) done() } catch (e: any) { done(e) } } runMethod(app, {}, 'myservice', 'blabla', [{}, callback]) }) it('method error calls back with normalized error', (done) => { const callback = (error: any) => { try { assert.deepStrictEqual(error, { name: 'NotAuthenticated', message: 'None shall pass', code: 401, className: 'not-authenticated' }) done() } catch (e: any) { done(e) } } runMethod(app, {}, 'myservice', 'get', [42, { error: true }, callback]) }) }) }) ================================================ FILE: packages/transport-commons/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: packages/typebox/CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. ## [5.0.42](https://github.com/feathersjs/feathers/compare/v5.0.41...v5.0.42) (2026-03-04) ### Bug Fixes - Update dependencies ([#3666](https://github.com/feathersjs/feathers/issues/3666)) ([477bf45](https://github.com/feathersjs/feathers/commit/477bf45f9c9dbde77a14a07828aa02300de23ae7)) ## [5.0.41](https://github.com/feathersjs/feathers/compare/v5.0.40...v5.0.41) (2026-02-19) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.40](https://github.com/feathersjs/feathers/compare/v5.0.39...v5.0.40) (2026-02-03) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.39](https://github.com/feathersjs/feathers/compare/v5.0.38...v5.0.39) (2026-01-31) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.38](https://github.com/feathersjs/feathers/compare/v5.0.37...v5.0.38) (2026-01-31) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.37](https://github.com/feathersjs/feathers/compare/v5.0.36...v5.0.37) (2025-11-10) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.36](https://github.com/feathersjs/feathers/compare/v5.0.35...v5.0.36) (2025-11-08) ### Bug Fixes - **dependencies:** Update all dependencies ([#3625](https://github.com/feathersjs/feathers/issues/3625)) ([2698e4e](https://github.com/feathersjs/feathers/commit/2698e4e2996fbf479d82435938d907bc3d5b583a)) ## [5.0.35](https://github.com/feathersjs/feathers/compare/v5.0.34...v5.0.35) (2025-09-09) ### Bug Fixes - Update all dependencies ([#3613](https://github.com/feathersjs/feathers/issues/3613)) ([5136bbd](https://github.com/feathersjs/feathers/commit/5136bbd2e2eeb4e6579e07c9e914006629542363)) ## [5.0.34](https://github.com/feathersjs/feathers/compare/v5.0.33...v5.0.34) (2025-05-03) ### Bug Fixes - Update dependencies ([#3584](https://github.com/feathersjs/feathers/issues/3584)) ([119fa4e](https://github.com/feathersjs/feathers/commit/119fa4e1ade8b0078aa235083d566e2538b3a084)) ## [5.0.33](https://github.com/feathersjs/feathers/compare/v5.0.32...v5.0.33) (2025-02-24) ### Bug Fixes - **dependencies:** Update dependencies ([#3571](https://github.com/feathersjs/feathers/issues/3571)) ([ad611cb](https://github.com/feathersjs/feathers/commit/ad611cb6ffb1dc31d603ba5817331318c5a23217)) ## [5.0.32](https://github.com/feathersjs/feathers/compare/v5.0.31...v5.0.32) (2025-02-01) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.31](https://github.com/feathersjs/feathers/compare/v5.0.30...v5.0.31) (2024-10-31) ### Bug Fixes - **dependencies:** Update all dependencies ([#3545](https://github.com/feathersjs/feathers/issues/3545)) ([221b92b](https://github.com/feathersjs/feathers/commit/221b92bb0ee5d54fb1036742968797cb02e56da2)) ## [5.0.30](https://github.com/feathersjs/feathers/compare/v5.0.29...v5.0.30) (2024-09-02) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.29](https://github.com/feathersjs/feathers/compare/v5.0.28...v5.0.29) (2024-07-10) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.28](https://github.com/feathersjs/feathers/compare/v5.0.27...v5.0.28) (2024-07-10) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.27](https://github.com/feathersjs/feathers/compare/v5.0.26...v5.0.27) (2024-06-18) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.26](https://github.com/feathersjs/feathers/compare/v5.0.25...v5.0.26) (2024-06-09) ### Bug Fixes - **typebox:** Add TRecord to getValidator arg1 type ([#3488](https://github.com/feathersjs/feathers/issues/3488)) ([ffbcc0a](https://github.com/feathersjs/feathers/commit/ffbcc0ad0c361f77171f9ad6224006727644433a)) ## [5.0.25](https://github.com/feathersjs/feathers/compare/v5.0.24...v5.0.25) (2024-05-03) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25) ### Bug Fixes - **core:** Update to latest feathersjs/hooks ([#3434](https://github.com/feathersjs/feathers/issues/3434)) ([1499ccc](https://github.com/feathersjs/feathers/commit/1499ccc41fb3ebba97b2c84e0cb19bc48ad3c651)) ## [5.0.22](https://github.com/feathersjs/feathers/compare/v5.0.21...v5.0.22) (2024-02-15) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.21](https://github.com/feathersjs/feathers/compare/v5.0.20...v5.0.21) (2024-01-25) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.20](https://github.com/feathersjs/feathers/compare/v5.0.19...v5.0.20) (2024-01-24) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.19](https://github.com/feathersjs/feathers/compare/v5.0.18...v5.0.19) (2024-01-23) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.18](https://github.com/feathersjs/feathers/compare/v5.0.17...v5.0.18) (2024-01-22) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.17](https://github.com/feathersjs/feathers/compare/v5.0.16...v5.0.17) (2024-01-22) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.16](https://github.com/feathersjs/feathers/compare/v5.0.15...v5.0.16) (2024-01-22) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.15](https://github.com/feathersjs/feathers/compare/v5.0.14...v5.0.15) (2024-01-22) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.14](https://github.com/feathersjs/feathers/compare/v5.0.13...v5.0.14) (2024-01-05) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.13](https://github.com/feathersjs/feathers/compare/v5.0.12...v5.0.13) (2023-12-29) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.12](https://github.com/feathersjs/feathers/compare/v5.0.11...v5.0.12) (2023-11-28) ### Bug Fixes - **schema:** Allow $in and $nin queries to work for arrays ([#3352](https://github.com/feathersjs/feathers/issues/3352)) ([677c214](https://github.com/feathersjs/feathers/commit/677c214a353a7f9a1f90649b9bbec4d0d6517a6f)) ## [5.0.11](https://github.com/feathersjs/feathers/compare/v5.0.10...v5.0.11) (2023-10-11) ### Bug Fixes - **knex:** Update all dependencies and Knex peer ([#3308](https://github.com/feathersjs/feathers/issues/3308)) ([d2f9860](https://github.com/feathersjs/feathers/commit/d2f986036c4741cce2339d8abbcc6b2eb037a12a)) ## [5.0.10](https://github.com/feathersjs/feathers/compare/v5.0.9...v5.0.10) (2023-10-03) ### Bug Fixes - **typebox:** Allow default value in StringEnum ([#3281](https://github.com/feathersjs/feathers/issues/3281)) ([25af09a](https://github.com/feathersjs/feathers/commit/25af09ad065e72768bf88bc8b529b68f2ca4da17)) ## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27) ### Bug Fixes - **typebox:** allow TUnion inside getValidator ([#3262](https://github.com/feathersjs/feathers/issues/3262)) ([cf9df96](https://github.com/feathersjs/feathers/commit/cf9df96c1011fcf13e9c6d652b06036bb0aac1c3)) ## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15) **Note:** Version bump only for package @feathersjs/typebox ## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28) ### Bug Fixes - **typebox:** Revert to TypeBox 0.25 ([#3183](https://github.com/feathersjs/feathers/issues/3183)) ([cacedf5](https://github.com/feathersjs/feathers/commit/cacedf59e3d2df836777f0cd06ab1b2484ed87c5)) ## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12) ### Bug Fixes - Make sure all Readme files are up to date ([#3154](https://github.com/feathersjs/feathers/issues/3154)) ([a5f0b38](https://github.com/feathersjs/feathers/commit/a5f0b38bbf2a11486415a39533bcc6c67fb51e3e)) - **typebox:** Implement custom TypeBuilder for backwards compatibility ([#3150](https://github.com/feathersjs/feathers/issues/3150)) ([962bd87](https://github.com/feathersjs/feathers/commit/962bd87217212320b1a68f6556a16b8a6b8f757c)) ## [5.0.3](https://github.com/feathersjs/feathers/compare/v5.0.2...v5.0.3) (2023-04-05) ### Bug Fixes - **authentication:** Ensure authentication.entity configuration can be null ([#3136](https://github.com/feathersjs/feathers/issues/3136)) ([c47349b](https://github.com/feathersjs/feathers/commit/c47349b9dcf2067b7b572c5463b15b2a8fbda972)) - **dependencies:** Update all dependencies ([#3139](https://github.com/feathersjs/feathers/issues/3139)) ([f24276e](https://github.com/feathersjs/feathers/commit/f24276e9a909e2e58a0730c730258ce1f70f4028)) - **knex:** Get by id and transactions should work with params.knex ([#3146](https://github.com/feathersjs/feathers/issues/3146)) ([b172b5e](https://github.com/feathersjs/feathers/commit/b172b5ea9b461642874eb7d2ba01dc4cfc275155)) - **typebox:** Upgrade to TypeBox 0.26.0 ([#3113](https://github.com/feathersjs/feathers/issues/3113)) ([d1d9598](https://github.com/feathersjs/feathers/commit/d1d95984dd94d2b9305e7338421f84f9c4f733fd)) ## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) **Note:** Version bump only for package @feathersjs/typebox # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) **Note:** Version bump only for package @feathersjs/typebox # [5.0.0-pre.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17) ### Features - **schema:** Add schema helper for handling Object ids ([#3058](https://github.com/feathersjs/feathers/issues/3058)) ([1393bed](https://github.com/feathersjs/feathers/commit/1393bed81a9ee814de6aab0e537af83e667591a2)) # [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09) ### Bug Fixes - **typebox:** Allow nested or in and queries ([#3029](https://github.com/feathersjs/feathers/issues/3029)) ([39e0b78](https://github.com/feathersjs/feathers/commit/39e0b785238b809aa9b4dea9b95efc3c188c9baa)) # [5.0.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29) ### Bug Fixes - **configuration:** Add pool and connection object to SQL database default configuration ([#3023](https://github.com/feathersjs/feathers/issues/3023)) ([092c749](https://github.com/feathersjs/feathers/commit/092c749d43f7da4d019576d1210fe7d3719a44a2)) - **schema:** Fix TypeBox extension value query syntax inference ([#3010](https://github.com/feathersjs/feathers/issues/3010)) ([f1c7a76](https://github.com/feathersjs/feathers/commit/f1c7a76586bbb8aed66ef866c3dcd666d79f3a24)) - Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0)) # [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12) ### Features - **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17)) - **schema:** Allow to add additional operators to the query syntax ([#2941](https://github.com/feathersjs/feathers/issues/2941)) ([f324940](https://github.com/feathersjs/feathers/commit/f324940d5795b41e8c6fc113defb0beb7ab03a0a)) # [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14) ### Bug Fixes - **schema:** Allow query schemas with no properties, error on unsupported types ([#2904](https://github.com/feathersjs/feathers/issues/2904)) ([b66c734](https://github.com/feathersjs/feathers/commit/b66c734357478f51b2d38fa7f3eee08640cea26e)) - **typebox:** Improve query syntax defaults ([#2888](https://github.com/feathersjs/feathers/issues/2888)) ([59f3cdc](https://github.com/feathersjs/feathers/commit/59f3cdca6376e34fe39a7b91db837d0325aeb5db)) # [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) ### Features - **schema:** Add StringEnum to TypeBox module ([#2827](https://github.com/feathersjs/feathers/issues/2827)) ([65d3665](https://github.com/feathersjs/feathers/commit/65d36656f50a48f633fa3fcabaea10521d04bf1c)) # [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) **Note:** Version bump only for package @feathersjs/typebox # [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12) ### Features - **cli:** Improve generated schema definitions ([#2783](https://github.com/feathersjs/feathers/issues/2783)) ([474a9fd](https://github.com/feathersjs/feathers/commit/474a9fda2107e9bcf357746320a8e00cda8182b6)) # [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07) ### Features - **schema:** Make schemas validation library independent and add TypeBox support ([#2772](https://github.com/feathersjs/feathers/issues/2772)) ([44172d9](https://github.com/feathersjs/feathers/commit/44172d99b566d11d9ceda04f1d0bf72b6d05ce76)) ================================================ FILE: packages/typebox/LICENSE ================================================ The MIT License (MIT) Copyright (c) 2024 Feathers Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: packages/typebox/README.md ================================================ # @feathersjs/typebox [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI) [![Download Status](https://img.shields.io/npm/dm/@feathersjs/typebox.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/typebox) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx) > [TypeBox](https://github.com/sinclairzx81/typebox) integration for @feathersjs/schema ## Installation ``` npm install @feathersjs/typebox --save ``` ## Documentation Refer to the [Feathers TypeBox documentation](https://feathersjs.com/api/schema/typebox.html) for more details. ## License Copyright (c) 2024 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) Licensed under the [MIT license](LICENSE). ================================================ FILE: packages/typebox/package.json ================================================ { "name": "@feathersjs/typebox", "description": "TypeBox integration for @feathersjs/schema", "version": "5.0.42", "homepage": "https://feathersjs.com", "main": "lib/", "types": "lib/", "keywords": [ "feathers", "feathers-plugin" ], "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/daffl" }, "repository": { "type": "git", "url": "git://github.com/feathersjs/feathers.git", "directory": "packages/schema" }, "author": { "name": "Feathers contributors", "email": "hello@feathersjs.com", "url": "https://feathersjs.com" }, "contributors": [], "bugs": { "url": "https://github.com/feathersjs/feathers/issues" }, "engines": { "node": ">= 12" }, "files": [ "CHANGELOG.md", "LICENSE", "README.md", "src/**", "lib/**", "*.d.ts", "*.js" ], "scripts": { "prepublish": "npm run compile", "pack": "npm pack --pack-destination ../generators/test/build", "compile": "shx rm -rf lib/ && tsc && npm run pack", "mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts", "test": "npm run compile && npm run mocha" }, "directories": { "lib": "lib" }, "publishConfig": { "access": "public" }, "dependencies": { "@feathersjs/schema": "^5.0.42", "@sinclair/typebox": "^0.25.0" }, "devDependencies": { "@types/mocha": "^10.0.10", "@types/node": "^25.3.3", "mocha": "^11.7.5", "shx": "^0.4.0", "typescript": "^5.9.3" }, "gitHead": "90caf635aec850550b9d37bea2762af959d9e8d5" } ================================================ FILE: packages/typebox/src/default-schemas.ts ================================================ import { Type, Static } from '@sinclair/typebox' export const authenticationSettingsSchema = Type.Object({ secret: Type.String({ description: 'The JWT signing secret' }), entity: Type.Optional( Type.Union([ Type.String({ description: 'The name of the authentication entity (e.g. user)' }), Type.Null() ]) ), entityId: Type.Optional(Type.String({ description: 'The name of the authentication entity id property' })), service: Type.Optional(Type.String({ description: 'The path of the entity service' })), authStrategies: Type.Array(Type.String(), { description: 'A list of authentication strategy names that are allowed to create JWT access tokens' }), parseStrategies: Type.Optional( Type.Array(Type.String(), { description: 'A list of authentication strategy names that should parse HTTP headers for authentication information (defaults to `authStrategies`)' }) ), jwtOptions: Type.Optional(Type.Object({})), jwt: Type.Optional( Type.Object({ header: Type.String({ default: 'Authorization', description: 'The HTTP header containing the JWT' }), schemes: Type.String({ description: 'An array of schemes to support' }) }) ), local: Type.Optional( Type.Object({ usernameField: Type.String({ description: 'Name of the username field (e.g. `email`)' }), passwordField: Type.String({ description: 'Name of the password field (e.g. `password`)' }), hashSize: Type.Optional(Type.Number({ description: 'The BCrypt salt length' })), errorMessage: Type.Optional(Type.String({ description: 'The error message to return on errors' })), entityUsernameField: Type.Optional( Type.String({ description: 'Name of the username field on the entity if authentication request data and entity field names are different' }) ), entityPasswordField: Type.Optional( Type.String({ description: 'Name of the password field on the entity if authentication request data and entity field names are different' }) ) }) ), oauth: Type.Optional( Type.Object({ redirect: Type.Optional(Type.String()), origins: Type.Optional(Type.Array(Type.String())), defaults: Type.Optional( Type.Object({ key: Type.Optional(Type.String()), secret: Type.Optional(Type.String()) }) ) }) ) }) export const sqlSettingsSchema = Type.Optional( Type.Object({ client: Type.String(), connection: Type.Union([ Type.String(), Type.Partial( Type.Object({ host: Type.String(), port: Type.Number(), user: Type.String(), password: Type.String(), database: Type.String() }) ) ]), pool: Type.Optional( Type.Object({ min: Type.Number(), max: Type.Number() }) ) }) ) export const defaultAppConfiguration = Type.Object( { authentication: Type.Optional(authenticationSettingsSchema), paginate: Type.Optional( Type.Object( { default: Type.Number(), max: Type.Number() }, { additionalProperties: false } ) ), origins: Type.Optional(Type.Array(Type.String())), mongodb: Type.Optional(Type.String()), mysql: sqlSettingsSchema, postgresql: sqlSettingsSchema, sqlite: sqlSettingsSchema, mssql: sqlSettingsSchema }, { $id: 'ApplicationConfiguration', additionalProperties: false } ) export type DefaultAppConfiguration = Static ================================================ FILE: packages/typebox/src/index.ts ================================================ import { Type, TObject, TInteger, TOptional, TSchema, ObjectOptions, TIntersect, TUnion, type TRecord } from '@sinclair/typebox' import { jsonSchema, Validator, DataValidatorMap, Ajv } from '@feathersjs/schema' export * from '@sinclair/typebox' export * from './default-schemas' export type TDataSchemaMap = { create: TObject update?: TObject patch?: TObject } /** * Returns a compiled validation function for a TypeBox object and AJV validator instance. * * @param schema The JSON schema definition * @param validator The AJV validation instance * @returns A compiled validation function */ export const getValidator = ( schema: TObject | TIntersect | TUnion | TRecord, validator: Ajv ): Validator => jsonSchema.getValidator(schema as any, validator) /** * Returns compiled validation functions to validate data for the `create`, `update` and `patch` * service methods. If not passed explicitly, the `update` validator will be the same as the `create` * and `patch` will be the `create` validator with no required fields. * * @param def Either general TypeBox object definition or a mapping of `create`, `update` and `patch` * to their respective type object * @param validator The Ajv instance to use as the validator * @returns A map of validator functions */ export const getDataValidator = (def: TObject | TDataSchemaMap, validator: Ajv): DataValidatorMap => jsonSchema.getDataValidator(def as any, validator) /** * A TypeBox utility that converts an array of provided strings into a string enum. * @param allowedValues array of strings for the enum * @returns TypeBox.Type */ export function StringEnum(allowedValues: [...T], options?: { default: T[number] }) { return Type.Unsafe({ type: 'string', enum: allowedValues, ...options }) } const arrayOfKeys = (type: T) => { const keys = Object.keys(type.properties) return Type.Unsafe<(keyof T['properties'])[]>({ type: 'array', maxItems: keys.length, items: { type: 'string', ...(keys.length > 0 ? { enum: keys } : {}) } }) } /** * Creates the `$sort` Feathers query syntax schema for an object schema * * @param schema The TypeBox object schema * @returns The `$sort` syntax schema */ export function sortDefinition(schema: T) { const properties = Object.keys(schema.properties).reduce( (res, key) => { const result = res as any result[key] = Type.Optional(Type.Integer({ minimum: -1, maximum: 1 })) return result }, {} as { [K in keyof T['properties']]: TOptional } ) return Type.Object(properties, { additionalProperties: false }) } /** * Returns the standard Feathers query syntax for a property schema, * including operators like `$gt`, `$lt` etc. for a single property * * @param def The property definition * @param extension Additional properties to add to the property query * @returns The Feathers query syntax schema */ export const queryProperty = ( def: T, extension: X = {} as X ) => Type.Optional( Type.Union([ def, Type.Partial( Type.Intersect( [ Type.Object({ $gt: def, $gte: def, $lt: def, $lte: def, $ne: def, $in: def.type === 'array' ? def : Type.Array(def), $nin: def.type === 'array' ? def : Type.Array(def) }), Type.Object(extension) ], { additionalProperties: false } ) ) ]) ) type QueryProperty = ReturnType< typeof queryProperty > /** * Creates a Feathers query syntax schema for the properties defined in `definition`. * * @param definition The properties to create the Feathers query syntax schema for * @param extensions Additional properties to add to a property query * @returns The Feathers query syntax schema */ export const queryProperties = < T extends TObject, X extends { [K in keyof T['properties']]?: { [key: string]: TSchema } } >( definition: T, extensions: X = {} as X ) => { const properties = Object.keys(definition.properties).reduce( (res, key) => { const result = res as any const value = definition.properties[key] result[key] = queryProperty(value, extensions[key]) return result }, {} as { [K in keyof T['properties']]: QueryProperty } ) return Type.Optional(Type.Object(properties, { additionalProperties: false })) } /** * Creates a TypeBox schema for the complete Feathers query syntax including `$limit`, $skip`, `$or` * and `$sort` and `$select` for the allowed properties. * * @param type The properties to create the query syntax for * @param extensions Additional properties to add to the query syntax * @param options Options for the TypeBox object schema * @returns A TypeBox object representing the complete Feathers query syntax for the given properties */ export const querySyntax = < T extends TObject, X extends { [K in keyof T['properties']]?: { [key: string]: TSchema } } >( type: T, extensions: X = {} as X, options: ObjectOptions = { additionalProperties: false } ) => { const propertySchema = queryProperties(type, extensions) const $or = Type.Array(propertySchema) const $and = Type.Array(Type.Union([propertySchema, Type.Object({ $or })])) return Type.Intersect( [ Type.Partial( Type.Object( { $limit: Type.Number({ minimum: 0 }), $skip: Type.Number({ minimum: 0 }), $sort: sortDefinition(type), $select: arrayOfKeys(type), $and, $or }, { additionalProperties: false } ) ), propertySchema ], options ) } export const ObjectIdSchema = () => Type.Union([Type.String({ objectid: true }), Type.Object({}, { additionalProperties: true })]) ================================================ FILE: packages/typebox/test/index.test.ts ================================================ import assert from 'assert' import { ObjectId as MongoObjectId } from 'mongodb' import { Ajv } from '@feathersjs/schema' import { querySyntax, Type, Static, defaultAppConfiguration, getDataValidator, getValidator, ObjectIdSchema } from '../src' describe('@feathersjs/schema/typebox', () => { describe('querySyntax', () => { it('basics', async () => { const schema = Type.Object({ name: Type.String(), age: Type.Number() }) const querySchema = querySyntax(schema) type Query = Static const query: Query = { name: 'Dave', age: { $gt: 42, $in: [50, 51] }, $select: ['age', 'name'], $sort: { age: 1 } } const validator = new Ajv().compile(querySchema) let validated = (await validator(query)) as any as Query assert.ok(validated) validated = (await validator({ ...query, something: 'wrong' })) as any as Query assert.ok(!validated) }) it('querySyntax works with no properties', async () => { const schema = querySyntax(Type.Object({})) new Ajv().compile(schema) }) it('query syntax can include additional extensions', async () => { const schema = Type.Object({ name: Type.String(), age: Type.Number() }) const querySchema = querySyntax(schema, { age: { $notNull: Type.Boolean() }, name: { $ilike: Type.String() } }) const validator = new Ajv().compile(querySchema) type Query = Static const query: Query = { age: { $gt: 10, $notNull: true }, name: { $gt: 'David', $ilike: 'Dave' } } const validated = (await validator(query)) as any as Query assert.ok(validated) }) }) it('$in and $nin works with array type', async () => { const schema = Type.Object({ things: Type.Array(Type.Number()) }) const querySchema = querySyntax(schema) const validator = new Ajv().compile(querySchema) type Query = Static const query: Query = { things: { $in: [10, 20], $nin: [30] } } const validated = (await validator(query)) as any as Query assert.ok(validated) }) it('defaultAppConfiguration', async () => { const configSchema = Type.Intersect([ defaultAppConfiguration, Type.Object({ host: Type.String(), port: Type.Number(), public: Type.String() }) ]) const validator = new Ajv().compile(configSchema) const validated = await validator({ host: 'something', port: 3030, public: './' }) assert.ok(validated) }) // Test ObjectId validation it('ObjectId', async () => { const schema = Type.Object({ _id: ObjectIdSchema() }) const validator = new Ajv({ strict: false }).compile(schema) const validated = await validator({ _id: '507f191e810c19729de860ea' }) assert.ok(validated) const validated2 = await validator({ _id: new MongoObjectId() }) assert.ok(validated2) }) it('validators', () => { assert.strictEqual(typeof getDataValidator(Type.Object({}), new Ajv()), 'object') assert.strictEqual(typeof getValidator(Type.Object({}), new Ajv()), 'function') assert.strictEqual( typeof getValidator(Type.Intersect([Type.Object({}), Type.Object({})]), new Ajv()), 'function' ) }) }) ================================================ FILE: packages/typebox/tsconfig.json ================================================ { "extends": "../../tsconfig", "include": [ "src/**/*.ts" ], "compilerOptions": { "outDir": "lib" } } ================================================ FILE: tsconfig.json ================================================ { "compilerOptions": { // TODO: We should remove this but lib types break all the time "skipLibCheck": true, /* Basic Options */ "target": "es2018", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ "declaration": true, /* Generates corresponding '.d.ts' file. */ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ // "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ /* Strict Type-Checking Options */ "strict": true, /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ "strictNullChecks": false, /* Enable strict null checks. */ // "strictFunctionTypes": true, /* Enable strict checking of function types. */ // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ /* Additional Checks */ "noUnusedLocals": true, /* Report errors on unused locals. */ "noUnusedParameters": true, /* Report errors on unused parameters. */ "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ /* Module Resolution Options */ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ /* Experimental Options */ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ } }