Skip to content

Instantly share code, notes, and snippets.

View henryruhs's full-sized avatar

Henry Ruhs henryruhs

View GitHub Profile
import { environmentHelper } from '../../../src/environments/environment';
const environment = environmentHelper(Cypress.env('APP_ENV'));
Cypress.Commands.add('pingApiUrl', () =>
{
cy.request('HEAD', environment.apiUrl);
});
Cypress.Commands.add('insertTestData', () =>
import environment from '../../../environments/environment';
export default class ExampleService
{
read(id)
{
const url = new URL(environment.apiRoutes.example + '/' + id, environment.apiUrl);
return fetch(url.toString());
}
module.exports =
{
metadata:
{
branch: 'develop',
environment: 'dev'
},
baseUrl: 'http://localhost:3000',
apiUrl: 'http://localhost:8000',
apiRoutes:
export const environmentHelper = environment =>
{
if (environment === 'dev')
{
return require('./environment.dev');
}
if (environment === 'stage')
{
return require('./environment.stage');
}
{
"name": "perfect-environment",
"version": "1.0.0",
"dependencies":
{
"react": "^17",
"react-dom": "^17"
},
"devDependencies":
{
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Options } from './common.interface';
import { Id } from './common.type';
import { RequestBody, ResponseBody } from './example.interface';
import { environment } from '@env';
@Injectable()
import { Component, OnChanges, OnInit } from '@angular/core';
import { ExampleService } from './example.service';
@Component(
{
selector: 'app-example',
styleUrls:
[
'./example.component.css'
],
import { Component, OnChanges, OnInit } from '@angular/core';
import { ExampleService } from './example.service';
@Component(
{
selector: 'app-example',
styleUrls:
[
'./example.component.css'
],
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { CrudService } from 'ngx-crud';
import { RequestBody, ResponseBody } from './example.interface';
import { environment } from '@env';
@Injectable()
export class ExampleService extends CrudService<RequestBody, ResponseBody>
{
import { Injectable } from '@angular/core';
import { CrudService } from 'ngx-crud';
import { RequestBody, ResponseBody } from './example.interface';
import { environment } from '@env';
@Injectable()
export class ExampleService extends CrudService<RequestBody, ResponseBody>
{
protected apiUrl : string = environment.apiUrl;