This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "scripts": { | |
| "update-dependencies": "ncu -u" | |
| }, | |
| "devDependencies": { | |
| "npm-check-updates": "^4.1.2" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { hooks, HookContext, NextFunction } from '@feathersjs/hooks'; | |
| const logRuntime = async (context: HookContext, next: NextFunction) => { | |
| const start = new Date().getTime(); | |
| await next(); | |
| const end = new Date().getTime(); | |
| console.log(`Function '${context.method || '[no name]'}' returned '${context.result}' after ${end - start}ms`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { hooks } = require('@feathersjs/hooks'); | |
| const logRuntime = async (context, next) => { | |
| const start = new Date().getTime(); | |
| await next(); | |
| const end = new Date().getTime(); | |
| console.log(`Function '${context.method || '[no name]'}' returned '${context.result}' after ${end - start}ms`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { setSchema } = require('@feathersjs/schema'); | |
| class User {} | |
| setSchema(User, { | |
| id: { | |
| type: Number | |
| }, | |
| email: { | |
| description: 'The user email', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Entity() | |
| class User { | |
| @PrimaryGeneratedColumn() | |
| id: string; | |
| @toLowerCase() | |
| @validate('email') | |
| @Column() | |
| email: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const service = require('feathers-<database>'); | |
| // Allow multi create, patch and remove | |
| service({ | |
| whitelist: [ '$regex' ] | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const service = require('feathers-<database>'); | |
| // Allow multi create, patch and remove | |
| service({ | |
| multi: true | |
| }); | |
| // Only allow create with an array | |
| service({ | |
| multi: [ 'create' ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Call `get` without running any hooks | |
| const message = await app.service('/messages')._get('<message id>'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Will throw `NotFound` if `companyId` does not match | |
| // Even if the `id` is available | |
| app.service('/messages').get('<message id>', { | |
| query: { companyId: '<my company>' } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const feathers = require('@feathersjs/feathers'); | |
| const app = feathers(); | |
| app.use('/', myService); |