We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
for "fieldSetRepo" i get undefined help me with resolve it
import 'reflect-metadata'; import { Request } from 'express'; import Container, { Service, Inject } from 'typedi'; import { Repository, getRepository } from 'typeorm'; import { IResponse } from '@interfaces'; import { success } from '@utils/common.util'; import { FieldSettings } from '@models/field-settings.model'; import { InjectRepository } from 'typeorm-typedi-extensions';
@service() class FieldSettingsController {
@InjectRepository(FieldSettings) private fieldSetRepo: Repository<FieldSettings>; private constructor() { // Private constructor to enforce singleton pattern } static getInstance(): FieldSettingsController { if (!FieldSettingsController.instance) { FieldSettingsController.instance = new FieldSettingsController(); } return FieldSettingsController.instance; } private static instance: FieldSettingsController; createFields = async (req: Request, res: IResponse): Promise<void> => { try { const fields = new FieldSettings({ name: req.body.name }); if (!this.fieldSetRepo) { throw new Error('Repository not initialized'); } await this.fieldSetRepo.save(fields); res.status(200).json(success('', {}, res.statusCode)); } catch (err) { console.error('Error:', err.message); res.status(400).json(success('', {}, res.statusCode)); } }; getAllFields = async (req: Request, res: IResponse): Promise<void> => { try { const fields = await this.fieldSetRepo.find(); res.status(200).json(success('', {fields}, res.statusCode)); } catch (err) { console.log('err', err); res.status(400).json(success('', {}, res.statusCode)); } } // ... other methods ...
}
const fieldSettingsController = FieldSettingsController.getInstance(); export { fieldSettingsController as FieldSettingsController };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
for "fieldSetRepo" i get undefined help me with resolve it
import 'reflect-metadata';
import { Request } from 'express';
import Container, { Service, Inject } from 'typedi';
import { Repository, getRepository } from 'typeorm';
import { IResponse } from '@interfaces';
import { success } from '@utils/common.util';
import { FieldSettings } from '@models/field-settings.model';
import { InjectRepository } from 'typeorm-typedi-extensions';
@service()
class FieldSettingsController {
}
const fieldSettingsController = FieldSettingsController.getInstance();
export { fieldSettingsController as FieldSettingsController };
The text was updated successfully, but these errors were encountered: