Giter VIP home page Giter VIP logo

book-monkey2-api's Introduction

book-monkey2-api

NPM version

Monkey

REST Server Backend for the BookMonkey2 demo.
A publicly available server is hosted at book-monkey2-api.angular-buch.com, which always serves the latest version (#master).
The API is fully described via swagger. Explore it here.

The book

Book

This backend is used to explain HTTP communication with Angular.
Read more about Angular in our book. Visit angular-buch.com for more information (German only).

Usage

The server is written on top of restify. It provides simple CRUD operations over books.
The data is stored in memory only. Eveything will be lost on restart or when DELETE /books is called.

Shared server

A publicly available server is hosted at book-monkey2-api.angular-buch.com.
Feel free to use it as your test-drive. Data will be erased periodically.

Development

You might want to extend or modify the project.
Execute the following commands to start the standalone-server:

git clone https://github.com/angular-buch/book-monkey2-api.git
cd book-monkey2-api
npm install
npm start

Open http://localhost:3000/ in your brower.

License

Code released under the MIT license.

book-monkey2-api's People

Contributors

d-koppenhagen avatar fmalcher avatar johanneshoppe avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

book-monkey2-api's Issues

Using TypeScript um Json auf Objekte zu "mappen"

Ich bin kürzlich auf eine einfache Methode gestoßen, um Json auf eigene Objekttypen mit dem as-Operator zu "mappen". Ganz ohne RxJS.map und Factories:
Beispiel-Json:
example.json

{
  "title": "Complexes Objekt",
  "persons": 
  [
	{
		"id": 1,
		"name": "Max"
	},
	{
		"id": 2,
		"name": "Moritz"
	},
	{
		"id": 3,
		"name": "Widow Bolte"
	}
  ],
  "actions": 
  [
	{
		"id": 1,
		"description": "saw gap into bridge"
	},
	{
		"id": 2,
		"description": "steal grilled chicken"
	}
  ],
}

example.models.ts

export class Person {
  public id: number;
  public name: string;
}

export class Action {
  public id: number;
  public description: string;
}

export class Events {
  public title: string;
  public persons: Person[];
  public actions: Action[];
}

example.services.ts

import { Person, Action, ComplexObj } from '.model.ts';
...
@Injectable()
export class exampleService {
	...
	public readAll(): Observable<Events> {
		return this.http
		  .get('/Api/AllEvents/')
		  .retry(3)
		  .map(response => response.json() as Events)
		  .catch(this.errorHandler);
	}

Die interessante Teil ist: .map(response => response.json() as Events)

example.component.ts

...
src: exampleService;
ev: Events;
constructor(@Inject(exampleService) exampleServiceFactory: any) {
	this.src = exampleServiceFactory();
}
ngOnInit(){
	this.src.readAll().subscribe(res => this.ev = res);
}

Falls ich einen entsprechenden Hinweis nicht überlesen habe, hoffe ich, dass diese eine hilfreiche Anmerkung ist.

Cross-Origin Request Blocked

Hi,

thanks for the api server! But I'm getting a "Cross-Origin Request Blocked" error when talking to your server! Any idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.