ng-aqueduct
TypeScript icon, indicating that this package has built-in type declarations

0.0.10 • Public • Published

NgAqueduct library

Provides connection between Angular (7+) and Laravel (Laravel Helpers)

Installation

npm i ng-aqueduct --save

Set config and add NgAqueductModule into AppModule.

const environmentConfig = {
  url: 'https://api.site.com',
  domains: ['api.site.com']
};

@NgModule({
  ...
  imports: [
    ...
    NgAqueductModule.forRoot(environmentConfig),
    ...
  ],
})

How to use

If you are planning to use Aqueduct into service just extends service from the ApiService

import { ApiService, RequestTypes } from 'ng-aqueduct';

@Injectable({
  providedIn: 'root'
})
export class MyService extends ApiService<MyInterface> {

}

Note! An interface MyInterface must contains id field or extends from the ApiEntity interface. It neccessary for working with update/get methods.

Now you can use all CRUD methods. Read detailed information in documentation about requests and responses.

export class MyComponent {
 constructor(
    private myService: MyService,
  ) { }


  addAction(data: MyInterface) {
    this.myService
      .add(data)
      .then(response => {
        ...
      });
  }

  getAction(id: string | number) {
    this.myService
      .get(id)
      .then(response => {
        ...
      });
  }

  updateAction(id: number, status: bool) {
    const data = {
        id: id,
        status: status
    };

    this.myService
      .update(data)
      .then(response => {
        ...
      });
  }

  anotherUpdateAction(data: MyInterface) {
    this.myService
      .update(data)
      .then(response => {
        ...
      });
  }

  deleteAction(id: string | number) {
    this.myService
      .delete(id)
      .then(response => {
        ...
      });
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i ng-aqueduct

Weekly Downloads

0

Version

0.0.10

License

none

Unpacked Size

696 kB

Total Files

82

Last publish

Collaborators

  • wills0n