jsapi-torchiodev.com
Typescript/Javascript API to access personal data of my own.
Dara from api.torchiodev.com. Used in torchiodev.com.
Typescript files in src folder.
index.ts exports every module.
Mirrorred Javascript generated in dist folder
package.main points to dist/index, exporting all files
Procedure:
- Import Api
- Create fetcher instance
- Set authorization
- Create api instance
- Call methods
let fetcher = new DirectusFetcher('http://api.address.com')
.setAuthorizationHeader('Bearer fdafdsa453')
let api = new Api(fetcher )
.getAppInfo()
.then(appinfo => console.dir(appinfo));
Methods - fetch(ModelName)
- getAppInfo(): Promise;
- getAbout(): Promise;
- getWorks(): Promise<Work[]>;
- getServices(): Promise<Service[]>;
- getExperiences(): Promise<Experience[]>;
- getSkills(): Promise<Skill[]>;
- getEducations(): Promise<Education[]>;
- getLanguages(): Promise<Language[]>;
- getSocials(): Promise<Social[]>;
Fetcher methods (get fetcher back in api.getFetcher())
- getApiUrl():string;
- getBaseUrl(): string;
- setApiUrl(apiUrl: string);
- setBaseUrl(baseUrl: string);
- setAuthorizationHeader(token:string): IFetcher;
Models
AppInfo
title: string;
contact_email: string;
main_image: Image;
logo: Image;
About
avatar_image: Image;
cover_letter: string;
Work
title: string;
url: string;
date: string;
info: string;
thumbnail: Image;
color: string;
Vue plugin
- import property 'vuePlugin' as torchioapi
- options baseUrl is required
Vue.use(torchioapi, {
baseUrl: 'https://api.torchiodev.com',
authentication: 'bearer hu5i432higfd...',
propertyName: 'whateverYouWant' // makes accessible in this.$whateverYouWant
});