我正在試驗 FeathersJS。為此,我
$ feathers g app使用以下配置生成了一個新的羽毛應用程式:
? Do you want to use JavaScript or TypeScript? JavaScript
? Project name test
? Description
? What folder should the source files live in? src
? Which package manager are you using (has to be installed globally)? npm
? What type of API are you making? REST, Realtime via Socket.io
? Which testing framework do you prefer? Mocha assert
? This app uses authentication Yes
? Which coding style do you want to use? ESLint
? What authentication strategies do you want to use? (See API docs for all 180 supported oAuth providers) Username Password (Local)
? What is the name of the user (entity) service? users
? What kind of service is it? Objection
? Which database are you connecting to? SQLite
? What is the database connection string? sqlite://test.sqlite
當我運行測驗套件$ npm run tests時,它會引發錯誤ERR GeneralError: strict mode: unknown keyword: "0"
到目前為止,我了解到這個錯誤是在 Knex 使用的 AJV 中的某個地方引發的,并且它在某種程度上與模式驗證有關。我也嘗試發帖以http://localhost:3030/users創建用戶,但我得到了同樣的錯誤。
我對配置為使用 Knex SQLite 和 Sequalize SQLite 的應用程式進行了相同的實驗。這些設定讓我可以創建新用戶。
有誰知道這個錯誤可能來自哪里以及如何解決?
uj5u.com熱心網友回復:
發現了問題。羽毛生成器在 ObjectionJS 模型中創建以下 jsonSchema:
static get jsonSchema() {
return {
type: 'object',
required: ['password'],
properties: {
email: { type: ['string', 'null'] },
password: 'string',
}
};
}
它的密碼屬性語法錯誤。它需要password: { type: 'string' }作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/476321.html
