Angular 2 library for DreamFactory Services Platform

Its been a long time I’m fascinated by DreamFactory Services Platform and wanted to contribute to the project somehow, and this humle library is an attempt to accomplish this noble goal.

If you’re a web developer and don’t know what DreamFactory is you’re missing a lot. In a nutshell, this platform creates RESTful APIs for resources like databases, file storage services and e-mail services, among others, instantly. It also takes care of authentication and authorization, allowing you to customize scripts to be run before and after each request to the server.

They provide an Angular 2 component for authenticationanother to deal with data, and an address book sample, but they’re still using Angular 2.0.0-beta 1 (released approximately 11 months ago). Many things changed in the framework since then and the libraries hadn’t been updated – which is quite frustrating. But hey, they’re doing the hard part (DSP itself), lets contribute with those amazing folks!

Honestly I’ve never been able to make the aforementioned modules to work, and I thouth they were confusing. I wanted something simpler. Two separate modules also didn’t make much sense to me, so I decided to create one single module for data access and authentication.

There is still a looot to do for this library (specially on documentation), but it is already something. Any contributions will be more than welcome 🙂

The Angular 2 service is available as a npm package at https://www.npmjs.com/package/ng2-dfservice. On GitHub you’ll find the sources for this package and another repository with a simplistic working example – which hopefully you’ll be able to put to work with little effort.

If you just want to know how to use the library, here you have the step-by-step:

1 – Install ng2-dfservice from npm

$ npm install ng2-dfservice --save

2 – Provide DFService, URL and API keys in your module


import { DFService } from 'ng2-dfservice';

(...)

providers: [
DFService,
{ provide: DFService.API_URL, useValue: 'YOUR_DF2_URL' },
{ provide: DFService.API_KEY, useValue: 'YOUR_DF2_API_KEY' },
],

3 – Be happy 🙂

Just inject DFService in your component and use get, post, put, patch, delete, login and logout methods.

import { DFService, DFResource } from 'ng2-dfservice';
(...)
this.dfservice.get( new DFResource('service_name', DFService.TABLE, 'table_name') );

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *