Meteor import of SimplSchema not working - meteor

I am trying to get access to objects using import, but am struggling with the logic:
schemas.js:
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
export default UsersExtraSchema = new SimpleSchema({
...
}
seed.js:
import '/imports/startup/server/schemas.js';
export default class SeedDB {
loadBaseData() {
....
UsersExtraSchema.validate(attr);
...
}
}
I am getting the error:
TypeError: Object [object Object] has no method 'validate'
at SeedDB.loadBaseData (imports/startup/server/seed.js:19:26)
at server/main.js:11:14
at /tidee/app/tidee-meteor/.meteor/local/build/programs/server/boot.js:290:5
Exited with code: 8
Your application is crashing. Waiting for file change.

Why do not you import like this?
import UsersExtraSchema from '/imports/startup/server/schemas.js';

Related

Error: Invalid AST Node: Undefined on Vue apollo query

I'm getting the error below when providing a constant with my graphql query to useQuery inside of my component.
Uncaught (in promise) Error: Invalid AST Node: undefined.
at devAssert (app.js:60958:11)
at visit (app.js:65283:130)
at Object.assign.added (app.js:59225:58)
at InMemoryCache.transformDocument (app.js:53379:101)
at QueryManager.transform (app.js:56649:42)
at QueryManager.getVariables (app.js:56681:121)
at QueryManager.watchQuery (app.js:56684:147)
at ApolloClient.watchQuery (app.js:55091:34)
at start (app.js:5304:26)
at immediate (app.js:5522:7)
My component script section looks like:
<script>
import { MY_QUERY } from "./constants/qraphql";
import {useQuery} from "#vue/apollo-composable";
export default {
setup() {
const {result, loading, error} = useQuery(MY_QUERY);
return {
result,
loading,
error
}
}
}
</script>
And my ./constants/graphql.js file looks like:
import gql from 'graphql-tag';
const MY_QUERY = gql`
query exampleQuery {
tasks {
id
name
title
text
}
}`;
Why is this happening?
Turns out I forgot to prefix export to my constant MY_QUERY. This caused the component to attempt to use a undefined constant because it failed to import.
In my ./constants/graphql.js file I have to change
const MY_QUERY
to
export const MY_QUERY
Now the error is fixed

Ccan't get item from database with Axios and NestJS

I can't get item from Firebase Realtime Database with Axios and NestJS.
My code is:
import { Injectable } from '#nestjs/common';
import { HttpService } from '#nestjs/axios';
import { Observable } from 'rxjs';
import { AxiosResponse } from 'axios';
#Injectable()
export class AppService {
constructor(private httpService: HttpService) {}
async getHello(): Promise<Observable<AxiosResponse<any>>> {
const data = await this.httpService.get(
'[my firebase url.]',
).pipe();
return data;
}
}
I get this error:
[Nest] 5104 - 01.11.2021 20:28:19 ERROR [ExceptionsHandler] Converting circular structure to JSON
--> starting at object with constructor 'ClientRequest'
| property 'socket' -> object with constructor 'TLSSocket'
--- property '_httpMessage' closes the circle
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'ClientRequest'
| property 'socket' -> object with constructor 'TLSSocket'
--- property '_httpMessage' closes the circle
at JSON.stringify (<anonymous>)
at stringify (C:\Users\Faruk\Desktop\projects\fbase\node_modules\express\lib\response.js:1123:12)
at ServerResponse.json (C:\Users\Faruk\Desktop\projects\fbase\node_modules\express\lib\response.js:260:14)
at ExpressAdapter.reply (C:\Users\Faruk\Desktop\projects\fbase\node_modules\#nestjs\platform-express\adapters\express-adapter.js:32:57)
at RouterResponseController.apply (C:\Users\Faruk\Desktop\projects\fbase\node_modules\#nestjs\core\router\router-response-controller.js:14:36)
at C:\Users\Faruk\Desktop\projects\fbase\node_modules\#nestjs\core\router\router-execution-context.js:175:48
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at C:\Users\Faruk\Desktop\projects\fbase\node_modules\#nestjs\core\router\router-execution-context.js:47:13
at C:\Users\Faruk\Desktop\projects\fbase\node_modules\#nestjs\core\router\router-proxy.js:9:17
Looks like you aren't mapping the response at all. Axios responses are, by definition, circular, so you need to return only the part of the response you need. Most of the time, this is simply just return this.httpService.get(url).pipe(map((resp) => resp.data))

Angular 5 Firebase 2 -- Property 'includes' is missing in type

I am following a tutorial which is clearly outdated. But I tried my best to follow up with the migration guide but I am still stuck with this one little error.
import { Injectable } from '#angular/core';
import { AngularFireList, AngularFireObject, AngularFireDatabase } from 'angularfire2/database';
import { ExpenseModel } from './expense-model';
#Injectable()
export class ExplistService {
private basePath = '/UD';
explist: AngularFireList<ExpenseModel[]> = null; // list of objects
exp: AngularFireObject<ExpenseModel> = null;
createExpenseModel(exp: ExpenseModel): void {
this.explist.push(exp)
.catch(error => this.handleError(error));
}
I am getting the error at the line
this.explist.push(exp)
Argument of type 'ExpenseModel' is not assignable to parameter of type
'ExpenseModel[]'. Property 'includes' is missing in type
'ExpenseModel'.

document.body is null when adding react component to meteor project

I am trying to add a react component to a meteor project. It works well when I run it in the browser but when I run on ios emulator or device, I will get an error.
template:
<template name="navbar_datepicker">
<div>
{{> React component=DesktopInfiniteCalendar}}
</div>
</template>
component:
import React from 'react';
import { render } from 'react-dom';
import InfiniteCalendar from 'react-infinite-calendar';
import 'react-infinite-calendar/styles.css';
var today = new Date();
var minDate = Number(new Date()) - (24*60*60*1000) * 7; // One week before today
export default class DesktopInfiniteCalendar extends React.Component {
render() {
return (<InfiniteCalendar width={400} height={600} selectedDate={today} minDate={minDate} keyboardSupport={true} rowHeight={40} />);
}
}
helpers:
import DesktopInfiniteCalendar from './datepicker_components.js';
Template.navbar_datepicker.helpers({
DesktopInfiniteCalendar() {
return DesktopInfiniteCalendar;
}
});
The above code works in combination with the meteor package react-template-helper, but in the browser only.
The error I get on emulator and real device is:
[Error] TypeError: null is not an object (evaluating 'document.body.appendChild')
exports (modules.js:43659)
(anonymous function) (modules.js:1645)
fileEvaluate (modules-runtime.js:180)
require (modules-runtime.js:109)
(anonymous function) (modules.js:809)
fileEvaluate (modules-runtime.js:180)
require (modules-runtime.js:109)
import (modules.js:394)
(anonymous function) (app.js:2657:539)
fileEvaluate (modules-runtime.js:180)
require (modules-runtime.js:109)
global code (app.js:13231)
Any thoughts about why this happens?

Meteor import flowRouter and IronRouter error

I use import folder on my Meteor App, but I got error with following config :
/imports/startup/client/routes.js
import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import '../../../ui/layout/layout.js';
import '../../../ui/pages/home/home.js';
FlowRouter.route('/', {
action: function() {
console.log("Yeah! We are on the post:");
}
});
and my /client/main.js
import '/imports/startup/client';
And I've this error :
Error: Cannot find module 'routes.js'
Do you have any idea why routes.js isn't loaded ?
Thank you !
You need to import the routes file. Your current import resolves to a folder so it will import the index file in the folder if there is one.

Resources