Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mobizerg/nest-ghost-content-api
Ghost Content Api integration module for Nest.js framework
https://github.com/mobizerg/nest-ghost-content-api
Last synced: about 2 months ago
JSON representation
Ghost Content Api integration module for Nest.js framework
- Host: GitHub
- URL: https://github.com/mobizerg/nest-ghost-content-api
- Owner: mobizerg
- License: mit
- Created: 2019-10-31T06:13:46.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-07T16:10:52.000Z (over 4 years ago)
- Last Synced: 2024-11-19T03:56:14.028Z (2 months ago)
- Language: TypeScript
- Size: 28.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Ghost Content Api integration module for Nest.js framework.### Installation
**Yarn**
```bash
yarn add @mobizerg/nest-ghost-content-api @tryghost/content-api
```**NPM**
```bash
npm install @mobizerg/nest-ghost-content-api @tryghost/content-api --save
```### Description
Ghost Content Api integration module for [Nest.js](https://github.com/nestjs/nest) based on the [Ghost Content Api](https://github.com/TryGhost/Ghost-SDK/tree/master/packages/content-api) package.### Usage
Import the **GhostContentApiModule** in `app.module.ts`
```typescript
import { Module } from '@nestjs/common';
import { GhostContentApiModule } from '@mobizerg/nest-ghost-content-api';@Module({
imports: [
GhostContentApiModule.register(options),
],
})
export class AppModule {}
```
With Async
```typescript
import { Module } from '@nestjs/common';
import { GhostContentApiModule } from '@mobizerg/nest-ghost-content-api';@Module({
imports: [
GhostContentApiModule.registerAsync({
imports: [ConfigModule],
useExisting: GhostContentApiConfigService,
}),
],
})
export class AppModule {}
```Example config file (async)
```typescript
import { Injectable } from '@nestjs/common';
import { ConfigService } from './config.service';
import { GhostContentApiModuleOptions, GhostContentApiOptionsFactory } from '@mobizerg/nest-ghost-content-api';@Injectable()
export class GhostContentApiConfigService implements GhostContentApiOptionsFactory {constructor(private readonly config: ConfigService) {}
createGhostContentApiOptions(name?: string): GhostContentApiModuleOptions {
return {
name,
url: 'https://demo.ghost.io',
key: '22444f78447824223cefc48062',
version: 'v3',
};
}
}
```Importing inside services
```typescript
import { Injectable } from '@nestjs/common';
import { GhostContentApiService, PostResponse } from '@mobizerg/nest-ghost-content-api';@Injectable()
export class BlogService {
constructor(private readonly ghostContentApiService: GhostContentApiService) {}
async findPosts(): Promise {
return await this.ghostContentApiService.findPosts({
filter: 'tag:demo',
page: query.page,
limit: query.limit,
order: {
propertyName: 'created_at',
sortOrder: Order.ASC,
},
});
}
}
```### License
MIT