JSPM

@rytass/quadrats-nestjs

0.1.9
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 69
  • Score
    100M100P100Q20302F
  • License MIT

Quadrats CMS Nestjs Module

Package Exports

  • @rytass/quadrats-nestjs
  • @rytass/quadrats-nestjs/index.cjs.js
  • @rytass/quadrats-nestjs/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rytass/quadrats-nestjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@rytass/quadrats-nestjs

Usage

// app.module.ts
import { Module } from '@nestjs/common';
import { QuadratsModule } from '@rytass/quadrats-nestjs';
import { ArticleModule } from './article.module';

@Module({
  imports: [
    QuadratsModule.forRoot({
      accessKey: 'QuadratsAccessKey',
      secret: 'QuadratsSecret',
    }),
    ArticleModule,
  ],
})
export class AppModule {}

// article.module.ts
import { Module } from '@nestjs/common';
import { QuadratsModule } from '@rytass/quadrats-nestjs';
import { ArticleController } from './article.controller';
import { ArticleService } from './article.service';

@Module({
  imports: [QuadratsModule],
  controllers: [ArticleController],
  providers: [ArticleService],
})
export class ArticleModule {}

// article.service.ts
import { Injectable } from '@nestjs/common';
import { QuadratsArticleService, type QuadratsArticle } from '@rytass/quadrats-nestjs';

@Injectable()
export class ArticleService {
  constructor(
    private readonly quadratsArticleService: QuadratsArticleService,
  ) {}

  get(id: string): Promise<QuadratsArticle | null> {
    return this.quadratsArticleService.get(id);
  }
}

// article.controller.ts
import { Controller, Get, Param } from '@nestjs/common';

@Controller('/articles')
export class ArticleController {
  constructor(
    private readonly articleService: ArticleService,
  ) {}

  @Get('/:articleId')
  getArticle(@Param('articleId') id: string): Promise<QuadratsArticle | null> {
    return this.articleService.get(id);
  }
}

Multi-language Support

// article.service.ts
import { Injectable } from '@nestjs/common';

@Injectable()
class ArticleService {
  constructor(
    private readonly quadratsArticleService: QuadratsArticleService,
  ) {}

  async addMultiLanguageArticle() {
    const article = await this.quadratsArticleService.create({
      title: 'Multiple Language',
      categoryIds: [],
      tags: ['Chinese', 'English'],
      languageContents: [{
        elements: [{
          type: 'p',
          children: [{ text: '中文內容' }],
        }],
        language: 'zh-Hant',
      }, {
        elements: [{
          type: 'p',
          children: [{ text: 'English Content' }],
        }],
        language: 'en',
      }],
    });
  }
}