Coder Social home page Coder Social logo

Comments (2)

joelalejandro avatar joelalejandro commented on June 16, 2024 1

Hey @nelson6e65! Thank you for reporting this. Type names are expected to be singularized for the router to work.

Can you share your app.ts file? In particular, the app instantiation. This might be a problem related to how the resource is being registered.

from kurier.

nelson6e65 avatar nelson6e65 commented on June 16, 2024

@joelalejandro Sure! Here you are!

// server.ts
import express from 'express';
import { jsonApiExpress, Application } from 'kurier';

import { FirebaseProcessor } from '~api/v1/processors/firebase.processor';
import { Tenant } from '~api/v1/resources/tenant';
import { User } from '~api/v1/resources/user';
import { JsonApiApplication } from '~utils/json-api/json-api-application';

const app = new Application({
  types: [
    //
    User,
    Tenant,
  ],
  defaultProcessor: FirebaseProcessor,
});

const server = express();

server.use(
  jsonApiExpress(app, {
    httpStrictMode: true,
  })
);

export default server;

My FirebaseProcessor it just extends OperationProcessor, I have not done anything yet.

/* eslint-disable @typescript-eslint/require-await */
import { HasId, Operation, OperationProcessor, Resource } from 'kurier';

/**
 * Preprocessor for firebase.
 */
export class FirebaseProcessor<TResource extends Resource> extends OperationProcessor<TResource> {
  async get(op: Operation): Promise<HasId[] | HasId> {
    if (op.ref.id) {
      return await this.getOne(op);
    }

    return this.getMany(op);
  }

  protected async getMany(op: Operation): Promise<HasId[]> {
    
    return [
      {
        // ...just testing data
      },
      {
        // ...
      },
    ];
  }

  protected async getOne(op: Operation): Promise<HasId> {
    const data: HasId = {
      id: op.ref.id,
      // ...
    };

    return data;
  }

  async remove(op: Operation): Promise<void> {
    throw new Error('Method not implemented.');
  }
  async update(op: Operation): Promise<HasId> {
    throw new Error('Method not implemented.');
  }
  async add(op: Operation): Promise<HasId> {
    throw new Error('Method not implemented.');
  }
}

from kurier.

Related Issues (20)

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.