Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jharrilim/nest-notion
Nest module for using the Notion API.
https://github.com/jharrilim/nest-notion
api module nestjs notion
Last synced: 11 days ago
JSON representation
Nest module for using the Notion API.
- Host: GitHub
- URL: https://github.com/jharrilim/nest-notion
- Owner: jharrilim
- License: mit
- Created: 2021-07-18T21:46:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-07-24T16:51:48.000Z (over 3 years ago)
- Last Synced: 2024-05-01T14:40:36.526Z (8 months ago)
- Topics: api, module, nestjs, notion
- Language: TypeScript
- Homepage: https://npmjs.org/nest-notion
- Size: 16.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nest-notion
![npm](https://img.shields.io/npm/v/nest-notion?style=flat-square)
![npm](https://img.shields.io/npm/dt/nest-notion?style=flat-square)Nest module for using the [Notion API](https://developers.notion.com/).
## Install
### NPM
```sh
npm i nest-notion
```### Yarn
```sh
yarn add nest-notion
```## Usage
In `app.module.ts`:
```ts
import { Module } from '@nestjs/common';
import { NotionModule } from 'nest-notion';
import { ConfigModule } from '@nestjs/config';
import { VegetableModule } from './vegetable/vegetable.module';@Module({
imports: [
ConfigModule.forRoot({ // Need this to use process.env.NOTION_SECRET if it is in .env
isGlobal: true,
}),
NotionModule.forRoot({
auth: process.env.NOTION_SECRET,
}),
VegetableModule,
],
})
export class AppModule {}
```An example module you wish to use it in:
```ts
import { Module } from '@nestjs/common';
import { VegetableService } from './vegetable.service';@Module({
providers: [VegetableService],
exports: [
VegetableService,
],
})
export class VegetableModule {}```
In the service within the module:
```ts
import { Injectable } from '@nestjs/common';
import { NotionService } from 'nest-notion';@Injectable()
export class VegetableService {
constructor(
private readonly notionService: NotionService
) { }listUsers() {
return this.notionService.notion.users.list({ page_size: 10 });
}
}```