Skip to content

Commit a5ed155

Browse files
committed
feat: update README
1 parent 3ba0abd commit a5ed155

File tree

1 file changed

+69
-70
lines changed

1 file changed

+69
-70
lines changed

README.md

Lines changed: 69 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,84 @@
1-
<p align="center">
2-
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
3-
</p>
1+
# NestJS wrapper for OneSignal official package: @onesignal/node-onesignal
2+
>[!warning]
3+
This package is based on @onesignal/node-onesignal which is currently in alpha state so it may come with breaking changes in the future, use with caution.
44

5-
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
6-
[circleci-url]: https://circleci.com/gh/nestjs/nest
7-
8-
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
9-
<p align="center">
10-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
11-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
12-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
13-
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
14-
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
15-
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
16-
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
17-
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
18-
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
19-
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
20-
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
21-
</p>
22-
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
23-
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
24-
25-
## Description
26-
27-
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
28-
29-
## Project setup
5+
## Installation
306

317
```bash
32-
$ npm install
8+
$ npm i nestjs-node-onesignal
339
```
3410

35-
## Compile and run the project
11+
## Getting Started
12+
To use OneSignal client you need register OneSignalModule in your app for example in app.module.ts
13+
```typescript
14+
import { OneSignalModule } from 'nestjs-node-onesignal';
15+
16+
@Module({
17+
imports: [
18+
OneSignalModule.forRoot({
19+
appId: process.env.ONESIGNAL_APP_ID,
20+
restApiKey: process.env.ONESIGNAL_API_KEY,
21+
})
22+
],
23+
controllers: [AppController],
24+
providers: [AppService],
25+
})
26+
export class AppModule { }
3627

37-
```bash
38-
# development
39-
$ npm run start
40-
41-
# watch mode
42-
$ npm run start:dev
43-
44-
# production mode
45-
$ npm run start:prod
4628
```
4729

48-
## Run tests
49-
50-
```bash
51-
# unit tests
52-
$ npm run test
30+
If you are using the ConfigModule from the Nest package @nestjs/config, you can use the registerAsync() function to inject your environment variables like this:
31+
```typescript
32+
import { OneSignalModule } from 'nestjs-node-onesignal';
33+
34+
@Module({
35+
imports: [
36+
OneSignalModule.forRootAsync({
37+
useFactory: async (configService: ConfigService) => ({
38+
appId: configService.get<string>("ONESIGNAL_APP_ID"),
39+
restApiKey: configService.get<string>("ONESIGNAL_API_KEY")
40+
}),
41+
inject: [ConfigService]
42+
})
43+
],
44+
controllers: [AppController],
45+
providers: [AppService],
46+
})
47+
export class AppModule { }
5348

54-
# e2e tests
55-
$ npm run test:e2e
5649

57-
# test coverage
58-
$ npm run test:cov
50+
```
51+
## Example
52+
The One signal service comes with an integrated notification builder so you can easily create your notifications.
53+
54+
```typescript
55+
import { OneSignalService } from "nestjs-node-onesignal";
56+
57+
@Injectable()
58+
export class AppService {
59+
constructor(
60+
private readonly oneSignalService: OneSignalService,
61+
) {}
62+
63+
async sendNotification() {
64+
const playerId = this.configService.get(ONESIGNAL_PLAYER_ID);
65+
const imageUrl = "https://www.example.com/image.jpg";
66+
const notification = this.oneSignalService.notificationBuilder
67+
.setContents({
68+
en: 'Send notification to a specific player ID',
69+
})
70+
.setIncludePlayerIds([playerId])
71+
.setContentAvailable(true)
72+
.setBigPicture(imageUrl)
73+
.setIosAttachments({ id1: this.imageUrl })
74+
.build();
75+
return await this.oneSignalService.client.createNotification(notification);
76+
}
77+
}
5978
```
6079

61-
## Resources
62-
63-
Check out a few resources that may come in handy when working with NestJS:
64-
65-
- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
66-
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
67-
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
68-
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
69-
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
70-
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
71-
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
72-
73-
## Support
74-
75-
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
76-
77-
## Stay in touch
78-
79-
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
80-
- Website - [https://nestjs.com](https://nestjs.com/)
81-
- Twitter - [@nestframework](https://twitter.com/nestframework)
80+
For full api reference see [One Signal Node SDK](https://github.com/OneSignal/node-onesignal)
8281

8382
## License
8483

85-
Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
84+
This package is [MIT licensed](https://github.com/PazminoJose/nestjs-node-onesignal/blob/main/LICENSE).

0 commit comments

Comments
 (0)