hapipal / schmervice Goto Github PK
View Code? Open in Web Editor NEWA service layer for hapi
License: MIT License
A service layer for hapi
License: MIT License
It would be nice if we could deconstruct methods from a schmervice instance and be able to use them while preserving this
context. I figured it could work much like Joi's bind method. One downside being that getter methods would not work.
const serviceX = server.services();
const { transform } = serviceX.bind();
const mappedDocument = transform(payload);
I currently find schmervice's API pretty good, and I can't think of any breaking changes that I'd like to make to it for v2. But— what do you think? Please feel free to broach discussions about any aspects of the API that you find limiting or otherwise suboptimal, and we can create additional issues as necessary to finalize discussions or flesh-out proposals.
If there are no issues then that would be great news— of course I don't want to encourage API changes just for fun, but now is a good time to make changes, so if something has been on your mind then let's talk about it!
Hello,
I was trying to update to hapi@21 today, and had an issue, noticed that schmervice peer dep range doesn't include 21
{
"peerDependencies": {
"@hapi/hapi": ">=19 <21"
}
}
Is there a way to pass parameters to the service? Either to the constructor or the initialize
-method? The options
-object is just options internal to schmervice
, right? Is my use-case for passing some initialisation options off base and the intent is to set dependencies/options on the context
-object? At least that's how I've solved passing options to the service.
In my opinion it would make sense to pass in an options-object to the registerService(service, initOptions)
that would be passed to the initialize()
and/or constructor.
The next major version of all packages in the org will be published under the @hapipal scope on npm. This module will be published as @hapipal/schmervice.
Now that we're all tested on hapi v20 and node v14, it's time to look ahead.
Hi @devinivy,
I am trying to use schmervice with another plugin. I have directory-based routing with wurst. https://github.com/felixheck/wurst
I register schmervice as
await server.register(Schmervice);
server.registerService(
class MathService extends Schmervice.Service {
add(x, y) {
this.server.log(['math-service'], 'Adding');
return Number(x) + Number(y);
}
multiply(x, y) {
this.server.log(['math-service'], 'Multiplying');
return Number(x) * Number(y);
}
}
);
await server.register({
plugin: wurst,
options: {
routes: '**/routes.js',
cwd: path.join(__dirname, 'lib/routes'),
log: true
}
});
in a routes folder, when I look at request.services(). It is an empty object. How do I register Schmervice with another plugin so that I get access to the service in my route?
PS: sorry for the tag!
Hello Im having a little trouble using Schmervice with typescript. I have imported @types for schmervice and I delare a class on a src/lib/services diresctory. i keep getting the error 'service must have a name' message meaning im not extending the base class properly. any initial guidance on setting up schmervice with typescript would be appreciated
Hi,
I'm trying to cache queries where data seldomly changes (also because the DB is dead slow and the response times to the server are shocking).
Relating to Vincit/objection.js#980 (comment)
Can you show an example of how you're using catbox to do this?
Hi!
I write integrational tests for my API server. Several services make requests to external servers like postgresql, redis etc. It's ok, but there is a service that makes requests to a server that I can't set up for each integrational test.
I tried to reinitialize the service like
server.registerService((server, options) => ({
name: 'service_that_I_wanna_stub',
stubbedMethod: () => {},
anotherStubbedMethod: () => {}
});
But I got the error A service named service_that_I_wanna_stub has already been registered.
I have no idea how to solve my problem. Is there a way to make it work? Thank you.
Hapi modules have been moved into a @hapi
namespace on npm. Update package.json to reflect this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.