mcpField
D
d2-02-api-service

d2-02-api-service

github.com/softinter-chiangraiDevelopment046 installsUpdated 9w ago
Repository

About d2-02-api-service

A skill for generating an Angular service that uses HttpClient for an entity exposed by up-api CRUD endpoints. It first checks which entity is in scope and notes that this step needs no redeployment.

Key features

  1. 01Angular service template
  2. 02Entity-specific CRUD service
  3. 03HttpClient setup guidance

Use cases

  1. 01Create a service for an up-api entity
  2. 02Register provideHttpClient in app.config.ts

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/softinter-chiangrai/up-ai-skill-training --skill d2-02-api-service

After installing, type/d2-02-api-servicein Claude Code to confirm it loaded.

Details

From the project README

Day 2 · Step 2 — API service

If the entity isn't already established in this conversation, ask which entity (it must match the one exposed by up-api's CRUD endpoints).

up-app/src/app/services/<entity>.service.ts:

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';

export interface <Entity> {
  id?: number;
  // one field per column from the Day 1 entity spec
}

@Injectable({ providedIn: 'root' })
export class <Entity>Service {
  private base = 'http://localhost:8080/api/<entity>s';
  constructor(private http: HttpClient) {}

  getAll(): Observable<<Entity>[]> { return this.http.get<<Entity>[]>(this.base); }
  getById(id: number): Observable<<Entity>> { return this.http.get<<Entity>>(`${this.base}/detail/${id}`); }
  save(item: <Entity>): Observable<<Entity>> { return this.http.post<<Entity>>(`${this.base}/save`, item); }
  update(id: number, item: <Entity>): Observable<<Entity>> { return this.http.put<<Entity>>(`${this.base}/update/${id}`, item); }
  delete(id: number): Observable<void> { return this.http.delete<void>(`${this.base}/${id}`); }
}

Register provideHttpClient() in app.config.ts if it isn't already there. No redeploy needed for this step.

Comments

Markdown supported