Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Kinvey } from "kinvey-nativescript-sdk";
import { Config } from "./config";
/* ***********************************************************
* The {N} Kinvey plugin initialization is explained in the plugin readme here:
* http://devcenter.kinvey.com/nativescript/guides/getting-started#ConfigureYourApp
* In this template, Kinvey is set up with a custom existing project, so that
* You can build and run this template without creating your own Kinvey project.
*************************************************************/
Kinvey.init({
appKey: Config.kinveyAppKey,
appSecret: Config.kinveyAppSecret
});
@NgModule({
bootstrap: [
AppComponent
],
imports: [
NativeScriptModule,
AppRoutingModule,
/* ***********************************************************
* The {N} Kinvey plugin initialization is explained in the plugin readme here:
* http://devcenter.kinvey.com/nativescript/guides/getting-started#ConfigureYourApp
* In this template, Kinvey is set up with a custom existing project, so that
* You can build and run this template without creating your own Kinvey project.
*************************************************************/
KinveyModule.init()
],
declarations: [
AppComponent
],
providers: [
LoggedInLazyLoadGuard
],
schemas: [
NO_ERRORS_SCHEMA
]
})
export class AppModule { }
// TODO: should be imported from kinvey-nativescript-sdk/angular but declaration file is currently missing
import { KinveyModule } from "kinvey-nativescript-sdk/lib/angular";
import { Config } from "./shared/config";
import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
import { LoggedInLazyLoadGuard } from "./logged-in-lazy-load.guard";
@NgModule({
bootstrap: [
AppComponent
],
imports: [
NativeScriptModule,
AppRoutingModule,
KinveyModule.init({
appKey: Config.kinveyAppKey,
appSecret: Config.kinveyAppSecret
})
],
declarations: [
AppComponent
],
providers: [
LoggedInLazyLoadGuard
],
schemas: [
NO_ERRORS_SCHEMA
]
})
export class AppModule { }
@NgModule({
bootstrap: [
AppComponent
],
imports: [
NativeScriptModule,
AppRoutingModule,
/* ***********************************************************
* The {N} Kinvey plugin initialization is explained in the plugin readme here:
* http://devcenter.kinvey.com/nativescript/guides/getting-started#ConfigureYourApp
* In this template, Kinvey is set up with a custom existing project, so that
* You can build and run this template without creating your own Kinvey project.
*************************************************************/
KinveyModule.init({
appKey: Config.kinveyAppKey,
appSecret: Config.kinveyAppSecret
})
],
declarations: [
AppComponent
],
schemas: [
NO_ERRORS_SCHEMA
]
})
export class AppModule { }
const Kinvey = require("kinvey-nativescript-sdk");
const config = require("./config");
/* ***********************************************************
* The {N} Kinvey plugin initialization is explained in the plugin readme here:
* http://devcenter.kinvey.com/nativescript/guides/getting-started#ConfigureYourApp
* In this template, Kinvey is set up with a custom existing project, so that
* You can build and run this template without creating your own Kinvey project.
*************************************************************/
Kinvey.init({
appKey: config.kinveyAppKey,
appSecret: config.kinveyAppSecret
});
const Kinvey = require("kinvey-nativescript-sdk");
/* ***********************************************************
* The {N} Kinvey plugin initialization is explained in the plugin readme here:
* http://devcenter.kinvey.com/nativescript/guides/getting-started#ConfigureYourApp
* In this template, Kinvey is set up with a custom existing project, so that
* You can build and run this template without creating your own Kinvey project.
*************************************************************/
Kinvey.init();
];
export class CarService {
static getInstance(): CarService {
return CarService._instance;
}
private static _instance: CarService = new CarService();
private static cloneUpdateModel(car: Car): object {
// tslint:disable-next-line:ban-comma-operator
return editableProperties.reduce((a, e) => (a[e] = car[e], a), { _id: car.id });
}
private allCars: Array = [];
private carsStore = DataStore.collection("cars");
constructor() {
if (CarService._instance) {
throw new Error("Use CarService.getInstance() instead of new.");
}
CarService._instance = this;
}
load(): Promise {
return this.login().then(() => {
return this.carsStore.sync();
}).then(() => {
const sortByNameQuery = new Query();
sortByNameQuery.ascending("name");
const stream = this.carsStore.find(sortByNameQuery);
"luggage",
"name",
"price",
"seats",
"imageUrl"
];
@Injectable()
export class CarService {
private static cloneUpdateModel(car: Car): object {
// tslint:disable-next-line:ban-comma-operator
return editableProperties.reduce((a, e) => (a[e] = car[e], a), { _id: car.id });
}
private allCars: Array = [];
private carsStore = Kinvey.DataStore.collection("cars");
getCarById(id: string): Car {
if (!id) {
return;
}
return this.allCars.filter((car) => {
return car.id === id;
})[0];
}
load(): Observable {
return new Observable((observer: any) => {
this.login().then(() => {
return this.carsStore.sync();
}).then(() => {
login() {
let activeUser = Kinvey.User.getActiveUser();
if (activeUser == null) {
Kinvey.User.loginWithMIC()
.then((user: Kinvey.User) => {
activeUser = user;
this.navigateHome(activeUser);
console.log("user: " + JSON.stringify(user));
})
.catch((error: Kinvey.BaseError) => {
alert("An error occurred. Check your Kinvey settings.");
console.log("error: " + error);
});
} else {
this.navigateHome(activeUser);
}
}
login() {
let activeUser = Kinvey.User.getActiveUser();
if (activeUser == null) {
Kinvey.User.loginWithMIC()
.then((user: Kinvey.User) => {
activeUser = user;
this.navigateHome(activeUser);
console.log("user: " + JSON.stringify(user));
})
.catch((error: Kinvey.BaseError) => {
alert("An error occurred. Check your Kinvey settings.");
console.log("error: " + error);
});
} else {
this.navigateHome(activeUser);
}
}