GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - xivapi/angular-client: xivapi client library (service and models) for angular applications

BranchesTags
Open more actions menu

Latest commit

 

History

140 Commits
140 Commits

Folders and files

NameName
Last commit message
Last commit date
.circleci
.circleci
 
 
.vscode
.vscode
 
 
projects/angular-client
projects/angular-client
 
 
scripts
scripts
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.npmrc
.npmrc
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
angular.json
angular.json
 
 
package.json
package.json
 
 
tsconfig.doc.json
tsconfig.doc.json
 
 
tsconfig.json
tsconfig.json
 
 
yarn.lock
yarn.lock
 
 

Repository files navigation

angular-client

CircleCI npm version

Documentation

Visit https://xivapi.com/docs for documentation about the web api mapped by this client.

Further documentation for this library available on documentation website: https://xivapi.github.io/angular-client/

Installation

Simply run npm i --save @xivapi/angular-client

Quick start

Add XivapiClientModule to your AppModule imports:

@NgModule({
    declarations: [
        AppComponent,
    ],
    imports: [
        ...
        XivapiClientModule.forRoot(),        
        ...
    ],
    bootstrap: [AppComponent]
})
export class AppModule {
}

In the other modules, don't call forRoot again, just import the module itself.

Then you can simply inject the service wherever you want to use it:

@Component({
    ...
})
export class FooComponent {
    
    public items$: Observable<XivapiList<any>>;
    
    constructor(private xivapi: XivapiService){
        this.items$ = this.xivapi.getList(XivapiEndpoint.Items);
    }
}

Use with private_key (Google Cloud Function)

  • Create a google cloud function, name it as you want.
  • Insert following code (with your key):
exports.xivapiProxy = (req, res) => {
  let request = require('request');
  const apiKey = '<your api key>>';
  res.set('Access-Control-Allow-Origin', '<your allowed origins>')
     .set('Access-Control-Allow-Headers', 'Content-Type');
  const url = Buffer.from(req.query.url, 'base64').toString();
  request(
    {
      url:`${url}${url.indexOf('?') > -1 ? '&':'?'}private_key=${apiKey}`,
    }, 
    function(error, response, body) {
    let errorBody = JSON.parse(body);
	let errorMessage = errorBody.error || errorBody.message;
    if (error || errorMessage) {
      res.status(400).send(errorMessage || 'Unknown Error');
    } else {
      res.status(200).set('Content-Type', 'application/json').send(body);
    }
  });
};
  • Enable proxy mode inside the api module:
   XivapiClientModule.forRoot('<GCF trigger url>')

Example url: https://us-central1-myproject.cloudfunctions.net/xivapi-proxy

Keep in mind that you can enable it based on the current environment, simply give null as proxy url if environment isn't prod, to use "normal" mode in order to get better debugging when using dev environment.

About

xivapi client library (service and models) for angular applications

Topics

xivapi

Resources

Readme
MIT license
Activity
Custom properties

Stars

4 stars

Watchers

2 watching

Forks

5 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.