knisterpeter / pretend Goto Github PK
View Code? Open in Web Editor NEWA decorator based http webservice client written in typescript
License: MIT License
A decorator based http webservice client written in typescript
License: MIT License
import { Get } from 'pretend';
import { UserEntity } from '../entities/user.entity';
export class UserWebService {
@Get('user/{id}')
public async get(id: number): Promise<UserEntity> {} // <-- error here, can't declaration return type
}
Is there any solution? thanks
If we create an interceptor and call the chain more than once, we get an error:
let response = await chain(request);
response2 = await chain(request);
...
[TypeError: interceptors[i++] is not a function. (In 'interceptors[i++](chainStep, request)', 'interceptors[i++]' is undefined)]
I need to call chain twice in my auth interceptor, if the token is expired, I refresh token and reissue the request. This functionality was working great in android java ok-http interceptors. I think we can fix this with a little tweak in code. I will send a PR soon.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
.github/workflows/build.yml
actions/checkout v3
actions/setup-node v3
actions/checkout v3
actions/setup-node v3
package.json
@knisterpeter/standard-tslint 1.7.2
@types/jest 29.5.10
@types/node 20.10.0
codecov 3.8.3
isomorphic-fetch 3.0.0
isomorphic-form-data 2.0.0
jest 29.7.0
nock 13.2.9
prettier 2.8.8
rimraf 3.0.2
ts-jest 29.1.1
tslint 6.1.3
typescript 4.9.5
isomorphic-fetch 3.0.0
isomorphic-form-data 2.0.0
This is the best (and almost only) declarative lib that I could find which works best across all of my projects (Vanilla React, Next.js SSR, Vanilla React Native, Expo managed RN etc). I'm using it quite a while and it's working great. Is there any more popular alternative that people are using? I would like to see this lib go over 10k stars :) Thousands of thanks for taking your time to share this with the world.
Branch | Build failing π¨ |
---|---|
Dependency | nock |
Current Version | 9.0.20 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As nock is βonlyβ a devDependency of this project it might not break production or downstream projects, but βonlyβ your build or test tools β preventing new deploys or publishes.
I recommend you give this issue a high priority. Iβm sure you can resolve this πͺ
The new version differs by 6 commits.
5209262
9.0.21
9ffab38
fix: compare falsy header values & numbers correctly
333e8e3
test: match number header values
fe00f67
multiple interceptors override headers from unrelated requests
4196cf0
Add an error code to NetConnectNotAllowedError
66cd477
chore(CHANGELOG): v9.0.20
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot π΄
Currently the only ways to add a header is by using @Header(...) decorator or an interceptor. I am currently in need of generating a header and add it to the request in runtime. I think I will go with interceptor pattern but it would be great to have appendHeaders in GET,POST,.. decorators and add the latest object as header to the request. I checked the code and it seems possible but appendQuery index checks are little obstructive there. If it seems easy for you, could you try to implement please, otherwise I will have a look again in some free time.
Following vscode-github
I write my own git tool for a local git service.
I got an error :
ReferenceError: Headers is not defined
at prepareHeaders
(/User/XXX/Code/oschina/gitee/node_modules/pretend/src/index.ts:70:19)
at execute (/User/XXX/Code/oschina/gitee/node_modules/pretend/src/index.ts:111:19)
at GiteeBlueprint.<anonymous> (/User/XXX/Code/oschina/gitee/node_modules/pretend/src/index.ts:132:14)
at /User/XXX/Code/oschina/gitee/node_modules/pretend/src/index.ts:169:36
at processTicksAndRejections (internal/process/task_queues.js:85:5)
Does Header must be set ? Where to set header ?
I set header like this:
export class GiteeBlueprint implements Gitee {
@Header('Accept: application/json')
@Post('/user/repos')
public createRepository(params: ICreateRepoParam): any { }
}
There is a problem with the latest v4 release. Dist folder is not deployed to npm, that's why we are getting "Cannot find module 'pretend'" error.
Hey everyone first of all thanks for creating this, I was thinking about doing something like this for a project but you guys got it covered! second here comes my question I still don't know if it is possible to define a response type like a class being created from what is returned from the service. I would probably also want to define which path of the object should be pointed to this class this could be a decorator. What do you guys think about all of this? I might be interested in helping this project it is really what I have been doing with Swift using Sourcery :)
when using the requestInterceptor
, the body of the request is already stringifyed.
so, whenever I want to change anything, I have to JSON.parse(...)
it.
is there a way to work on the data before being stringifyed?
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Location: package.json
Error type: The renovate configuration file contains some invalid settings
Message: Invalid configuration option: author, Invalid configuration option: files, Invalid configuration option: jest, Invalid configuration option: license, Invalid configuration option: main, Invalid configuration option: name, Invalid configuration option: packageRules[0].@knisterpeter/standard-tslint, Invalid configuration option: packageRules[0].@types/jest, Invalid configuration option: packageRules[0].@types/node, Invalid configuration option: packageRules[0].codecov, Invalid configuration option: packageRules[0].isomorphic-fetch, Invalid configuration option: packageRules[0].isomorphic-form-data, Invalid configuration option: packageRules[0].jest, Invalid configuration option: packageRules[0].nock, Invalid configuration option: packageRules[0].prettier, Invalid configuration option: packageRules[0].rimraf, Invalid configuration option: packageRules[0].shipjs, Invalid configuration option: packageRules[0].ts-jest, Invalid configuration option: packageRules[0].tslint, Invalid configuration option: packageRules[0].typescript, Invalid configuration option: packageRules[1].isomorphic-fetch, Invalid configuration option: packageRules[1].isomorphic-form-data, Invalid configuration option: prettier, Invalid configuration option: renovate, Invalid configuration option: scripts, Invalid configuration option: types, Invalid configuration option: version
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.