Socket
Socket
Sign inDemoInstall

aspida

Package Overview
Dependencies
3
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.20.3 to 0.21.0

dist/createDocComment.d.ts

2

dist/buildTemplate.d.ts
import { AspidaConfig } from './getConfigs';
declare const _default: ({ input, baseURL, trailingSlash, outputEachDir }: AspidaConfig) => {
declare const _default: ({ input, baseURL, trailingSlash, outputEachDir }: AspidaConfig, isFirstBuild: boolean) => {
text: string;

@@ -4,0 +4,0 @@ filePath: string;

@@ -28,18 +28,32 @@ "use strict";

var createTemplateValues_1 = __importDefault(require("./createTemplateValues"));
var createDocComment_1 = __importDefault(require("./createDocComment"));
var getDirentTree_1 = require("./getDirentTree");
var listNotIndexFiles = function (tree) {
return __spread(tree.children
.filter(function (c) { return !c.name.startsWith('_') && !c.isDir && c.name !== 'index.ts'; })
.map(function (c) {
return path_1.default.posix.join(tree.path, c.name) + " -> " + path_1.default.posix.join(tree.path, c.name.replace('.ts', ''), 'index.ts');
}), tree.children
.map(function (c) { return (!c.name.startsWith('_') && c.isDir ? listNotIndexFiles(c.tree) : []); })
.reduce(function (p, c) { return __spread(p, c); }, []));
};
var listNotIndexFiles = function (tree) { return __spread(tree.children
.filter(function (c) { return !c.name.startsWith('_') && !c.isDir && c.name !== 'index.ts'; })
.map(function (c) {
return tree.path + "/\u001B[31m" + c.name + "\u001B[0m -> \u001B[32m" + c.name.replace('.ts', '') + "/index.ts\u001B[0m";
}), tree.children
.map(function (c) { return (!c.name.startsWith('_') && c.isDir ? listNotIndexFiles(c.tree) : []); })
.reduce(function (p, c) { return __spread(p, c); }, [])); };
var listNamedFiles = function (tree) { return __spread(tree.children
.filter(function (c) { return !c.isDir && c.name !== 'index.ts'; })
.map(function (c) {
return tree.path + "/\u001B[31m" + c.name + "\u001B[0m -> \u001B[32m" + c.name.replace('.ts', '') + "/index.ts\u001B[0m";
}), tree.children
.map(function (c) { return (c.isDir ? listNamedFiles(c.tree) : []); })
.reduce(function (p, c) { return __spread(p, c); }, [])); };
var listTypeAliasFiles = function (tree) { return __spread(tree.children
.filter(function (c) { return /_.+@[A-Z]/.test(c.name); })
.map(function (c) {
return tree.path + "/\u001B[31m" + c.name + "\u001B[0m -> \u001B[32m" + c.name.replace(/@.+?(.ts|$)/, '@{number|string}$1') + "\u001B[0m";
}), tree.children
.map(function (c) { return (c.isDir ? listTypeAliasFiles(c.tree) : []); })
.reduce(function (p, c) { return __spread(p, c); }, [])); };
var createTemplate = function (tree, baseURL, trailingSlash, basePath) {
var _a = createTemplateValues_1.default(tree, basePath, trailingSlash), api = _a.api, imports = _a.imports, pathes = _a.pathes;
var text = ("/* eslint-disable */\nimport { AspidaClient" + (api.includes('BasicHeaders') ? ', BasicHeaders' : '') + " } from 'aspida'\n<% types %><% imports %>\n" + ['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'PATCH', 'OPTIONS']
var _a;
var _b = createTemplateValues_1.default(tree, basePath, trailingSlash), api = _b.api, imports = _b.imports, pathes = _b.pathes;
var text = ("/* eslint-disable */\nimport { AspidaClient" + (api.includes('BasicHeaders') ? ', BasicHeaders' : '') + (api.includes('dataToURLString') ? ', dataToURLString' : '') + " } from 'aspida'\n<% types %><% imports %>\n\n" + createDocComment_1.default('', (_a = tree.children.find(function (c) { return !c.isDir && c.name === 'index.ts'; })) === null || _a === void 0 ? void 0 : _a.doc) + "const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {\n const prefix = (baseURL === undefined ? '<% baseURL %>' : baseURL).replace(/\\/$/, '')\n" + pathes.map(function (p, i) { return " const PATH" + i + " = " + p; }).join('\n') + "\n" + ['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'PATCH', 'OPTIONS']
.filter(function (m) { return api.includes(", " + m + ", option"); })
.map(function (m) { return "\nconst " + m + " = '" + m + "'"; })
.join('') + pathes.map(function (p, i) { return "\nconst PATH" + i + " = " + p; }).join('') + "\nconst api = <T>({ baseURL, fetch }: AspidaClient<T>) => {\n const prefix = (baseURL === undefined ? '<% baseURL %>' : baseURL).replace(/\\/$/, '')\n\n return <% api %>\n}\n\nexport type ApiInstance = ReturnType<typeof api>\nexport default api\n")
.map(function (m) { return " const " + m + " = '" + m + "'"; })
.join('\n') + "\n\n return <% api %>\n}\n\nexport type ApiInstance = ReturnType<typeof api>\nexport default api\n")
.replace('<% types %>', api.includes(': ApiTypes.')

@@ -58,3 +72,3 @@ ? "import * as ApiTypes from '" + (basePath

};
exports.default = (function (_a) {
exports.default = (function (_a, isFirstBuild) {
var input = _a.input, baseURL = _a.baseURL, trailingSlash = _a.trailingSlash, outputEachDir = _a.outputEachDir;

@@ -66,3 +80,3 @@ var direntTree = getDirentTree_1.getDirentTree(input);

if (notIndexFiles.length) {
console.error("Error on aspida: Since true is specified in outputEachDir at aspida.config.js, you need to rename the following files\n" + notIndexFiles.join('\n') + "\n");
console.log("aspida \u001B[43m\u001B[31mERROR\u001B[0m Since true is specified in outputEachDir at aspida.config.js, you need to rename the following files\n " + notIndexFiles.join('\n '));
return [];

@@ -80,4 +94,14 @@ }

}
if (isFirstBuild) {
var namedFiles = listNamedFiles(direntTree);
var typeAliasFiles = listTypeAliasFiles(direntTree);
if (namedFiles.length) {
console.log("aspida \u001B[43m\u001B[30mWARN\u001B[0m {endpoint}.ts format is deprecated. Please rename the following files\n " + namedFiles.join('\n '));
}
if (typeAliasFiles.length) {
console.log("aspida \u001B[43m\u001B[30mWARN\u001B[0m {endpoint}@{Type Alias}.ts format is deprecated. Please rename the following names\n " + typeAliasFiles.join('\n '));
}
}
return templates;
});
//# sourceMappingURL=buildTemplate.js.map
import { getConfigs, AspidaConfig } from './getConfigs';
export { parse } from './parseInterface';
export { getConfigs, AspidaConfig };

@@ -4,0 +3,0 @@ export declare const version: () => string;

@@ -12,14 +12,14 @@ "use strict";

var watchInputDir_1 = __importDefault(require("./watchInputDir"));
var parseInterface_1 = require("./parseInterface");
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parseInterface_1.parse; } });
exports.version = function () { return require('../package.json').version; };
exports.build = function (config) {
return getConfigs_1.getConfigs(config).flatMap(buildTemplate_1.default).forEach(writeRouteFile_1.default);
return getConfigs_1.getConfigs(config)
.flatMap(function (c) { return buildTemplate_1.default(c, true); })
.forEach(writeRouteFile_1.default);
};
exports.watch = function (config) {
return getConfigs_1.getConfigs(config).map(function (c) {
buildTemplate_1.default(c).forEach(writeRouteFile_1.default);
return watchInputDir_1.default(c.input, function () { return buildTemplate_1.default(c).forEach(writeRouteFile_1.default); });
buildTemplate_1.default(c, true).forEach(writeRouteFile_1.default);
return watchInputDir_1.default(c.input, function () { return buildTemplate_1.default(c, false).forEach(writeRouteFile_1.default); });
});
};
//# sourceMappingURL=commands.js.map
"use strict";
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var createDocComment_1 = __importDefault(require("./createDocComment"));
exports.default = (function (methods, indent, importName, path) {
return methods
.map(function (_a) {
var name = _a.name, props = _a.props;
return __spread(methods.map(function (_a) {
var name = _a.name, props = _a.props, doc = _a.doc;
var isOptionRequired = (props.query && !props.query.hasQuestion) ||

@@ -59,6 +82,21 @@ (props.reqBody && !props.reqBody.hasQuestion) ||

];
return indent + " " + name + ": " + tmpChanks[0] + "\n" + indent + " " + tmpChanks[1] + ",\n" + indent + " $" + name + ": " + tmpChanks[0] + "\n" + indent + " " + tmpChanks[1] + ".then(r => r.body)";
})
.join(',\n');
return "" + createDocComment_1.default(indent + " ", doc, props) + indent + " " + name + ": " + tmpChanks[0] + "\n" + indent + " " + tmpChanks[1] + ",\n" + createDocComment_1.default(indent + " ", doc, props) + indent + " $" + name + ": " + tmpChanks[0] + "\n" + indent + " " + tmpChanks[1] + ".then(r => r.body)";
}), [
methods.filter(function (_a) {
var props = _a.props;
return props.query;
}).length
? indent + " $path: (option?: " + methods
.filter(function (_a) {
var props = _a.props;
return props.query;
})
.map(function (_a) {
var name = _a.name;
return "{ method" + (name === 'get' ? '?' : '') + ": '" + name + "'; query: " + importName + "['" + name + "']['query'] }";
})
.join(' | ') + ") =>\n" + indent + " `${prefix}${" + (path.startsWith('`') ? path.slice(3, -2) : path) + "}${option?.query ? `?${dataToURLString(option.query)}` : ''}`"
: indent + " $path: () => `${prefix}${" + (path.startsWith('`') ? path.slice(3, -2) : path) + "}`"
]).join(',\n');
});
//# sourceMappingURL=createMethodsString.js.map

@@ -22,10 +22,10 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var path_1 = __importDefault(require("path"));
var createMethodsString_1 = __importDefault(require("./createMethodsString"));
var createDocComment_1 = __importDefault(require("./createDocComment"));
exports.default = (function (direntTree, basePath, trailingSlash) {
var imports = [];
var pathes = [];
var getMethodsString = function (file, methods, indent, newPrefix, newUrl) {
var getMethodsString = function (filepath, methods, indent, newPrefix, newUrl) {
var importName = "Methods" + imports.length;
imports.push("import { Methods as " + importName + " } from '" + file.replace(/'/g, "\\'") + "'");
imports.push("import { Methods as " + importName + " } from '" + filepath.replace(/'/g, "\\'") + "'");
var newPath = "'" + newUrl + (trailingSlash ? '/' : '') + "'";

@@ -43,6 +43,6 @@ if (newPath.length > 2) {

.map(function (dirent) {
var _a;
var file = dirent.name;
var basename = path_1.default.basename(file, '.ts');
var hasVal = file.startsWith('_');
var _a, _b;
var filename = dirent.name;
var basename = dirent.isDir ? filename : filename.replace(/\.ts$/, '');
var hasVal = filename.startsWith('_');
var valFn = "" + indent + basename

@@ -54,3 +54,3 @@ .replace(/[^a-zA-Z0-9$_]/g, '_')

if (hasVal) {
var _b = __read(basename.split('@'), 2), valName_1 = _b[0], _c = _b[1], valType = _c === void 0 ? 'number | string' : _c;
var _c = __read(basename.split('@'), 2), valName_1 = _c[0], _d = _c[1], valType = _d === void 0 ? 'number | string' : _d;
if (/^[A-Z]/.test(valType)) {

@@ -70,9 +70,9 @@ valType = "ApiTypes." + valType;

if (dirent.isDir) {
var methodsOfIndexTsFile_1 = (_a = tree.children.find(function (c) { return c.name === file + ".ts"; })) !== null && _a !== void 0 ? _a : dirent.tree.children.find(function (c) { return c.name === 'index.ts'; });
return createApiString(dirent.tree, importBasePath + "/" + file, "" + indent + (hasVal ? ' ' : '') + " ", newPrefix, newUrl, valFn.replace('<% next %>', '<% props %>'), (methodsOfIndexTsFile_1 === null || methodsOfIndexTsFile_1 === void 0 ? void 0 : methodsOfIndexTsFile_1.isDir) === false
? getMethodsString(importBasePath + "/" + file, methodsOfIndexTsFile_1.methods, "" + indent + (hasVal ? ' ' : ''), newPrefix, newUrl)
var methodsOfIndexTsFile_1 = (_a = tree.children.find(function (c) { return c.name === filename + ".ts"; })) !== null && _a !== void 0 ? _a : dirent.tree.children.find(function (c) { return c.name === 'index.ts'; });
return createApiString(dirent.tree, importBasePath + "/" + filename, "" + indent + (hasVal ? ' ' : '') + " ", newPrefix, newUrl, "" + createDocComment_1.default(indent, (_b = methodsOfIndexTsFile_1) === null || _b === void 0 ? void 0 : _b.doc) + valFn.replace('<% next %>', '<% props %>'), (methodsOfIndexTsFile_1 === null || methodsOfIndexTsFile_1 === void 0 ? void 0 : methodsOfIndexTsFile_1.isDir) === false
? getMethodsString(importBasePath + "/" + filename, methodsOfIndexTsFile_1.methods, "" + indent + (hasVal ? ' ' : ''), newPrefix, newUrl)
: undefined);
}
else if (file !== 'index.ts' && tree.children.every(function (d) { return d.name !== basename; })) {
return valFn.replace('<% next %>', getMethodsString(importBasePath + "/" + basename, dirent.methods, "" + indent + (hasVal ? ' ' : ''), newPrefix, newUrl));
else if (filename !== 'index.ts' && tree.children.every(function (d) { return d.name !== basename; })) {
return "" + createDocComment_1.default(indent, dirent.doc) + valFn.replace('<% next %>', getMethodsString(importBasePath + "/" + basename, dirent.methods, "" + indent + (hasVal ? ' ' : ''), newPrefix, newUrl));
}

@@ -79,0 +79,0 @@ })

@@ -1,6 +0,7 @@

import { Method } from './parseInterface';
declare type FileData = {
import { Doc, Method } from './parseInterface';
export declare type FileData = {
name: string;
isDir: false;
methods: Method[];
doc?: Doc;
};

@@ -7,0 +8,0 @@ declare type DirData = {

@@ -23,9 +23,14 @@ "use strict";

else if (dirent.name.endsWith('.ts')) {
var methods = parseInterface_1.parse(fs_1.default.readFileSync(input + "/" + dirent.name, 'utf8'), 'Methods');
if (!methods || methods.every(function (_a) {
var value = parseInterface_1.parse(fs_1.default.readFileSync(input + "/" + dirent.name, 'utf8'), 'Methods');
if (!(value === null || value === void 0 ? void 0 : value.methods.some(function (_a) {
var props = _a.props;
return !Object.keys(props).length;
}))
return Object.keys(props).length;
})))
return;
tree.children.push({ name: dirent.name, isDir: false, methods: methods });
tree.children.push({
name: dirent.name,
isDir: false,
methods: value.methods,
doc: value.doc
});
}

@@ -32,0 +37,0 @@ });

@@ -6,9 +6,15 @@ import { LowerHttpMethod, AspidaMethodParams } from './';

hasQuestion: boolean;
doc?: Doc;
};
export declare type Doc = string[];
export declare type Method = {
name: LowerHttpMethod;
props: Partial<Record<MethodsProperties, Prop>>;
doc?: Doc;
};
export declare const parse: (text: string, name: string) => Method[] | null;
export declare const parse: (text: string, name: string) => {
methods: Method[];
doc?: Doc | undefined;
} | null;
export {};
//# sourceMappingURL=parseInterface.d.ts.map

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

while (cursor < length) {
var _a = __read(text.slice(cursor), 2), first = _a[0], second = _a[1];
var _a = __read(text.slice(cursor), 3), first = _a[0], second = _a[1], third = _a[2];
if (isLineComment) {

@@ -81,3 +81,3 @@ if (first === '\n') {

else if (isMultiComment) {
if (first === '*' && second === '/') {
if ("" + first + second === '*/') {
cursor += 1;

@@ -87,11 +87,13 @@ isMultiComment = false;

}
else if (first === '/') {
if (second === '/') {
isLineComment = true;
}
else {
isMultiComment = true;
}
else if ("" + first + second + third === '/**') {
break;
}
else if ("" + first + second === '//') {
isLineComment = true;
cursor += 1;
}
else if ("" + first + second === '/*') {
isMultiComment = true;
cursor += 1;
}
else if (/[^ \r\n;,]/.test(first)) {

@@ -104,2 +106,14 @@ break;

};
var parseDoc = function (text) {
if (!text.startsWith('/**'))
return;
var endsIndex = text.indexOf('*/') + 2;
return {
values: text
.split(/(\r?\n? +)?\*\//)[0]
.replace(/^\/\*\*(\r?\n +\*)? ?/, '')
.split(/\r?\n +\* ?/),
length: endsIndex + countIgnored(text.slice(endsIndex))
};
};
var parseTypeName = function (text) {

@@ -142,6 +156,11 @@ var length = text.length;

var parseProp = function (text) {
var cursor = 0;
var doc = parseDoc(text);
if (doc) {
cursor += doc.length;
}
var length = text.length;
var name = parseName(text);
var prop = { value: '', hasQuestion: name.hasQuestion };
var cursor = name.length;
var name = parseName(text.slice(cursor));
var prop = { value: '', hasQuestion: name.hasQuestion, doc: doc === null || doc === void 0 ? void 0 : doc.values };
cursor += name.length;
while (cursor < length) {

@@ -181,5 +200,10 @@ cursor += countIgnored(text.slice(cursor));

var parseMethod = function (text) {
var cursor = 0;
var doc = parseDoc(text);
if (doc) {
cursor += doc.length;
}
var length = text.length;
var methodName = parseName(text);
var cursor = methodName.length;
var methodName = parseName(text.slice(cursor));
cursor += methodName.length;
var props = {};

@@ -194,3 +218,6 @@ cursor += countIgnored(text.slice(cursor)) + 1; // '{'

cursor += 1; // '}'
return { value: { name: methodName.value, props: props }, length: cursor };
return {
value: { name: methodName.value, props: props, doc: doc === null || doc === void 0 ? void 0 : doc.values },
length: cursor
};
};

@@ -212,9 +239,16 @@ var parseMethods = function (text) {

exports.parse = function (text, name) {
var interfaceRegExp = new RegExp("(^|\n)export (interface " + name + "|type " + name + " ?=) ?{");
var _a;
var interfaceRegExp = new RegExp("(^|\r?\n)export (interface " + name + "|type " + name + " ?=) ?{");
if (!interfaceRegExp.test(text))
return null;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
var methods = parseMethods(text.split(interfaceRegExp).pop());
return methods.length ? methods : null;
var _b = __read(text.split(interfaceRegExp)), d = _b[0], m = _b.slice(1);
var methods = parseMethods(m[m.length - 1]);
return methods.length
? {
methods: methods,
doc: /\/\*\*[\s\S]+\*\/$/.test(d)
? (_a = parseDoc(d.slice(d.lastIndexOf('/**')))) === null || _a === void 0 ? void 0 : _a.values : undefined
}
: null;
};
//# sourceMappingURL=parseInterface.js.map
{
"name": "aspida",
"version": "0.20.3",
"version": "0.21.0",
"description": "TypeScript friendly HTTP client wrapper for the browser and node.js",

@@ -5,0 +5,0 @@ "author": "Solufa <solufa2020@gmail.com>",

@@ -1,10 +0,5 @@

| aspida | [aspida-mock] | [@aspida/axios] | [@aspida/ky] | [@aspida/fetch] | [@aspida/node-fetch] |
| ------ | ------------- | --------------- | ------------ | --------------- | -------------------- |
# aspida
<br />
<br />
<br />
<br />
<br />
<div align="center">

@@ -68,3 +63,2 @@ <img src="https://aspida.github.io/aspida/logos/svg/black.svg" alt="aspida" title="aspida" width="600" />

- HTTP client supports axios / ky / ky-universal / fetch / node-fetch
- Path definition is the same naming convention as Nuxt.js pages

@@ -213,8 +207,8 @@ <br />

### Learn more about HTTP clients
### aspida official HTTP clients
- **[aspida-axios](https://github.com/aspida/aspida/tree/develop/packages/aspida-axios#readme)**
- **[aspida-ky](https://github.com/aspida/aspida/tree/develop/packages/aspida-ky#readme)**
- **[aspida-fetch](https://github.com/aspida/aspida/tree/develop/packages/aspida-fetch#readme)**
- **[aspida-node-fetch](https://github.com/aspida/aspida/tree/develop/packages/aspida-node-fetch#readme)**
- **[@aspida/axios](https://github.com/aspida/aspida/tree/master/packages/aspida-axios#readme)**
- **[@aspida/ky](https://github.com/aspida/aspida/tree/master/packages/aspida-ky#readme)**
- **[@aspida/fetch](https://github.com/aspida/aspida/tree/master/packages/aspida-fetch#readme)**
- **[@aspida/node-fetch](https://github.com/aspida/aspida/tree/master/packages/aspida-node-fetch#readme)**

@@ -303,2 +297,16 @@ ## Command Line Interface Options

1. [Change the directory where type definition file is placed to other than "api"](#tips1)
1. [Serialize GET parameters manually](#tips2)
1. [POST with FormData](#tips3)
1. [POST with URLSearchParams](#tips4)
1. [Receive response with ArrayBuffer](#tips5)
1. [Convert from OpenAPI / Swagger](#tips6)
1. [Define endpoints that contain special characters](#tips7)
1. [Import only some endpoints](#tips8)
1. [Retrieve endpoint URL string](#tips9)
1. [Reflect TSDoc comments](#tips10)
1. [Use mock](#tips11)
<a id="tips1"></a>
### Change the directory where type definition file is placed to other than "api"

@@ -329,2 +337,4 @@

<a id="tips2"></a>
### Serialize GET parameters manually

@@ -357,2 +367,4 @@

<a id="tips3"></a>
### POST with FormData

@@ -400,2 +412,4 @@

<a id="tips4"></a>
### POST with URLSearchParams

@@ -437,2 +451,4 @@

<a id="tips5"></a>
### Receive response with ArrayBuffer

@@ -469,2 +485,4 @@

<a id="tips6"></a>
### Convert from OpenAPI / Swagger

@@ -483,2 +501,4 @@

<a id="tips7"></a>
### Define endpoints that contain special characters

@@ -515,2 +535,4 @@

<a id="tips8"></a>
### Import only some endpoints

@@ -548,2 +570,107 @@

<a id="tips9"></a>
### Retrieve endpoint URL string
`src/index.ts`
```ts
import aspida from "@aspida/axios"
import api from "../api/$api"
;(async () => {
const client = api(aspida())
console.log(client.v1.users.$path())
// /v1/users
console.log(client.vi.users.$path({ query: { limit: 10 } }))
// /v1/users?limit=10
console.log(client.vi.users.$path({
method: 'post',
query: { id: 1 }
}))
// /v1/users?id=1
})()
```
<a id="tips10"></a>
### Reflect TSDoc comments
`api/index.ts`
```ts
/**
* root comment
*
* @remarks
* root remarks comment
*/
export type Methods = {
/**
* post method comment
*
* @remarks
* post method remarks comment
*/
post: {
/** post query comment */
query: { limit: number }
/** post reqHeaders comment */
reqHeaders: { token: string }
reqFormat: FormData
/** post reqBody comment */
reqBody: UserCreation
/**
* post resBody comment1
* post resBody comment2
*/
resBody: User
}
}
```
```sh
$ npm run api:build
```
`api/$api.ts`
```ts
/**
* root comment
*
* @remarks
* root remarks comment
*/
const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
return {
/**
* post method comment
*
* @remarks
* post method remarks comment
*
* @param option.query - post query comment
* @param option.headers - post reqHeaders comment
* @param option.body - post reqBody comment
* @returns post resBody comment1
* post resBody comment2
*/
$post: (option: { body: Methods0['post']['reqBody'], query: Methods0['post']['query'], headers: Methods0['post']['reqHeaders'], config?: T }) =>
fetch<Methods0['post']['resBody']>(prefix, PATH0, POST, option).json().then(r => r.body)
}
}
```
<a id="tips11"></a>
### Use mock
**[GitHub aspida/aspida-mock](https://github.com/aspida/aspida-mock)**
## Support

@@ -558,7 +685,1 @@

aspida is licensed under a [MIT License](https://github.com/aspida/aspida/blob/master/packages/aspida/LICENSE).
[aspida-mock]: https://github.com/aspida/aspida/tree/master/packages/aspida-mock
[@aspida/axios]: https://github.com/aspida/aspida/tree/master/packages/aspida-axios
[@aspida/ky]: https://github.com/aspida/aspida/tree/master/packages/aspida-ky
[@aspida/fetch]: https://github.com/aspida/aspida/tree/master/packages/aspida-fetch
[@aspida/node-fetch]: https://github.com/aspida/aspida/tree/master/packages/aspida-node-fetch

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

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc