@batlify/mscms-api-nextjs
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-dev2 • Public • Published

MSCMS2 API Library

Installation

npm:

npm i @batlify/mscms-api-nextjs

yarn:

yarn add @batlify/mscms-api-nextjs

pnpm:

pnpm add @batlify/mscms-api-nextjs

Example of usage

import { Auth, User } from '@batlify/mscms-api-nextjs';

class Test {
    protected auth: Auth;
    protected user: User;

    constructor() {
        this.auth = new Auth();
        this.user = new User();
    }

    async login(type: string, username: string) {
        try {
            const r = await this.auth.login(type, username);
            return r;
        } catch (error) {
            throw error;
        }
    }

    async fetchUser() {
        try {
            const userData = await this.user.get();
            return userData;
        } catch (error) {
            throw error;
        }
    }
}

const test = new Test();

(async () => {
    try {
        await test.login('classic', 'sxagondev')
            .then((r) => {
                if (r.status === 'success') {
                    console.log('Login successful');
                    test.fetchUser()
                        .then((r) => {
                            console.log('Fetched user data:', r);
                        })
                } else if (r.status === 'banned') {
                    console.log('You are banned from this store');
                } else {
                    console.log('An error occurred:', r);
                }
            });
    } catch (e) {
        console.error('An error occurred:', e);
    }
})();

IMPORTANT

This library is a ~complete "backend" for MineStoreCMS v3 theme/frontend. It already stores the authorization token and all important data in cookies itself. So there is no need to solve anything, as the library will do 80% of the work for you. All you have to do is design and develop the frontend design.

Docs: https://minestorev3-api.ci.batlify.com/

License

MIT © Michal "Sxagon" Lipka

Package Sidebar

Install

npm i @batlify/mscms-api-nextjs

Weekly Downloads

9

Version

1.0.0-dev2

License

MIT

Unpacked Size

43.7 kB

Total Files

68

Last publish

Collaborators

  • batlifyuser