DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Trending

  • Conditional Breakpoints: A Guide to Effective Debugging
  • Google Becomes A Java Developer's Best Friend: Instantiations Developer Tools Relaunched For Free
  • Top 10 Pillars of Zero Trust Networks
  • Clear Details on Java Collection ‘Clear()’ API
  1. DZone
  2. Coding
  3. Frameworks
  4. Entity Framework for Angular (kind of)

Entity Framework for Angular (kind of)

Simplify the creation of your Angular HTTP service layer, and creating your backend, by letting Magic automatically take care of everything besides your UX

Thomas Hansen user avatar by
Thomas Hansen
CORE ·
Oct. 05, 20 · Presentation
Like (1)
Save
Tweet
Share
4.34K Views

Join the DZone community and get the full member experience.

Join For Free

When you just want to learn how to create Angular apps, creating an HTTP REST backend, with authentication and authorisation, and wrapping your URLs into an HttpClient can, sometimes feel like baggage - Still it's necessary to learn Angular. I've therefor created a scaffolder for this process in Magic, that allows you to literally click a button to create your backend, wrapping your database with CRUD operations, for then to click another button, and get a zip file containing an Angular project - Which wraps every single CRUD operation towards every single database table in your backend, into an automatically generated Angular HttpClient Service layer for you. If you download version 8.3.1 of Magic, you will find a new template, not producing any UX at all, only HTTP methods.

After having setup Magic, literally the process of wrapping an existing database, is no more than 5 seconds in total. If you run it towards for instance the Sakila database published by Oracle, Magic will generate an HttpClient service layer resembling the following for you automatically.

TypeScript
 




xxxxxxxxxx
1
44


 
1
  /**
2
   * HTTP CRUD service methods for your 'actor' entities.
3
   */
4
  get actor() : ICrudEntity {
5

          
6
    return {
7

          
8
      delete: (filter: any) => {
9
        return this.httpClient.delete<DeleteResponse>(
10
          environment.apiUrl +
11
          'magic/modules/sakila/actor' +
12
          this.getQueryArgs(filter));
13
      },
14

          
15
      read: (filter: any) => {
16
        return this.httpClient.get<any[]>(
17
          environment.apiUrl +
18
          'magic/modules/sakila/actor' +
19
          this.getQueryArgs(filter));
20
      },
21

          
22
      count: (filter: any) => {
23
        return this.httpClient.get<CountResponse>(
24
          environment.apiUrl +
25
          'magic/modules/sakila/actor-count' +
26
          this.getQueryArgs(filter));
27
      },
28

          
29
      create: (args: any) => {
30
        return this.httpClient.post<CreateResponse>(
31
          environment.apiUrl +
32
          'magic/modules/sakila/actor',
33
          args);
34
      },
35

          
36
      update: (args: any) => {
37
        return this.httpClient.put<UpdateResponse>(
38
          environment.apiUrl +
39
          'magic/modules/sakila/actor',
40
          args);
41
      }
42
    }
43
  }
44

          


The above syntax groups all related service methods for you, that belongs to the same "CRUD method group", allowing you to almost use the equivalent of "fluid syntax" to retrieve data from your backend. Everything perfectly secured, using JWT token may I add. Complete with an authentication and authorisation service too.

Admittedly, I could do a slightly better job at documenting the scaffolded result - And I could improve things in regards to typing, since endpoint methods now simply takes an "any" object, and you'll manually have to play around with your Endpoints menu item to figure out how to apply filtering, etc - But since I'm eager to show this to you, I figure you'll probably bear over with me.

Anyways, find and download Magic below. I'll probably create more templates like this. Suggestions ...?

  • Download Magic
AngularJS Entity Framework Database Framework

Opinions expressed by DZone contributors are their own.

Trending

  • Conditional Breakpoints: A Guide to Effective Debugging
  • Google Becomes A Java Developer's Best Friend: Instantiations Developer Tools Relaunched For Free
  • Top 10 Pillars of Zero Trust Networks
  • Clear Details on Java Collection ‘Clear()’ API

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: