Tag: feathersjs

HTTP POST的作品,但GET失败,羽毛集合标准服务

我正在尝试开始使用羽毛球.js和续集。 我正在按照聊天指南,但我使用sequelize而不是默认数据库。 我正在使用本地SQL Server 2016实例,这是我的续集对象的样子: const sequelize = new Sequelize('feathers_backend', null, null, { dialect: 'mssql', dialectModulePath: 'sequelize-msnodesqlv8', logging: false, dialectOptions: { driver: 'SQL Server Native Client 11.0', instanceName: 'MSSQLSERVER01', trustedConnection: true, } }); 我得到了创build消息API和下载postman HTTP示例。 我希望应用程序按照指南中的描述进行工作 – 即定期的CRUD行为。 发布新邮件工作正常,预期的结果返回。 但是,一旦我做了一个GET,我得到这个错误: info:after:messages – 方法:创buildinfo:after:messages – 方法:create info:error:messages – 方法:find:[Microsoft] [SQL Server Native Client 11.0] [SQL Server]'OFFSET'附近的语法错误。 […]

使用feathersjs创build后无法从对象中删除_id字段

我想在插入数据后在我的节点应用程序中修改我的hook.data对象。 其实我不能。 create: [function(hook, next) { delete hook.data._id; hook.data = { problem: hook.data } postJson(hook.app.get('jsprintUrl'), hook.data) .then(data =>{ hook.result = data; next() }) }] 结果:仍然存在_id { "_id": "59ca334e7bc4e06b140aadf9", "algorithm": [ { "name": "SA" } ] }

Feathers.js – 加载静态内容

我正在评估一个项目的羽毛.js 。 我喜欢它的愿望。 所以,我决定尝试build立一个基本的内容pipe理系统,就像学习一样。 事情进展得相当顺利。 不过,我想在应用程序启动时将一些静态内容(文章)加载到内存中。 我无法弄清楚如何做到这一点。 我在data / articles目录中有我的文章。 每篇文章都是名为[title] .md的降价。 我有一个JavaScript块,我在一个控制台应用程序testing,将降价转换为HTML。 该代码使用markdown-js将HTML获取到JSON对象中。 它看起来像这样: const fs = require('fs'); const markdownConverter = require('markdown'); let articles = []; let files = fs.readdirSync('./data/articles'); for (let i=0; i<files.length; i++) { let title = files[i].substr((files[i].lastIndexOf('/')+1), (files[i].length-3)); let markdown = fs.readFileSync(files[i], 'utf8'); let html = markdownConverter.toHTML(markdown); articles[title] = html; } […]

如何覆盖feathersjs默认的服务方法

我有一个使用feathers generate service命令创build的feathers generate service 。 我想覆盖它的create方法的定义。 这是我的服务课 /* eslint-disable no-unused-vars */ // Initializes the `userGroup` service on path `/usergroup` const createService = require('feathers-sequelize'); const createModel = require('../../models/user-group.model'); const hooks = require('./user-group.hooks'); const filters = require('./user-group.filters'); const async = require('async'); module.exports = function () { const app = this; const Model = createModel(app); const paginate […]

Feathersjspipe理员angular色(或用auth检查羽毛中间件)

我有一个愚蠢的问题与feathersjs auth钩(或其他)。 这是我的代码评论: app.get('/admin', function (req, res) { // i'd like to check here if (req.connection.isAdmin) then render page res.render('admin/admin.html', { title: 'admin' }) }); 我无法find哪里我可以实现用户身份validation的钩子chek用户的pipe理angular色。 我怎样才能做到这一点?

如何对待羽毛球内的承诺?

我想在插入数据库之前validation数据。 Feathersjs的方式是通过使用钩子。 在插入一组权限之前,我必须考虑用户post提供的数据的完整性。 我的解决scheme是find与用户提供的数据相关的所有权限。 通过比较列表的长度,我可以certificate,如果数据是正确的。 钩子的代码贴在下面: const permissionModel = require('./../../models/user-group.model'); module.exports = function (options = {}) { return function usergroupBefore(hook) { function fnCreateGroup(data, params) { let inIds = []; // the code in this block is for populating the inIds array if (inIds.length === 0) { throw Error('You must provide the permission List'); } //now […]

如何使用feathersjs-authentication将JWT令牌发送到客户端?

我在我的feathersjs REST-API应用程序中使用了本地身份validation ,但是在用户通过身份validation之后,而不是向我发送身份validation令牌 ,羽毛会发送以下HTML作为对身份validation请求的响应: <body> <img class="logo" src="alongbase64string" alt="Feathers Logo"> <main> <h1 class="center-text">Success</h1> <h3 class="center-text">You are now logged in. We've stored your JWT in a cookie with the name <span class="italic">"feathers-jwt"</span> for you. It is: </h3> <pre id="token"></pre> </main> <script type="text/javascript"> function getCookie(name) { var value = "; " + document.cookie; var parts = value.split("; […]

如何解决请求实体在feathersjs太大的错误?

我在羽毛服务上传csv文件,文件大小为203kb,它抛出一个错误请求实体太大的错误是这样的。 错误: { "name": "GeneralError", "message": "request entity too large", "code": 500, "className": "general-error", "data": {}, "errors": {} } 我正在写这样的中间件代码,但我无法解决 app.js: app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); location.service.js: // Initializes the `location` service on path `/location` const createService = require('feathers-mongoose'); const createModel = require('../../models/location.model'); const hooks = require('./location.hooks'); const filters = require('./location.filters'); const multer = require('multer'); […]

调用自定义API方法的羽毛

我用下面的东西来定义我的api: class MyFeathersApi { feathersClient: any; accountsAPI: any; productsAPI: any; constructor(app) { var port: number = app.get('port'); this.accountsAPI = app.service('/api/accounts'); this.productsAPI = app.service('/api/products'); } findAdminAccounts(filter: any, cb: (err:Error, accounts:Models.IAccount[]) => void) { filter = { query: { adminProfile: { $exists: true } } } this.accountsAPI.find(filter, cb); } 当我想要使用数据库适配器的方法,从客户端,即查找和/或创build,我做到以下几点: var accountsAPIService = app.service('/api/accounts'); accountsAPIService.find( function(error, accounts) […]