-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
pushToQueue
hooks added,creates sdk recv endpoint
- Loading branch information
Showing
9 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Use this hook to manipulate incoming or outgoing data. | ||
// For more information on hooks see: http://docs.feathersjs.com/api/hooks.html | ||
import { Hook, HookContext } from '@feathersjs/feathers'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export default (options = {}): Hook => { | ||
return async (context: HookContext): Promise<HookContext> => { | ||
return context; | ||
}; | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// recv-data-model.ts - A mongoose model | ||
// | ||
// See http://mongoosejs.com/docs/models.html | ||
// for more of what you can do here. | ||
import { Application } from '../declarations'; | ||
import { Model, Mongoose } from 'mongoose'; | ||
|
||
export default function (app: Application): Model<any> { | ||
const modelName = 'recvData'; | ||
const mongooseClient: Mongoose = app.get('mongooseClient'); | ||
const { Schema } = mongooseClient; | ||
const schema = new Schema({ | ||
text: { type: String, required: true } | ||
}, { | ||
timestamps: true | ||
}); | ||
|
||
// This is necessary to avoid model compilation errors in watch mode | ||
// see https://mongoosejs.com/docs/api/connection.html#connection_Connection-deleteModel | ||
if (mongooseClient.modelNames().includes(modelName)) { | ||
(mongooseClient as any).deleteModel(modelName); | ||
} | ||
return mongooseClient.model<any>(modelName, schema); | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Service, MongooseServiceOptions } from 'feathers-mongoose'; | ||
import { Application } from '../../declarations'; | ||
|
||
export class RecvData extends Service { | ||
//eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
constructor(options: Partial<MongooseServiceOptions>, app: Application) { | ||
super(options); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { HooksObject } from '@feathersjs/feathers'; | ||
|
||
import pushToQueue from '../../hooks/push-to-queue'; | ||
|
||
export default { | ||
before: { | ||
all: [], | ||
find: [], | ||
get: [], | ||
create: [pushToQueue()], | ||
update: [], | ||
patch: [], | ||
remove: [] | ||
}, | ||
|
||
after: { | ||
all: [], | ||
find: [], | ||
get: [], | ||
create: [], | ||
update: [], | ||
patch: [], | ||
remove: [] | ||
}, | ||
|
||
error: { | ||
all: [], | ||
find: [], | ||
get: [], | ||
create: [], | ||
update: [], | ||
patch: [], | ||
remove: [] | ||
} | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Initializes the `recv-data` service on path `/recv-data` | ||
import { ServiceAddons } from '@feathersjs/feathers'; | ||
import { Application } from '../../declarations'; | ||
import { RecvData } from './recv-data.class'; | ||
import createModel from '../../models/recv-data.model'; | ||
import hooks from './recv-data.hooks'; | ||
|
||
// Add this service to the service type index | ||
declare module '../../declarations' { | ||
interface ServiceTypes { | ||
'recv-data': RecvData & ServiceAddons<any>; | ||
} | ||
} | ||
|
||
export default function (app: Application): void { | ||
const options = { | ||
Model: createModel(app), | ||
paginate: app.get('paginate') | ||
}; | ||
|
||
// Initialize our service with any options it requires | ||
app.use('/recv-data', new RecvData(options, app)); | ||
|
||
// Get our initialized service so that we can register hooks | ||
const service = app.service('recv-data'); | ||
|
||
service.hooks(hooks); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import app from '../../src/app'; | ||
|
||
describe('\'recv-data\' service', () => { | ||
it('registered the service', () => { | ||
const service = app.service('recv-data'); | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4870,6 +4870,11 @@ jws@^3.2.2: | |
jwa "^1.4.1" | ||
safe-buffer "^5.0.1" | ||
|
||
kafkajs@^2.2.4: | ||
version "2.2.4" | ||
resolved "https://registry.yarnpkg.com/kafkajs/-/kafkajs-2.2.4.tgz#59e6e16459d87fdf8b64be73970ed5aa42370a5b" | ||
integrity sha512-j/YeapB1vfPT2iOIUn/vxdyKEuhuY2PxMBvf5JWux6iSaukAccrMtXEY/Lb7OvavDhOWME589bpLrEdnVHjfjA== | ||
|
||
[email protected]: | ||
version "2.5.1" | ||
resolved "https://registry.yarnpkg.com/kareem/-/kareem-2.5.1.tgz#7b8203e11819a8e77a34b3517d3ead206764d15d" | ||
|