# ng4-engine

> ## Installation

Latest version **0.0.27** (published 2017-10-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install ng4-engine
pnpm add ng4-engine
yarn add ng4-engine
bun add ng4-engine
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.27 |
| Published | 2017-10-02 |
| First published | 2017-07-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=6.0.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Adrian Etter |
| Maintainers | eydrian |
| Keywords | angular4, APIService, Authentication, Storage |

## Links

- npm: https://www.npmjs.com/package/ng4-engine
- Repository: https://econgit.uzh.ch/engineering/ng4-engine
- Issues: https://econgit.uzh.ch/engineering/ng4-engine/issues
- npm.io page: https://npm.io/package/ng4-engine

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 0.0.27 (latest) — 2017-10-02
- 0.0.25 — 2017-10-02
- 0.0.15 — 2017-07-25

## README

# ng4-engine

## Installation

To install this library:

```bash
$ git clone git@econgit.uzh.ch:engineering/ng4-engine.git
$ cd ng4-engine && npm run pack
$ cd /your/project/path 
$ cp ../path/to/survey-component-library/ng4-engine-0.0.0.tgz .
$ npm install ng4-engine-0.0.11.tgz
```

## Installation

1. Install the npm package.

    ```
    git clone git@econgit.uzh.ch:engineering/ng4-engine.git
    cd ng4-engine && npm run pack
    $ cd /your/project/path 
    $ cp ../path/to/survey-component-library/ng4-engine-0.0.0.tgz .
    $ npm install ng4-engine-0.0.11.tgz
    # Not: version might change => 0.0.4
    ```
        
2. Import the things you need in your application and use configuration to configure providers :

    ```
    import { EnvironmentsModule } from '../environments/environment.module';
    import {
      ConfigurationService,
      APIService,
      AuthenticationService,
      LocalStorageService,
      BroadcastService,
      MenuProvider
    } from 'ng4-engine';
     
    @NgModule({
        imports:      [ BrowserModule],
        providers: [
          ConfigurationService,
          BroadcastService,
          AuthenticationService,
          APIService,
          LocalStorageService,
        ],
        declarations: [ AppComponent ],
        bootstrap:    [ AppComponent ]
    })
    export class AppModule { } 
    ```

3. Create the environment module

        ```
        //../environments/environment.module
        import { NgModule } from '@angular/core';
        import { environment as devVariables } from './environment.dev';
        import { environment as testVariables } from './environment.test';
        import { environment as prodVariables } from './environment.prod';



        export function environmentFactory() {
          const location = window.location.host.split('.')[0];
          switch (location) {
            case 'www': {
              return prodVariables;
            }
            case 'test': {
              return testVariables;
            }
            case '': {
              if (window.location.origin === 'file://') {
                return testVariables;
              }
              break;
            }
            default: {
              return devVariables;
            }
          }
          
        }

        @NgModule({
          providers: [
            {
              provide: 'configuration',
              useFactory: environmentFactory
            }
          ]
        })
        export class EnvironmentsModule {}
        ```

## Usage of API Service

Inherit API Service in your services :
 
  ```
  import {
    APIService,
    User
  } from 'ng4-engine';

  @Injectable()
  export class UserService  extends APIService {
    private user: User;
    protected url = 'users/';

    get(q?: any) {
      let params: URLSearchParams = new URLSearchParams(q ? `q=${ q }` : '');
      return super.get(params);
    }
  }
  ```

## Development

To generate all `*.js`, `*.d.ts` and `*.metadata.json` files:

```bash
$ npm run build
```

To lint all `*.ts` files:

```bash
$ npm run lint
```

## License

MIT © [Adrian Etter](mailto:adrian.etter@econ.uzh.ch)

---
_Source: https://npm.io/package/ng4-engine · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
