yxlolxy-open-api
TypeScript icon, indicating that this package has built-in type declarations

1.3.7 • Public • Published

yxlolxy-open-api

✨ Features

  • 🏁 Published with es modules
  • ⚽ Support gitee api
  • ⚾ Support github api
  • ⛄ Support gaode weather api
  • 🎓 Other useful tool,such as date, base64, dom, etc.

🔨 Install

yarn add yxlolxy-open-api
# Or with npm:
npm i yxlolxy-open-api

🍴 Import

1. full import

import { xxx } from 'yxlolxy-open-api';

2. partial import

import xxx from 'yxlolxy-open-api/dist/third-party/yyy';

🔧 Usage

1. prepare to use gitee/github/gd api

import axios from "axios";
import { request, gitee, github, gd } from "yxlolxy-open-api";

const TOKEN = 'xxxxyyyyzzzzz'; // your personal access tokens
const USERNAME = 'username'; // your github/gitee account name
const REPONAME = 'repoName'; // your github/gitee repo name
const client = request.initAxiosInterceptors(axios); // optional,your can use your own interceptors
const GDKEY = '1231321321'; // gaode api access key
const giteeFetch = new gitee.Fetcher(client, TOKEN, USERNAME, REPO, isDev());
const githubFetch = new github.Fetcher(client, TOKEN, USERNAME, REPO, isDev());

const gdFetch = new gd.Fetcher(client, GDKEY, isDev())
export {giteeFetch, githubFetch, gdFetch}; // import anywhere you need
...

2. gitee api list

// get content of a repo file, sunch as /test/a.json, add content to the repo file or update、delete
getContent(filenameWithPath?: string): Promise<any>;
addContent(filenameWithPath: string, content: string): Promise<any>;
updateContent(filenameWithPath: string, content: string, sha: string): Promise<any>;
deleteContent(filenameWithPath: string, sha: string): Promise<any>;

// get all labels of your repo
getLabels(): Promise<any>;
// get issues of your repo
getIssues(page: number, per_page: number, labels?: string[], sort?: 'updated' | 'created'): Promise<any>;
// get issue detail
getIssue(number: string): Promise<any>;
// parse gitee markdown
parseMarkdown(text: string): Promise<any>;
...
// more detail can be viewed in node_modules\yxlolxy-open-api\types\third-party\gitee.d.ts

3. github api list

// base64 encode
// get content of a repo file, sunch as /test/a.json, add content to the repo file or update、delete
getContent(filenameWithPath?: string): Promise<any>;
addContent(filenameWithPath: string, content: string, encode?: boolean): Promise<any>;
updateContent(filenameWithPath: string, content: string, sha: string, encode?: boolean): Promise<any>;
deleteContent(filenameWithPath: string, sha: string): Promise<any>;
...
// give it up because of CN firewall!!!

4. gaode api list

// get gaode location
locateByIp(): Promise<any>;
// get live weather data
getWeather(adcode: string): Promise<any>;
// more api to be continued

5. other api

// these apis list in node_modules\yxlolxy-open-api\types\utils
// get days of some month, such as 1 31
function getMonthDays(year: number, month: number): number;
// get the week day of some month's first day
function getFirstWeekday(year: number, month: number): number;
// get weekday array of some month
function getMonthDayArr(year: number, month: number): string[][];
// get weekday array of current month
function getCurMonthDayArr(): string[][];
// get datastr yyyy-MM-dd HH:mm:ss
function getDateTimeStr(str?: string): string;
// rt
function isBeforenoon(str?: string): boolean;
...
// more chek yourself

📞 Contact With Me

Email: yxlolxy@qq.com

enjoy it! 🍎🍎🍎

Package Sidebar

Install

npm i yxlolxy-open-api

Weekly Downloads

9

Version

1.3.7

License

ISC

Unpacked Size

53.8 kB

Total Files

40

Last publish

Collaborators

  • yxlolxy