UNPKG

3.97 kBJavaScriptView Raw
1var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5 return c > 3 && r && Object.defineProperty(target, key, r), r;
6};
7var __metadata = (this && this.__metadata) || function (k, v) {
8 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9};
10import { Injectable } from '@angular/core';
11/**
12* Interface for a class that creates an in-memory database
13*
14* Its `createDb` method creates a hash of named collections that represents the database
15*
16* For maximum flexibility, the service may define HTTP method overrides.
17* Such methods must match the spelling of an HTTP method in lower case (e.g, "get").
18* If a request has a matching method, it will be called as in
19* `get(info: requestInfo, db: {})` where `db` is the database object described above.
20*/
21var InMemoryDbService = /** @class */ (function () {
22 function InMemoryDbService() {
23 }
24 return InMemoryDbService;
25}());
26export { InMemoryDbService };
27/**
28* Interface for InMemoryBackend configuration options
29*/
30var InMemoryBackendConfigArgs = /** @class */ (function () {
31 function InMemoryBackendConfigArgs() {
32 }
33 return InMemoryBackendConfigArgs;
34}());
35export { InMemoryBackendConfigArgs };
36/////////////////////////////////
37/**
38* InMemoryBackendService configuration options
39* Usage:
40* InMemoryWebApiModule.forRoot(InMemHeroService, {delay: 600})
41*
42* or if providing separately:
43* provide(InMemoryBackendConfig, {useValue: {delay: 600}}),
44*/
45var InMemoryBackendConfig = /** @class */ (function () {
46 function InMemoryBackendConfig(config) {
47 if (config === void 0) { config = {}; }
48 Object.assign(this, {
49 // default config:
50 caseSensitiveSearch: false,
51 dataEncapsulation: false,
52 delay: 500,
53 delete404: false,
54 passThruUnknownUrl: false,
55 post204: true,
56 post409: false,
57 put204: true,
58 put404: false,
59 apiBase: undefined,
60 host: undefined,
61 rootPath: undefined // default value is actually set in InMemoryBackendService ctor
62 }, config);
63 }
64 InMemoryBackendConfig = __decorate([
65 Injectable(),
66 __metadata("design:paramtypes", [InMemoryBackendConfigArgs])
67 ], InMemoryBackendConfig);
68 return InMemoryBackendConfig;
69}());
70export { InMemoryBackendConfig };
71/** Return information (UriInfo) about a URI */
72export function parseUri(str) {
73 // Adapted from parseuri package - http://blog.stevenlevithan.com/archives/parseuri
74 // tslint:disable-next-line:max-line-length
75 var URL_REGEX = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
76 var m = URL_REGEX.exec(str);
77 var uri = {
78 source: '',
79 protocol: '',
80 authority: '',
81 userInfo: '',
82 user: '',
83 password: '',
84 host: '',
85 port: '',
86 relative: '',
87 path: '',
88 directory: '',
89 file: '',
90 query: '',
91 anchor: ''
92 };
93 var keys = Object.keys(uri);
94 var i = keys.length;
95 while (i--) {
96 uri[keys[i]] = m[i] || '';
97 }
98 return uri;
99}
100export function removeTrailingSlash(path) {
101 return path.replace(/\/$/, '');
102}
103//# sourceMappingURL=interfaces.js.map
\No newline at end of file