Socket
Socket
Sign inDemoInstall

aspida

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aspida - npm Package Compare versions

Comparing version 0.15.3 to 0.16.0

2

dist/buildTemplate.js

@@ -11,3 +11,3 @@ "use strict";

var _b = createTemplateValues_1.default(input, trailingSlash), api = _b.api, imports = _b.imports;
var text = "/* eslint-disable */\nimport { AspidaClient } from 'aspida'\n<% types %><% imports %>\n\nconst api = <T>(client: AspidaClient<T>) => {\n const prefix = (client.baseURL === undefined ? '<% baseURL %>' : client.baseURL).replace(/\\/$/, '')\n\n return <% api %>\n}\n\nexport type ApiInstance = ReturnType<typeof api>\nexport default api\n"
var text = ("/* eslint-disable */\nimport { AspidaClient" + (api.includes('BasicHeaders') ? ', BasicHeaders' : '') + " } from 'aspida'\n<% types %><% imports %>\n\nconst api = <T>(client: AspidaClient<T>) => {\n const prefix = (client.baseURL === undefined ? '<% baseURL %>' : client.baseURL).replace(/\\/$/, '')\n\n return <% api %>\n}\n\nexport type ApiInstance = ReturnType<typeof api>\nexport default api\n")
.replace('<% types %>', api.includes(': ApiTypes.') ? "import * as ApiTypes from './@types'\n" : '')

@@ -14,0 +14,0 @@ .replace('<% imports %>', imports.map(function (i) { return i.replace(input, '.'); }).join('\n'))

@@ -26,4 +26,11 @@ "use strict";

var resHeaders = function (method) {
return props.resHeaders ? ", " + importName + "['" + method + "']['resHeaders']" : '';
return props.resHeaders
? ", " + importName + "['" + method + "']['resHeaders']"
: props.status
? ', BasicHeaders'
: '';
};
var status = function (method) {
return "" + (props.status ? ", " + importName + "['" + method + "']['status']" : '');
};
var option = function (method) {

@@ -52,3 +59,3 @@ return "option" + (isOptionRequired ? '' : '?') + ": {" + reqBody(method) + query(method) + reqHeaders(method) + " config?: T }";

"(" + option(name) + ") =>",
"client.fetch<" + resBody(name) + resHeaders(name) + ">(prefix, " + quotation + newUrl + (trailingSlash ? '/' : '') + quotation + ", '" + name.toUpperCase() + "'" + request() + ")." + resMethodName() + "()"
"client.fetch<" + resBody(name) + resHeaders(name) + status(name) + ">(prefix, " + quotation + newUrl + (trailingSlash ? '/' : '') + quotation + ", '" + name.toUpperCase() + "'" + request() + ")." + resMethodName() + "()"
];

@@ -55,0 +62,0 @@ return indent + " " + name + ": " + tmpChanks[0] + "\n" + indent + " " + tmpChanks[1] + ",\n" + indent + " $" + name + ": async " + tmpChanks[0] + "\n" + indent + " (await " + tmpChanks[1] + ").data";

export declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'PATCH' | 'OPTIONS';
export declare type LowerHttpMethod = 'get' | 'post' | 'put' | 'delete' | 'head' | 'patch' | 'options';
export declare type RequestType = 'FormData' | 'URLSearchParams' | 'ArrayBuffer' | 'Blob' | 'string' | 'any';
declare type BasicHeaders = Record<string, string>;
export declare type HttpStatusOk = 200 | 201 | 202 | 203 | 204 | 205 | 206;
export declare type BasicHeaders = Record<string, string>;
export declare type AspidaRequest<Config = any> = {

@@ -12,4 +13,4 @@ query?: any;

};
export declare type AspidaResponse<T, U> = {
status: number;
export declare type AspidaResponse<T, U, V> = {
status: V;
headers: U;

@@ -27,9 +28,9 @@ originalResponse: any;

baseURL: string | undefined;
fetch: <T, U = BasicHeaders>(prefix: string, path: string, method: HttpMethod, params?: AspidaParams<Config>, type?: RequestType) => {
send(): Promise<AspidaResponse<null, U>>;
json(): Promise<AspidaResponse<T, U>>;
text(): Promise<AspidaResponse<string, U>>;
arrayBuffer(): Promise<AspidaResponse<ArrayBuffer, U>>;
blob(): Promise<AspidaResponse<Blob, U>>;
formData(): Promise<AspidaResponse<FormData, U>>;
fetch: <T, U = BasicHeaders, V = HttpStatusOk>(prefix: string, path: string, method: HttpMethod, params?: AspidaParams<Config>, type?: RequestType) => {
send(): Promise<AspidaResponse<null, U, V>>;
json(): Promise<AspidaResponse<T, U, V>>;
text(): Promise<AspidaResponse<string, U, V>>;
arrayBuffer(): Promise<AspidaResponse<ArrayBuffer, U, V>>;
blob(): Promise<AspidaResponse<Blob, U, V>>;
formData(): Promise<AspidaResponse<FormData, U, V>>;
};

@@ -41,2 +42,3 @@ };

export declare type AspidaMethodParams = {
status?: number;
query?: any;

@@ -52,3 +54,2 @@ reqHeaders?: any;

};
export {};
//# sourceMappingURL=index.d.ts.map

@@ -9,2 +9,4 @@ "use strict";

var filePath = _a.filePath, text = _a.text;
if (fs_1.default.existsSync(filePath) && fs_1.default.readFileSync(filePath, 'utf8') === text)
return;
fs_1.default.writeFileSync(filePath, text, 'utf8');

@@ -11,0 +13,0 @@ console.log(filePath + " was built successfully.");

{
"name": "aspida",
"version": "0.15.3",
"version": "0.16.0",
"description": "TypeScript friendly HTTP client wrapper for the browser and node.js",

@@ -5,0 +5,0 @@ "author": "m-mitsuhide <m.mitsuhide@amatelus.com>",

@@ -193,2 +193,3 @@ | aspida | [aspida-mock] | [openapi2aspida] | [pathpida] |

```
### Read more posts by DEV Community

@@ -205,2 +206,48 @@

## Command Line Interface Options
<table>
<thead>
<tr>
<th>Option</th>
<th>Type</th>
<th>Default</th>
<th width="100%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td nowrap><code>--build</code><br /><code>-b</code></td>
<td></td>
<td></td>
<td>
Generate <code>$api.ts</code> required for
aspida routing.
</td>
</tr>
<tr>
<td nowrap><code>--config</code><br /><code>-c</code></td>
<td><code>string</code></td>
<td><code>"aspida.config.js"</code></td>
<td>Specify the path to the configuration file.</td>
</tr>
<tr>
<td nowrap><code>--watch</code><br /><code>-w</code></td>
<td></td>
<td></td>
<td>
Enable watch mode.<br />
Regenerate <code>$api.ts</code> according to
the increase / decrease of the API endpoint file.
</td>
</tr>
<tr>
<td nowrap><code>--version</code><br /><code>-v</code></td>
<td></td>
<td></td>
<td>Print aspida version.</td>
</tr>
</tbody>
</table>
## Tips

@@ -207,0 +254,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc