Namespace Pollution Mechanism

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

    1.2.9 • Public • Published

    yxlolxy-open-api

    Features

    • 🏁 Published with es modules and commonjs
    • 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

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

    🔧 Usage

    1. prepare to use gitee/github/gd api

    import axios from "axios";
    import { yxl_request, yxl_gitee, yxl_github, yxl_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 = yxl_request.initAxiosInterceptors(axios); // optional,your can use your own interceptors
    const GDKEY = '1231321321'; // gaode api access key
    const giteeFetch = new yxl_gitee.Fetcher(client, TOKEN, USERNAME, REPO, isDev());
    const githubFetch = new yxl_github.Fetcher(client, TOKEN, USERNAME, REPO, isDev());
    
    const gdFetch = new yxl_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

    enjoy it! 🍎🍎🍎

    Install

    npm i yxlolxy-open-api

    DownloadsWeekly Downloads

    6

    Version

    1.2.9

    License

    ISC

    Unpacked Size

    173 kB

    Total Files

    77

    Last publish

    Collaborators

    • yxlolxy